Skip to contentSkip to conversation

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

PATCH Applied Maxim Levitsky 2 participants 2 messages Feb 23 – Feb 24 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 target/i386/kvm/kvm.c | 4 ----
 1 file changed, 4 deletions(-)
target/i386/kvm/kvm.c +0 -4
index 9f1a4d4cbb26..bed7768c28d7 100644
@@ -5502,8 +5502,6 @@ static int kvm_get_vcpu_events(X86CPU *cpu)
         }
         if (events.smi.pending) {
             cpu_interrupt(CPU(cpu), CPU_INTERRUPT_SMI);
-        } else {
-            cpu_reset_interrupt(CPU(cpu), CPU_INTERRUPT_SMI);
         }
         if (events.smi.smm_inside_nmi) {
             env->hflags2 |= HF2_SMM_INSIDE_NMI_MASK;
@@ -5512,8 +5510,6 @@ static int kvm_get_vcpu_events(X86CPU *cpu)
         }
         if (events.smi.latched_init) {
             cpu_interrupt(CPU(cpu), CPU_INTERRUPT_INIT);
-        } else {
-            cpu_reset_interrupt(CPU(cpu), CPU_INTERRUPT_INIT);
         }
     }
 
Signature · 1 line
2.49.0