Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2200077pxb; Wed, 30 Mar 2022 19:06:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEr/YDDdg6Ob1ZFHTfEzn2RbX3mbiPY5Vq2eKtCFyqf61Og8X16U0Aijt/jRBWCwUqRLD4 X-Received: by 2002:a63:5747:0:b0:381:54b9:b083 with SMTP id h7-20020a635747000000b0038154b9b083mr8611053pgm.178.1648692416627; Wed, 30 Mar 2022 19:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648692416; cv=none; d=google.com; s=arc-20160816; b=FtVT0yudlIvtfC3G/U9RguPlVlcdytzRtgv3CL2AJ/gl9uiA5/qHwyyX/Uo4L+2FN3 KjczOdIvspWTPPVVBMTfhfpSHUzx8p/N3GrpOrTha3Vmb1zsVLiM4BAIqACLr0niOy84 8hUllGvxsaa/8PyBdv1Zqgc+rjwChQ0gMZpluntcAVwgOEF7L2wnB1luJSr1d7YfbjFw Sv1l5y9tEjV7UdipR1helqrqfqM/GDDZPvTnE6sh9PpYReTVBNWrtgsCm0wW91NTowNd ENKQzuZZFr1CSi5G4ZJ69TADRwPp5H/Bn+o2Tw7nInCq0dzW8xs7mnokdwYRBtHCFsqU SJrg== 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=1cw9ntyCmuV7l9ArGaV6CB27HGkEQiMnt/2CZZvrUw0=; b=KB2zWAg1GUBOdrocbpPz/21dZdK81m/JuQjqgX/MEIvYT+88AJbqUkrZxKzooWHmqZ ZBqtJaTp+feeesY3eA14ULAAyhq1gg8QLH625iQ0X81uEc1G//XI/ewgocmXu/eDKhpf mfxYRDcY5qk5M6KI4ua/zIEX53XfHmh8J6m9wLsy1dN2AJM51Ez5WkgQANQpfSns/N45 M9QfY+8RO5DM/vnpnZdmoPZunKcIdHFU9+LQKOv3rMQVPKKsH+NfQf13wYwRb2RSv5so LuJcnqd8lmCVcEj3q9roq6Swin1L/m+bwXByIVnPNdbeIyTMMEV1/5+w/GbsZgl71ZmL wOQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=QOFj1wEg; 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 y24-20020a170902b49800b00155f7af1822si17698818plr.484.2022.03.30.19.06.42; Wed, 30 Mar 2022 19:06:56 -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=QOFj1wEg; 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 S1346384AbiC3MjC (ORCPT + 99 others); Wed, 30 Mar 2022 08:39:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344121AbiC3Mh2 (ORCPT ); Wed, 30 Mar 2022 08:37:28 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5910B90CC3; Wed, 30 Mar 2022 05:26:19 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22UCAZai009583; Wed, 30 Mar 2022 12:26:19 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=1cw9ntyCmuV7l9ArGaV6CB27HGkEQiMnt/2CZZvrUw0=; b=QOFj1wEgzgsi0NLy+ejW/Syri26nC9I/RK640AdyoQvDaneNGb+SyK7vpAOlct2MI/Ur cU5zwcBYqVUsMxZc8qhzUK4mNRnAP39Iw0yYIyAQrlkagtIzZ+RCxhATXUiYhnyN1nYm k3uXTN1GroH+8FEPg59wABVtMkKKSii6UxIppNoIMjhMWRhjGdXmZs4/yN2iayY6DyEj AqzuvwRZg/cdGBZcobXzq/+xQ7ilXVv+oiL+NfQOuCgyePcB/NHrwSbzZ37uSp4xyFX6 sAuhdegWvNm8l/s9pOYenTIh3l2h3oePE0VVIs9uF9J53cULyxKTsJ5Sa9OaUfU/bi8N 1A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f3ygtny05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Mar 2022 12:26:18 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 22UCKf58028909; Wed, 30 Mar 2022 12:26:18 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3f3ygtnxye-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Mar 2022 12:26:18 +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 22UCNCUx013721; Wed, 30 Mar 2022 12:26:16 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 3f1tf8y9hd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Mar 2022 12:26:15 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22UCQC9934799916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Mar 2022 12:26:12 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C637C11C050; Wed, 30 Mar 2022 12:26:12 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 39BA511C04A; Wed, 30 Mar 2022 12:26:12 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.13.95]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 30 Mar 2022 12:26:12 +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 v9 03/18] KVM: s390: pv: handle secure storage exceptions for normal guests Date: Wed, 30 Mar 2022 14:25:50 +0200 Message-Id: <20220330122605.247613-4-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220330122605.247613-1-imbrenda@linux.ibm.com> References: <20220330122605.247613-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: N-6jEMuZ6erUaEhL7AOO2-0Gx5oJbw2u X-Proofpoint-ORIG-GUID: JLLWbCtMQ31Mm3klrjExf8CAyBPBxyzk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-30_04,2022-03-30_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 impostorscore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxlogscore=623 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203300062 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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. 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 47b52e5384f8..54571a88a641 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -770,6 +770,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; /* @@ -799,6 +800,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); @@ -827,7 +839,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.34.1