mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] Fix 'Spurious APIC interrupt (vector 0xFF) on CPU#n' issue
@ 2023-07-18  9:13 Maxim Levitsky
  2023-07-18  9:13 ` [PATCH 1/3] KVM: x86: VMX: __kvm_apic_update_irr must update the IRR atomically Maxim Levitsky
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Maxim Levitsky @ 2023-07-18  9:13 UTC (permalink / raw)
  To: kvm
  Cc: H. Peter Anvin, Sean Christopherson, linux-kernel,
	Thomas Gleixner, Paolo Bonzini, Ingo Molnar, Dave Hansen, x86,
	Borislav Petkov, Maxim Levitsky

Recently we found an issue which causes these error messages
to be sometimes logged if the guest has VFIO device attached:

'Spurious APIC interrupt (vector 0xFF) on CPU#0, should never happen'

It was traced to the incorrect APICv inhibition bug which started with
'KVM: x86: inhibit APICv/AVIC on changes to APIC ID or APIC base'
(All these issues are now fixed)

However, there are valid cases for the APICv to be inhibited and it should not
cause spurious interrupts to be injected to the guest.

After some debug, the root cause was found and it is that __kvm_apic_update_irr
doesn't set irr_pending which later triggers a int->unsigned char conversion
bug which leads to the wrong 0xFF injection.

This also leads to an unbounded delay in injecting the interrupt and hurts
performance.

In addition to that, I also noticed that __kvm_apic_update_irr is not atomic
in regard to IRR, which can lead to an even harder to debug bug.

Best regards,
	Maxim Levitsky

Maxim Levitsky (3):
  KVM: x86: VMX: __kvm_apic_update_irr must update the IRR atomically
  KVM: x86: VMX: set irr_pending in kvm_apic_update_irr
  KVM: x86: check the kvm_cpu_get_interrupt result before using it

 arch/x86/kvm/lapic.c | 23 +++++++++++++++--------
 arch/x86/kvm/x86.c   | 10 +++++++---
 2 files changed, 22 insertions(+), 11 deletions(-)

-- 
2.26.3



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-18 13:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18  9:13 [PATCH 0/3] Fix 'Spurious APIC interrupt (vector 0xFF) on CPU#n' issue Maxim Levitsky
2023-07-18  9:13 ` [PATCH 1/3] KVM: x86: VMX: __kvm_apic_update_irr must update the IRR atomically Maxim Levitsky
2023-07-18 11:41   ` Paolo Bonzini
2023-07-18 13:35     ` Maxim Levitsky
2023-07-18  9:13 ` [PATCH 2/3] KVM: x86: VMX: set irr_pending in kvm_apic_update_irr Maxim Levitsky
2023-07-18  9:13 ` [PATCH 3/3] KVM: x86: check the kvm_cpu_get_interrupt result before using it Maxim Levitsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®