Message ID | 20210824110743.531127-2-xiaoyao.li@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: VMX: PT (processor trace) optimizations and fixes | expand |
On Tue, Aug 24, 2021, Xiaoyao Li wrote: > A minor optimation to WRMSR MSR_IA32_RTIT_CTL when necessary. > > Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com> > --- > arch/x86/kvm/vmx/vmx.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index fada1055f325..e0a9460e4dab 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -1075,7 +1075,8 @@ static void pt_guest_exit(struct vcpu_vmx *vmx) > } > > /* Reload host state (IA32_RTIT_CTL will be cleared on VM exit). */ Could you opportunistically update the comment to call out that KVM requires VM_EXIT_CLEAR_IA32_RTIT_CTL to expose PT to the guest? E.g. something like /* * KVM's 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. */ With that, Reviewed-by: Sean Christopherson <seanjc@google.com> > - wrmsrl(MSR_IA32_RTIT_CTL, vmx->pt_desc.host.ctl); > + 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, > -- > 2.27.0 >
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index fada1055f325..e0a9460e4dab 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1075,7 +1075,8 @@ static void pt_guest_exit(struct vcpu_vmx *vmx) } /* Reload host state (IA32_RTIT_CTL will be cleared on VM exit). */ - wrmsrl(MSR_IA32_RTIT_CTL, vmx->pt_desc.host.ctl); + 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,
A minor optimation to WRMSR MSR_IA32_RTIT_CTL when necessary. Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com> --- arch/x86/kvm/vmx/vmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)