Re: [PATCH] x86: only load initrd above 4g on second try

2014-09-02 Thread Anders Darander
* Matt Fleming  [140830 13:24]:
> On Wed, 27 Aug, at 10:13:22AM, Yinghai Lu wrote:
> > How about adding more info print out like:
> >   "Try to load initrd file to higher address..."

> Yeah, that could work, at least we've had some debugging information to
> go on if people start reporting hangs, though I'd suggest using "Trying"
> or "Attempting".

That should be fine. That would at least give the user something easy to
search for (both web and source), and thus make it possible to at least
get an idea of why the boot is hanging for the few people that's going
to hit this.

For most systems, the default to load the initrd/initramfs below 4G (and
only load it above on the second attempt) will handle our buggy EFI's...

To me this sounds like something that should work.

Cheers,
Anders

-- 
Option Paralysis:
The tendency, when given unlimited choices, to make none.
-- Douglas Coupland, "Generation X: Tales for an Accelerated
   Culture"
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] x86: only load initrd above 4g on second try

2014-08-30 Thread Matt Fleming
On Wed, 27 Aug, at 10:13:22AM, Yinghai Lu wrote:
>
> How about adding more info print out like:
>   "Try to load initrd file to higher address..."

Yeah, that could work, at least we've had some debugging information to
go on if people start reporting hangs, though I'd suggest using "Trying"
or "Attempting".

-- 
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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] x86: only load initrd above 4g on second try

2014-08-27 Thread Yinghai Lu
On Wed, Aug 27, 2014 at 10:49 AM, H. Peter Anvin  wrote:
> On 08/26/2014 03:05 PM, Yinghai Lu wrote:
> This does, however, suggest at least two possible solutions:
>
> 1. We can read the initramfs into a temporary buffer and memcpy() it to
> the target.
>
> 2. We might be able to align the initramfs buffer to a 512-byte section
> and then round up the size.
>
> The 512 bytes here is probably a hardware sector, I'm not sure how this
> will play on 4K-hard-sectored media, although those are few and far between.

efi_high_alloc() already round up the buffer size with EFI_PAGE_SIZE
(it is 4KiB now), and the buffer is aligned to EFI_PAGE_SIZE.

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


Re: [PATCH] x86: only load initrd above 4g on second try

2014-08-27 Thread H. Peter Anvin
On 08/26/2014 03:05 PM, Yinghai Lu wrote:
> 
> The firmware has bug and can use buffer above 4G to read files.
> and if the file size is 512 bytes alignment, then reading could go through.
> 

File size, or alignment?  Different things.  Again, your patch
description is not just incomplete, but seems to be actively misleading.

This does, however, suggest at least two possible solutions:

1. We can read the initramfs into a temporary buffer and memcpy() it to
the target.

2. We might be able to align the initramfs buffer to a 512-byte section
and then round up the size.

The 512 bytes here is probably a hardware sector, I'm not sure how this
will play on 4K-hard-sectored media, although those are few and far between.

-hpa

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


Re: [PATCH] x86: only load initrd above 4g on second try

2014-08-27 Thread Yinghai Lu
On Wed, Aug 27, 2014 at 3:59 AM, Matt Fleming  wrote:
> On Tue, 26 Aug, at 02:45:44PM, Yinghai Lu wrote:
> The reason I suggested introducing some kind of kernel parameter to
> allow loading above 4G is because if Mantas loads a 5GB initrd with your
> patch, his machine is still going to hang, with no indication of why it
> hung.
>
> At least with a kernel paramter, by default we can try to load under 4G,
> and if that fails because the file is too big we can print something
> along the lines of,
>
>   "initramfs file too large: try booting with efi=file-max"
>
> No, it's not ideal, but I think it's a worthwhile compromise because
> you're only going to run into this issue when loading a huge initramfs
> with the EFI boot stub.

I would like to avoid adding more kernel parameter.

How about adding more info print out like:
  "Try to load initrd file to higher address..."

Thanks

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


Re: [PATCH] x86: only load initrd above 4g on second try

