public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Sean Christopherson <seanjc@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: VMX: Update PT MSR intercepts during filter change iff PT in host+guest
Date: Tue, 12 Jul 2022 11:23:33 +0800	[thread overview]
Message-ID: <34935bcd-0a5a-e239-d434-42187f94ad09@intel.com> (raw)
In-Reply-To: <20220712015838.1253995-1-seanjc@google.com>

On 7/12/2022 9:58 AM, Sean Christopherson wrote:
> Update the Processor Trace (PT) MSR intercepts during a filter change if
> and only if PT may be exposed to the guest, i.e. only if KVM is operating
> in the so called "host+guest" mode where PT can be used simultaneously by
> both the host and guest.  If PT is in system mode, the host is the sole
> owner of PT and the MSRs should never be passed through to the guest.
> 
> Luckily the missed check only results in unnecessary work, as select RTIT
> MSRs are passed through only when RTIT tracing is enabled "in" the guest,
> and tracing can't be enabled in the guest when KVM is in system mode
> (writes to guest.MSR_IA32_RTIT_CTL are disallowed).

Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>

> Cc: Xiaoyao Li <xiaoyao.li@intel.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
>   arch/x86/kvm/vmx/vmx.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 74ca64e97643..e6ab2c2c4d3b 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -4004,7 +4004,9 @@ static void vmx_msr_filter_changed(struct kvm_vcpu *vcpu)
>   			vmx_disable_intercept_for_msr(vcpu, msr, MSR_TYPE_W);
>   	}
>   
> -	pt_update_intercept_for_msr(vcpu);
> +	/* PT MSRs can be passed through iff PT is exposed to the guest. */
> +	if (vmx_pt_mode_is_host_guest())
> +		pt_update_intercept_for_msr(vcpu);
>   }
>   
>   static inline void kvm_vcpu_trigger_posted_interrupt(struct kvm_vcpu *vcpu,
> 
> base-commit: 5406e590ac8fa33e390616031370806cdbcc5791


      reply	other threads:[~2022-07-12  3:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12  1:58 [PATCH] KVM: VMX: Update PT MSR intercepts during filter change iff PT in host+guest Sean Christopherson
2022-07-12  3:23 ` Xiaoyao Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34935bcd-0a5a-e239-d434-42187f94ad09@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox