From 3e306fcdfa8d93d9f0abb2b7a0469496e96d507c Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Sat, 16 Oct 2004 01:03:14 -0700 Subject: [PATCH] [PATCH] ppc64: fix some issues with mem_reserve I found a couple of issues with reserve_mem: - If we try and mem_reserve something of zero length, everything reserved after it would get ignored. This is because early_reserve_mem sees a zero length as a terminator. - The code rounded the top down instead of up. Signed-off-by: Anton Blanchard Signed-off-by: Linus Torvalds --- arch/ppc64/kernel/prom_init.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/ppc64/kernel/prom_init.c b/arch/ppc64/kernel/prom_init.c index f7b44772cba2..88aaa02c57e8 100644 --- a/arch/ppc64/kernel/prom_init.c +++ b/arch/ppc64/kernel/prom_init.c @@ -587,17 +587,19 @@ static unsigned long __init prom_next_cell(int s, cell_t **cellp) static void reserve_mem(unsigned long base, unsigned long size) { unsigned long offset = reloc_offset(); - unsigned long top = base + size; unsigned long cnt = RELOC(mem_reserve_cnt); - /* We need to always keep one empty entry so that we + if (!size) + return; + + base = _ALIGN_DOWN(base, PAGE_SIZE); + size = _ALIGN_UP(size, PAGE_SIZE); + + /* + * We need to always keep one empty entry so that we * have our terminator with "size" set to 0 since we are * dumb and just copy this entire array to the boot params */ - base = _ALIGN_DOWN(base, PAGE_SIZE); - top = _ALIGN_DOWN(top, PAGE_SIZE); - size = top - base; - if (cnt >= (MEM_RESERVE_MAP_SIZE - 1)) prom_panic("Memory reserve map exhausted !\n"); RELOC(mem_reserve_map)[cnt].base = base; -- 2.39.5