2014-08-27 Thread Matt Fleming
On Tue, 26 Aug, at 02:45:44PM, Yinghai Lu wrote:
> Mantas found that after commit 4bf7111f5016 ("x86/efi: Support initrd
> loaded above 4G"), the kernel freezes at the earliest possible moment
> when trying to boot via UEFI on Asus laptop.
> 
> There are buggy EFI implementations: with EFI run time, kernel need
> to load file with 512bytes alignment when buffer is above 4G.
> 
> So revert to old way to load initrd on first try,
> second try will use above 4G buffer when initrd is more than
> 2G and does not fit under 4G.
> 
> Reported-by: Mantas Mikulėnas 
> Tested-by: Anders Darander 
> Signed-off-by: Yinghai Lu 
> 
> ---
>  arch/x86/boot/compressed/eboot.c |   16 +---
>  1 file changed, 9 insertions(+), 7 deletions(-)

The reason I suggested introducing some kind of kernel parameter to
allow loading above 4G is because if Mantas loads a 5GB initrd with your
patch, his machine is still going to hang, with no indication of why it
hung.

At least with a kernel paramter, by default we can try to load under 4G,
and if that fails because the file is too big we can print something
along the lines of,

  "initramfs file too large: try booting with efi=file-max"

No, it's not ideal, but I think it's a worthwhile compromise because
you're only going to run into this issue when loading a huge initramfs
with the EFI boot stub.

If instead you're using Grub or Syslinux (and the EFI handover protocol)
it's a non-issue because both of those boot loaders carry FAT drivers
and use EFI_BLOCK_IO_PROTOCOL which doesn't trigger the firmware bug.

It's only because we don't have a FAT driver in the EFI boot stub and
have to resort to using EFI_FILE_PROTOCOL that we've encountered this
problem at all.

-- 
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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] x86: only load initrd above 4g on second try

2014-08-26 Thread Yinghai Lu
On Tue, Aug 26, 2014 at 3:16 PM, Mantas Mikulėnas  wrote:
>
> In particular, I just realized yesterday that I don't know whether
> it's referring to physical or virtual addresses in the initrd load
> code -- and the laptop only has 4 GB of memory, so the kernel
> shouldn't be using larger physical addresses in the first place.
> (Virtual ones, on the other hand, /would/ mean a weird bug like
> described above.)

When you have 4G ram installed, the mmio could take [3G,4G).
ram range will be [0,3G), [4G, 5G).

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


Re: [PATCH] x86: only load initrd above 4g on second try

2014-08-26 Thread Mantas Mikulėnas
On Wed, Aug 27, 2014 at 1:05 AM, Yinghai Lu  wrote:
> On Tue, Aug 26, 2014 at 2:53 PM, H. Peter Anvin  wrote:
>> On 08/26/2014 02:45 PM, Yinghai Lu wrote:
>>> Mantas found that after commit 4bf7111f5016 ("x86/efi: Support initrd
>>> loaded above 4G"), the kernel freezes at the earliest possible moment
>>> when trying to boot via UEFI on Asus laptop.
>>>
>>> There are buggy EFI implementations: with EFI run time, kernel need
>>> to load file with 512bytes alignment when buffer is above 4G.
>>>
>>
>> This makes absolutely zero sense.  Please explain what the actual
>> problem is here.
>
> The firmware has bug and can use buffer above 4G to read files.
> and if the file size is 512 bytes alignment, then reading could go through.
>
> From Mantas:
> --
> On Wed, Aug 20, 2014 at 12:05 PM, Mantas Mikulėnas  wrote:
>>
>> I experimented with some things (like setting chunk size to a few kB
>> to see if it hangs earlier or only at the very end; etc.), and finally
>> found out that it stops freezing if I pad the initrd file to a
>> multiple of 512 bytes :/ That is, 5684268 bytes will freeze, 5684736
>> bytes will not.
>>
>> ...In other words, seems like it cannot read chunks that aren't
>> multiples of 512 into a location above 4 GB. Or something like that..

Note that I'm mostly clueless about how EFI works (my "debugging" is
mostly just 'efi_printk()'s to see where it hangs), so take my
description with a grain of salt...

In particular, I just realized yesterday that I don't know whether
it's referring to physical or virtual addresses in the initrd load
code -- and the laptop only has 4 GB of memory, so the kernel
shouldn't be using larger physical addresses in the first place.
(Virtual ones, on the other hand, /would/ mean a weird bug like
described above.)

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


Re: [PATCH] x86: only load initrd above 4g on second try

