grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba.org>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH] Fix module relocation errors on PowerPC
Date: Tue, 18 Oct 2011 16:49:40 +1100	[thread overview]
Message-ID: <20111018164940.42101700@kryten> (raw)
In-Reply-To: <20111018154817.752a92f6@kryten>

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 


  reply	other threads:[~2011-10-18  5:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-18  4:48 [PATCH] Fix module relocation errors on PowerPC Anton Blanchard
2011-10-18  5:49 ` Anton Blanchard [this message]
2011-10-29  9:39   ` Vladimir 'φ-coder/phcoder' Serbinenko
2011-11-03 18:03 ` Vladimir 'φ-coder/phcoder' Serbinenko
2011-11-08  8:57   ` Anton Blanchard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111018164940.42101700@kryten \
    --to=anton@samba.org \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).