Skip to content

Commit f71a1a4

Browse files
committed
arm64: Ignore memory blocks below PHYS_OFFSET
According to Documentation/arm64/booting.txt, the kernel image must be loaded at a pre-defined offset from the start of RAM so that the kernel can calculate PHYS_OFFSET based on this address. If the DT contains memory blocks below this PHYS_OFFSET, report them and ignore the corresponding memory range. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent c60b0c2 commit f71a1a4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

arch/arm64/kernel/setup.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,19 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
170170

171171
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
172172
{
173+
base &= PAGE_MASK;
173174
size &= PAGE_MASK;
175+
if (base + size < PHYS_OFFSET) {
176+
pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
177+
base, base + size);
178+
return;
179+
}
180+
if (base < PHYS_OFFSET) {
181+
pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
182+
base, PHYS_OFFSET);
183+
size -= PHYS_OFFSET - base;
184+
base = PHYS_OFFSET;
185+
}
174186
memblock_add(base, size);
175187
}
176188

0 commit comments

Comments
 (0)