* [PATCH] KVM: s390: enable SIMD only when no VCPUs were created
@ 2015-12-07 12:54 David Hildenbrand
2015-12-07 13:42 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: David Hildenbrand @ 2015-12-07 12:54 UTC (permalink / raw)
To: stable; +Cc: dahi, borntraeger, cornelia.huck, gregkh
This is the backport of the patch 5967c17b118a ("KVM: s390: enable SIMD
only when no VCPUs were created") for 4.1-stable and 4.2-stable.
We should never allow to enable/disable any facilities for the guest
when other VCPUs were already created.
kvm_arch_vcpu_(load|put) relies on SIMD not changing during runtime.
If somebody would create and run VCPUs and then decides to enable
SIMD, undefined behaviour could be possible (e.g. vector save area
not being set up).
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
---
arch/s390/kvm/kvm-s390.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 8cd8e7b..3c14beb 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -283,12 +283,16 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
r = 0;
break;
case KVM_CAP_S390_VECTOR_REGISTERS:
- if (MACHINE_HAS_VX) {
+ mutex_lock(&kvm->lock);
+ if (atomic_read(&kvm->online_vcpus)) {
+ r = -EBUSY;
+ } else if (MACHINE_HAS_VX) {
set_kvm_facility(kvm->arch.model.fac->mask, 129);
set_kvm_facility(kvm->arch.model.fac->list, 129);
r = 0;
} else
r = -EINVAL;
+ mutex_unlock(&kvm->lock);
break;
case KVM_CAP_S390_USER_STSI:
kvm->arch.user_stsi = 1;
--
2.3.9
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-07 13:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-07 12:54 [PATCH] KVM: s390: enable SIMD only when no VCPUs were created David Hildenbrand
2015-12-07 13:42 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.