All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosry@kernel.org>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org,  linux-kernel@vger.kernel.org,
	Maxim Levitsky <mlevitsk@redhat.com>,
	 David Kaplan <david.kaplan@amd.com>
Subject: Re: [PATCH v2] KVM: nSVM: Never use L0's PAUSE loop exiting while L2 is running
Date: Tue, 12 May 2026 00:38:01 +0000	[thread overview]
Message-ID: <agJ1Banej3qmdPoR@google.com> (raw)
In-Reply-To: <20260508213321.373309-1-seanjc@google.com>

> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index e7fdd7a9c280..ac21f402c1ca 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -913,7 +913,12 @@ static void grow_ple_window(struct kvm_vcpu *vcpu)
>  	struct vmcb_control_area *control = &svm->vmcb->control;
>  	int old = control->pause_filter_count;
>  
> -	if (kvm_pause_in_guest(vcpu->kvm))
> +	/*
> +	 * While running L2, KVM should intercept PAUSE if and only if L1 wants
> +	 * to intercept PAUSE, and L1's intercept should take priority, i.e.
> +	 * KVM should never handle a PAUSE intercept from L2.
> +	 */
> +	if (WARN_ON_ONCE(is_guest_mode(vcpu) || kvm_pause_in_guest(vcpu->kvm)))
>  		return;

I initially thought putting kvm_pause_in_guest() inside the
WARN_ON_ONCE() was a mistake, but I don't think it is. KVM only
intercepts PAUSE if kvm_pause_in_guest() is false, so grow_ple_window()
should never be called.

But I think this applies even without this patch, right? Maybe would be
clearer to do WARN_ON_ONCE(kvm_pause_in_guest()) in one commit and then
add is_guest_mode() here?

>  
>  	control->pause_filter_count = __grow_ple_window(old,
> @@ -934,7 +939,7 @@ static void shrink_ple_window(struct kvm_vcpu *vcpu)
>  	struct vmcb_control_area *control = &svm->vmcb->control;
>  	int old = control->pause_filter_count;
>  
> -	if (kvm_pause_in_guest(vcpu->kvm))
> +	if (is_guest_mode(vcpu))
>  		return;
>  
>  	control->pause_filter_count =
> 
> base-commit: 6d35786de28116ecf78797a62b84e6bf3c45aa5a
> -- 
> 2.54.0.563.g4f69b47b94-goog
> 
> 

  reply	other threads:[~2026-05-12  0:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 21:33 [PATCH v2] KVM: nSVM: Never use L0's PAUSE loop exiting while L2 is running Sean Christopherson
2026-05-12  0:38 ` Yosry Ahmed [this message]
2026-05-12 20:12 ` Paolo Bonzini

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=agJ1Banej3qmdPoR@google.com \
    --to=yosry@kernel.org \
    --cc=david.kaplan@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mlevitsk@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.