Received: by 10.192.165.148 with SMTP id m20csp121293imm; Thu, 19 Apr 2018 14:16:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx48IjRMM7LiMYjbqLnItrYWcn1caSQPdBn7kSRbejxtDx+5SCyEqYtcgd1624xTrNpAcZxy2 X-Received: by 10.99.50.134 with SMTP id y128mr6493597pgy.419.1524172563987; Thu, 19 Apr 2018 14:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524172563; cv=none; d=google.com; s=arc-20160816; b=u8G20LYqAWZIEf6QMZxHHBq4ubocV/5n5ZV/Nt3l/zRTP75jpD6+IiuQ0KkoQvVMvB 6Wr+cjG1cWZRyDFvbzdOO4FobMSsBwA6x2tx4g31tO+ZbuAL6x4F7aHwC+OuIAXQL69M paJQd5V4ULcNo2aoyYHWJiffv1H4QC2U+1ILPfn95xAFLInG0wL/fZD/589+jbLK7BZ6 0iKQB4QV617u2feYohY4HbrxPt47ZfRK5TZYUeG5OvC8cbInBtHNxuIEZVa2Tlx1yjd0 huAJYAoknUcZtvjkjq/trHeQLpZSg3SASZPQivNneQS6Ni+QsUMgJG958Fw3P0WoSxNv pY3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=gKhgjdLksWkRKNgDOXRu9vohkvs6lC5PxX5rV8RlyTk=; b=JGTTaAmA8SnEUMGhhiwjKY4ZBTMZ6fOB8Ly++LvS70oSnSm6e8XD++7o15t0dQxAsj Ak6hjlhcSuxlRssdQNsgsbn+qKv+loLv3VL+sLRs8vGIyZ2MW8q2/n+P6OSe3/SQQVHL 2ClewhRFBH+J++Fe03viNfyp+ymnbID2ponui5p1e1Yq5vMkt+TFfplKBXSS5yFbnm0z 6WEDKS7lsFk50nbu+ru+SKHoeSEvDteSfz5QcLOj2WwhuCvYN39J6aJoOkKeNTFm0gKX qR3ZBEVqcZu5eKpfelajpQnAhpH1kj7oquLS8l+Cl0ZnzahCwMyIWWXUPC2qHoGT7r2q zVaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h32-v6si3802161pld.170.2018.04.19.14.15.36; Thu, 19 Apr 2018 14:16:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753483AbeDSVOE (ORCPT + 99 others); Thu, 19 Apr 2018 17:14:04 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54340 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753319AbeDSVOC (ORCPT ); Thu, 19 Apr 2018 17:14:02 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3JLBIYm123281 for ; Thu, 19 Apr 2018 17:14:01 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2heye2120j-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 19 Apr 2018 17:14:01 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 19 Apr 2018 15:14:00 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 19 Apr 2018 15:13:57 -0600 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3JLDus38454640; Thu, 19 Apr 2018 14:13:56 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 97650136043; Thu, 19 Apr 2018 15:13:56 -0600 (MDT) Received: from localhost.localdomain (unknown [9.60.75.175]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTPS id 9D9B8136040; Thu, 19 Apr 2018 15:13:55 -0600 (MDT) From: Tony Krowiak To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: borntraeger@de.ibm.com, cohuck@redhat.com, pmorel@linux.vnet.ibm.com, pasic@linux.vnet.ibm.com, akrowiak@linux.vnet.ibm.com, pbonzini@redhat.com, rkrcmar@redhat.com Subject: [PATCH] KVM: s390: reset crypto attributes for all vcpus Date: Thu, 19 Apr 2018 17:13:52 -0400 X-Mailer: git-send-email 1.7.1 X-TM-AS-GCONF: 00 x-cbid: 18041921-8235-0000-0000-00000D56EA55 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008885; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000257; SDB=6.01020342; UDB=6.00520615; IPR=6.00799579; MB=3.00020672; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-19 21:13:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041921-8236-0000-0000-0000408EEA6A Message-Id: <1524172432-26211-1-git-send-email-akrowiak@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-19_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804190186 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduces a new function to reset the crypto attributes for all vcpus whether they are running or not. Each vcpu in KVM will be removed from SIE prior to resetting the crypto attributes in its SIE state description. After all vcpus have had their crypto attributes reset the vcpus will be restored to SIE. This function is incorporated into the kvm_s390_vm_set_crypto(kvm) function to fix a reported issue whereby the crypto key wrapping attributes could potentially get out of synch for running vcpus. Reported-by: Halil Pasic Signed-off-by: Tony Krowiak --- arch/s390/kvm/kvm-s390.c | 18 ++++++++++++++---- arch/s390/kvm/kvm-s390.h | 13 +++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index fa355a6..4fa3037 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -789,6 +789,19 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *att return ret; } +void kvm_s390_vcpu_crypto_reset_all(struct kvm *kvm) + { + int i; + struct kvm_vcpu *vcpu; + + kvm_s390_vcpu_block_all(kvm); + + kvm_for_each_vcpu(i, vcpu, kvm) + kvm_s390_vcpu_crypto_setup(vcpu); + + kvm_s390_vcpu_unblock_all(kvm); +} + static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu); static int kvm_s390_vm_set_crypto(struct kvm *kvm, struct kvm_device_attr *attr) @@ -832,10 +845,7 @@ static int kvm_s390_vm_set_crypto(struct kvm *kvm, struct kvm_device_attr *attr) return -ENXIO; } - kvm_for_each_vcpu(i, vcpu, kvm) { - kvm_s390_vcpu_crypto_setup(vcpu); - exit_sie(vcpu); - } + kvm_s390_vcpu_crypto_reset_all(kvm); mutex_unlock(&kvm->lock); return 0; } diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h index 1b5621f..981e3ba 100644 --- a/arch/s390/kvm/kvm-s390.h +++ b/arch/s390/kvm/kvm-s390.h @@ -410,4 +410,17 @@ static inline int kvm_s390_use_sca_entries(void) } void kvm_s390_reinject_machine_check(struct kvm_vcpu *vcpu, struct mcck_volatile_info *mcck_info); + +/** + * kvm_s390_vcpu_crypto_reset_all + * + * Reset the crypto attributes for each vcpu. This can be done while the vcpus + * are running as each vcpu will be removed from SIE before resetting the crypt + * attributes and restored to SIE afterward. + * + * Note: The kvm->lock must be held while calling this function + * + * @kvm: the KVM guest + */ +void kvm_s390_vcpu_crypto_reset_all(struct kvm *kvm); #endif -- 1.7.1