summaryrefslogtreecommitdiff
path: root/drivers/firmware/efi/libstub/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firmware/efi/libstub/file.c')
-rw-r--r--drivers/firmware/efi/libstub/file.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/drivers/firmware/efi/libstub/file.c b/drivers/firmware/efi/libstub/file.c
index 0d67432ed067..be78f64f8d80 100644
--- a/drivers/firmware/efi/libstub/file.c
+++ b/drivers/firmware/efi/libstub/file.c
@@ -123,7 +123,8 @@ static int find_file_option(const efi_char16_t *cmdline, int cmdline_len,
static efi_status_t handle_cmdline_files(efi_loaded_image_t *image,
const efi_char16_t *optstr,
int optstr_size,
- unsigned long max_addr,
+ unsigned long soft_limit,
+ unsigned long hard_limit,
unsigned long *load_addr,
unsigned long *load_size)
{
@@ -179,8 +180,15 @@ static efi_status_t handle_cmdline_files(efi_loaded_image_t *image,
round_up(alloc_size, EFI_ALLOC_ALIGN)) {
unsigned long old_addr = alloc_addr;
- status = efi_allocate_pages(alloc_size + size, &alloc_addr,
- max_addr);
+ status = EFI_OUT_OF_RESOURCES;
+ if (soft_limit < hard_limit)
+ status = efi_allocate_pages(alloc_size + size,
+ &alloc_addr,
+ soft_limit);
+ if (status == EFI_OUT_OF_RESOURCES)
+ status = efi_allocate_pages(alloc_size + size,
+ &alloc_addr,
+ hard_limit);
if (status != EFI_SUCCESS) {
pr_efi_err("Failed to reallocate memory for files\n");
goto err_close_file;
@@ -236,14 +244,15 @@ efi_status_t efi_load_dtb(efi_loaded_image_t *image,
unsigned long *load_size)
{
return handle_cmdline_files(image, L"dtb=", sizeof(L"dtb=") - 2,
- ULONG_MAX, load_addr, load_size);
+ ULONG_MAX, ULONG_MAX, load_addr, load_size);
}
efi_status_t efi_load_initrd(efi_loaded_image_t *image,
unsigned long *load_addr,
unsigned long *load_size,
- unsigned long max_addr)
+ unsigned long soft_limit,
+ unsigned long hard_limit)
{
return handle_cmdline_files(image, L"initrd=", sizeof(L"initrd=") - 2,
- max_addr, load_addr, load_size);
+ soft_limit, hard_limit, load_addr, load_size);
}