of: Fix memory block alignment in early_init_dt_add_memory_arch()
authorGeert Uytterhoeven <geert+renesas@glider.be>
Wed, 20 Aug 2014 15:10:31 +0000 (17:10 +0200)
committerGrant Likely <grant.likely@linaro.org>
Mon, 8 Sep 2014 14:57:26 +0000 (15:57 +0100)
If a memory block is not aligned to PAGE_SIZE, its base address must be
rounded up, not down, and its size must be reduced.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
drivers/of/fdt.c

index 79cb8313c7d8b0b86681bc75867e8b6e5ee746ef..2d34afb2647d6b4bc8b8296577c9aee4efb6bb0e 100644 (file)
@@ -928,7 +928,11 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
 void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
 {
        const u64 phys_offset = __pa(PAGE_OFFSET);
-       base &= PAGE_MASK;
+
+       if (!PAGE_ALIGNED(base)) {
+               size -= PAGE_SIZE - (base & ~PAGE_MASK);
+               base = PAGE_ALIGN(base);
+       }
        size &= PAGE_MASK;
 
        if (base > MAX_PHYS_ADDR) {