]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ppc64: fix some issues with mem_reserve
authorAnton Blanchard <anton@samba.org>
Sat, 16 Oct 2004 08:03:14 +0000 (01:03 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 16 Oct 2004 08:03:14 +0000 (01:03 -0700)
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 <anton@samba.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/ppc64/kernel/prom_init.c

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