]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: SVM: Move STGI and CLGI intercept handling
authorKevin Cheng <chengkev@google.com>
Wed, 4 Mar 2026 00:30:09 +0000 (16:30 -0800)
committerSean Christopherson <seanjc@google.com>
Thu, 5 Mar 2026 00:08:57 +0000 (16:08 -0800)
commit69f779f79e0d1ff321a89ab56cdcab34613104c0
treec52e89850362abaf720ffb4ada614376c28364f0
parent33d3617a52f9930d22b2af59f813c2fbdefa6dd5
KVM: SVM: Move STGI and CLGI intercept handling

Move STGI/CLGI intercept handling to svm_recalc_instruction_intercepts()
in preparation for making the function EFER.SVME-aware.  This will allow
configuring STGI/CLGI intercepts along with other intercepts for other SVM
instructions when EFER.SVME is toggled (KVM needs to intercept SVM
instructions when EFER.SVME=0 to inject #UD).

When clearing the STGI intercept in particular, request KVM_REQ_EVENT if
there is at least one a pending GIF-controlled event. This avoids breaking
NMI/SMI window tracking, as enable_{nmi,smi}_window() sets INTERCEPT_STGI
to detect when NMIs become unblocked. KVM_REQ_EVENT forces
kvm_check_and_inject_events() to re-evaluate pending events and re-enable
the intercept if needed.

Extract the pending GIF event check into a helper function
svm_has_pending_gif_event() to deduplicate the logic between
svm_recalc_instruction_intercepts() and svm_set_gif().

Signed-off-by: Kevin Cheng <chengkev@google.com>
[sean: keep vgif handling out of the "Intel CPU model" path]
Reviewed-by: Yosry Ahmed <yosry@kernel.org>
Link: https://patch.msgid.link/20260304003010.1108257-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/svm.c