All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: The development of GRUB 2 <grub-devel@gnu.org>
Cc: Jan Nieuwenhuizen <janneke-list@xs4all.nl>
Subject: Re: Testing on PowerMac G4
Date: Fri, 04 Jan 2008 13:26:59 -0500	[thread overview]
Message-ID: <1199471219.17196.35.camel@dv> (raw)
In-Reply-To: <20080104123224.GA6657@thorin>

On Fri, 2008-01-04 at 13:32 +0100, Robert Millan wrote:
> On Thu, Jan 03, 2008 at 11:23:01AM -0500, Pavel Roskin wrote:
> > >Why?  Does the firmware impose this restriction, or is it GRUB itself that
> > >gets confused?
> > 
> > I wish I knew it.  0x7000 is not OK, 0x8000 is OK.  Less granularity  
> > makes no sense since the value is aligned at the 0x1000 boundary.
> 
> AFAICT, it can only happen in three ways:
> 
>   1- The firmware doesn't like GRUB image, and aborts with bogus errors before
>   transferring control to GRUB.  You can easily tell this appart by checking
>   for early "Welcome to GRUB" message.

I'm quite sure now that it's the case.  That's how it looks on the
surface, I just was extra cautious before I had a chance to learn more
about OpenFirmware and the GRUB code.

Not only there is no "Welcome to GRUB" message, but the screen is not
erased and remains black on white.  "CLAIM failed" is followed by the
OpenFirmware prompt.  There are no messages that the execution was
interrupted, which would appear in other failure cases.

I tried to convert grub-mkimage output to the binary format, and found
that objcopy doesn't like it.  In fact, the image doesn't even survive
simple objcopy intact.  "objcopy grubof.modules grubof.modules1"
produces a file 208 bytes long.

Moreover, "objdump -h grubof.modules" doesn't show any sections at all,
whereas "objdump -p grubof.modules" shows the segments.  It seems to me
that grub-mkimage produces something that looks like and ELF file and
the first glance, but is not a valid ELF file.  I can reproduce this
problem with linuxbios images on i386.

We just cannot expect OpenFirmware to process invalid ELF files.  It can
be looking for the section headers and finding non-zero data is the gap
is not wide enough.  It can be just anything.

A quick look into util/elf/grub-mkimage.c finds "Don't bother preserving
the section headers".  I don't even know if the problem is specifically
with the section headers or with something else.  Perhaps
util/elf/grub-mkimage.c should be rewritten as a linker script, or maybe
it should use the BFD library that comes with binutils.  I'm optimistic
about the linker script, since all we need is essentially linking.

> > There is a possibility that grub_errno remains set to some error.
> 
> Well, that's easy to tell appart with some printfs.

What I see is the last invocation of grub_ofdisk_open() has grub_errno
set to 13 (EACCESS) throughout the code.  It's never unset by any
successful operations.  I think some filesystem module may be resetting
grub_errno to 0.  It's strange that I don't even see EACCESS in the
code.

A quote from the glibc manual:

These functions do not change `errno' when they succeed; thus, the value
of `errno' after a successful call is not necessarily zero, and you
should not use `errno' to determine _whether_ a call failed.  The proper
way to do that is documented for each function.  _If_ the call failed,
you can examine `errno'.

grub_ofdisk_open() is in direct violation of that rule.  The execution
can reach the "fail:" label without having failed anywhere, yet the code
returns grub_errno unconditionally.

That's not to negate your findings, of course.

-- 
Regards,
Pavel Roskin



  parent reply	other threads:[~2008-01-04 18:27 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
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 [this message]
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=1199471219.17196.35.camel@dv \
    --to=proski@gnu.org \
    --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.