public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM: x86: Fix a WARN in kvm_apic_send_ipi()
@ 2023-09-04  1:35 Tao Su
  2023-09-04  1:35 ` [PATCH 1/2] x86/apic: Introduce X2APIC_ICR_UNUSED_12 for x2APIC mode Tao Su
  2023-09-04  1:35 ` [PATCH 2/2] KVM: x86: Clear X2APIC_ICR_UNUSED_12 after APIC-write VM-exit Tao Su
  0 siblings, 2 replies; 14+ messages in thread
From: Tao Su @ 2023-09-04  1:35 UTC (permalink / raw)
  To: kvm; +Cc: seanjc, pbonzini, chao.gao, guang.zeng, yi1.lai, tao1.su

When IPI virtualization is enabled, a WARN is triggered if bit12 of ICR
MSR is set after APIC-write VM-exit. The reason is kvm_apic_send_ipi()
thinks the APIC_ICR_BUSY bit should be cleared because KVM has no delay,
but kvm_apic_write_nodecode() doesn't clear the APIC_ICR_BUSY bit.

The APIC_ICR_BUSY bit is removed in x2APIC mode, and bit12 of ICR is
changed to UNUSED bit, but kvm_x2apic_icr_write() still uses
APIC_ICR_BUSY, which may cause ambiguity, so introducing
X2APIC_ICR_UNUSED_12 instead.

When X2APIC_ICR_UNUSED_12 is set, how the hardware handles it
determines how the WARN is fixed. However SDM has no detail about it,
we tested on Intel CPU (SRF/GNR) with IPI virtualization and found
X2APIC_ICR_UNUSED_12 was also cleared by hardware without #GP. Therefore,
the clearing of bit12 should be still kept being consistent with the
hardware behavior.

Tao Su (2):
  x86/apic: Introduce X2APIC_ICR_UNUSED_12 for x2APIC mode
  KVM: x86: Clear X2APIC_ICR_UNUSED_12 after APIC-write VM-exit

 arch/x86/include/asm/apicdef.h |  1 +
 arch/x86/kvm/lapic.c           | 27 ++++++++++++++++++++-------
 2 files changed, 21 insertions(+), 7 deletions(-)


base-commit: 708283abf896dd4853e673cc8cba70acaf9bf4ea
-- 
2.34.1


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

end of thread, other threads:[~2023-09-24 13:58 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-04  1:35 [PATCH 0/2] KVM: x86: Fix a WARN in kvm_apic_send_ipi() Tao Su
2023-09-04  1:35 ` [PATCH 1/2] x86/apic: Introduce X2APIC_ICR_UNUSED_12 for x2APIC mode Tao Su
2023-09-04  2:58   ` Chao Gao
2023-09-04  3:03     ` Tao Su
2023-09-04  1:35 ` [PATCH 2/2] KVM: x86: Clear X2APIC_ICR_UNUSED_12 after APIC-write VM-exit Tao Su
2023-09-04  2:46   ` Chao Gao
2023-09-04  3:00     ` Tao Su
2023-09-04  4:16   ` kernel test robot
2023-09-04  5:02   ` Tao Su
2023-09-05 23:03   ` Sean Christopherson
2023-09-06  5:07     ` Tao Su
2023-09-06 22:17       ` Sean Christopherson
2023-09-07  9:56         ` Tao Su
2023-09-24 13:58   ` kernel test robot

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