summaryrefslogtreecommitdiff
path: root/target-s390x
diff options
context:
space:
mode:
Diffstat (limited to 'target-s390x')
-rw-r--r--target-s390x/cpu.h2
-rw-r--r--target-s390x/kvm.c19
2 files changed, 9 insertions, 12 deletions
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 95abe595b3..a66aa0166b 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -309,6 +309,8 @@ static inline void kvm_s390_interrupt_internal(CPUState *env, int type,
}
#endif
CPUState *s390_cpu_addr2state(uint16_t cpu_addr);
+void s390_add_running_cpu(CPUState *env);
+unsigned s390_del_running_cpu(CPUState *env);
/* from s390-virtio-bus */
extern const target_phys_addr_t virtio_size;
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 4beb794cca..40b0ab1922 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -185,8 +185,7 @@ void kvm_s390_interrupt_internal(CPUState *env, int type, uint32_t parm,
return;
}
- env->halted = 0;
- env->exception_index = -1;
+ s390_add_running_cpu(env);
qemu_cpu_kick(env);
kvmint.type = type;
@@ -299,8 +298,7 @@ static int handle_diag(CPUState *env, struct kvm_run *run, int ipb_code)
static int s390_cpu_restart(CPUState *env)
{
kvm_s390_interrupt(env, KVM_S390_RESTART, 0);
- env->halted = 0;
- env->exception_index = -1;
+ s390_add_running_cpu(env);
qemu_cpu_kick(env);
dprintf("DONE: SIGP cpu restart: %p\n", env);
return 0;
@@ -425,17 +423,16 @@ static int handle_intercept(CPUState *env)
r = handle_instruction(env, run);
break;
case ICPT_WAITPSW:
- /* XXX What to do on system shutdown? */
- env->halted = 1;
- env->exception_index = EXCP_HLT;
+ case ICPT_CPU_STOP:
+ if (s390_del_running_cpu(env) == 0) {
+ qemu_system_shutdown_request();
+ }
+ r = EXCP_HALTED;
break;
case ICPT_SOFT_INTERCEPT:
fprintf(stderr, "KVM unimplemented icpt SOFT\n");
exit(1);
break;
- case ICPT_CPU_STOP:
- qemu_system_shutdown_request();
- break;
case ICPT_IO:
fprintf(stderr, "KVM unimplemented icpt IO\n");
exit(1);
@@ -468,8 +465,6 @@ int kvm_arch_handle_exit(CPUState *env, struct kvm_run *run)
if (ret == 0) {
ret = EXCP_INTERRUPT;
- } else if (ret > 0) {
- ret = 0;
}
return ret;
}