From patchwork Wed Jan 10 20:40:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 187072 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1044594dyi; Wed, 10 Jan 2024 12:44:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1EG6zv1EoZ+n9a5a/KgcP01q3gi0k8brQJRrKC/ELMywKfl6bKp20752+kjFPRRk+8suM X-Received: by 2002:a17:906:371a:b0:a2c:199d:557f with SMTP id d26-20020a170906371a00b00a2c199d557fmr45009ejc.51.1704919493982; Wed, 10 Jan 2024 12:44:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704919493; cv=none; d=google.com; s=arc-20160816; b=xMbmkFlBx5iHUzXzMnVJ4vLszEit0Lg3fwOVoYhHSwuxoIpekp5UKRU+TIsWRmJfHr zrRvCNzH5J5g0L+4RE3cpThaw9iMfXLcs0vzsuAFCidTM39TLfhExsNtndwRqKjmLDKA RrowoWG5Kumpj+8MM3wplI23WIWXyoLIH5UReO8Izh2/76n/0NkjCnABXfX9knGZlXyy AbLQmx8/Z3kl59pEyblr/iEPrM9yw/U364rieFzzXJSxVJKfg7UpqkVQ3cZNzk0S1w8h Lx5eefd88oNhRjnzIQ4VGixOAlqgci0PK+x5lFNqnhQ7QVvlMHfJPqoseHS9tn5TQcZU nSLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=ozrzwgDgje72Ak3YBhfPtWMph3qwJiDzAJ5pWQvnhwU=; fh=NLOUc4UpZ/0A9JrieYT9bxhjFpxay5qeZXON7PgxqoM=; b=zLWpSsXSGBSYumMWOHSGHUGlBe+6rXlUHTuQaxIXuWeINfus5t/6NBouwiyYy8nlCF RD8oJG9pMdSgJUKBDz+WyW1bSTC3Ffw/uZ8Fj77qSvQ5Ep0U3v1r6bAkyw7pR3Wk03L9 J+RCnqWpdqWnA6iTwDd9kYD+dn9Mks+uh3wzJSdHAyJA83pxtuYa8eqI7ONzlOUr0eSB oXXSU4VIFVmoPAQw+pv5EM6m6cdw9LEzozgU90vZv3xsvcCGFBM/40nnuj7GAXcrwwZu 1k3uheIEiO2CBXTAPkRXKN+Xqhcw8rNgLr/RoNUEm6dLCDboaJDHzTAu6zpTq4y5Tmos rWaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=FW3HzgVP; spf=pass (google.com: domain of linux-kernel+bounces-22760-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22760-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l16-20020a1709061c5000b00a29b8bce8absi2014670ejg.1039.2024.01.10.12.44.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 12:44:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22760-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=FW3HzgVP; spf=pass (google.com: domain of linux-kernel+bounces-22760-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22760-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 841041F2276E for ; Wed, 10 Jan 2024 20:44:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70D8053E30; Wed, 10 Jan 2024 20:40:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="FW3HzgVP" Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEC484F60F for ; Wed, 10 Jan 2024 20:40:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40AJgBcx024051; Wed, 10 Jan 2024 20:40:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2023-11-20; bh=ozrzwgDgje72Ak3YBhfPtWMph3qwJiDzAJ5pWQvnhwU=; b=FW3HzgVPCn/KF8o9W0qOaX8hff+KWsWzT6rhTE2jPd/COIYCzZ4fsWBMW/3cKMx/npvu HXSKmq/CQ7/f2VV0jIt0h+hqZxNsdq5OQRFgl0ihxbXrFq75A34ycjX95nLjP3IUknuU go/AaQ9fKn/zb+QK2hodsUaqJP3DcIiJRo3mBwaTIg08fpS3YIXIROXZXzENs7YkovCw gcW17hRYWOub6l7dPbMi76badfMeHh+iDoky3+HSwIVZwtLh+lQ0FAv0s5EyTmrJw56e Fd5puGnq9KT0r80rDpvt5dffZg+tAoDn0+kmt3e9jEm4L735AGJn/bNLJVBSehMi6RUA 0w== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vj1m5r493-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40:22 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 40AKbb9b030303; Wed, 10 Jan 2024 20:40:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vfutp5x9t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40:22 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40AKeGrb005067; Wed, 10 Jan 2024 20:40:21 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3vfutp5x5e-7; Wed, 10 Jan 2024 20:40:21 +0000 From: Steve Sistare To: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: "Michael S. Tsirkin" , Jason Wang , Si-Wei Liu , Eugenio Perez Martin , Xuan Zhuo , Dragos Tatulea , Eli Cohen , Xie Yongji , Steve Sistare Subject: [RFC V1 06/13] vhost-vdpa: VHOST_BACKEND_F_IOTLB_REMAP Date: Wed, 10 Jan 2024 12:40:08 -0800 Message-Id: <1704919215-91319-7-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1704919215-91319-1-git-send-email-steven.sistare@oracle.com> References: <1704919215-91319-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-10_10,2024-01-10_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401100163 X-Proofpoint-ORIG-GUID: -Vu2mJH_2nflUo3UQH3FAAxeRLutXKmC X-Proofpoint-GUID: -Vu2mJH_2nflUo3UQH3FAAxeRLutXKmC Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787737663007998714 X-GMAIL-MSGID: 1787737663007998714 Add the VHOST_BACKEND_F_IOTLB_REMAP backend capability, which indicates that VHOST_IOTLB_REMAP is supported. If VHOST_BACKEND_F_IOTLB_REMAP is advertised, then the user must call VHOST_IOTLB_REMAP after ownership of a device is transferred to a new process via VHOST_NEW_OWNER. Disabling the feature during negotiation does not negate this requirement. Signed-off-by: Steve Sistare --- drivers/vhost/vdpa.c | 8 +++++++- include/uapi/linux/vhost_types.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index ec5ca20bd47d..8fe1562d24af 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -789,7 +789,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, BIT_ULL(VHOST_BACKEND_F_SUSPEND) | BIT_ULL(VHOST_BACKEND_F_RESUME) | BIT_ULL(VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK) | - BIT_ULL(VHOST_BACKEND_F_NEW_OWNER))) + BIT_ULL(VHOST_BACKEND_F_NEW_OWNER) | + BIT_ULL(VHOST_BACKEND_F_IOTLB_REMAP))) return -EOPNOTSUPP; if ((features & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) && !vhost_vdpa_can_suspend(v)) @@ -1229,11 +1230,16 @@ static int vhost_vdpa_process_iotlb_remap(struct vhost_vdpa *v, u64 start = msg->iova; u64 last = start + msg->size - 1; struct vhost_iotlb_map *map; + u64 features; int r = 0; if (msg->perm || !msg->size) return -EINVAL; + features = ops->get_backend_features(vdpa); + if (!(features & BIT_ULL(VHOST_BACKEND_F_IOTLB_REMAP))) + return -EOPNOTSUPP; + map = vhost_iotlb_itree_first(iotlb, start, last); if (!map) return -ENOENT; diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h index 35908315ff55..7e79e9bd0f7b 100644 --- a/include/uapi/linux/vhost_types.h +++ b/include/uapi/linux/vhost_types.h @@ -203,5 +203,7 @@ struct vhost_vdpa_iova_range { #define VHOST_BACKEND_F_IOTLB_PERSIST 0x8 /* Supports VHOST_NEW_OWNER */ #define VHOST_BACKEND_F_NEW_OWNER 0x9 +/* Supports VHOST_IOTLB_REMAP */ +#define VHOST_BACKEND_F_IOTLB_REMAP 0xa #endif