Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7498403ioo; Fri, 3 Jun 2022 07:45:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRCnGGZo+v+MMJ7TZZ52DnAliKvpn3tTwdTbUPgKTCBnCQpl2I5a2SLIxc+koH9AWWV3qP X-Received: by 2002:a65:6b8a:0:b0:3fc:4c06:8a8d with SMTP id d10-20020a656b8a000000b003fc4c068a8dmr9394228pgw.83.1654267510934; Fri, 03 Jun 2022 07:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654267510; cv=none; d=google.com; s=arc-20160816; b=TM/zlLe8PrUN7Mxb3vX1kZuv/QkyKYH9DfiR6RW4QyyZ4Zdy5ODWA7w9z3D5Hi5Bk/ uQp5nToxYxXt5kmHSBcnVX6wzu1qUr0Vm2cJt8zPSI7Wfv5gIqcQ7QBEPrzBMX2//KOm klaXQIVda6A6ROqqGJ1nHuk6CGuVECe4eZ1CCRIszmUGvGRI18LhNO1dYovwDQ2bzPz1 NgyggyFogtA86j4TRxYi1uF9r/zePsl1DHwXmOzyUZlxfdF0RA6Yz/nd6Mgpkclz4te8 TEwznZ3jtLYdiCX1kZnyz2UkTao6BFt02dmizoDXw7BALYCRYRZgdHgw+eqRTUeWp5om 5jYA== 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=4tL+kasI9nBMjiqp4vjVXihPA2t7suHnxIfg3UMDjq4=; b=W1Kwq1M1A2DNCP/NuttCRJV3wwFw5uE7fEIl7IjTAj07ILuK0q6agveGLji/VrIxHC 7QSiHEl1Mas76uayYF2R34SAjDBjW8zHtuEirT59q93Yi0/KIW0+5LYceGbP8eAtoLTA W1DwEqjkxil7OQJ/x0OkssO+wTQNJ/UjhS1pb8rhdVPNY0SBjy4vccn9jfrF4UPaMms9 zeYsyFI8KPHX8rdw8CT4lkZfeifC6jBrfAxE1lrL+TWWoB0I+bpYVKznU74HZ2eNF0D0 udilWJgjM3WXh9ByIH8QmJkfyt8Y6hLEtvsAIG/n03qeyCJk5fSjeWfF863Bxk/GLkG+ N4HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=gm9uUcv2; 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 w2-20020a170902d70200b00163868019a3si9383774ply.360.2022.06.03.07.44.54; Fri, 03 Jun 2022 07:45:10 -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=gm9uUcv2; 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 S241858AbiFCG54 (ORCPT + 99 others); Fri, 3 Jun 2022 02:57:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241810AbiFCG5F (ORCPT ); Fri, 3 Jun 2022 02:57:05 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89D8D1108; Thu, 2 Jun 2022 23:56:58 -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 2536hqJ7031311; Fri, 3 Jun 2022 06:56:57 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=4tL+kasI9nBMjiqp4vjVXihPA2t7suHnxIfg3UMDjq4=; b=gm9uUcv2Q++h2J2vBvKci3sxISeyptvNPUD8HtMGNAt5wliOH+2M2Fv6TSVrgbqfQUFo XgV3+0bYO405VM40ZnS6QM0G/OyyVsgihAxD9SHvnCVOaZVBVsWMfeixFWcSrfdUGopT fSvGaiSHbd1Z9cTG0yWzXq8cfep3UdjohXGcxORY/5rzhydSKjOIuuYv73xPUGZxP0SI LvhpAnNDSIOVJB7jxdFvzrUZAf3hHf/FDGysgHMlGW8snEZ0C28kQdvBJjAy2FZH9X9R A1Xrez9CnyTzkOhEoBw6RVXjvkt4ys4YPZmcFUvFk6J7+BNB4Uhfoxj42nMGdztrq7CK 2g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gfd9fg69q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Jun 2022 06:56:56 +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 2536hxGF031452; Fri, 3 Jun 2022 06:56:56 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gfd9fg697-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Jun 2022 06:56:56 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2536ptAv009840; Fri, 3 Jun 2022 06:56:54 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 3gbcae80v4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 03 Jun 2022 06:56:54 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2536upbr42402072 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 3 Jun 2022 06:56:51 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E908442042; Fri, 3 Jun 2022 06:56:50 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9A60C42047; Fri, 3 Jun 2022 06:56:50 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.40]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 3 Jun 2022 06:56:50 +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 v11 11/19] s390/mm: KVM: pv: when tearing down, try to destroy protected pages Date: Fri, 3 Jun 2022 08:56:37 +0200 Message-Id: <20220603065645.10019-12-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603065645.10019-1-imbrenda@linux.ibm.com> References: <20220603065645.10019-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: cp_swF1N08g-gO1BeF3q4fCItdgS-Xpk X-Proofpoint-GUID: Jt0sJL2iXNP5Iptr1oscGA5zCOA-1Vxa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-03_02,2022-06-02_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 adultscore=0 clxscore=1015 mlxscore=0 spamscore=0 malwarescore=0 priorityscore=1501 suspectscore=0 mlxlogscore=861 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206030027 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 When ptep_get_and_clear_full is called for a mm teardown, we will now attempt to destroy the secure pages. This will be faster than export. In case it was not a teardown, or if for some reason the destroy page UVC failed, we try with an export page, like before. Signed-off-by: Claudio Imbrenda Acked-by: Janosch Frank --- arch/s390/include/asm/pgtable.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index f16403ba81ec..cf81acf3879c 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1182,9 +1182,22 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, } else { res = ptep_xchg_lazy(mm, addr, ptep, __pte(_PAGE_INVALID)); } - /* At this point the reference through the mapping is still present */ - if (mm_is_protected(mm) && pte_present(res)) - uv_convert_owned_from_secure(pte_val(res) & PAGE_MASK); + /* Nothing to do */ + if (!mm_is_protected(mm) || !pte_present(res)) + return res; + /* + * At this point the reference through the mapping is still present. + * The notifier should have destroyed all protected vCPUs at this + * point, so the destroy should be successful. + */ + if (full && !uv_destroy_owned_page(pte_val(res) & PAGE_MASK)) + return res; + /* + * If something went wrong and the page could not be destroyed, or + * if this is not a mm teardown, the slower export is used as + * fallback instead. + */ + uv_convert_owned_from_secure(pte_val(res) & PAGE_MASK); return res; } -- 2.36.1