Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp323806pxm; Wed, 2 Mar 2022 16:23:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8Yng2RtsdcPE9UKL/RspqLG9il8+POGmpcKd3c7QnvzkVAEhsKdaTpNrQRK7qti6cuevT X-Received: by 2002:a17:903:2290:b0:150:8ce:963a with SMTP id b16-20020a170903229000b0015008ce963amr33524125plh.53.1646267012187; Wed, 02 Mar 2022 16:23:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646267012; cv=none; d=google.com; s=arc-20160816; b=CLOOS39Z1InB+T6apTA81ooMLO9/0ZgTqW2h7GYyShebeNFrQFicuajVRLdLPXWcah i50kGuKs45Y9ILRJghbyzmBf+mQ1khFoHJpuEAr3cXQK5Ux4RGhgpLa+b2iVjhx2HzDz 2px91uvmpGNVZNj6Knti8tO+9FbxelWJekgK0dmlRYlmCUJNcvr7S1Wz7oBvL4yPF75u zCBaJFUBfmlE5vFER1dhhmFXOt6GWZWRfPSwdNdrURwnVmpHqkJkVRrkGG2m+B2HH6L6 s7zNJDdRdkcJ9wHBkd6OSldX/jRKS0qsCHTSmCFT628YLUCh87lcXcwXbjiv3Vzkthi6 dpMw== 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=2zLdKaE85V+2qiG6JE8eqhAObTmnsmKJ0bLt2qUlZn8=; b=nPuS9Id1L5KRyvA50NJCtCvTdXhOfgHTaFpsBtQ28GvKev9FDJK8hJofgxperwwqtZ gTDh9F1gL7xHf3TbjlYFwYNqYElCq5MLBU/Ys/bNDZ3jMnjhnFU1z50DII2vPo36AQP2 Anhw9I+8MRO2Ca8Ww7MnnVHpkxhNvgqT9aUC5kfZibcwKcvRO1+RqtC7SoRqDx7DqL+Y yAmb/oMZEEtTbZITZsSbry4/t2A2WqSbR5Js2ElIb5pqqYbPTYSXHTq+2exbbJH41Nfa R8OI3NJaNwpdIcXkT4vL1Aa4FOnK6xT3TnNwoaq3k23oKN/ckgzKcQek797LhQ+Di0o8 5L1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=gH3BgdV1; 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 x1-20020a17090ad68100b001b9b82f070bsi417776pju.66.2022.03.02.16.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 16:23:32 -0800 (PST) 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=gH3BgdV1; 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 9C09A1F7668; Wed, 2 Mar 2022 15:35:59 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244404AbiCBSNa (ORCPT + 99 others); Wed, 2 Mar 2022 13:13:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244475AbiCBSMl (ORCPT ); Wed, 2 Mar 2022 13:12:41 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D91FFCA71E; Wed, 2 Mar 2022 10:11:56 -0800 (PST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 222GO63V021075; Wed, 2 Mar 2022 18:11:56 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=2zLdKaE85V+2qiG6JE8eqhAObTmnsmKJ0bLt2qUlZn8=; b=gH3BgdV1q8sGFT1gSdLDv+pzcrmi4dwmOoqXlNRkP48XsznHFvD9AFw3wh5kXLugY7Lj 8iQFdSssV/1OYw+gsdAnz350kDTv8SSOT+X3M1XiN7umTw+qk2qdOOXexnivN+R7RW0Q oowvME6hOVQSJzYaUus6cPSK476FpuYFgAJuQ5S7NPchyHQYO9ZxgZR95Noplli1YRdb pnBHh+k/dYxdRQvs3k7fA3HJtg9sxMp9/qB7kURdBxXzJPYYZMlKq1uTfbUg8auiEbRV cKyX3MUix6PMfkFEsu2eKfnadnsm8HP26JF+n2S01rzCudCYIguH8BjVvQpoQdAmeQJc MQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3ejc2rt621-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Mar 2022 18:11:55 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 222I2KCw029773; Wed, 2 Mar 2022 18:11:55 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com with ESMTP id 3ejc2rt61h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Mar 2022 18:11:55 +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 222I9BQf022241; Wed, 2 Mar 2022 18:11:53 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 3efbfjqm2u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Mar 2022 18:11:53 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 222IBokj30015946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Mar 2022 18:11:50 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 986625204E; Wed, 2 Mar 2022 18:11:50 +0000 (GMT) Received: from p-imbrenda.ibmuc.com (unknown [9.145.5.37]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 19F4C52052; Wed, 2 Mar 2022 18:11: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 v8 11/17] s390/mm: KVM: pv: when tearing down, try to destroy protected pages Date: Wed, 2 Mar 2022 19:11:37 +0100 Message-Id: <20220302181143.188283-12-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: L240aPVdy4fF3dFbR7sNv5fUBvUBYEup X-Proofpoint-ORIG-GUID: HVRN17ENyDmsC00TJAL5g5AT8C7VDV0G 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 lowpriorityscore=0 impostorscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxscore=0 mlxlogscore=953 spamscore=0 phishscore=0 malwarescore=0 bulkscore=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 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 23ca0d8e058a..72544a1b4a68 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1118,9 +1118,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