Return-Path: Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:49171 "EHLO e06smtp15.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755499AbbLGMyg (ORCPT ); Mon, 7 Dec 2015 07:54:36 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 Dec 2015 12:54:34 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id C538B1B0806E for ; Mon, 7 Dec 2015 12:54:59 +0000 (GMT) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tB7CsV8966650282 for ; Mon, 7 Dec 2015 12:54:31 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tB7CsU0X017635 for ; Mon, 7 Dec 2015 05:54:31 -0700 From: David Hildenbrand To: stable@vger.kernel.org Cc: dahi@linux.vnet.ibm.com, borntraeger@de.ibm.com, cornelia.huck@de.ibm.com, gregkh@linuxfoundation.org Subject: [PATCH] KVM: s390: enable SIMD only when no VCPUs were created Date: Mon, 7 Dec 2015 13:54:28 +0100 Message-Id: <1449492868-72683-1-git-send-email-dahi@linux.vnet.ibm.com> Sender: stable-owner@vger.kernel.org List-ID: 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 Acked-by: Cornelia Huck Signed-off-by: David Hildenbrand --- 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