Skip to content

Commit ce2c403

Browse files
virtuosohansendc
authored andcommitted
x86/efi: Move runtime service initialization to arch/x86
The EFI call in start_kernel() is guarded by #ifdef CONFIG_X86. Move the thing to the arch_cpu_finalize_init() path on x86 and get rid of the #ifdef in start_kernel(). No functional change intended. Suggested-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Signed-off-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Reviewed-by: Sohil Mehta <[email protected]> Acked-by: Ard Biesheuvel <[email protected]> Link: https://lore.kernel.org/all/20250620135325.3300848-5-kirill.shutemov%40linux.intel.com
1 parent e04c78d commit ce2c403

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

arch/x86/kernel/cpu/common.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/pgtable.h>
2727
#include <linux/stackprotector.h>
2828
#include <linux/utsname.h>
29+
#include <linux/efi.h>
2930

3031
#include <asm/alternative.h>
3132
#include <asm/cmdline.h>
@@ -2529,6 +2530,12 @@ void __init arch_cpu_finalize_init(void)
25292530
fpu__init_system();
25302531
fpu__init_cpu();
25312532

2533+
/*
2534+
* This needs to follow the FPU initializtion, since EFI depends on it.
2535+
*/
2536+
if (efi_enabled(EFI_RUNTIME_SERVICES))
2537+
efi_enter_virtual_mode();
2538+
25322539
/*
25332540
* Ensure that access to the per CPU representation has the initial
25342541
* boot CPU configuration.

init/main.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
#include <linux/cpuset.h>
5454
#include <linux/memcontrol.h>
5555
#include <linux/cgroup.h>
56-
#include <linux/efi.h>
5756
#include <linux/tick.h>
5857
#include <linux/sched/isolation.h>
5958
#include <linux/interrupt.h>
@@ -1068,10 +1067,6 @@ void start_kernel(void)
10681067

10691068
pid_idr_init();
10701069
anon_vma_init();
1071-
#ifdef CONFIG_X86
1072-
if (efi_enabled(EFI_RUNTIME_SERVICES))
1073-
efi_enter_virtual_mode();
1074-
#endif
10751070
thread_stack_cache_init();
10761071
cred_init();
10771072
fork_init();

0 commit comments

Comments
 (0)