From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1RG2Yg-0008Gf-GZ for mharc-grub-devel@gnu.org; Tue, 18 Oct 2011 01:49:50 -0400 Received: from eggs.gnu.org ([140.186.70.92]:58643) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RG2Yb-0008GT-3j for grub-devel@gnu.org; Tue, 18 Oct 2011 01:49:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RG2Ya-0000Nf-7b for grub-devel@gnu.org; Tue, 18 Oct 2011 01:49:45 -0400 Received: from ozlabs.org ([203.10.76.45]:56954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RG2YZ-0000NZ-TB for grub-devel@gnu.org; Tue, 18 Oct 2011 01:49:44 -0400 Received: from kryten (ppp121-44-79-234.lns20.syd6.internode.on.net [121.44.79.234]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPSA id 59D9CB70DC for ; Tue, 18 Oct 2011 16:49:41 +1100 (EST) Date: Tue, 18 Oct 2011 16:49:40 +1100 From: Anton Blanchard To: The development of GNU GRUB Subject: Re: [PATCH] Fix module relocation errors on PowerPC Message-ID: <20111018164940.42101700@kryten> In-Reply-To: <20111018154817.752a92f6@kryten> References: <20111018154817.752a92f6@kryten> X-Mailer: Claws Mail 3.7.8 (GTK+ 2.24.4; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2011 05:49:49 -0000 Hi, > Modules (and therefore the heap) need to be close to the executable to > avoid requiring more complicated relocations. This patch uses the same > method sparc does and puts the heap directly above the executable. Sparc doesn't appear to claim the heap. Adding this patch on top of the relocation one fixes things for me on PowerPC. Any suggestions on the best way to fix it? The non Sparc version of grub_claim_heap is rather complicated and I'm not sure why it just doesn't allocate a couple of MB right above the executable. Assuming we have ~4MB of free space at the address OF loads us is pretty reasonable to me. Anton -- Index: grub/grub-core/kern/ieee1275/init.c =================================================================== --- grub.orig/grub-core/kern/ieee1275/init.c 2011-10-18 16:30:03.824984376 +1100 +++ grub/grub-core/kern/ieee1275/init.c 2011-10-18 16:38:34.394100481 +1100 @@ -139,8 +139,16 @@ grub_machine_get_bootlocation (char **de static void grub_claim_heap (void) { - grub_mm_init_region ((void *) (grub_modules_get_end () - + GRUB_KERNEL_MACHINE_STACK_SIZE), 0x200000); + grub_uint64_t addr, len; + + addr = grub_modules_get_end () + GRUB_KERNEL_MACHINE_STACK_SIZE; + len = 0x200000; + + if (grub_claimmap (addr, len) < 0) + grub_error (GRUB_ERR_OUT_OF_MEMORY, + "failed to claim heap at 0x%llx, len 0x%llx", + addr, len); + grub_mm_init_region ((void *) (grub_addr_t)addr, len); } #else static void