Skip to content

Commit 8acf63e

Browse files
nivedita76Ingo Molnar
authored and
Ingo Molnar
committed
efi/x86: Avoid using code32_start
code32_start is meant for 16-bit real-mode bootloaders to inform the kernel where the 32-bit protected mode code starts. Nothing in the protected mode kernel except the EFI stub uses it. efi_main() currently returns boot_params, with code32_start set inside it to tell efi_stub_entry() where startup_32 is located. Since it was invoked by efi_stub_entry() in the first place, boot_params is already known. Return the address of startup_32 instead. This will allow a 64-bit kernel to live above 4Gb, for example, and it's cleaner as well. Signed-off-by: Arvind Sankar <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 3fab433 commit 8acf63e

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

arch/x86/boot/compressed/head_32.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,8 @@ SYM_FUNC_END(startup_32)
156156
SYM_FUNC_START(efi32_stub_entry)
157157
SYM_FUNC_START_ALIAS(efi_stub_entry)
158158
add $0x4, %esp
159+
movl 8(%esp), %esi /* save boot_params pointer */
159160
call efi_main
160-
movl %eax, %esi
161-
movl BP_code32_start(%esi), %eax
162161
leal startup_32(%eax), %eax
163162
jmp *%eax
164163
SYM_FUNC_END(efi32_stub_entry)

arch/x86/boot/compressed/head_64.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,9 @@ SYM_CODE_END(startup_64)
472472
SYM_FUNC_START(efi64_stub_entry)
473473
SYM_FUNC_START_ALIAS(efi_stub_entry)
474474
and $~0xf, %rsp /* realign the stack */
475+
movq %rdx, %rbx /* save boot_params pointer */
475476
call efi_main
476-
movq %rax,%rsi
477-
movl BP_code32_start(%esi), %eax
477+
movq %rbx,%rsi
478478
leaq startup_64(%rax), %rax
479479
jmp *%rax
480480
SYM_FUNC_END(efi64_stub_entry)

arch/x86/kernel/asm-offsets.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ static void __used common(void)
8888
OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment);
8989
OFFSET(BP_init_size, boot_params, hdr.init_size);
9090
OFFSET(BP_pref_address, boot_params, hdr.pref_address);
91-
OFFSET(BP_code32_start, boot_params, hdr.code32_start);
9291

9392
BLANK();
9493
DEFINE(PTREGS_SIZE, sizeof(struct pt_regs));

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -703,10 +703,11 @@ static efi_status_t exit_boot(struct boot_params *boot_params, void *handle)
703703
}
704704

705705
/*
706-
* On success we return a pointer to a boot_params structure, and NULL
707-
* on failure.
706+
* On success, we return the address of startup_32, which has potentially been
707+
* relocated by efi_relocate_kernel.
708+
* On failure, we exit to the firmware via efi_exit instead of returning.
708709
*/
709-
struct boot_params *efi_main(efi_handle_t handle,
710+
unsigned long efi_main(efi_handle_t handle,
710711
efi_system_table_t *sys_table_arg,
711712
struct boot_params *boot_params)
712713
{
@@ -736,7 +737,6 @@ struct boot_params *efi_main(efi_handle_t handle,
736737
goto fail;
737738
}
738739
}
739-
hdr->code32_start = (u32)bzimage_addr;
740740

741741
/*
742742
* efi_pe_entry() may have been called before efi_main(), in which
@@ -799,7 +799,7 @@ struct boot_params *efi_main(efi_handle_t handle,
799799
goto fail;
800800
}
801801

802-
return boot_params;
802+
return bzimage_addr;
803803
fail:
804804
efi_printk("efi_main() failed!\n");
805805

0 commit comments

Comments
 (0)