@@ -2081,7 +2081,6 @@ static __init void identify_boot_cpu(void)
enable_sep_cpu();
#endif
cpu_detect_tlb(&boot_cpu_data);
- setup_cr_pinning();
tsx_init();
tdx_init();
@@ -2532,10 +2531,21 @@ void __init arch_cpu_finalize_init(void)
/*
* This needs to follow the FPU initializtion, since EFI depends on it.
+ *
+ * It also needs to precede the CR pinning setup, because the CR4.LASS
+ * bit has to be cleared temporarily in order to execute the
+ * set_virtual_address_map() EFI call, which resides in lower addresses
+ * and would trip LASS if enabled.
+ *
+ * Wrapping efi_enter_virtual_mode() into lass_stac()/clac() is not
+ * enough because AC flag gates data accesses, but not instruction
+ * fetch. Clearing the CR4 bit is required.
*/
if (efi_enabled(EFI_RUNTIME_SERVICES))
efi_enter_virtual_mode();
+ setup_cr_pinning();
+
/*
* Ensure that access to the per CPU representation has the initial
* boot CPU configuration.