Skip to content

Commit 5d51035

Browse files
Sean Christophersonsuryasaimadhu
authored andcommitted
x86/cpu: Reinitialize IA32_FEAT_CTL MSR on BSP during wakeup
Reinitialize IA32_FEAT_CTL on the BSP during wakeup to handle the case where firmware doesn't initialize or save/restore across S3. This fixes a bug where IA32_FEAT_CTL is left uninitialized and results in VMXON taking a #GP due to VMX not being fully enabled, i.e. breaks KVM. Use init_ia32_feat_ctl() to "restore" IA32_FEAT_CTL as it already deals with the case where the MSR is locked, and because APs already redo init_ia32_feat_ctl() during suspend by virtue of the SMP boot flow being used to reinitialize APs upon wakeup. Do the call in the early wakeup flow to avoid dependencies in the syscore_ops chain, e.g. simply adding a resume hook is not guaranteed to work, as KVM does VMXON in its own resume hook, kvm_resume(), when KVM has active guests. Fixes: 21bd346 ("KVM: VMX: Drop initialization of IA32_FEAT_CTL MSR") Reported-by: Brad Campbell <[email protected]> Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Liam Merwick <[email protected]> Reviewed-by: Maxim Levitsky <[email protected]> Tested-by: Brad Campbell <[email protected]> Cc: [email protected] # v5.6 Link: https://lkml.kernel.org/r/[email protected]
1 parent 8e742aa commit 5d51035

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

arch/x86/include/asm/cpu.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,9 @@ static inline bool handle_guest_split_lock(unsigned long ip)
5858
return false;
5959
}
6060
#endif
61+
#ifdef CONFIG_IA32_FEAT_CTL
62+
void init_ia32_feat_ctl(struct cpuinfo_x86 *c);
63+
#else
64+
static inline void init_ia32_feat_ctl(struct cpuinfo_x86 *c) {}
65+
#endif
6166
#endif /* _ASM_X86_CPU_H */

arch/x86/kernel/cpu/centaur.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <linux/sched.h>
44
#include <linux/sched/clock.h>
55

6+
#include <asm/cpu.h>
67
#include <asm/cpufeature.h>
78
#include <asm/e820/api.h>
89
#include <asm/mtrr.h>

arch/x86/kernel/cpu/cpu.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,4 @@ extern void update_srbds_msr(void);
8181

8282
extern u64 x86_read_arch_cap_msr(void);
8383

84-
#ifdef CONFIG_IA32_FEAT_CTL
85-
void init_ia32_feat_ctl(struct cpuinfo_x86 *c);
86-
#endif
87-
8884
#endif /* ARCH_X86_CPU_H */

arch/x86/kernel/cpu/zhaoxin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <linux/sched.h>
33
#include <linux/sched/clock.h>
44

5+
#include <asm/cpu.h>
56
#include <asm/cpufeature.h>
67

78
#include "cpu.h"

arch/x86/power/cpu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ static void fix_processor_context(void)
193193
*/
194194
static void notrace __restore_processor_state(struct saved_context *ctxt)
195195
{
196+
struct cpuinfo_x86 *c;
197+
196198
if (ctxt->misc_enable_saved)
197199
wrmsrl(MSR_IA32_MISC_ENABLE, ctxt->misc_enable);
198200
/*
@@ -263,6 +265,10 @@ static void notrace __restore_processor_state(struct saved_context *ctxt)
263265
mtrr_bp_restore();
264266
perf_restore_debug_store();
265267
msr_restore_context(ctxt);
268+
269+
c = &cpu_data(smp_processor_id());
270+
if (cpu_has(c, X86_FEATURE_MSR_IA32_FEAT_CTL))
271+
init_ia32_feat_ctl(c);
266272
}
267273

268274
/* Needed by apm.c */

0 commit comments

Comments
 (0)