From patchwork Wed Jan 10 20:40:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 187081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp1046639dyi; Wed, 10 Jan 2024 12:50:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGi1p3wefcQyascBTTa20PUzX2pyfNp0HW3XYOi21U2u1O13QPOAgqHHuRGo38Pf2EqeEwo X-Received: by 2002:a05:6359:738d:b0:175:78df:7a69 with SMTP id uz13-20020a056359738d00b0017578df7a69mr146375rwb.35.1704919802137; Wed, 10 Jan 2024 12:50:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704919802; cv=none; d=google.com; s=arc-20160816; b=c/9CQzAtolB/9WCRlXkiWapeeN1EJuc3+/tcUVUZz8f56/g4oL9gC+0vnPT5s7uu6y daM4etXoHawellk4t8SwytVkCf2R9uyivRZf+3RQ3mrcllgddH0fR8PppSTaeuyNvRG0 bkvXE9phPRUuSIaLbXZzhEm9siJWWHW71v2Xonbho9+Kg6Jcb6VFULy4O6K/Dzz4HABT DPz6zcYTseHRoyYOxe0xwY9Ak1Ureawq2+k8a8aecTo4RYfIxH0VTsbrclY4m+ENkRSK regFIgNwZSBSKjD2QQD6Xo2bzh9pY/RlfcG37yikLRmR/BXYQOrDeP3QOBLwavho0mES Xrdg== 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=FpiZoHvSUlbsgeuYSF8i9bTFE5kjVtx0H07bVgfyAlU=; fh=NLOUc4UpZ/0A9JrieYT9bxhjFpxay5qeZXON7PgxqoM=; b=fDOQ7K15kDY4YroZrRIv5twZsgUe2upz8UU6chM1AVqFphg9bv/pSCxO/oOLTYf70/ xr6ZG+TXbPSjfWtqgd/J2XsAPPJgXPTLfHCxyG+TpW5Zw64YfdWabMGWn0v2sqIjoULO OfVwJU/C+4CxSDFZ7QlreClGjb7KdLAkjYYqosjmWWN7KoP+3DEroi+xP21/4mQY3tSg edpKuMtPxM514sSf/Zzi1n1/O7+YEWrNlKTA7SRZX8oZYJdIcvcfu8LCLpVdHa688h26 JQOzMeIWlG4oRybR07DGbHBRFlCCpx5T82tL7EWHxy/tZSlRZaUgZRo84+POaw6tFXFe EBzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=gYMmM0Pm; spf=pass (google.com: domain of linux-kernel+bounces-22762-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22762-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id by2-20020a056a02058200b005cf28d6d7d0si999145pgb.369.2024.01.10.12.50.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 12:50:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22762-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-11-20 header.b=gYMmM0Pm; spf=pass (google.com: domain of linux-kernel+bounces-22762-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22762-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 188E0B2471A for ; Wed, 10 Jan 2024 20:45:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C06FD56B74; 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="gYMmM0Pm" Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.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 22F424F887 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 (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40AK3w0s029998; Wed, 10 Jan 2024 20:40:22 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=FpiZoHvSUlbsgeuYSF8i9bTFE5kjVtx0H07bVgfyAlU=; b=gYMmM0PmVOwVx3w4/XFZ8XbmGCKfA8vKeDYw9pbl2jHzMrerwU0XgleXNGZ1ki/XRR5z mu7Htr+2rlg9o/8m/AcEDLoYzB05SIbiy48bxTvogj7Heta/SaGVY5SHWPzsIl7pRfaz V5ekQR1koWy8rmp+TBxlOBUoUGVCgAMlO8nF01trnp0nXmtOu1VbXAL/V3uC0+crMZBB WmewGFAATsknj20g3g9uFqHhzPfiOHyt5OsNJ0FLRUyT8At2K6irxU+Xi2hhlpttMMep YcJRsJEOZ8y27mMzUNe8zvfVfLS6Tu5LG9KDOhtnH7JGWlwr7ryOi64CMOS8RzL7sNUh Pg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3vhpg7hn7m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40:21 +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 40AKO3M9030351; Wed, 10 Jan 2024 20:40:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3vfutp5x8f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 20:40:20 +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 40AKeGrX005067; Wed, 10 Jan 2024 20:40:20 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-5; Wed, 10 Jan 2024 20:40:20 +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 04/13] vhost-vdpa: VHOST_BACKEND_F_NEW_OWNER Date: Wed, 10 Jan 2024 12:40:06 -0800 Message-Id: <1704919215-91319-5-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: a7Axpk9an_Q3GVL_3g0hV04yn0LVxpTx X-Proofpoint-GUID: a7Axpk9an_Q3GVL_3g0hV04yn0LVxpTx 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: 1787737986447906351 X-GMAIL-MSGID: 1787737986447906351 Add the VHOST_BACKEND_F_NEW_OWNER backend capability, which indicates that VHOST_NEW_OWNER is supported. Signed-off-by: Steve Sistare --- drivers/vhost/vdpa.c | 7 ++++++- include/uapi/linux/vhost_types.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index eb3a95e703b0..faed6471934a 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -621,6 +621,10 @@ static long vhost_vdpa_new_owner(struct vhost_vdpa *v) struct mm_struct *mm_new = current->mm; long pinned_vm = v->pinned_vm; unsigned long lock_limit = PFN_DOWN(rlimit(RLIMIT_MEMLOCK)); + u64 features = vhost_vdpa_get_backend_features(v); + + if (!(features & BIT_ULL(VHOST_BACKEND_F_NEW_OWNER))) + return -EOPNOTSUPP; if (!mm_old) return -EINVAL; @@ -784,7 +788,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, BIT_ULL(VHOST_BACKEND_F_IOTLB_PERSIST) | 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_ENABLE_AFTER_DRIVER_OK) | + BIT_ULL(VHOST_BACKEND_F_NEW_OWNER))) return -EOPNOTSUPP; if ((features & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) && !vhost_vdpa_can_suspend(v)) diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h index d7656908f730..9177843951e9 100644 --- a/include/uapi/linux/vhost_types.h +++ b/include/uapi/linux/vhost_types.h @@ -192,5 +192,7 @@ struct vhost_vdpa_iova_range { #define VHOST_BACKEND_F_DESC_ASID 0x7 /* IOTLB don't flush memory mapping across device reset */ #define VHOST_BACKEND_F_IOTLB_PERSIST 0x8 +/* Supports VHOST_NEW_OWNER */ +#define VHOST_BACKEND_F_NEW_OWNER 0x9 #endif