@samitouri / QOSamiQemu / commits / 777d9f78ff

accel/kvm: Don't clear pending #SMI in kvm_get_vcpu_events

The kvm_get_vcpu_events propogates the state of the pending smi from the kernel to the cpu->interrupt_request, with the intention of having un up to date migration state. Later the opposite is done, the kvm_put_vcpu_events restores the state of the pending #SMI from the 'cs->interrupt_request' The only problem is that kvm_get_vcpu_events also resets the SMI in cpu->interrupt_request when there is no pending #SMI indicated by the kernel, and that is wrong as the SMI might be still raised by qemu. While at it, also fix a similar but more theoretical bug with regard to a latched #INIT while in SMM. A simple reproducer for this bug is to read an EFI variable in a loop from within a guest, while at the same time run 'info registers' on the qemu HMP monitor. The reads will, once in a while, fail with an 'Invalid argument' error. Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Link: https://lore.kernel.org/r/20260223221908.361456-1-mlevitsk@redhat.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Maxim Levitsky committed Feb 23, 2026 at 17:19 UTC 777d9f78ff0ba50a7fb9c7bc05fca0213101897d
1 file changed -4
target/i386/kvm/kvm.c
-4
@@ -5501,8 +5501,6 @@ static int kvm_get_vcpu_events(X86CPU *cpu)
5501 }
5502 if (events.smi.pending) {
5503 cpu_interrupt(CPU(cpu), CPU_INTERRUPT_SMI);
5504 - } else {
5505 - cpu_reset_interrupt(CPU(cpu), CPU_INTERRUPT_SMI);
5504 }
5505 if (events.smi.smm_inside_nmi) {
5506 env->hflags2 |= HF2_SMM_INSIDE_NMI_MASK;
@@ -5511,8 +5509,6 @@ static int kvm_get_vcpu_events(X86CPU *cpu)
5509 }
5510 if (events.smi.latched_init) {
5511 cpu_interrupt(CPU(cpu), CPU_INTERRUPT_INIT);
5514 - } else {
5515 - cpu_reset_interrupt(CPU(cpu), CPU_INTERRUPT_INIT);
5512 }
5513 }
5514