Re: [PATCH v2] KVM: nSVM: Never use L0's PAUSE loop exiting while L2 is running
From: Yosry Ahmed
Date: Mon May 11 2026 - 20:38:15 EST
> 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
>
>