From 9b9407e86a02600f452e768bb5c0071ff919df6b Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Sat, 16 Oct 2004 06:19:14 -0700 Subject: [PATCH] [PATCH] ppc64: more issues with mem_reserve As Milton noticed, Anton actually broke the logic if the memory isn't aligned in the first place. Sorry about this mess for such a little piece of code. This _really_ fixes is it all Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Linus Torvalds --- arch/ppc64/kernel/prom_init.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/ppc64/kernel/prom_init.c b/arch/ppc64/kernel/prom_init.c index 88aaa02c57e8b..f62bda79e1026 100644 --- a/arch/ppc64/kernel/prom_init.c +++ b/arch/ppc64/kernel/prom_init.c @@ -587,19 +587,20 @@ 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); - if (!size) + if (size == 0) return; - base = _ALIGN_DOWN(base, PAGE_SIZE); - size = _ALIGN_UP(size, PAGE_SIZE); - - /* - * We need to always keep one empty entry so that we + /* 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_UP(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.53.0