From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Sean Christopherson <seanjc@google.com>
Cc: yosry@kernel.org, Maxim Levitsky <mlevitsk@redhat.com>,
David Kaplan <david.kaplan@amd.com>
Subject: [PATCH v2] KVM: nSVM: Never use L0's PAUSE loop exiting while L2 is running
Date: Tue, 12 May 2026 22:12:19 +0200 [thread overview]
Message-ID: <20260512201219.3021354-1-pbonzini@redhat.com> (raw)
In-Reply-To: <20260508213321.373309-1-seanjc@google.com>
On 5/8/26 23:33, Sean Christopherson wrote:
> Never use L0's (KVM's) PAUSE loop exiting controls while L2 is running,
> and instead always configure vmcb02 according to L1's exact capabilities
> and desires.
Queued, thanks. While I didn't go as far as splitting in two commits,
I did apply a more or less cosmetic tweak to the WARNs. Calling
grow_ple_window/shrink_ple_window with PLE disabled is harmless but
also makes little sense. This can be represented by a WARN that
does not have an early return.
The WARN condition is obviously false for shrink_ple_window and
a little less obviously so for grow_ple_window, but in case any
other callers are added it can be useful to have it as a heads up.
Paolo
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index ac21f402c1ca..e02a38da5296 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -913,12 +913,15 @@ static void grow_ple_window(struct kvm_vcpu *vcpu)
struct vmcb_control_area *control = &svm->vmcb->control;
int old = control->pause_filter_count;
+ /* Adjusting pause_filter_count makes no sense if PLE is disabled. */
+ WARN_ON_ONCE(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)))
+ if (WARN_ON_ONCE(is_guest_mode(vcpu)))
return;
control->pause_filter_count = __grow_ple_window(old,
(1/2) Stage this hunk [y,n,q,a,d,k,K,j,J,g,/,s,e,p,P,?]? y
@@ -939,6 +942,9 @@ static void shrink_ple_window(struct kvm_vcpu *vcpu)
struct vmcb_control_area *control = &svm->vmcb->control;
int old = control->pause_filter_count;
+ /* Adjusting pause_filter_count makes no sense if PLE is disabled. */
+ WARN_ON_ONCE(kvm_pause_in_guest(vcpu->kvm));
+
if (is_guest_mode(vcpu))
return;
prev parent reply other threads:[~2026-05-12 20:12 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
2026-05-12 20:12 ` Paolo Bonzini [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=20260512201219.3021354-1-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=david.kaplan@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=seanjc@google.com \
--cc=yosry@kernel.org \
/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