All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Millan <rmh@aybabtu.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Cc: Jan Nieuwenhuizen <janneke-list@xs4all.nl>
Subject: Re: Testing on PowerMac G4
Date: Thu, 3 Jan 2008 16:57:34 +0100	[thread overview]
Message-ID: <20080103155734.GA25410@thorin> (raw)
In-Reply-To: <20080103102846.mhnl7v6xw4ksk48k@webmail.spamcop.net>

On Thu, Jan 03, 2008 at 10:28:46AM -0500, Pavel Roskin wrote:
> Quoting Robert Millan <rmh@aybabtu.com>:
> 
> >>The module base address is calculated separately in kernel.elf and in
> >>grub-mkimage.  kernel.elf uses the "_end" symbol, whereas grub-mkimage
> >>looks for the ELF segment with the highest end address.
> >
> >Ok, so you mean this setting:
> >
> >  phdr->p_vaddr = grub_host_to_target32 (modbase);
> >  phdr->p_paddr = grub_host_to_target32 (modbase);
> >
> >is not what it's used to calculate _end ?
> 
> OK, it turns out the values of _end actually match, so it's not a problem.
> 
> It turns out there needs to be a gap between _end and the module base.  
>  16k (0x4000) is not enough.  32k (0x8000) is enough.

Why?  Does the firmware impose this restriction, or is it GRUB itself that
gets confused?

> This patch against the current CVS version fixes loading:
> 
> diff --git a/kern/powerpc/ieee1275/init.c b/kern/powerpc/ieee1275/init.c
> index 4727d7d..d2fa980 100644
> --- a/kern/powerpc/ieee1275/init.c
> +++ b/kern/powerpc/ieee1275/init.c
> @@ -231,5 +231,5 @@ grub_get_rtc (void)
>  grub_addr_t
>  grub_arch_modules_addr (void)
>  {
> -  return ALIGN_UP(_end, GRUB_MOD_ALIGN);
> +  return ALIGN_UP(_end + 0x8000, GRUB_MOD_ALIGN);
>  }
> diff --git a/util/elf/grub-mkimage.c b/util/elf/grub-mkimage.c
> index 9e44af1..c39717a 100644
> --- a/util/elf/grub-mkimage.c
> +++ b/util/elf/grub-mkimage.c
> @@ -228,6 +228,7 @@ add_segments (char *dir, FILE *out, int chrp, char  
> *mods[])
>        phdr->p_offset = grub_host_to_target32 (ALIGN_UP  
> (grub_util_get_fp_size (out),
>  						   sizeof (long)));
> 
> +      modbase += 0x8000;
>        load_modules (modbase, phdr, dir, mods, out);
>      }

This might differ from the init.c counterpart.  There's an ALIGN_UP just
a few lines above, if you set it to:

  modbase = ALIGN_UP(grub_end + 0x8000, GRUB_MOD_ALIGN);

both alignment and 0x8000 gap are still garanteed, without claiming more
space than necessary.

That is, if it really is a gap that you need :-)

> I haven't looked at binutils yet.  Anyway, the problem doesn't exist  
> with the current grub code because it suppressed build ID on  
> kernel.elf.  My workaround to get older grub compiled didn't actually  
> strip build ID, it just fooled the objcopy test.

Ah, ok.

> But it would be great to detect and skip the segment corresponding to  
> the build ID in grub-mkimage, just to make it more robust.

Can we make this work per inclusion rather than exclusion?  The names
of needed segments are well-known, right?

> >>I actually doubt that it's the right behavior to go through segments.
> >
> >No idea about that I'm afraid :-(
> 
> We need to figure out why the extra gap is needed.  Maybe something  
> doesn't get counted.

Yep.  How did you find that an extra gap solves the problem?

> >>But maybe it's because in the normal mode with all modules loaded,
> >>unlike bare kernel.elf.
> >
> >But you don't need modules for ofdisk to work, it's built into the kernel.
> 
> Just going to the rescue mode with the "rescue" command won't cause  
> those hidden failures.  It seems like they are caused by some missing  
> module.  I need to look into it.

It might be simpler than this.  If you check what is the code flow between
those two:

disk/ieee1275/ofdisk.c:74: Opened `ide1/disk:0' as handle 0xff9d1c00.
kern/disk.c:299: Opening `ide1/disk' failed.

that'll give more details.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)



  reply	other threads:[~2008-01-03 16:03 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-31  8:12 Testing on PowerMac G4 Pavel Roskin
2007-12-31  8:45 ` Jan Nieuwenhuizen
2007-12-31 22:37   ` Pavel Roskin
2007-12-31 23:34     ` Robert Millan
2008-01-02  6:46       ` Pavel Roskin
2008-01-02 10:32         ` Robert Millan
2008-01-03  8:09           ` Pavel Roskin
2008-01-03 12:11             ` Robert Millan
2008-01-03 15:28               ` Pavel Roskin
2008-01-03 15:57                 ` Robert Millan [this message]
2008-01-03 16:23                   ` Pavel Roskin
2008-01-04 12:32                     ` Robert Millan
2008-01-04 12:54                       ` Robert Millan
2008-01-04 18:26                       ` Pavel Roskin
2008-01-04 20:37                         ` Robert Millan
2008-01-05  1:45                           ` Yoshinori K. Okuji
2008-01-05 11:43                             ` Robert Millan
2008-01-05  2:10                           ` Pavel Roskin
2008-01-05 11:45                             ` Robert Millan
2008-01-05  1:27                 ` Yoshinori K. Okuji
2008-01-05  2:02                   ` Pavel Roskin
2008-01-05 10:31                     ` Yoshinori K. Okuji
2008-01-05 11:46                   ` Robert Millan
2007-12-31 14:04 ` Robert Millan
2007-12-31 22:58   ` Pavel Roskin

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=20080103155734.GA25410@thorin \
    --to=rmh@aybabtu.com \
    --cc=grub-devel@gnu.org \
    --cc=janneke-list@xs4all.nl \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.