Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp299533pxm; Wed, 2 Mar 2022 15:48:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzN+SZRO2g7OIviabeve1lgDjB9fxnmJ81e4Sc327fvXIBoWgsyiE810EsE0HvpD6T2NghE X-Received: by 2002:a05:6a00:1da3:b0:4e1:68a4:3f1f with SMTP id z35-20020a056a001da300b004e168a43f1fmr35531246pfw.64.1646264930020; Wed, 02 Mar 2022 15:48:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646264930; cv=none; d=google.com; s=arc-20160816; b=kAq1Hw8gmVQGPOZk0u7DsG0rCOlVxPuiR21950ffe49RikaNuLv02T6Qy0Dl8aGitQ efXsjjFZYYKEs//5qkJ2MsSYYsc11ggZhm9EWS7ZrhfA1KxGlRr8JGldGmObWMkDvSNv d0RxPC9Ez3wIyrHXyKfjsDUD1qQzkflcfVKJLXs1k434BsUu3j/2IsyMGJpTtHMH+cVj lQ4kp+gwZkcEA0Davc/YbjKUpqTLstZI2s4p6c3ktSsn270cf4DK9/f/yMCa+ALrszOz LRHbqttt0/k3pqsOX2azCa/F4FffvdkFHc3nnsD9XngeSbCMUYVwE6orz5yhPirsF9gl C19g== 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=XBG1gj3MP8sthW4i00V2G9iwnGACLa4dHh19cozzlGg+Q6zqokyhUl4maVjw7FNgIq 3uCGHzlFSd08eYozY36lqc4+it266ajghmBZ+viukBGA+tLqEN3vN1kB7MKIgQnJWz2T 0uXWqHMXcT87TdjSV6NkhVc27FGEOl3EmfhQbOmq6ZjJwkVNqdicyGcSq6XLuo+DFb7Q qdEDENuv1+GsxY1E5kVkl4wHnxV/T3VpuC6XjRV4/5l+NMrbsP9xxXCMhPOW67T88bGh 0b1B41WqIWdqfOzHiPwiLuX1BYu/13hHSVdX/+4Lnns6lO+ul5vp3/BSh5SKlqaDA/hp BGCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=DmE0Wy4z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v21-20020a1709028d9500b0014fc36dde2fsi454909plo.318.2022.03.02.15.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 15:48:50 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=DmE0Wy4z; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1B2EC1786A7; Wed, 2 Mar 2022 15:12:17 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244485AbiCBSMm (ORCPT + 99 others); Wed, 2 Mar 2022 13:12:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244444AbiCBSMi (ORCPT ); Wed, 2 Mar 2022 13:12:38 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF44CFBBB; Wed, 2 Mar 2022 10:11:52 -0800 (PST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 222GlmaS035189; Wed, 2 Mar 2022 18:11:52 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=DmE0Wy4zam5iM3oEpYf8lH0eMsbbi4ZAe/1Ve+jkvoZYHBRyvJbxKfupn+dgved5SVEs nxZL1zr3uubewUULBWK3xfj/qhKxsCccbZ3dCmOeRYlcLE7QUnL2WRc32NoorXX/2U9u GXgxYan1FzdLfPk1jRQXoLMuTz+UauLQQa4naESda9tCRfUNcJhzfbM15wXxDbCn5Von hN/vg0o1+y6556Q79aWdV+r+i/eCKIE1xRaYHE0KwPFAbRDJZifMYkz+JKwimnW2ZVBH Rhj3LAXsNbDB/QBs51uGCpu6lf3R+nKidJ5E0EbaWdgVsQhRmzemwgzTif8lFYkIPRTq Xw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3ejcdv9q68-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Mar 2022 18:11:52 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 222HiqKh024579; Wed, 2 Mar 2022 18:11:52 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3ejcdv9q4y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Mar 2022 18:11:51 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 222I9dY4011226; Wed, 2 Mar 2022 18:11:49 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma06fra.de.ibm.com with ESMTP id 3efbfj6413-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Mar 2022 18:11:49 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 222IBkdl49086952 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Mar 2022 18:11:46 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25DB452054; Wed, 2 Mar 2022 18:11:46 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.145.5.37]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9C69F52051; Wed, 2 Mar 2022 18:11:45 +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 v8 03/17] KVM: s390: pv: handle secure storage exceptions for normal guests Date: Wed, 2 Mar 2022 19:11:29 +0100 Message-Id: <20220302181143.188283-4-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220302181143.188283-1-imbrenda@linux.ibm.com> References: <20220302181143.188283-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: WpUbPvBkSM9t8-L8BMcs_K2Cyivsif8k X-Proofpoint-ORIG-GUID: 7NvItU5DdztZUscK_ZuuBw4mqLgUWGDh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-02_12,2022-02-26_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 malwarescore=0 adultscore=0 mlxlogscore=589 spamscore=0 impostorscore=0 clxscore=1015 phishscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2203020078 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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