summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx/vmx.c
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2021-05-04 19:17:30 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-05-07 12:06:18 +0200
commit5e17c624010a82bbcca9b955155781927eb6532a (patch)
tree79f93fe027e29bf8706a0a8193c216f6ef1de15a /arch/x86/kvm/vmx/vmx.c
parentKVM: VMX: Use common x86's uret MSR list as the one true list (diff)
downloadlinux-5e17c624010a82bbcca9b955155781927eb6532a.tar.xz
linux-5e17c624010a82bbcca9b955155781927eb6532a.zip
KVM: VMX: Disable loading of TSX_CTRL MSR the more conventional way
Tag TSX_CTRL as not needing to be loaded when RTM isn't supported in the host. Crushing the write mask to '0' has the same effect, but requires more mental gymnastics to understand. Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20210504171734.1434054-12-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to '')
-rw-r--r--arch/x86/kvm/vmx/vmx.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 39506704be96..bd2187b4cc53 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -1771,7 +1771,13 @@ static void setup_msrs(struct vcpu_vmx *vmx)
guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP) ||
guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDPID));
- vmx_setup_uret_msr(vmx, MSR_IA32_TSX_CTRL, true);
+ /*
+ * hle=0, rtm=0, tsx_ctrl=1 can be found with some combinations of new
+ * kernel and old userspace. If those guests run on a tsx=off host, do
+ * allow guests to use TSX_CTRL, but don't change the value in hardware
+ * so that TSX remains always disabled.
+ */
+ vmx_setup_uret_msr(vmx, MSR_IA32_TSX_CTRL, boot_cpu_has(X86_FEATURE_RTM));
if (cpu_has_vmx_msr_bitmap())
vmx_update_msr_bitmap(&vmx->vcpu);
@@ -6919,23 +6925,15 @@ static int vmx_create_vcpu(struct kvm_vcpu *vcpu)
vmx->guest_uret_msrs[i].data = 0;
vmx->guest_uret_msrs[i].mask = -1ull;
}
- tsx_ctrl = vmx_find_uret_msr(vmx, MSR_IA32_TSX_CTRL);
- if (tsx_ctrl) {
+ if (boot_cpu_has(X86_FEATURE_RTM)) {
/*
* TSX_CTRL_CPUID_CLEAR is handled in the CPUID interception.
* Keep the host value unchanged to avoid changing CPUID bits
* under the host kernel's feet.
- *
- * hle=0, rtm=0, tsx_ctrl=1 can be found with some combinations
- * of new kernel and old userspace. If those guests run on a
- * tsx=off host, do allow guests to use TSX_CTRL, but do not
- * change the value on the host so that TSX remains always
- * disabled.
*/
- if (boot_cpu_has(X86_FEATURE_RTM))
+ tsx_ctrl = vmx_find_uret_msr(vmx, MSR_IA32_TSX_CTRL);
+ if (tsx_ctrl)
vmx->guest_uret_msrs[i].mask = ~(u64)TSX_CTRL_CPUID_CLEAR;
- else
- vmx->guest_uret_msrs[i].mask = 0;
}
err = alloc_loaded_vmcs(&vmx->vmcs01);