Patchwork [05/18] kvm: Set up signal mask also for !CONFIG_IOTHREAD

login
register
mail settings
Submitter Jan Kiszka
Date Jan. 10, 2011, 8:31 a.m.
Message ID <ce38ce90f07ddfc5b8cabf0666947b2379e3a00e.1294648329.git.jan.kiszka@web.de>
Download mbox | patch
Permalink /patch/78096/
State New
Headers show

Comments

Jan Kiszka - Jan. 10, 2011, 8:31 a.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

Block SIG_IPI and SIGBUS, unblock them during KVM_RUN, just like in
io-thread mode. This will be required to process SIGBUS and for
self-IPIs. As Windows doesn't support signal services, we need to
provide a stub for the init function.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 cpus.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

Patch

diff --git a/cpus.c b/cpus.c
index a21e2d6..bf0fb85 100644
--- a/cpus.c
+++ b/cpus.c
@@ -223,7 +223,6 @@  fail:
     return err;
 }
 
-#ifdef CONFIG_IOTHREAD
 static void dummy_signal(int sig)
 {
 }
@@ -238,6 +237,13 @@  static void qemu_kvm_init_cpu_signals(CPUState *env)
     sigact.sa_handler = dummy_signal;
     sigaction(SIG_IPI, &sigact, NULL);
 
+#ifndef CONFIG_IOTHREAD
+    sigemptyset(&set);
+    sigaddset(&set, SIG_IPI);
+    sigaddset(&set, SIGBUS);
+    pthread_sigmask(SIG_BLOCK, &set, NULL);
+#endif
+
     pthread_sigmask(SIG_BLOCK, NULL, &set);
     sigdelset(&set, SIG_IPI);
     sigdelset(&set, SIGBUS);
@@ -247,7 +253,6 @@  static void qemu_kvm_init_cpu_signals(CPUState *env)
         exit(1);
     }
 }
-#endif
 
 #else /* _WIN32 */
 
@@ -276,6 +281,10 @@  static void qemu_event_increment(void)
         exit (1);
     }
 }
+
+static void qemu_kvm_init_cpu_signals(CPUState *env)
+{
+}
 #endif /* _WIN32 */
 
 #ifndef CONFIG_IOTHREAD
@@ -296,8 +305,10 @@  void qemu_init_vcpu(void *_env)
 
     env->nr_cores = smp_cores;
     env->nr_threads = smp_threads;
-    if (kvm_enabled())
+    if (kvm_enabled()) {
         kvm_init_vcpu(env);
+        qemu_kvm_init_cpu_signals(env);
+    }
     return;
 }