Skip to contentSkip to conversation

qemu-kvm: event writeback can overwrite interrupts with -no-kvm-irqchip

PATCH Applied Marcelo Tosatti 3 participants 3 messages May 4, 2010 – May 5, 2010 KVM

lore
Share & tools
lore
#0 lore raw

Interrupts that are injected during a vcpu event save/writeback cycle are lost.

Fix by writebacking the state before injecting interrupts.

qemu-kvm.c +4 -5
index 91f0222..90ace20 100644
@@ -885,11 +885,6 @@ int pre_kvm_run(kvm_context_t kvm, CPUState *env)
 {
     kvm_arch_pre_run(env, env->kvm_run);
 
-    if (env->kvm_vcpu_dirty) {
-        kvm_arch_load_regs(env, KVM_PUT_RUNTIME_STATE);
-        env->kvm_vcpu_dirty = 0;
-    }
-
     pthread_mutex_unlock(&qemu_mutex);
     return 0;
 }
@@ -907,6 +902,10 @@ int kvm_run(CPUState *env)
     int fd = env->kvm_fd;
 
   again:
+    if (env->kvm_vcpu_dirty) {
+        kvm_arch_load_regs(env, KVM_PUT_RUNTIME_STATE);
+        env->kvm_vcpu_dirty = 0;
+    }
     push_nmi(kvm);
 #if !defined(__s390__)
     if (!kvm->irqchip_in_kernel)
#1 lore raw
Quoted 4 lines · Marcelo Tosatti

Interrupts that are injected during a vcpu event save/writeback cycle are lost.

Fix by writebacking the state before injecting interrupts.

Good catch.

If that code were to stay, I would now suggest to move the injection into pre_kvm_run instead, just like upstream does. But it I guess that doesn't matters anymore.

Jan

Quoted 30 lines
qemu-kvm.c +4 -5
index 91f0222..90ace20 100644
@@ -885,11 +885,6 @@ int pre_kvm_run(kvm_context_t kvm, CPUState *env)
 {
     kvm_arch_pre_run(env, env->kvm_run);
 
-    if (env->kvm_vcpu_dirty) {
-        kvm_arch_load_regs(env, KVM_PUT_RUNTIME_STATE);
-        env->kvm_vcpu_dirty = 0;
-    }
-
     pthread_mutex_unlock(&qemu_mutex);
     return 0;
 }
@@ -907,6 +902,10 @@ int kvm_run(CPUState *env)
     int fd = env->kvm_fd;
 
   again:
+    if (env->kvm_vcpu_dirty) {
+        kvm_arch_load_regs(env, KVM_PUT_RUNTIME_STATE);
+        env->kvm_vcpu_dirty = 0;
+    }
     push_nmi(kvm);
 #if !defined(__s390__)
     if (!kvm->irqchip_in_kernel)
Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
Applied
#2 lore raw
In reply to Marcelo Tosatti
Quoted 5 lines · Marcelo Tosatti

Interrupts that are injected during a vcpu event save/writeback cycle are lost.

Fix by writebacking the state before injecting interrupts.

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function