Commit 2d2da60f authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by H. Peter Anvin

x86, efi: Break up large initrd reads

The efi boot stub tries to read the entire initrd in 1 go, however
some efi implementations hang if too much if asked to read too much
data at the same time. After some experimentation I found out that my
asrock p67 board will hang if asked to read chunks of 4MiB, so use a
safe value.

elilo reads in chunks of 16KiB, but since that requires many read
calls I use a value of 1 MiB.  hpa suggested adding individual
blacklists for when systems are found where this value causes a crash.
Signed-off-by: default avatarMaarten Lankhorst <m.b.lankhorst@gmail.com>
Link: http://lkml.kernel.org/r/4EEB3A02.3090201@gmail.comSigned-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 291f3632
...@@ -643,14 +643,22 @@ static efi_status_t handle_ramdisks(efi_loaded_image_t *image, ...@@ -643,14 +643,22 @@ static efi_status_t handle_ramdisks(efi_loaded_image_t *image,
u64 size; u64 size;
size = initrds[j].size; size = initrds[j].size;
status = efi_call_phys3(fh->read, initrds[j].handle, while (size) {
&size, addr); u64 chunksize;
if (status != EFI_SUCCESS) if (size > EFI_READ_CHUNK_SIZE)
goto free_initrd_total; chunksize = EFI_READ_CHUNK_SIZE;
else
chunksize = size;
status = efi_call_phys3(fh->read,
initrds[j].handle,
&chunksize, addr);
if (status != EFI_SUCCESS)
goto free_initrd_total;
addr += chunksize;
size -= chunksize;
}
efi_call_phys1(fh->close, initrds[j].handle); efi_call_phys1(fh->close, initrds[j].handle);
addr += size;
} }
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define DESC_TYPE_CODE_DATA (1 << 0) #define DESC_TYPE_CODE_DATA (1 << 0)
#define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT) #define EFI_PAGE_SIZE (1UL << EFI_PAGE_SHIFT)
#define EFI_READ_CHUNK_SIZE (1024 * 1024)
#define PIXEL_RGB_RESERVED_8BIT_PER_COLOR 0 #define PIXEL_RGB_RESERVED_8BIT_PER_COLOR 0
#define PIXEL_BGR_RESERVED_8BIT_PER_COLOR 1 #define PIXEL_BGR_RESERVED_8BIT_PER_COLOR 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment