Re: [PATCH v5 10/10] x86, efi: EFI boot stub support

From: Matt Fleming
Date: Thu Nov 24 2011 - 15:57:10 EST


On Thu, 2011-11-24 at 15:43 +0100, Maarten Lankhorst wrote:
> Hey Matt,
>
> On 11/23/2011 08:27 PM, Matt Fleming wrote:
>
> > On Wed, 2011-11-23 at 01:44 +0100, Maarten Lankhorst wrote:
> >> When I tested this with v3.2-rc2 it didn't boot, it hung before it
> >> initialized the kernel.
> >> Without initrd it works fine, though.
> > Bah, so this change actually makes booting worse? You said before that
> > you almost made it to userspace but this seems to hang much earlier now.
> > Is that correct?
> >
> > ... back to the drawing board.
> I was looking at why grub2 could boot, seems to be it reads in chunks of
> 256 kilobytes. I seem to be able to get it to boot with chunks of 4 mb
> as well, but didn't test beyond that.
>
> So the fix is to simply read the file in parts, otherwise efi hangs..
> As a nice side effect, short reads are also handled, but the efi
> firmware seems to choke over huge reads and dies.

Urrggghh.....

Thanks a lot for diagnosing this, Maarten! The copy of grub that I have
(fedora's version) looks like it uses the disk_io protocol to read from
disks, I wonder if there's a reason for this. I Cc'd Peter Jones in case
he's seen anything like this before.

Aha, read_file() in the elilo source contains this helpful comment,

/*
* We load by chunks rather than a single big read because
* early versions of EFI had troubles loading files
* from floppies in a single big request. Breaking
* the read down into chunks of 4KB fixed that
* problem. While this problem has been fixed, we still prefer
* this method because it tells us whether or not we're making
* forward progress.
*/

(but reading the code it's clear it uses a chunk size of 16KB, not 4KB)

So, it looks like it's not just reading from floppies that hits this bug
in the firmware.

Maarten, could you send a patch against the 'x86/efi-stub' branch at
git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/linux.git that
splits the read up into 16KB chunks and explains,

- why we need to do the reading in chunks
- why we chose the 16KB chunk size (because elilo said so)

That way, the bug fix will be properly documented and attributed to you.

--
Matt Fleming, Intel Open Source Technology Center

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/