]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: Introduce kvm_get_arch_capabilities()
authorBen Hutchings <ben@decadent.org.uk>
Tue, 8 Oct 2019 22:35:30 +0000 (23:35 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 15 Nov 2019 00:56:47 +0000 (00:56 +0000)
Extracted from commit 5b76a3cff011 "KVM: VMX: Tell the nested
hypervisor to skip L1D flush on vmentry".  We will need this to let a
nested hypervisor know that we have applied the mitigation for TAA.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/x86.c

index 92a9ba2595b36c813e4f6e60e5a73e09144611c6..0249450e2e50d21492fe9b5b6b5cf72138481c2f 100644 (file)
@@ -1062,6 +1062,7 @@ int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu);
 int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
 void kvm_vcpu_reset(struct kvm_vcpu *vcpu);
 
+u64 kvm_get_arch_capabilities(void);
 void kvm_define_shared_msr(unsigned index, u32 msr);
 int kvm_set_shared_msr(unsigned index, u64 val, u64 mask);
 
index 2c0f1ea119d6beaf303d1a46c14d45a0297d2938..62f4e56fd350baca41b16062dcdc17990280a449 100644 (file)
@@ -911,6 +911,16 @@ static u32 emulated_msrs[] = {
 
 static unsigned num_emulated_msrs;
 
+u64 kvm_get_arch_capabilities(void)
+{
+       u64 data;
+
+       rdmsrl_safe(MSR_IA32_ARCH_CAPABILITIES, &data);
+
+       return data;
+}
+EXPORT_SYMBOL_GPL(kvm_get_arch_capabilities);
+
 bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer)
 {
        if (efer & efer_reserved_bits)
@@ -6969,8 +6979,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
        int r;
 
        if (boot_cpu_has(X86_FEATURE_ARCH_CAPABILITIES))
-               rdmsrl(MSR_IA32_ARCH_CAPABILITIES,
-                      vcpu->arch.arch_capabilities);
+               vcpu->arch.arch_capabilities = kvm_get_arch_capabilities();
        vcpu->arch.mtrr_state.have_fixed = 1;
        r = vcpu_load(vcpu);
        if (r)