Skip to contentSkip to conversation

target/i386/kvm: fix latched INIT lost in kvm_put_vcpu_events()

PATCH Applied Denis V. Lunev 2 participants 2 messages Nov 3

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/i386/kvm: fix latched INIT lost in kvm_put_vcpu_events()

From: Denis V. Lunev <[email protected]>

CPU_INTERRUPT_INIT is 0x0400, while kvm_vcpu_events.smi.latched_init is a __u8. The assignment truncates the masked value to 0, so every KVM_SET_VCPU_EVENTS tells KVM to clear an INIT it has latched for a vCPU in SMM. smi.pending survives only because CPU_INTERRUPT_SMI is 0x0040; normalize both with !! like the neighbouring fields.

Fixes fc12d72e1082 ("target-i386: add support for SMBASE MSR and SMIs")
---
 target/i386/kvm/kvm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/i386/kvm/kvm.c +3 -2
index 3cbaee700b..4e435c864a 100644
@@ -5512,8 +5512,9 @@ static int kvm_put_vcpu_events(X86CPU *cpu, KvmPutState level)
             /* As soon as these are moved to the kernel, remove them
              * from cs->interrupt_request.
              */
-            events.smi.pending = cs->interrupt_request & CPU_INTERRUPT_SMI;
-            events.smi.latched_init = cs->interrupt_request & CPU_INTERRUPT_INIT;
+            events.smi.pending = !!(cs->interrupt_request & CPU_INTERRUPT_SMI);
+            events.smi.latched_init =
+                !!(cs->interrupt_request & CPU_INTERRUPT_INIT);
             cpu_reset_interrupt(cs, CPU_INTERRUPT_INIT | CPU_INTERRUPT_SMI);
         } else {
             /* Keep these in cs->interrupt_request.  */

base-commit: a3565937b39779d4e3704298095f566e7559ad53

Signature · 1 line
2.53.0