From ab83f017e6edf6010bb30c6d8ceb3dddeb7178c0 Mon Sep 17 00:00:00 2001 From: bl4ckhyun Date: Wed, 15 Apr 2026 13:42:07 +0900 Subject: [PATCH] [lib][fdtwalk] fix unaligned FDT memory reservation Signed-off-by: bl4ckhyun --- lib/fdtwalk/helpers.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/fdtwalk/helpers.cpp b/lib/fdtwalk/helpers.cpp index ea67e48cc..85fad135c 100644 --- a/lib/fdtwalk/helpers.cpp +++ b/lib/fdtwalk/helpers.cpp @@ -51,11 +51,11 @@ status_t fdtwalk_reserve_fdt_memory(const void *fdt, paddr_t fdt_phys) { return ERR_NOT_FOUND; } - uint32_t length = fdt_totalsize(fdt); + size_t length = fdt_totalsize(fdt); - paddr_t base = fdt_phys; - base = PAGE_ALIGN(base); - length = ROUNDUP(length, PAGE_SIZE); + paddr_t base = ROUNDDOWN(fdt_phys, PAGE_SIZE); + size_t offset = fdt_phys - base; + length = ROUNDUP(length + offset, PAGE_SIZE); dprintf(INFO, "FDT: reserving physical range for FDT: [%#lx, %#lx]\n", base, base + length - 1);