Files
kata-containers/tools/packaging/kernel/patches/5.10.x/0001-arm64-mmu-compared-with-linear-start-physical-addres.patch
Jianyong Wu 28bd8c1110 kernel: upgrade kernel to 5.10.x for arm64.
In kernel 5.10.x on arm64 side, When CONFIG_RANDOM_BASE is enabled,
physical base address can be a negative number. It may lead to bug
when a PA is taken as a unsigned number in comparison, as PA is
calculated based on the physical base address. The bug has been fixed
latest code by commit ee7febce051945be2 in memory hotplug zone. We can
eliminate the bug in an easy way by casting the PA as a signed value in
the current code base to avoid lots of backport.

Depends-on: github.com/kata-containers/tests#3388
Fixes: #1596
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
2021-04-01 17:01:44 +08:00

32 lines
1.0 KiB
Diff

From 0b0f3b3cd9c00bc5bce5686303ef008212ce9b99 Mon Sep 17 00:00:00 2001
From: Jianyong Wu <jianyong.wu@arm.com>
Date: Wed, 31 Mar 2021 10:00:53 +0800
Subject: [PATCH] arm64/mmu: compared with linear start physical address as
signed
When CONFIG_RANDOM_BASE is enabled, the physical base address can be
a negative number. It may lead to bug if it is compared as a unsigned
number. So cast it before comparison.
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
---
arch/arm64/mm/mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index ca692a815731..24b36c85edf4 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -1453,7 +1453,7 @@ static bool inside_linear_region(u64 start, u64 size)
* range which can be mapped inside this linear mapping range, must
* also be derived from its end points.
*/
- return start >= __pa(_PAGE_OFFSET(vabits_actual)) &&
+ return (s64)start >= (s64)(__pa(_PAGE_OFFSET(vabits_actual))) &&
(start + size - 1) <= __pa(PAGE_END - 1);
}
--
2.17.1