From patchwork Fri Nov 11 17:06:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudio Imbrenda X-Patchwork-Id: 18914 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp863234wru; Fri, 11 Nov 2022 09:09:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf59ZuSlPXpfzCiNm24XiUudXGkjVQ11DVJWgiiyd8CMR6v0jNN/wq/MrzAWfLaFF9FU5xBo X-Received: by 2002:a63:4306:0:b0:46f:918e:7339 with SMTP id q6-20020a634306000000b0046f918e7339mr2374774pga.429.1668186562123; Fri, 11 Nov 2022 09:09:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668186562; cv=none; d=google.com; s=arc-20160816; b=mtQoYYb+wqQAgVk+4UGD4UCTV1sZSzML+Oan30/6bufama+l59Z1/GR/u31VhNHg2f 5mps9Di2EbmZXqgCplfnnqnIiyDU0VnYSXClUED6MB06y0TCNAzU2ZY81QmMJXuXsHv4 N5p7w593BqqV1urAfhtbPD4yOtRgWOFzQTaZo8RnuJdcT395TbVA0cvxs30FA4Gju04h 0CP2N0KGwJQrMP3qCpqngjWOQ1KrFS0/3lokkAlsxQtmb2QvwP8IWM/sKdp/mRvHJrYF Z5TdlL78hLNFU6J6AD320Jwrw1ZpqSlox+Ie337NpYVVlPKJiCVUYCQJXNvSXu1+6En3 U43g== 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=ygebbGXz0lYqdQJxINUIxigHihkBy49WZx6/0vKY7B0=; b=0QVxK0eKBORZnBhjyBsUNVBz9sHFJOVbVgmBsYsACriXGrTi01zZCIqrcS2mAc06Aj Y/sVMRyPe8BnETBAykarUiHKGUPvIU+TaxbPDnhvO/5obxlFBXrsZCo3vqFz9NEu+lX9 hksCZIYMMfife0zY4Cyser6clnfRSf2BxTB8JZcJS2t0fN9Y5GBELn70jfZgxoXynCka v54gzcnWHzkwVwxAf9QLrHFCtT0yz1/F96L8M6ULlp+lniVKc+vJ6XJXET5mtvsXhhT7 EEmftEn3Sxl0TX3G9dcfpPRbQCRlG8xv0nHqxHJhFypX+GrkHle1eLm8H4fzssVrRTAL o2FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=D8HXD7Ox; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n3-20020a170902d2c300b00178380f525bsi3351016plc.547.2022.11.11.09.09.07; Fri, 11 Nov 2022 09:09:22 -0800 (PST) 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=D8HXD7Ox; 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 S233368AbiKKRHF (ORCPT + 99 others); Fri, 11 Nov 2022 12:07:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233353AbiKKRGs (ORCPT ); Fri, 11 Nov 2022 12:06:48 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 835AB7341F; Fri, 11 Nov 2022 09:06:47 -0800 (PST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2ABGpLJ0002480; Fri, 11 Nov 2022 17:06:47 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=ygebbGXz0lYqdQJxINUIxigHihkBy49WZx6/0vKY7B0=; b=D8HXD7OxUBVx9f1TUQYiKiDNyUEjGONeaqoyV1f/UwuGaOIEvkwuhc/5QG21AjsawSnv T8S4HtSh01v/+Uo4eAHpuxiQxluvhwKPNVnwnN3+hD5Pge+p9Cejxh2JFVMHlVOxHFHk wh+atUGYrRbykLBbetIaeVD+/AG5Z9zZyPOZUNZ9UPILYgkR9nE8Dcn2p/47ObH0AaAx GaN8LtAgVNuSkIyKt5OXDaeGEo8joNNb7AqLvFI2asI1qflR70xC2VGNbJ+59aDa72Js xeX36AIUYNcojgpvr8n7rX0aL+Qj8Y90JL90PIpndfD1IBfm8AaRAi/L3227BYYgM6JD IQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kst99gdba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 17:06:47 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2ABGuGDP016479; Fri, 11 Nov 2022 17:06:46 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kst99gd9v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 17:06:46 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2ABH6bbC012876; Fri, 11 Nov 2022 17:06:44 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma02fra.de.ibm.com with ESMTP id 3kngpgpkau-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 17:06:43 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2ABH6ebH8651274 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Nov 2022 17:06:40 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AF5294C04A; Fri, 11 Nov 2022 17:06:40 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1ED1E4C040; Fri, 11 Nov 2022 17:06:40 +0000 (GMT) Received: from localhost.localdomain (unknown [9.171.65.74]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 11 Nov 2022 17:06:40 +0000 (GMT) From: Claudio Imbrenda To: kvm@vger.kernel.org Cc: borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, david@redhat.com, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, scgl@linux.ibm.com, seiden@linux.ibm.com, nrb@linux.ibm.com Subject: [PATCH v16 4/6] KVM: s390: pv: avoid export before import if possible Date: Fri, 11 Nov 2022 18:06:30 +0100 Message-Id: <20221111170632.77622-5-imbrenda@linux.ibm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221111170632.77622-1-imbrenda@linux.ibm.com> References: <20221111170632.77622-1-imbrenda@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: M7mHJvldDek4Hi-YRVHQf6Ndf67lZed6 X-Proofpoint-GUID: gT1wCSWWM2FwMoWApBrfJ3A_995ThIq_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-11_08,2022-11-11_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 impostorscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 priorityscore=1501 bulkscore=0 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211110115 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749220392913588207?= X-GMAIL-MSGID: =?utf-8?q?1749220392913588207?= If the appropriate UV feature bit is set, there is no need to perform an export before import. The misc feature indicates, among other things, that importing a shared page from a different protected VM will automatically also transfer its ownership. Signed-off-by: Claudio Imbrenda Reviewed-by: Nico Boehr Reviewed-by: Janosch Frank Reviewed-by: Steffen Eiden --- arch/s390/kernel/uv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c index f9810d2a267c..9f18a4af9c13 100644 --- a/arch/s390/kernel/uv.c +++ b/arch/s390/kernel/uv.c @@ -255,6 +255,13 @@ static int make_secure_pte(pte_t *ptep, unsigned long addr, */ static bool should_export_before_import(struct uv_cb_header *uvcb, struct mm_struct *mm) { + /* + * The misc feature indicates, among other things, that importing a + * shared page from a different protected VM will automatically also + * transfer its ownership. + */ + if (test_bit_inv(BIT_UV_FEAT_MISC, &uv_info.uv_feature_indications)) + return false; if (uvcb->cmd == UVC_CMD_UNPIN_PAGE_SHARED) return false; return atomic_read(&mm->context.protected_count) > 1;