Skip to contentSkip to conversation

kvm-ppc: halt secondary cpus when guest reset

PATCH In review Liu Yu 2 participants 2 messages Nov 29, 2011 – Dec 19, 2011

lore
Share & tools
lore

Liu Yu

author
#0 lore raw

PATCH 1/1 kvm-ppc: halt secondary cpus when guest reset

When guest reset, we need to halt secondary cpus until guest kick them. This already works for tcg. The patch add the support for kvm.

For kvm, if use in-kernel mpic, it should not be halted. In this case, we pause the sencondaries instead. This has impact to handling of halt exit,
but fortunately, kvmppc doesn't use halt exit.

---
 hw/ppce500_spin.c |    1 +
 target-ppc/kvm.c  |   11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletions(-)
hw/ppce500_spin.c +1 -0
index cccd940..2b52728 100644
@@ -112,6 +112,7 @@ static void spin_kick(void *data)
 
     env->halted = 0;
     env->exception_index = -1;
+    env->stopped = 0;
     qemu_cpu_kick(env);
 }
 
target-ppc/kvm.c +10 -1
index 429349f..ff4cfdb 100644
@@ -504,7 +504,16 @@ void kvm_arch_post_run(CPUState *env, struct kvm_run *run)
 
 int kvm_arch_process_async_events(CPUState *env)
 {
-    return 0;
+    if (kvm_irqchip_in_kernel()) {
+        if (env->halted == 1 && env->exception_index == EXCP_HLT) {
+            env->stopped = 1;
+            return 1;
+        } else {
+            return 0;
+        }
+    }
+
+    return env->halted;
 }
 
 static int kvmppc_handle_halt(CPUState *env)
Signature · 1 line
1.6.4
#1 lore raw
Quoted 31 lines · Liu Yu

When guest reset, we need to halt secondary cpus until guest kick them. This already works for tcg. The patch add the support for kvm.

For kvm, if use in-kernel mpic, it should not be halted. In this case, we pause the sencondaries instead. This has impact to handling of halt exit,
but fortunately, kvmppc doesn't use halt exit.

---
hw/ppce500_spin.c | 1 +
target-ppc/kvm.c | 11 ++++++++++-

2 files changed, 11 insertions(+), 1 deletions(-)
hw/ppce500_spin.c +1 -0
index cccd940..2b52728 100644
@@ -112,6 +112,7 @@ static void spin_kick(void *data)
 
    env->halted = 0;
    env->exception_index = -1;
+    env->stopped = 0;
    qemu_cpu_kick(env);
 }
 
target-ppc/kvm.c +0 -0
index 429349f..ff4cfdb 100644

target-ppc/kvm.c void kvm_arch_post_run(CPUState *env, struct kvm_run *run) · line 507

Quoted 5 lines
target-ppc/kvm.c +1 -1
@@ -504,7 +504,16 @@ void kvm_arch_post_run(CPUState *env, struct kvm_run *run)
 
 int kvm_arch_process_async_events(CPUState *env)
 {
-    return 0;
+    if (kvm_irqchip_in_kernel()) {

There is no in-kernel irqchip in upstream KVM for BookE. I'll drop this branch. The rest is applied to ppc-next.

Alex