Skip to content

Commit 8c19b6f

Browse files
kimphillamdbp3tk0v
authored andcommitted
KVM: x86: Propagate the AMD Automatic IBRS feature to the guest
Add the AMD Automatic IBRS feature bit to those being propagated to the guest, and enable the guest EFER bit. Signed-off-by: Kim Phillips <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Acked-by: Sean Christopherson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e7862ed commit 8c19b6f

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

arch/x86/kvm/cpuid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ void kvm_set_cpu_caps(void)
743743

744744
kvm_cpu_cap_mask(CPUID_8000_0021_EAX,
745745
F(NO_NESTED_DATA_BP) | F(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ |
746-
F(NULL_SEL_CLR_BASE) | 0 /* PrefetchCtlMsr */
746+
F(NULL_SEL_CLR_BASE) | F(AUTOIBRS) | 0 /* PrefetchCtlMsr */
747747
);
748748

749749
/*

arch/x86/kvm/svm/svm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4969,6 +4969,9 @@ static __init int svm_hardware_setup(void)
49694969

49704970
tsc_aux_uret_slot = kvm_add_user_return_msr(MSR_TSC_AUX);
49714971

4972+
if (boot_cpu_has(X86_FEATURE_AUTOIBRS))
4973+
kvm_enable_efer_bits(EFER_AUTOIBRS);
4974+
49724975
/* Check for pause filtering support */
49734976
if (!boot_cpu_has(X86_FEATURE_PAUSEFILTER)) {
49744977
pause_filter_count = 0;

arch/x86/kvm/x86.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,9 @@ static int do_get_msr_feature(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
16851685

16861686
static bool __kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer)
16871687
{
1688+
if (efer & EFER_AUTOIBRS && !guest_cpuid_has(vcpu, X86_FEATURE_AUTOIBRS))
1689+
return false;
1690+
16881691
if (efer & EFER_FFXSR && !guest_cpuid_has(vcpu, X86_FEATURE_FXSR_OPT))
16891692
return false;
16901693

0 commit comments

Comments
 (0)