This started as a simple cleanup, and then I made the mistake of writing a test to verify my changes to AVIC's handling of logical mode interrupts. TL;DR: KVM's AVIC and optimized APIC map code doesn't correctly handle various edge cases that are 100% architecturally legal, but are unlikely to occur in most real world scenarios. There are a variety of other fixes, but most of them are non-fatal. I have tested this heavily with KUT, but I haven't booted Windows and don't have access to x2AVIC, so additional testing would be much appreciated. I'll post my KVM-Unit-Tests later this week (need to write quite a few changelogs). The gist of the tests is to target multiple and non-existent vCPUs in logical mode, and to target multiple vCPUs in physical mode by aliasing vCPU0 and vCPU1 to the same physical ID. Sean Christopherson (19): KVM: SVM: Process ICR on AVIC IPI delivery failure due to invalid target KVM: SVM: Don't put/load AVIC when setting virtual APIC mode Revert "KVM: SVM: Introduce hybrid-AVIC mode" KVM: SVM: Replace "avic_mode" enum with "x2avic_enabled" boolean KVM: SVM: Compute dest based on sender's x2APIC status for AVIC kick KVM: SVM: Get x2APIC logical dest bitmap from ICRH[15:0], not ICHR[31:16] KVM: SVM: Drop buggy and redundant AVIC "single logical dest" check KVM: SVM: Remove redundant cluster calculation that also creates a shadow KVM: SVM: Drop duplicate calcuation of AVIC/x2AVIC "logical index" KVM: SVM: Document that vCPU ID == APIC ID in AVIC kick fastpatch KVM: SVM: Add helper to perform final AVIC "kick" of single vCPU KVM: x86: Disable APIC logical map if logical ID covers multiple MDAs KVM: x86: Disable APIC logical map if vCPUs are aliased in logical mode KVM: x86: Honor architectural behavior for aliased 8-bit APIC IDs KVM: x86: Explicitly skip optimized logical map setup if vCPU's LDR==0 KVM: x86: Explicitly track all possibilities for APIC map's logical modes KVM: SVM: Handle multiple logical targets in AVIC kick fastpath KVM: SVM: Ignore writes to Remote Read Data on AVIC write traps Revert "KVM: SVM: Do not throw warning when calling avic_vcpu_load on a running vcpu" Documentation/virt/kvm/x86/errata.rst | 11 ++ arch/x86/include/asm/kvm_host.h | 27 ++- arch/x86/kvm/lapic.c | 100 ++++++++-- arch/x86/kvm/svm/avic.c | 273 ++++++++++++++------------ arch/x86/kvm/svm/svm.c | 2 +- arch/x86/kvm/svm/svm.h | 9 +- 6 files changed, 260 insertions(+), 162 deletions(-) base-commit: 372d07084593dc7a399bf9bee815711b1fb1bcf2 -- 2.37.2.672.g94769d06f0-goog