aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2024-08-02 11:19:35 -0700
committerSean Christopherson <seanjc@google.com>2024-08-22 12:07:39 -0700
commit44dd0f5732b466a6e4d2a9b3aad1678f43f061af (patch)
tree2ba069335f03e3f27c0088aab9b1b7eac151dcaa
parentKVM: x86: Suppress failures on userspace access to advertised, unsupported MSRs (diff)
downloadwireguard-linux-44dd0f5732b466a6e4d2a9b3aad1678f43f061af.tar.xz
wireguard-linux-44dd0f5732b466a6e4d2a9b3aad1678f43f061af.zip
KVM: x86: Suppress userspace access failures on unsupported, "emulated" MSRs
Extend KVM's suppression of userspace MSR access failures to MSRs that KVM reports as emulated, but are ultimately unsupported, e.g. if the VMX MSRs are emulated by KVM, but are unsupported given the vCPU model. Suggested-by: Weijiang Yang <weijiang.yang@intel.com> Reviewed-by: Weijiang Yang <weijiang.yang@intel.com> Link: https://lore.kernel.org/r/20240802181935.292540-11-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
-rw-r--r--arch/x86/kvm/x86.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1762bde488a2..00e792725052 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -476,7 +476,7 @@ static bool kvm_is_immutable_feature_msr(u32 msr)
return false;
}
-static bool kvm_is_msr_to_save(u32 msr_index)
+static bool kvm_is_advertised_msr(u32 msr_index)
{
unsigned int i;
@@ -485,6 +485,11 @@ static bool kvm_is_msr_to_save(u32 msr_index)
return true;
}
+ for (i = 0; i < num_emulated_msrs; i++) {
+ if (emulated_msrs[i] == msr_index)
+ return true;
+ }
+
return false;
}
@@ -514,11 +519,11 @@ static __always_inline int kvm_do_msr_access(struct kvm_vcpu *vcpu, u32 msr,
/*
* Userspace is allowed to read MSRs, and write '0' to MSRs, that KVM
- * reports as to-be-saved, even if an MSR isn't fully supported.
+ * advertises to userspace, even if an MSR isn't fully supported.
* Simply check that @data is '0', which covers both the write '0' case
* and all reads (in which case @data is zeroed on failure; see above).
*/
- if (host_initiated && !*data && kvm_is_msr_to_save(msr))
+ if (host_initiated && !*data && kvm_is_advertised_msr(msr))
return 0;
if (!ignore_msrs) {