[RFC PATCH v2 20/43] arm64: pi: Clear the FDT ptes on every remap in map_fdt()

Eric Curtin ericcurtin17 at gmail.com
Mon Nov 30 17:51:52 PST 2026


From: Eric Curtin <eric.curtin at docker.com>

map_fdt() is called a second time once the final page size is known, and
the static ptes[] array must be zeroed before the FDT is mapped again
because the new page size gives it a different layout. The first_time
flag is initialised to true and was only cleared inside the
"if (!first_time)" block, so it was never cleared and the memset() never
ran.

Clear first_time unconditionally after the check, so that the first call
leaves the array alone and every later call zeroes it before building
the new mapping.

Signed-off-by: Ryan Roberts <ryan.roberts at arm.com>
Signed-off-by: Eric Curtin <eric.curtin at docker.com>
(cherry picked from commit cacdf8d80bbab6eaafc3bcbc5689636ac521cb0a)
---
 arch/arm64/kernel/pi/map_kernel.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/pi/map_kernel.c b/arch/arm64/kernel/pi/map_kernel.c
index 357ccb562746..fa3549701927 100644
--- a/arch/arm64/kernel/pi/map_kernel.c
+++ b/arch/arm64/kernel/pi/map_kernel.c
@@ -219,10 +219,9 @@ static void *__init map_fdt(phys_addr_t fdt, int page_shift)
 	phys_addr_t efdt = fdt + MAX_FDT_SIZE;
 	phys_addr_t ptep = (phys_addr_t)ptes; /* We're idmapped when called */
 
-	if (!first_time) {
+	if (!first_time)
 		memset(ptes, 0, sizeof(ptes));
-		first_time = false;
-	}
+	first_time = false;
 
 	/*
 	 * Map up to MAX_FDT_SIZE bytes, but avoid overlap with



More information about the linux-arm-kernel mailing list