Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5291780pxv; Wed, 28 Jul 2021 07:32:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrLfFXVkJeGpayukWedybcxyqzKkl3cg16lT3l1z54z15m8U0PS+v3yWVgiOQ5RVwWzKI1 X-Received: by 2002:a05:6602:342a:: with SMTP id n42mr23122844ioz.126.1627482758645; Wed, 28 Jul 2021 07:32:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627482758; cv=none; d=google.com; s=arc-20160816; b=iBSzPIcyYg5Blf3iyBLuIqjwM9O7xXv5p6lqKMuTX+119m+UyCWq04Q5y5utoMuVLM aGCDCTIzzK8uq2t9NW9OP0YrtTKd1cRu37Vwei19eKJqSl48QsYAVU0HD45Jq0MgoSen Tv+7wJULaMFjhnNFEZpmkhD4lQON+0Fh3u2axDQ2FokgCQ2tHdgi22ajrAaeYlBYWR3Q GXXJIZuDLudIK0tld55VRou9ZgsrKiclKn9RmkCCzdidCelvidmDZJbmDjcoUgEfginX xlsxGS4WvlP+oED5mNL8gD+KGGOgTlSkeL2qQypEvu/YJhaVixnoof5Le+939dXbKXOm zlbQ== 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=LmVmIyaPaE6xRsJjyoEEql0PPQ+iwGSHiWosbZfTE20=; b=J7wsJ55gDHXnHh0vL05NJ4eBH/gNO7AwZFMvNYU8Yb6I5ImazeBQm/yuKDuEqwysvP /A2dno9B/o/7NQcAEZ1li6+SoO1Mk47vD9YGZl140if3+QjQr4yOnWD3vYkvTq961u0e jj3jFWnkrA4Lq/yfSk6COO9psQBRUEjTRos0N4JvLDPvbRqEKs+y0MyniF8Ix3vYDBfi D3iuSW4x6kR/AQE0Cfmlhlwwxs9E33Dr7IHDeB2/1JGsQEJIMtqPMG+g8S3hHxX6yulJ TIZKu5hCxevwo6hncY0idUcfLSkrbDJc3eDheKQe714OEXafkkU2HQ+WqgOCv3D+Y1Ha LBOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=hpqYA8fL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n5si8024362ilk.136.2021.07.28.07.32.23; Wed, 28 Jul 2021 07:32:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=hpqYA8fL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236979AbhG1O1r (ORCPT + 99 others); Wed, 28 Jul 2021 10:27:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59836 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237004AbhG1O0r (ORCPT ); Wed, 28 Jul 2021 10:26:47 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16SENQKf052799; Wed, 28 Jul 2021 10:26:45 -0400 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=LmVmIyaPaE6xRsJjyoEEql0PPQ+iwGSHiWosbZfTE20=; b=hpqYA8fLF2JrLBmPdZcMwhlwWzcUEE8dR8S00wghRNzj0KdMu9OqBVgYs/MDdnWrUPsJ DZEoIkgA7Z3zCvIUIBprqDGDxG7fA3ifarkGbXOmoxtsJ5Hih8eYi/LuS9I6qsD3XVMc SMnqly0sGtk0iihL2L87uEt9gIE2t19xvGys9BGP+23swO9NlLm3glY2GTMt8Nz5e4sT bNK34J7VRzcsnWqv7xeWnHVXjHZa8xLCpwf2qyIwN4MY/6mhEWpGGQM6wBHd+6zsaTzE fb2E6abm3DNMHn9N3VtLVwzJwU9ayHeXgbDJWhibB1i1xhnb7zdTYh7SvFxCH6h5DhnR mg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3a38tere2d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jul 2021 10:26:45 -0400 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 16SEPfDB060770; Wed, 28 Jul 2021 10:26:45 -0400 Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 3a38tere0v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jul 2021 10:26:45 -0400 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16SEJge5017962; Wed, 28 Jul 2021 14:26:42 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma01fra.de.ibm.com with ESMTP id 3a235krqrm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Jul 2021 14:26:42 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16SENxOp30474576 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Jul 2021 14:23:59 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3BF49A4053; Wed, 28 Jul 2021 14:26:39 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD783A4055; Wed, 28 Jul 2021 14:26:38 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.9.194]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 28 Jul 2021 14:26:38 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org Cc: cohuck@redhat.com, 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 Subject: [PATCH v2 05/13] KVM: s390: pv: handle secure storage exceptions for normal guests Date: Wed, 28 Jul 2021 16:26:23 +0200 Message-Id: <20210728142631.41860-6-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728142631.41860-1-imbrenda@linux.ibm.com> References: <20210728142631.41860-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: X7Ic9V76maBm8WnQNEVEJeCITWC3v-XC X-Proofpoint-ORIG-GUID: ajgT3PwTdSlG2semFiR595t1FoukduSi X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-28_08:2021-07-27,2021-07-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 spamscore=0 clxscore=1015 mlxlogscore=898 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107280079 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, a non-secure guest might touch secure memory, which will need to be handled properly. Signed-off-by: Claudio Imbrenda --- arch/s390/mm/fault.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index eb68b4f36927..b89d625ea2ec 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -767,6 +767,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; /* @@ -796,6 +797,16 @@ void do_secure_storage_access(struct pt_regs *regs) } switch (get_fault_type(regs)) { + case GMAP_FAULT: + gmap = (struct gmap *)S390_lowcore.gmap; + /* + * Very unlikely, but if it happens, simply try again. + * The next attempt will trigger a different exception. + */ + addr = __gmap_translate(gmap, addr); + if (addr == -EFAULT) + break; + fallthrough; case USER_FAULT: mm = current->mm; mmap_read_lock(mm); @@ -824,7 +835,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.31.1