diff options
author | Cornelia Huck <cornelia.huck@de.ibm.com> | 2011-11-17 05:00:41 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-11-17 09:25:43 -0500 |
commit | 9e6dabeffd1d0ec2aa19aa076c4886067238d442 (patch) | |
tree | 6f5f2a06184a0e4ec0b8cff8db912ce6013c5056 /arch/s390/kvm/kvm-s390.c | |
parent | 3439a8da16bcad6b0982ece938c9f8299bb53584 (diff) |
KVM: s390: Fix RUNNING flag misinterpretation
CPUSTAT_RUNNING was implemented signifying that a vcpu is not stopped.
This is not, however, what the architecture says: RUNNING should be
set when the host is acting on the behalf of the guest operating
system.
CPUSTAT_RUNNING has been changed to be set in kvm_arch_vcpu_load()
and to be unset in kvm_arch_vcpu_put().
For signifying stopped state of a vcpu, a host-controlled bit has
been used and is set/unset basically on the reverse as the old
CPUSTAT_RUNNING bit (including pushing it down into stop handling
proper in handle_stop()).
Cc: stable@kernel.org
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/s390/kvm/kvm-s390.c')
-rw-r--r-- | arch/s390/kvm/kvm-s390.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 0bd3bea1e4cd..630ab65b488b 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
@@ -270,10 +270,12 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | |||
270 | restore_fp_regs(&vcpu->arch.guest_fpregs); | 270 | restore_fp_regs(&vcpu->arch.guest_fpregs); |
271 | restore_access_regs(vcpu->arch.guest_acrs); | 271 | restore_access_regs(vcpu->arch.guest_acrs); |
272 | gmap_enable(vcpu->arch.gmap); | 272 | gmap_enable(vcpu->arch.gmap); |
273 | atomic_set_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags); | ||
273 | } | 274 | } |
274 | 275 | ||
275 | void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) | 276 | void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) |
276 | { | 277 | { |
278 | atomic_clear_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags); | ||
277 | gmap_disable(vcpu->arch.gmap); | 279 | gmap_disable(vcpu->arch.gmap); |
278 | save_fp_regs(&vcpu->arch.guest_fpregs); | 280 | save_fp_regs(&vcpu->arch.guest_fpregs); |
279 | save_access_regs(vcpu->arch.guest_acrs); | 281 | save_access_regs(vcpu->arch.guest_acrs); |
@@ -301,7 +303,9 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu) | |||
301 | 303 | ||
302 | int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) | 304 | int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) |
303 | { | 305 | { |
304 | atomic_set(&vcpu->arch.sie_block->cpuflags, CPUSTAT_ZARCH | CPUSTAT_SM); | 306 | atomic_set(&vcpu->arch.sie_block->cpuflags, CPUSTAT_ZARCH | |
307 | CPUSTAT_SM | | ||
308 | CPUSTAT_STOPPED); | ||
305 | vcpu->arch.sie_block->ecb = 6; | 309 | vcpu->arch.sie_block->ecb = 6; |
306 | vcpu->arch.sie_block->eca = 0xC1002001U; | 310 | vcpu->arch.sie_block->eca = 0xC1002001U; |
307 | vcpu->arch.sie_block->fac = (int) (long) facilities; | 311 | vcpu->arch.sie_block->fac = (int) (long) facilities; |
@@ -428,7 +432,7 @@ static int kvm_arch_vcpu_ioctl_set_initial_psw(struct kvm_vcpu *vcpu, psw_t psw) | |||
428 | { | 432 | { |
429 | int rc = 0; | 433 | int rc = 0; |
430 | 434 | ||
431 | if (atomic_read(&vcpu->arch.sie_block->cpuflags) & CPUSTAT_RUNNING) | 435 | if (!(atomic_read(&vcpu->arch.sie_block->cpuflags) & CPUSTAT_STOPPED)) |
432 | rc = -EBUSY; | 436 | rc = -EBUSY; |
433 | else { | 437 | else { |
434 | vcpu->run->psw_mask = psw.mask; | 438 | vcpu->run->psw_mask = psw.mask; |
@@ -501,7 +505,7 @@ rerun_vcpu: | |||
501 | if (vcpu->sigset_active) | 505 | if (vcpu->sigset_active) |
502 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); | 506 | sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved); |
503 | 507 | ||
504 | atomic_set_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags); | 508 | atomic_clear_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags); |
505 | 509 | ||
506 | BUG_ON(vcpu->kvm->arch.float_int.local_int[vcpu->vcpu_id] == NULL); | 510 | BUG_ON(vcpu->kvm->arch.float_int.local_int[vcpu->vcpu_id] == NULL); |
507 | 511 | ||