Skip to content

Commit 8de4a1c

Browse files
Maxim Levitskysean-jc
authored andcommitted
KVM: SVM: Disable (x2)AVIC IPI virtualization if CPU has erratum #1235
Disable IPI virtualization on AMD Family 17h CPUs (Zen2 and Zen1), as hardware doesn't reliably detect changes to the 'IsRunning' bit during ICR write emulation, and might fail to VM-Exit on the sending vCPU, if IsRunning was recently cleared. The absence of the VM-Exit leads to KVM not waking (or triggering nested VM-Exit of) the target vCPU(s) of the IPI, which can lead to hung vCPUs, unbounded delays in L2 execution, etc. To workaround the erratum, simply disable IPI virtualization, which prevents KVM from setting IsRunning and thus eliminates the race where hardware sees a stale IsRunning=1. As a result, all ICR writes (except when "Self" shorthand is used) will VM-Exit and therefore be correctly emulated by KVM. Disabling IPI virtualization does carry a performance penalty, but benchmarkng shows that enabling AVIC without IPI virtualization is still much better than not using AVIC at all, because AVIC still accelerates posted interrupts and the receiving end of the IPIs. Note, when virtualizing Self-IPIs, the CPU skips reading the physical ID table and updates the vIRR directly (because the vCPU is by definition actively running), i.e. Self-IPI isn't susceptible to the erratum *and* is still accelerated by hardware. Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> [sean: rebase, massage changelog, disallow user override] Acked-by: Naveen N Rao (AMD) <naveen@kernel.org> Link: https://lore.kernel.org/r/20250611224604.313496-20-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent d921665 commit 8de4a1c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/x86/kvm/svm/avic.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,14 @@ bool avic_hardware_setup(void)
11881188
if (x2avic_enabled)
11891189
pr_info("x2AVIC enabled\n");
11901190

1191+
/*
1192+
* Disable IPI virtualization for AMD Family 17h CPUs (Zen1 and Zen2)
1193+
* due to erratum 1235, which results in missed VM-Exits on the sender
1194+
* and thus missed wake events for blocking vCPUs due to the CPU
1195+
* failing to see a software update to clear IsRunning.
1196+
*/
1197+
enable_ipiv = enable_ipiv && boot_cpu_data.x86 != 0x17;
1198+
11911199
amd_iommu_register_ga_log_notifier(&avic_ga_log_notifier);
11921200

11931201
return true;

0 commit comments

Comments
 (0)