Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754469Ab1EVVRa (ORCPT ); Sun, 22 May 2011 17:17:30 -0400 Received: from mail4.comsite.net ([205.238.176.238]:49539 "EHLO mail4.comsite.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754468Ab1EVVRY (ORCPT ); Sun, 22 May 2011 17:17:24 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=71.22.127.106; Subject: Re: [PATCH v3] powerpc: Force page alignment for initrd reserved memory To: Dave Carroll From: "'Milton Miller'" CC: Paul Mackerras , LPPC , LKML , "Benjamin Herrenschmidt" Subject: Re: [PATCH v3] powerpc: Force page alignment for initrd reserved memory Message-ID: In-Reply-To: <522F24EF533FC546962ECFA2054FF777373072AB73@MAILSERVER2.cos.astekcorp.com> References: <522F24EF533FC546962ECFA2054FF777373072AB73@MAILSERVER2.cos.astekcorp.com> Date: Sun, 22 May 2011 16:17:18 -0500 X-Originating-IP: 71.22.127.106 X-HeloNotChecked: Helo response was not checked before commands sent Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2423 Lines: 63 On Sat, 21 May 2011 about 11:05:27 -0600, Dave Carroll wrote: > > When using 64K pages with a separate cpio rootfs, U-Boot will align > the rootfs on a 4K page boundary. When the memory is reserved, and > subsequent early memblock_alloc is called, it will allocate memory > between the 64K page alignment and reserved memory. When the reserved > memory is subsequently freed, it is done so by pages, causing the > early memblock_alloc requests to be re-used, which in my case, caused > the device-tree to be clobbered. > > This patch forces the reserved memory for initrd to be kernel page > aligned, and adds the same range extension when freeing initrd. Getting better, but > > > Signed-off-by: Dave Carroll > --- > arch/powerpc/kernel/prom.c | 4 +++- > arch/powerpc/mm/init_32.c | 3 +++ > arch/powerpc/mm/init_64.c | 3 +++ > 3 files changed, 9 insertions(+), 1 deletions(-) > > diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c > index 48aeb55..397d4a0 100644 > --- a/arch/powerpc/kernel/prom.c > +++ b/arch/powerpc/kernel/prom.c > @@ -555,7 +555,9 @@ static void __init early_reserve_mem(void) > #ifdef CONFIG_BLK_DEV_INITRD > /* then reserve the initrd, if any */ > if (initrd_start && (initrd_end > initrd_start)) Here you test the unaligned values > void free_initrd_mem(unsigned long start, unsigned long end) > { > + start = _ALIGN_DOWN(start, PAGE_SIZE); > + end = _ALIGN_UP(end, PAGE_SIZE); > + > if (start < end) > printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10); But here you test the aligned values. And they are aligned with opposite bias. Which means that if start == end (or is less than, but within the same page), a page that wasn't reserved (same 32 and 64 bit) gets freed. I thought "what happens if we are within a page of end, could we free the last page of bss?", but then I checked vmlinux.lds and we align end to page size. I thought other allocations should be safe, but then remembered: The flattened device tree (of which we continue to use the string table after boot) could be a problem. milton -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/