Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp62770lfe; Fri, 15 Apr 2022 19:37:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyViHEFeTXbKhxFtIy0110rc1APAW4lQyI9eGxcxHL8hkwjL07omFfxvU0SzhncJ52Iu5+e X-Received: by 2002:a05:6a00:1804:b0:505:b6d4:a1d0 with SMTP id y4-20020a056a00180400b00505b6d4a1d0mr1768669pfa.52.1650076669079; Fri, 15 Apr 2022 19:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650076669; cv=none; d=google.com; s=arc-20160816; b=O6VGcpERzA4DxlmaHcB0k5+MwQkIqq/+31bqHAwG4Hc0KkwinvmKRHbvKWsbiIAemN 1B7S26swA8jPcv2x3BHysto+43mdFlm19i0NMkm10flFbcRUZrcZGQTknbM2kYSTB61X Rn1OgRkSkMnajvTSh4VJNRT4DMGH2fKBqBIIyOukdwh9H0aSPFPvQ0W1V8TfHme9KW6c Nowgdb6n3F1igr/3fGuhBp715VUAozdTKXf+/yzTvpkSuEY6QHFXQNz4KTAKEIVbGEsX mV/dOYWgwO5T/mWBjEUF5qj5uxIBe73YwpUO7cdmeSs5CyKXzJzzKvCbgrAO43n9IvLU gPSQ== 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=zMLB5/lYYcI5ENMFS2sWpdab42cEl6xZ38s1mR0bzKg=; b=zOiffoQai3IlLNJiovcCvk3jXjOQHS1ilAcrRyrVVPltfCMFNgiGr//+1a/nGdAxRS M3IH9GXF7JMwVQi3TUZjq4+HLo92rYmP9IqliKxezQIeSlJ2+xp1wUO2SCko20acR6M7 4r3vhJH3Vgn+O97Fws9/O8qyWKnxO7ymUeQPj6hOoUP1z8st6wJ1cOwbmh3MR+4AYes9 Pg+fFEz0soqDqE6/VTNkzO/XGaw6edX64Z4vpCuCt87ZquWa4VPP9QOnIa1e0z+19Jh5 euM65eyH8yAd+n4NExu3gc3MPwmjDHh2X6waSYucY9FV1RfyWszdr8Fws8wk8hhCINDi TAeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=U7pO5QR4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k186-20020a6384c3000000b0039958ddae74si2954266pgd.486.2022.04.15.19.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:37:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=U7pO5QR4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 9694418460C; Fri, 15 Apr 2022 18:48:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240856AbiDNIGL (ORCPT + 99 others); Thu, 14 Apr 2022 04:06:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240695AbiDNIFt (ORCPT ); Thu, 14 Apr 2022 04:05:49 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC4F14C7A2; Thu, 14 Apr 2022 01:03:25 -0700 (PDT) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23E70d8e022854; Thu, 14 Apr 2022 08:03:25 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=zMLB5/lYYcI5ENMFS2sWpdab42cEl6xZ38s1mR0bzKg=; b=U7pO5QR40GeKvqeNQDrm1XjMYm5pD4y3eQFcz2nUMrbgzVUrq7H5UukSv+NslkuYQ0eq Q0aIlu5YVwxGWtmYl/FM72oszvKXA4xqDNnt9keZbGHdfgtOjKXfjPfC4BivW9iz6egg BQtpOPZ/DAb3KU0/Jl31ByE2Ltmgtnp59UELRJ4i3nMv3hgqi59q/w35LqGm9JvcGsz3 Q8Bd6+TaNT5ZkeAXb5yvIj7IcTwZ6eORwxKcWFgKofjr0gr565Lt2r3lEGYLNIEsxGWw tiSgYLm2BNhr8eu7nPVI1mxLlSFZjGNUSMXuw8Y9aGYdfYhPYCvblyYpBZQ6ryM0gnl/ Pg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3feeun13qj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Apr 2022 08:03:24 +0000 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 23E7qqFn011259; Thu, 14 Apr 2022 08:03:24 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3feeun13pe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Apr 2022 08:03:24 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23E7lrad029118; Thu, 14 Apr 2022 08:03:22 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 3fb1dj7yh7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Apr 2022 08:03:22 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23E83JU732375286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Apr 2022 08:03:19 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0BD9FAE056; Thu, 14 Apr 2022 08:03:19 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7BD73AE053; Thu, 14 Apr 2022 08:03:18 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.1.140]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 14 Apr 2022 08:03:18 +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 v10 03/19] KVM: s390: pv: handle secure storage exceptions for normal guests Date: Thu, 14 Apr 2022 10:02:54 +0200 Message-Id: <20220414080311.1084834-4-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220414080311.1084834-1-imbrenda@linux.ibm.com> References: <20220414080311.1084834-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 9Ii2svW5mmlac63aOLNgawJtFD2Gb4SH X-Proofpoint-GUID: 9kePlA2VWkYrzQVtx5FlWlb85CtfUlfA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-14_01,2022-04-13_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 spamscore=0 clxscore=1015 suspectscore=0 mlxscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=610 phishscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204140040 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 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.34.1