From ce2c403c26c1ed0e28fc541ab30fe13ff50236be Mon Sep 17 00:00:00 2001 From: Alexander Shishkin Date: Fri, 20 Jun 2025 16:53:12 +0300 Subject: [PATCH] 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 Signed-off-by: Alexander Shishkin Signed-off-by: Kirill A. Shutemov Signed-off-by: Dave Hansen Reviewed-by: Sohil Mehta Acked-by: Ard Biesheuvel Link: https://lore.kernel.org/all/20250620135325.3300848-5-kirill.shutemov%40linux.intel.com --- arch/x86/kernel/cpu/common.c | 7 +++++++ init/main.c | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 8feb8fd2957ad..4f430be285ded 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -2529,6 +2530,12 @@ void __init arch_cpu_finalize_init(void) fpu__init_system(); fpu__init_cpu(); + /* + * This needs to follow the FPU initializtion, since EFI depends on it. + */ + if (efi_enabled(EFI_RUNTIME_SERVICES)) + efi_enter_virtual_mode(); + /* * Ensure that access to the per CPU representation has the initial * boot CPU configuration. diff --git a/init/main.c b/init/main.c index 225a58279acd7..f9f401b6fdfbc 100644 --- a/init/main.c +++ b/init/main.c @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include @@ -1068,10 +1067,6 @@ void start_kernel(void) pid_idr_init(); anon_vma_init(); -#ifdef CONFIG_X86 - if (efi_enabled(EFI_RUNTIME_SERVICES)) - efi_enter_virtual_mode(); -#endif thread_stack_cache_init(); cred_init(); fork_init(); -- 2.47.2