Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3990527iog; Tue, 28 Jun 2022 06:59:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tl5BNnrrqtbJzulp6/9T6vxHeiT9g0LsoImtpwrt8zemZYmx65O5oPQ0Jjl6MUSUdwt2sb X-Received: by 2002:a17:902:8e8b:b0:168:a135:d636 with SMTP id bg11-20020a1709028e8b00b00168a135d636mr3716696plb.140.1656424796714; Tue, 28 Jun 2022 06:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656424796; cv=none; d=google.com; s=arc-20160816; b=hRHxu5ki3AqEAYPo2Ct700XFTtAnRxBWK/Ay24L+KA7LKWoAN/XKjeLh8ZbLJDVOO+ DyirdG7B3SQzy6yA4syZwj5ih+IK6U8iUEYqdkSx+5yYEkFgfcqMM4cHwzD/iCbbAhkB 9pTlT/z0i5V9F2qG2UbGFA3716ygzEwDTrhIYXPQJ7zRDGzgtfzR1we42D1LmXhZxwvi OdK0ZcZYRupJvYBTf/C0+aCJJpNzLfjrt0GVeabaJVCBKaiaSy8o6Sp2v4pOHpec89mV iniv0mE4xLtU8lKOLoNRpd6b9/xhyUmJJoUu7xH5VxehEdP4zcOI9EcdEeOz+IXVGYTl z3DQ== 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=9Jy/lxaIMvsbgkqVtkBljfb5OpijIlsVL8zS7JB9Lv0=; b=aJYQiAl7SoWYKwxrDEY+y6e2h648V+AODzZIBY7e5b4RmgqoMEZr2TlYGMNF3xRYJ7 I+l8TrNJkM4KghUr44KkgcRVYjdmg67dgwI1jj5zYh4C3oAthDSBXrQ8FXR7/x6YQlTa OpHHIVJA7sPTeoYyr5ZIbA5vscvfordqabJIXfcV0RJ3avDZ0sYKriN0r6XvGW/1zISL nUgRU4UBufZ+qL6askS9MoX1I5e5TRhmtsyOmiLkt7gHvgExPiygCTwjFrFT3Gm5MQlY V+zY4Laa0szeHKIAdUwfO8WCFoMasXIfkv49o+psTt61WtUojBNncDx4rdm0NwLbp7WL ZKoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=VLRgSaxE; 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 m3-20020a170902d18300b0016777c63534si15083464plb.129.2022.06.28.06.59.42; Tue, 28 Jun 2022 06:59:56 -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=VLRgSaxE; 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 S1347051AbiF1N5C (ORCPT + 99 others); Tue, 28 Jun 2022 09:57:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346259AbiF1N4b (ORCPT ); Tue, 28 Jun 2022 09:56:31 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92E1F3336F; Tue, 28 Jun 2022 06:56:30 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25SDlEe7020719; Tue, 28 Jun 2022 13:56: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=9Jy/lxaIMvsbgkqVtkBljfb5OpijIlsVL8zS7JB9Lv0=; b=VLRgSaxEVEjnXtKMiR/5dHI7ZINEKiQWHvNzHJjjbkCl6ATBD3ja6u3oyHm0FAHpeyra IYh8e3npa9mFEpQjUoXd3PsRqp+p8637vhPTA2ySrIsRRkydpccOK5aMng4RY5xjOfvF 8NI8Nzfyu3o5L6+ds1CusibdAb4uPr9Iq0qtesB+lyxWQETgmjv5UtB6yOJCdGM0O2mq t/VCULPOQliBGCuVcbbeyB9pFKq56g7bUAtnCaMAe2pqnjXc0gmq/74B9zvSAJzyC38M k23qcELzjWb+CSKlYxeukHpcudZ2US5vNgIRxUL4Yq7k4nl5vmeVIkmBlxi03/SmfFv0 Aw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3h02u7raxk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jun 2022 13:56:29 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25SDmDqb023838; Tue, 28 Jun 2022 13:56:29 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3h02u7raww-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jun 2022 13:56:29 +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 25SDoeMB004286; Tue, 28 Jun 2022 13:56:27 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 3gwt08vy10-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jun 2022 13:56:27 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25SDuVEt33358178 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 Jun 2022 13:56:31 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 557CF4C044; Tue, 28 Jun 2022 13:56:24 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F17684C04E; Tue, 28 Jun 2022 13:56:23 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.40]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 28 Jun 2022 13:56: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 v12 10/18] s390/mm: KVM: pv: when tearing down, try to destroy protected pages Date: Tue, 28 Jun 2022 15:56:11 +0200 Message-Id: <20220628135619.32410-11-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628135619.32410-1-imbrenda@linux.ibm.com> References: <20220628135619.32410-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: q9djnWwsuzDtZ7v52vpXUp6y8_A71uNL X-Proofpoint-ORIG-GUID: u8N4cVuSZ1l9C2r2UYcOZAFobKxnChVJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-28_07,2022-06-28_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 malwarescore=0 suspectscore=0 mlxlogscore=862 phishscore=0 impostorscore=0 adultscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206280057 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 Reviewed-by: Nico Boehr --- 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