Skip to content

Commit ae835a9

Browse files
committed
x86/efistub: Revert to heap allocated boot_params for PE entrypoint
This is a partial revert of commit 8117961 ("x86/efi: Disregard setup header of loaded image") which triggers boot issues on older Dell laptops. As it turns out, switching back to a heap allocation for the struct boot_params constructed by the EFI stub works around this, even though it is unclear why. Cc: Christian Heusel <[email protected]> Reported-by: <mavrix#[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent ee8b8f5 commit ae835a9

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

drivers/firmware/efi/libstub/x86-stub.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,12 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
534534
efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
535535
efi_system_table_t *sys_table_arg)
536536
{
537-
static struct boot_params boot_params __page_aligned_bss;
538-
struct setup_header *hdr = &boot_params.hdr;
539537
efi_guid_t proto = LOADED_IMAGE_PROTOCOL_GUID;
538+
struct boot_params *boot_params;
539+
struct setup_header *hdr;
540540
int options_size = 0;
541541
efi_status_t status;
542+
unsigned long alloc;
542543
char *cmdline_ptr;
543544

544545
efi_system_table = sys_table_arg;
@@ -553,6 +554,13 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
553554
efi_exit(handle, status);
554555
}
555556

557+
status = efi_allocate_pages(PARAM_SIZE, &alloc, ULONG_MAX);
558+
if (status != EFI_SUCCESS)
559+
efi_exit(handle, status);
560+
561+
boot_params = memset((void *)alloc, 0x0, PARAM_SIZE);
562+
hdr = &boot_params->hdr;
563+
556564
/* Assign the setup_header fields that the kernel actually cares about */
557565
hdr->root_flags = 1;
558566
hdr->vid_mode = 0xffff;
@@ -562,13 +570,15 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
562570

563571
/* Convert unicode cmdline to ascii */
564572
cmdline_ptr = efi_convert_cmdline(image, &options_size);
565-
if (!cmdline_ptr)
573+
if (!cmdline_ptr) {
574+
efi_free(PARAM_SIZE, alloc);
566575
efi_exit(handle, EFI_OUT_OF_RESOURCES);
576+
}
567577

568578
efi_set_u64_split((unsigned long)cmdline_ptr, &hdr->cmd_line_ptr,
569-
&boot_params.ext_cmd_line_ptr);
579+
&boot_params->ext_cmd_line_ptr);
570580

571-
efi_stub_entry(handle, sys_table_arg, &boot_params);
581+
efi_stub_entry(handle, sys_table_arg, boot_params);
572582
/* not reached */
573583
}
574584

0 commit comments

Comments
 (0)