Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1805600imm; Thu, 23 Aug 2018 09:02:36 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwck13He4R4G9d/kHWVXo0p/sLomyqq1tsy6F5ybxos3DesOKCDu8WhG9o/5FPiz4V5rESe X-Received: by 2002:a63:91:: with SMTP id 139-v6mr25409553pga.389.1535040142308; Thu, 23 Aug 2018 09:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535040141; cv=none; d=google.com; s=arc-20160816; b=u7ZU/Mq7pG0ze2MKj9RW085X2cKc0G4pZYHfBQWqw3k25Vy4MRncqdF8apQTiWK/uo plMG/7Jcr7CMAe+5WNnsRxd3pCvgHZKx8sMEHmRBfMpmX8Ku3JesYUAgqK9zrMVfxQmx Ph+KTi/OSmPNAm7CpaSKLAogx1QpXYFv+Gh2j6lryozjTf+ZZT3Gen5WrShQagoBgj1d aAFlEGrHYfDmQyfcOoFEamtrwwUuCRotWIHv9PJ3CGROrspIU2OchJejAXgYUdA0hBrw 5YCR4HsfP4PTnuSAoINyn1KbneGXbiMfxErH8h+h0fBoyWLVbGuTXXQRbZ+nx5STuc/m 6snA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=37gyzmKILjNAvRNTb/dfvDtz2Stf9CFCE7w/jyIwfPM=; b=z3RMqp5UYRFUg7UfuYRKxEnK6E+n6jT/XT4ETEvky/QxrML+UF8DXkn1q40rIsFjYY 4iihwub32jM7mkQ51NjxWnLoeW+eeVmqkgAlnp/5Htx6pTbfhW1TMOGb3bG4Yl8mNwwX LCOcj5/aEoHjCUZxNa9XLOlo5blUxSJhJe071RfPt+k51H0gs5qgvzKI2Zm2o4C2Y9rc NhAinjWfJvXjIWAkXbuRq7swCIZrN2V3+cpGcWNLC5q/O+zqEUVCkBRV4n23AOol5LxO KcFRngrJb9G8sLvWm3lUjqUYO1eN9aHTJPWPxzB76U/qS8Ig8whuxUydLsyS+rahoLp3 uOsQ== 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 u11-v6si4193228pgg.683.2018.08.23.09.02.06; Thu, 23 Aug 2018 09:02:21 -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 S1730635AbeHWNzO (ORCPT + 99 others); Thu, 23 Aug 2018 09:55:14 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36144 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730453AbeHWNzJ (ORCPT ); Thu, 23 Aug 2018 09:55:09 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w7NAJxd8036298 for ; Thu, 23 Aug 2018 06:26:06 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2m1r06qsj8-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 23 Aug 2018 06:26:06 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 23 Aug 2018 11:26:04 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 23 Aug 2018 11:26:02 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w7NAQ0O021102662 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 23 Aug 2018 10:26:00 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D4336A4057; Thu, 23 Aug 2018 13:25:59 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7DAD4A4040; Thu, 23 Aug 2018 13:25:59 +0100 (BST) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.92]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 23 Aug 2018 13:25:59 +0100 (BST) From: Pierre Morel To: david@redhat.com Cc: linux-kernel@vger.kernel.org, cohuck@redhat.com, linux-s390@vger.kernel.org, kvm@vger.kernel.org, frankja@linux.ibm.com, akrowiak@linux.ibm.com, borntraeger@de.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com Subject: [PATCH v3 2/3] KVM: s390: vsie: Do the CRYCB validation first Date: Thu, 23 Aug 2018 12:25:55 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535019956-23539-1-git-send-email-pmorel@linux.ibm.com> References: <1535019956-23539-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18082310-4275-0000-0000-000002AE19BA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18082310-4276-0000-0000-000037B7224B Message-Id: <1535019956-23539-3-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-23_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=878 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808230111 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When entering the SIE the CRYCB validation better be done independently of the instruction's availability. Signed-off-by: Pierre Morel --- arch/s390/kvm/vsie.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c index 12b9707..38ea5da 100644 --- a/arch/s390/kvm/vsie.c +++ b/arch/s390/kvm/vsie.c @@ -161,17 +161,18 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) /* format-1 is supported with message-security-assist extension 3 */ if (!test_kvm_facility(vcpu->kvm, 76)) return 0; - /* we may only allow it if enabled for guest 2 */ - ecb3_flags = scb_o->ecb3 & vcpu->arch.sie_block->ecb3 & - (ECB3_AES | ECB3_DEA); - if (!ecb3_flags) - return 0; if ((crycb_addr & PAGE_MASK) != ((crycb_addr + 128) & PAGE_MASK)) return set_validity_icpt(scb_s, 0x003CU); else if (!crycb_addr) return set_validity_icpt(scb_s, 0x0039U); + /* we may only allow it if enabled for guest 2 */ + ecb3_flags = scb_o->ecb3 & vcpu->arch.sie_block->ecb3 & + (ECB3_AES | ECB3_DEA); + if (!ecb3_flags) + return 0; + /* copy only the wrapping keys */ if (read_guest_real(vcpu, crycb_addr + 72, vsie_page->crycb.dea_wrapping_key_mask, 56)) -- 2.7.4