]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ppc64: more issues with mem_reserve
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Sat, 16 Oct 2004 13:19:14 +0000 (06:19 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 16 Oct 2004 13:19:14 +0000 (06:19 -0700)
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 <benh@kernel.crashing.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/ppc64/kernel/prom_init.c

index 88aaa02c57e8b756c874822fdc03b4df111ed13a..f62bda79e10262060ecc4e7c4da69a6f33df28e4 100644 (file)
@@ -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;