]> git.ipfire.org Git - thirdparty/linux.git/commit
KVM: SVM: Generate GA log IRQs only if the associated vCPUs is blocking
authorSean Christopherson <seanjc@google.com>
Wed, 11 Jun 2025 22:46:04 +0000 (15:46 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 23 Jun 2025 16:50:52 +0000 (09:50 -0700)
commitb03500f03ea09f5fa31a408135c95c665542ff15
tree87fd245699cdfcd9bd9625fc5b8f122a6b7e726c
parentb9e53f9ff4a88f01b22524878c9a381a6c5f65ff
KVM: SVM: Generate GA log IRQs only if the associated vCPUs is blocking

Configure IRTEs to GA log interrupts for device posted IRQs that hit
non-running vCPUs if and only if the target vCPU is blocking, i.e.
actually needs a wake event.  If the vCPU has exited to userspace or was
preempted, generating GA log entries and interrupts is wasteful and
unnecessary, as the vCPU will be re-loaded and/or scheduled back in
irrespective of the GA log notification (avic_ga_log_notifier() is just a
fancy wrapper for kvm_vcpu_wake_up()).

Use a should-be-zero bit in the vCPU's Physical APIC ID Table Entry to
track whether or not the vCPU's associated IRTEs are configured to
generate GA logs, but only set the synthetic bit in KVM's "cache", i.e.
never set the should-be-zero bit in tables that are used by hardware.
Use a synthetic bit instead of a dedicated boolean to minimize the odds
of messing up the locking, i.e. so that all the existing rules that apply
to avic_physical_id_entry for IS_RUNNING are reused verbatim for
GA_LOG_INTR.

Note, because KVM (by design) "puts" AVIC state in a "pre-blocking"
phase, using kvm_vcpu_is_blocking() to track the need for notifications
isn't a viable option.

Link: https://lore.kernel.org/r/20250611224604.313496-63-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/include/asm/svm.h
arch/x86/kvm/svm/avic.c