Skip to content

Commit

Permalink
of: Fix memory block alignment in early_init_dt_add_memory_arch()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Geert Uytterhoeven authored and Grant Likely committed Sep 8, 2014
1 parent 7dbe584 commit 8f73d4b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/of/fdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8f73d4b

Please sign in to comment.