KVM: s390: move finalization of SIGP STOP orders to kvm_s390_vcpu_stop
Let's move the finalization of SIGP STOP and SIGP STOP AND STORE STATUS orders to the point where the VCPU is actually stopped. This change is needed to prepare for a user space driven VCPU state change. The action_bits may only be cleared when setting the cpu state to STOPPED while holding the local irq lock. Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
This commit is contained in:
parent
7dfc63cf97
commit
32f5ff63ff
|
@ -56,32 +56,25 @@ static int handle_noop(struct kvm_vcpu *vcpu)
|
||||||
static int handle_stop(struct kvm_vcpu *vcpu)
|
static int handle_stop(struct kvm_vcpu *vcpu)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
unsigned int action_bits;
|
||||||
|
|
||||||
vcpu->stat.exit_stop_request++;
|
vcpu->stat.exit_stop_request++;
|
||||||
spin_lock_bh(&vcpu->arch.local_int.lock);
|
|
||||||
|
|
||||||
trace_kvm_s390_stop_request(vcpu->arch.local_int.action_bits);
|
trace_kvm_s390_stop_request(vcpu->arch.local_int.action_bits);
|
||||||
|
|
||||||
if (vcpu->arch.local_int.action_bits & ACTION_STOP_ON_STOP) {
|
action_bits = vcpu->arch.local_int.action_bits;
|
||||||
kvm_s390_vcpu_stop(vcpu);
|
|
||||||
vcpu->arch.local_int.action_bits &= ~ACTION_STOP_ON_STOP;
|
|
||||||
VCPU_EVENT(vcpu, 3, "%s", "cpu stopped");
|
|
||||||
rc = -EOPNOTSUPP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vcpu->arch.local_int.action_bits & ACTION_STORE_ON_STOP) {
|
if (!(action_bits & ACTION_STOP_ON_STOP))
|
||||||
vcpu->arch.local_int.action_bits &= ~ACTION_STORE_ON_STOP;
|
return 0;
|
||||||
/* store status must be called unlocked. Since local_int.lock
|
|
||||||
* only protects local_int.* and not guest memory we can give
|
if (action_bits & ACTION_STORE_ON_STOP) {
|
||||||
* up the lock here */
|
|
||||||
spin_unlock_bh(&vcpu->arch.local_int.lock);
|
|
||||||
rc = kvm_s390_vcpu_store_status(vcpu,
|
rc = kvm_s390_vcpu_store_status(vcpu,
|
||||||
KVM_S390_STORE_STATUS_NOADDR);
|
KVM_S390_STORE_STATUS_NOADDR);
|
||||||
if (rc >= 0)
|
if (rc)
|
||||||
rc = -EOPNOTSUPP;
|
return rc;
|
||||||
} else
|
}
|
||||||
spin_unlock_bh(&vcpu->arch.local_int.lock);
|
|
||||||
return rc;
|
kvm_s390_vcpu_stop(vcpu);
|
||||||
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_validity(struct kvm_vcpu *vcpu)
|
static int handle_validity(struct kvm_vcpu *vcpu)
|
||||||
|
|
|
@ -1494,7 +1494,15 @@ void kvm_s390_vcpu_stop(struct kvm_vcpu *vcpu)
|
||||||
spin_lock_bh(&vcpu->kvm->arch.start_stop_lock);
|
spin_lock_bh(&vcpu->kvm->arch.start_stop_lock);
|
||||||
online_vcpus = atomic_read(&vcpu->kvm->online_vcpus);
|
online_vcpus = atomic_read(&vcpu->kvm->online_vcpus);
|
||||||
|
|
||||||
|
/* Need to lock access to action_bits to avoid a SIGP race condition */
|
||||||
|
spin_lock_bh(&vcpu->arch.local_int.lock);
|
||||||
atomic_set_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
|
atomic_set_mask(CPUSTAT_STOPPED, &vcpu->arch.sie_block->cpuflags);
|
||||||
|
|
||||||
|
/* SIGP STOP and SIGP STOP AND STORE STATUS has been fully processed */
|
||||||
|
vcpu->arch.local_int.action_bits &=
|
||||||
|
~(ACTION_STOP_ON_STOP | ACTION_STORE_ON_STOP);
|
||||||
|
spin_unlock_bh(&vcpu->arch.local_int.lock);
|
||||||
|
|
||||||
__disable_ibs_on_vcpu(vcpu);
|
__disable_ibs_on_vcpu(vcpu);
|
||||||
|
|
||||||
for (i = 0; i < online_vcpus; i++) {
|
for (i = 0; i < online_vcpus; i++) {
|
||||||
|
|
Loading…
Reference in New Issue