diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2019-10-08 23:35:30 +0100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2019-11-15 00:56:47 +0000 |
commit | b8918441ba1b928801032721962af1a59f4e82de (patch) | |
tree | 9f28e894a3ccee0bd302528143d6f62e76979a68 /arch/x86 | |
parent | 582441d3f8d0a120af98cf05dd56c6701161883a (diff) | |
download | linux-stable-b8918441ba1b928801032721962af1a59f4e82de.tar.gz linux-stable-b8918441ba1b928801032721962af1a59f4e82de.tar.bz2 linux-stable-b8918441ba1b928801032721962af1a59f4e82de.zip |
KVM: Introduce kvm_get_arch_capabilities()
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>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 1 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 13 |
2 files changed, 12 insertions, 2 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 92a9ba2595b3..0249450e2e50 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -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); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2c0f1ea119d6..62f4e56fd350 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -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) |