2014-08-26 Thread Yinghai Lu
On Tue, Aug 26, 2014 at 2:53 PM, H. Peter Anvin  wrote:
> On 08/26/2014 02:45 PM, Yinghai Lu wrote:
>> Mantas found that after commit 4bf7111f5016 ("x86/efi: Support initrd
>> loaded above 4G"), the kernel freezes at the earliest possible moment
>> when trying to boot via UEFI on Asus laptop.
>>
>> There are buggy EFI implementations: with EFI run time, kernel need
>> to load file with 512bytes alignment when buffer is above 4G.
>>
>
> This makes absolutely zero sense.  Please explain what the actual
> problem is here.

The firmware has bug and can use buffer above 4G to read files.
and if the file size is 512 bytes alignment, then reading could go through.

>From Mantas:
--
On Wed, Aug 20, 2014 at 12:05 PM, Mantas Mikulėnas  wrote:
>
> I experimented with some things (like setting chunk size to a few kB
> to see if it hangs earlier or only at the very end; etc.), and finally
> found out that it stops freezing if I pad the initrd file to a
> multiple of 512 bytes :/ That is, 5684268 bytes will freeze, 5684736
> bytes will not.
>
> ...In other words, seems like it cannot read chunks that aren't
> multiples of 512 into a location above 4 GB. Or something like that..


>From Matt:
---
> OK, we're out of options here. Yinghai, we're going to have to revert
> your patch, 4bf7111f5016 ("x86/efi: Support initrd loaded above 4G")
>
> We could conceivably add a boot parameter option to attempt loading
> inirds above 4G, but we can't turn the feature on by default because of
> all these buggy EFI implementations - things must work out of the box.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] x86: only load initrd above 4g on second try

2014-08-26 Thread H. Peter Anvin
On 08/26/2014 02:45 PM, Yinghai Lu wrote:
> Mantas found that after commit 4bf7111f5016 ("x86/efi: Support initrd
> loaded above 4G"), the kernel freezes at the earliest possible moment
> when trying to boot via UEFI on Asus laptop.
> 
> There are buggy EFI implementations: with EFI run time, kernel need
> to load file with 512bytes alignment when buffer is above 4G.
> 

This makes absolutely zero sense.  Please explain what the actual
problem is here.

-hpa

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


[PATCH] x86: only load initrd above 4g on second try

2014-08-26 Thread Yinghai Lu
Mantas found that after commit 4bf7111f5016 ("x86/efi: Support initrd
loaded above 4G"), the kernel freezes at the earliest possible moment
when trying to boot via UEFI on Asus laptop.

There are buggy EFI implementations: with EFI run time, kernel need
to load file with 512bytes alignment when buffer is above 4G.

So revert to old way to load initrd on first try,
second try will use above 4G buffer when initrd is more than
2G and does not fit under 4G.

Reported-by: Mantas Mikulėnas 
Tested-by: Anders Darander 
Signed-off-by: Yinghai Lu 

---
 arch/x86/boot/compressed/eboot.c |   16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

Index: linux-2.6/arch/x86/boot/compressed/eboot.c
===
--- linux-2.6.orig/arch/x86/boot/compressed/eboot.c
+++ linux-2.6/arch/x86/boot/compressed/eboot.c
@@ -1032,7 +1032,6 @@ struct boot_params *make_boot_params(str
int i;
unsigned long ramdisk_addr;
unsigned long ramdisk_size;
-   unsigned long initrd_addr_max;
 
efi_early = c;
sys_table = (efi_system_table_t *)(unsigned long)efi_early->table;
@@ -1095,15 +1094,18 @@ struct boot_params *make_boot_params(str
 
memset(sdt, 0, sizeof(*sdt));
 
-   if (hdr->xloadflags & XLF_CAN_BE_LOADED_ABOVE_4G)
-   initrd_addr_max = -1UL;
-   else
-   initrd_addr_max = hdr->initrd_addr_max;
-
status = handle_cmdline_files(sys_table, image,
  (char *)(unsigned long)hdr->cmd_line_ptr,
- "initrd=", initrd_addr_max,
+ "initrd=", hdr->initrd_addr_max,
+ &ramdisk_addr, &ramdisk_size);
+
+   if (status != EFI_SUCCESS &&
+   hdr->xloadflags & XLF_CAN_BE_LOADED_ABOVE_4G)
+   status = handle_cmdline_files(sys_table, image,
+ (char *)(unsigned long)hdr->cmd_line_ptr,
+ "initrd=", -1UL,
  &ramdisk_addr, &ramdisk_size);
+
if (status != EFI_SUCCESS)
goto fail2;
hdr->ramdisk_image = ramdisk_addr & 0x;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/