Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1797705pxb; Thu, 14 Apr 2022 14:25:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+9I9XD8OT0uMAn0ACVqopIGGzuO0b85Rb6MuIp1p4KVZc2Z56XmNMYk2wrTuHREKNxLJS X-Received: by 2002:a05:6402:40cd:b0:41d:984c:1dc8 with SMTP id z13-20020a05640240cd00b0041d984c1dc8mr5163881edb.52.1649971555907; Thu, 14 Apr 2022 14:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649971555; cv=none; d=google.com; s=arc-20160816; b=RUY1sh0WisaT41dU/HNJ9fGOW7OyOZ3bCDejJbg8swkES1fXikTbEOqT/KC6pbI6Ak 6Dx7izb6p7TFwcyxBcwHgdUMkkqW6LqyEn4ltL8s/xe59yL68i0PFTR7bb7runPygb4h LjvIblmUaYvpEWAVpLAQgkVDaXD8tP7z8ykTIraaIY+04Uaywz1PyFr+OUBlHmoAhj8g +AAOuuNJ+kji5TDK01EVt+4CpoX9J6tpo1c+BTEdo/iiBJVVjYLM/P/Jxq6jGiav5/iE YJ2DGj5K2QZI/JEv0f/pjnHorcK5WssnyoZhxyAgvt9zOljgpIzLaKVBZiRRtujm4mXe nbYw== 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=G6PK3UfFqNd0oh3aXwwPf6rcz15ZnK/xOGLr55XRSYI=; b=iwCO38TwPWle1B77ArYdCHSX/CUbEHNxLHVzbEZ54zxO+fde8vkjQFBjXyZrk56rg/ vSa8xi6eZFM71TXLIl/+Sa/9nfHX/7cyz+P90OpRQthRvMaoNoOhzJsIune+TXBb2aYk sX7tZGtnnlwM8Uepvzz669dZ/HsWCF23YUbm00Fcj9BzIeoXIZeYEve0WGqA9xvWMwhj OynlQ1BVXGG712ecWFwu1dLMn67VjyaqO6OzvS6pMMrdZnr/RfZuYCPSf4rTiddPYvDN gAqIyDCE2OWweuJ/ano2UMkPArFH9rny2kN/RGpauhn+2JQxftROOrJdwdnqx2MeoBn2 dG+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="o/lPMffa"; 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 y11-20020a170906518b00b006e8038543c4si2901074ejk.887.2022.04.14.14.25.29; Thu, 14 Apr 2022 14:25:55 -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="o/lPMffa"; 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 S236188AbiDNIG4 (ORCPT + 99 others); Thu, 14 Apr 2022 04:06:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240758AbiDNIFz (ORCPT ); Thu, 14 Apr 2022 04:05:55 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B3B94C7AE; Thu, 14 Apr 2022 01:03:30 -0700 (PDT) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23E7FX7w015151; Thu, 14 Apr 2022 08:03:29 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=G6PK3UfFqNd0oh3aXwwPf6rcz15ZnK/xOGLr55XRSYI=; b=o/lPMffal7SmwShH1xhWZR1QwP+h5E7KVifQZnRchptVSH2ncZjBtmzd+8Z/wc6BjuSA hYAOEENOgSsy1Y+h4Gjw5fB1GDmMoRrGwqibRwiFbd7OEc7BllrOdXoOmpsKTcGENLd7 b0pG0o+EDH0dM73fm7xx/xMzX61QFCrV3EyBvleEVy+vLFuvTfet7edTsWg4bD29IdMi 6BoCaAun0N5H04/Sv55oeOPeR12q6qZEFa5kaLl7lI8vJt0LXiGt0YVRjIJ/JPiomm7D 3xxF8A1kEAf8gd1MLx9j2K6t1CPz1tHuzqOhSlVeCR5s95NokPmMHQaumwkNdCpqn2Zb qg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fef2mgsph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Apr 2022 08:03:29 +0000 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 23E7topo021574; Thu, 14 Apr 2022 08:03:28 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fef2mgsnp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Apr 2022 08:03:28 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23E7mGUM016640; Thu, 14 Apr 2022 08:03:27 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 3fb1s8yxgs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Apr 2022 08:03:26 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23E83XCR35652018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Apr 2022 08:03:33 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 08EFFAE056; Thu, 14 Apr 2022 08:03:24 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 792A5AE04D; Thu, 14 Apr 2022 08:03:23 +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:23 +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 11/19] s390/mm: KVM: pv: when tearing down, try to destroy protected pages Date: Thu, 14 Apr 2022 10:03:02 +0200 Message-Id: <20220414080311.1084834-12-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: TIFF55H6HT4kVLEb8fmIUsk3dB3DmL6Z X-Proofpoint-GUID: uCI4ubuRT3ERTEBHZfLBgSRs0035GfQM 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_02,2022-04-13_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=897 lowpriorityscore=0 adultscore=0 clxscore=1015 suspectscore=0 spamscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204140040 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3,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 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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 31b7cfb97635..200000f0e1de 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1164,9 +1164,21 @@ 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; + /* + * But if something went wrong and the pages could not be destroyed, + * the slower export is used as fallback instead. + */ + uv_convert_owned_from_secure(pte_val(res) & PAGE_MASK); return res; } -- 2.34.1