diff options
author | Christian Borntraeger <borntraeger@de.ibm.com> | 2011-10-04 05:20:59 +0000 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2011-11-14 17:47:26 +0100 |
commit | 854e42f3e8d3dcaf35b018cf56618fbcd15082d9 (patch) | |
tree | 1ee5914028ec3423eaf28a73291ae07d581c5d02 /hw/s390-virtio.c | |
parent | 13449a6e0ecf6c73e34657100566a471f0c26bbb (diff) |
s390: Fix cpu shutdown for KVM
On s390 a shutdown is the state of all CPUs being either stopped
or disabled (for interrupts) waiting. We have to track the overall
number of running CPUs to call the shutdown sequence accordingly.
This patch implements the counting and shutdown handling for the
kvm path in qemu.
Lets also wrap changes to env->halted and env->exception_index.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'hw/s390-virtio.c')
-rw-r--r-- | hw/s390-virtio.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c index ee850f0559..37945d5d83 100644 --- a/hw/s390-virtio.c +++ b/hw/s390-virtio.c @@ -121,6 +121,34 @@ int s390_virtio_hypercall(CPUState *env, uint64_t mem, uint64_t hypercall) return r; } +/* + * The number of running CPUs. On s390 a shutdown is the state of all CPUs + * being either stopped or disabled (for interrupts) waiting. We have to + * track this number to call the shutdown sequence accordingly. This + * number is modified either on startup or while holding the big qemu lock. + */ +static unsigned s390_running_cpus; + +void s390_add_running_cpu(CPUState *env) +{ + if (env->halted) { + s390_running_cpus++; + env->halted = 0; + env->exception_index = -1; + } +} + +unsigned s390_del_running_cpu(CPUState *env) +{ + if (env->halted == 0) { + assert(s390_running_cpus >= 1); + s390_running_cpus--; + env->halted = 1; + env->exception_index = EXCP_HLT; + } + return s390_running_cpus; +} + /* PC hardware initialisation */ static void s390_init(ram_addr_t my_ram_size, const char *boot_device, @@ -179,8 +207,8 @@ static void s390_init(ram_addr_t my_ram_size, tmp_env->storage_keys = storage_keys; } - env->halted = 0; - env->exception_index = 0; + /* One CPU has to run */ + s390_add_running_cpu(env); if (kernel_filename) { kernel_size = load_image(kernel_filename, qemu_get_ram_ptr(0)); |