Explanation.

It seems to be a case of  spurious line that got back into grub_elf32_load
and grub_elf64_load, nested function.

    if (load_hook && load_hook (phdr, &load_addr))
      return 1;
    load_addr = phdr->p_paddr;

That sequence did not make sense to me, it overwrites the correct value of
load_addr from the preceding line.

Briefly -

with set debug=elf

Result -
 for the bug -
..kernel/elf.c:429 Loading segment at 0x0 size 6ae0c8
 fails to load kernel at 0x0 as expected.

 the fix /* load_addr = phdr->p_paddr; */
..kernel/elf.c:429 Loading segment at 0x1400000 size 6ae0c8
  loads kernel

----------------------

Details -

Both 32bit ibook G4 and 64bit powerpc G5 were affected, and failed to load
linux kernel.

I rechecked and got some debug results to illustrate, hand copied from boot
screen.

I  used grub_dprintf("elfpxw","phdr->p_paddr=%llx,
load_addr=%x\n",phdr->p_paddr,load_addr);

In grub_elf64_load as used by my powerpc64 g5.

The debugging outputs shown as they occur in sequence with the code (approx
line umbers)

    if (load_hook && load_hook (phdr, &load_addr))
      return 1;

..kernel/elf.c:421 phdr->p_paddr= c000000000000000 load_addr= 1400000

/* spurious line overwrites load_addr value from load_hook*/
    load_addr = phdr->p_paddr;

..kernel/elf.c:424 phdr->p_paddr= c000000000000000 load_addr= 0

    grub_dprintf ("elfpxw", "Loading segment at 0x%llx, size 0x%llx\n",
          (unsigned long long) load_addr,
          (unsigned long long) phdr->p_memsz);

..kernel/elf.c:429 Loading segment at 0x0 size 6ae0c8

 - load kernel at 0x0 fails as expected

=========
The correct result with /* load_addr = phdr->p_paddr;*/

    if (load_hook && load_hook (phdr, &load_addr))
      return 1;
 phdr->p_paddr= c000000000000000 load_addr= 1400000
/*    load_addr = phdr->p_paddr;  */
 phdr->p_paddr= c000000000000000 load_addr= 1400000
  Loading segment at 0x1400000 size 6ae0c8

 - load kernel at 0x1400000 succeeds.
=========
peter cros.



On Mon, Sep 29, 2008 at 12:46 AM, Robert Millan <[EMAIL PROTECTED]> wrote:

> On Mon, Sep 29, 2008 at 12:42:36AM +1000, peter cros wrote:
> > Hi,
> >
> > There is a bug in /kern/elf.c/ (target powerpc, platform ieee1275),
> > causing load linux to fail on my powerpc64 g5 and ibook g4 32bit.
> >
> > Here is a diff of the fix I found necessary for rev 1878 (bug has existed
> in
> > previous versions).
> >
> > It was a one liner -
> >
> > diff -pu grubsvn/kern grubtry/kern/elf.c
> > ---------------------------------------------
> > --- grubsvn/kern/elf.c    2008-09-28 17:27:56.000000000 +1000
> > +++ grubtry/kern/elf.c    2008-09-28 23:16:38.000000000 +1000
> > @@ -234,7 +234,7 @@ grub_elf32_load (grub_elf_t _elf, grub_e
> >
> >      if (load_hook && load_hook (phdr, &load_addr))
> >        return 1;
> > -    load_addr = phdr->p_paddr;
> > +/** pxwdebug - not required -  load_addr = phdr->p_paddr; **/
>
> Hi,
>
> Thanks for pointing this out.  Unless someone understands your change,
> we'd need you to explain why this line isn't necessary, and why it was
> causing trouble.
>
> --
> Robert Millan
>
>  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
>  how) you may access your data; but nobody's threatening your freedom: we
>  still allow you to remove your data and not access it at all."
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to