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

From: Maarten Lankhorst
Date: Thu Nov 24 2011 - 09:43:24 EST


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.

diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 8627a56..9b076f0 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -695,14 +695,16 @@ grow:
u64 size;

size = initrds[j].size;
- status = efi_call_phys3(fh->read, initrds[j].handle,
- &size, addr);
- if (status != EFI_SUCCESS)
- goto free_initrd_total;
-
+ while (size) {
+ u64 toread = size > 1024 * 1024 ? 1024 * 1024 : size;
+ status = efi_call_phys3(fh->read, initrds[j].handle,
+ &toread, addr);
+ if (status != EFI_SUCCESS)
+ goto free_initrd_total;
+ size -= toread;
+ addr += toread;
+ }
efi_call_phys1(fh->close, initrds[j].handle);
-
- addr += size;
}

}


--
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/