summaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorXiaoyao Li <xiaoyao.li@intel.com>2021-08-27 15:02:43 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2021-10-22 05:19:26 -0400
commit2e6e0d683b77b1e08e5e03146ca3b8e033492666 (patch)
tree70f543e2d0974c14b4680dfcb4196fbd764df780 /arch/x86
parent2839180ce5bb27ad5e1f092fdafede284a925e5c (diff)
downloadlinux-stable-2e6e0d683b77b1e08e5e03146ca3b8e033492666.tar.gz
linux-stable-2e6e0d683b77b1e08e5e03146ca3b8e033492666.tar.bz2
linux-stable-2e6e0d683b77b1e08e5e03146ca3b8e033492666.zip
KVM: VMX: Restore host's MSR_IA32_RTIT_CTL when it's not zero
A minor optimization to WRMSR MSR_IA32_RTIT_CTL when necessary. Opportunistically refine the comment to call out that KVM requires VM_EXIT_CLEAR_IA32_RTIT_CTL to expose PT to the guest. Reviewed-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com> Message-Id: <20210827070249.924633-2-xiaoyao.li@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/vmx/vmx.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 1c8b2b6e7ed9..9a8cd7f8481e 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -1074,8 +1074,12 @@ static void pt_guest_exit(struct vcpu_vmx *vmx)
pt_load_msr(&vmx->pt_desc.host, vmx->pt_desc.addr_range);
}
- /* Reload host state (IA32_RTIT_CTL will be cleared on VM exit). */
- wrmsrl(MSR_IA32_RTIT_CTL, vmx->pt_desc.host.ctl);
+ /*
+ * KVM requires VM_EXIT_CLEAR_IA32_RTIT_CTL to expose PT to the guest,
+ * i.e. RTIT_CTL is always cleared on VM-Exit. Restore it if necessary.
+ */
+ if (vmx->pt_desc.host.ctl)
+ wrmsrl(MSR_IA32_RTIT_CTL, vmx->pt_desc.host.ctl);
}
void vmx_set_host_fs_gs(struct vmcs_host_state *host, u16 fs_sel, u16 gs_sel,