Commit 8c19b6f2 authored by Kim Phillips's avatar Kim Phillips Committed by Borislav Petkov (AMD)
Browse files

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: default avatarKim Phillips <kim.phillips@amd.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Acked-by: default avatarSean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20230124163319.2277355-9-kim.phillips@amd.com
parent e7862eda
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -743,7 +743,7 @@ void kvm_set_cpu_caps(void)


	kvm_cpu_cap_mask(CPUID_8000_0021_EAX,
	kvm_cpu_cap_mask(CPUID_8000_0021_EAX,
		F(NO_NESTED_DATA_BP) | F(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ |
		F(NO_NESTED_DATA_BP) | F(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ |
		F(NULL_SEL_CLR_BASE) | 0 /* PrefetchCtlMsr */
		F(NULL_SEL_CLR_BASE) | F(AUTOIBRS) | 0 /* PrefetchCtlMsr */
	);
	);


	/*
	/*
+3 −0
Original line number Original line Diff line number Diff line
@@ -4969,6 +4969,9 @@ static __init int svm_hardware_setup(void)


	tsc_aux_uret_slot = kvm_add_user_return_msr(MSR_TSC_AUX);
	tsc_aux_uret_slot = kvm_add_user_return_msr(MSR_TSC_AUX);


	if (boot_cpu_has(X86_FEATURE_AUTOIBRS))
		kvm_enable_efer_bits(EFER_AUTOIBRS);

	/* Check for pause filtering support */
	/* Check for pause filtering support */
	if (!boot_cpu_has(X86_FEATURE_PAUSEFILTER)) {
	if (!boot_cpu_has(X86_FEATURE_PAUSEFILTER)) {
		pause_filter_count = 0;
		pause_filter_count = 0;
+3 −0
Original line number Original line Diff line number Diff line
@@ -1685,6 +1685,9 @@ static int do_get_msr_feature(struct kvm_vcpu *vcpu, unsigned index, u64 *data)


static bool __kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer)
static bool __kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer)
{
{
	if (efer & EFER_AUTOIBRS && !guest_cpuid_has(vcpu, X86_FEATURE_AUTOIBRS))
		return false;

	if (efer & EFER_FFXSR && !guest_cpuid_has(vcpu, X86_FEATURE_FXSR_OPT))
	if (efer & EFER_FFXSR && !guest_cpuid_has(vcpu, X86_FEATURE_FXSR_OPT))
		return false;
		return false;