Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3990373iog; Tue, 28 Jun 2022 06:59:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ubUE5CiLZyQ3R0rqHIjwoHz7NsY/cQgFjtjLrP2abCb6aYZ9cv18uumN3ajwgSxsbNYSao X-Received: by 2002:a17:902:e80b:b0:16a:61da:924 with SMTP id u11-20020a170902e80b00b0016a61da0924mr5146605plg.54.1656424784995; Tue, 28 Jun 2022 06:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656424784; cv=none; d=google.com; s=arc-20160816; b=McWkYjEUpkbalAkWhaaJMc5+CimQRWDIvKfh8mNWWfK49lWNfGiI/Kqq/Q3fZL6UbY GvaZf7d6ZzAmrmofWEo6w5Oo03wUyoF3nC9mmPpBttLo4XZPSxJGXr0KMGwnX6DKH1+L Nj9SEunz9OrqjKsFbfxH7OZmwY9Ql0kssyvhFOac49z+U3Cw9IWuxK406isG/JLUsqyy OXM9OH5f8cFy1+J9p06wePEqOKjtvjr0QmGkH7iVy77aVvWr71LqOD4Qs6zJ7S4adE1z /BuNKIApGdM1VyoryKVa51bv8wLBAiSTY5vHkcb9YlekurghwS2EJanIKTgpil6bdiX5 2BVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B76ii6aGW9eLNBNEMMOE6K6NRx7mIr3K+oSU22gMg14=; b=YLiApqukcii4nE8qkXek0OOP2+TtA8Hf6f9qtpn6PoATLZMvfKXoZsUsvsj5dniua5 vk3JSmWTWD46+3J7MNCtsX5XLtPBzvTBwZgRTh0FDaLsQE/iomleIAowNu8I2YmHoKbu yV4qXjH8jlhRiQAeD7yVfIvznky2BCPtVauX8hFqOQ229ivtygJ1SJdtcdNswNPHr4AN UdCMKn+KvE/GmDtMlze7ukcqVZflRs325v1L27z8tdMtMPGjfj4OfttEJgJfS2XCXOdK /Tm5RlyLd/BBeS9QmmVgfe70yCm/jaYWilYgA2YRCV61313FZEtZcB1yWv4b6sOzN7iO zLMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lyPc14AM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d1-20020aa797a1000000b005252bb2fda9si16692540pfq.71.2022.06.28.06.59.32; Tue, 28 Jun 2022 06:59:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lyPc14AM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347016AbiF1N4p (ORCPT + 99 others); Tue, 28 Jun 2022 09:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbiF1N43 (ORCPT ); Tue, 28 Jun 2022 09:56:29 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C5FE3337F; Tue, 28 Jun 2022 06:56:28 -0700 (PDT) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25SDiQfC012143; Tue, 28 Jun 2022 13:56:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=B76ii6aGW9eLNBNEMMOE6K6NRx7mIr3K+oSU22gMg14=; b=lyPc14AMSX69R7k4Ub8LnV/cXlQ9lZcf07oVmCEMTf0NKyBAYl2+B4IDUoYFpBl9a6Pq h5qpmmB5q28iYRSKkVUnV5+4kThYJPumPxUK5YoaWXfqSDhecC+p3Trt/AJjwIeOMisC a5NiK8423QrskCGYBV8oP90I+9nfyOL+9NW2+cctEfPGrtE/YCfmgSGWnfJ4CAR1VXf3 3AbV7af4HBb42s3TbgTZtd0zQeB2EbDMoFIlNEEFVRrwrZeCiQKi3wwTQz8wTePwYf+i ZTYZdexzivXoDIoaxxA9wcE2wh3H4j91fgAkwq10R1caPkzQBN3FdECVFLzEwEpQMkti /w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3h02swge32-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jun 2022 13:56:27 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25SDkARj021617; Tue, 28 Jun 2022 13:56:26 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3h02swge1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jun 2022 13:56:26 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25SDq5I2006308; Tue, 28 Jun 2022 13:56:24 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04fra.de.ibm.com with ESMTP id 3gwt093pdv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jun 2022 13:56:24 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25SDuLOh14746018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Jun 2022 13:56:21 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 442454C04E; Tue, 28 Jun 2022 13:56:21 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB04A4C04A; Tue, 28 Jun 2022 13:56:20 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.40]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 28 Jun 2022 13:56:20 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org Cc: borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, david@redhat.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, scgl@linux.ibm.com, mimu@linux.ibm.com, nrb@linux.ibm.com Subject: [PATCH v12 03/18] KVM: s390: pv: handle secure storage exceptions for normal guests Date: Tue, 28 Jun 2022 15:56:04 +0200 Message-Id: <20220628135619.32410-4-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628135619.32410-1-imbrenda@linux.ibm.com> References: <20220628135619.32410-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 8ZrXCmnwywm1w-atIcwjK_JtXho9Yh22 X-Proofpoint-ORIG-GUID: GyGRAMoVaYSx6xag7PbZTvJT8vWyzkEJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-28_07,2022-06-28_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 suspectscore=0 clxscore=1015 mlxscore=0 adultscore=0 priorityscore=1501 bulkscore=0 mlxlogscore=482 phishscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206280057 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With upcoming patches, normal guests might touch secure pages. This patch extends the existing exception handler to convert the pages to non secure also when the exception is triggered by a normal guest. This can happen for example when a secure guest reboots; the first stage of a secure guest is non secure, and in general a secure guest can reboot into non-secure mode. If the secure memory of the previous boot has not been cleared up completely yet (which will be allowed to happen in an upcoming patch), a non-secure guest might touch secure memory, which will need to be handled properly. This means that gmap faults must be handled and not cause termination of the process. The handling is the same as userspace accesses, it's enough to translate the gmap address to a user address and then let the normal user fault code handle it. Signed-off-by: Claudio Imbrenda Reviewed-by: Janosch Frank --- arch/s390/mm/fault.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index af1ac49168fb..ee7871f770fb 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -754,6 +754,7 @@ void do_secure_storage_access(struct pt_regs *regs) struct vm_area_struct *vma; struct mm_struct *mm; struct page *page; + struct gmap *gmap; int rc; /* @@ -783,6 +784,17 @@ void do_secure_storage_access(struct pt_regs *regs) } switch (get_fault_type(regs)) { + case GMAP_FAULT: + mm = current->mm; + gmap = (struct gmap *)S390_lowcore.gmap; + mmap_read_lock(mm); + addr = __gmap_translate(gmap, addr); + mmap_read_unlock(mm); + if (IS_ERR_VALUE(addr)) { + do_fault_error(regs, VM_ACCESS_FLAGS, VM_FAULT_BADMAP); + break; + } + fallthrough; case USER_FAULT: mm = current->mm; mmap_read_lock(mm); @@ -811,7 +823,6 @@ void do_secure_storage_access(struct pt_regs *regs) if (rc) BUG(); break; - case GMAP_FAULT: default: do_fault_error(regs, VM_READ | VM_WRITE, VM_FAULT_BADMAP); WARN_ON_ONCE(1); -- 2.36.1