From nobody Mon Feb 9 10:40:13 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 6C3102263A for ; Mon, 9 Sep 2024 01:36:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725845812; cv=none; b=GZ7/4Kvl4c1hdGQ3RiWi90Qt5H6La4+6cKLGRwXepL+AqWVJuX/Kj5pn983pOcc9zbSei37zf/LJWUdTEpuk6EGOYxxWcsgEyLHEnxx8ULZOvRAK5Ygd2scxEtJi+0dH7vh1EN4rarogCEmGHHqn5nrlAfkFd5CG1s3hPZpBtMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725845812; c=relaxed/simple; bh=oE3m8E6nH9UMyhDIkgGxy8s79NH/H0CVrWS1/6DOtq4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=StaNph4LfeVqPh0gJdbIubML7D59T+Z5AY5uY3zNOnbtnawPYfvo0JZ7cMKOBWnAViuHoI2bPpKayy/oIHWBUN/YhLft8BIq9QTzQnBfER2khWx8cRLbrQbnZde35OA86SOn5Qt1i+yr6jHlwy9w9YHoGeG83P3YWhCIT6+MdAg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bs1+pRh+; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bs1+pRh+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725845809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QC3M+l8iJWZEevnljOoIIP4I/7torTZh9gwIfyPDAYw=; b=bs1+pRh+wiSlhAVf2zcDgypysy8Yv5Re76tsQvtqDqpmQifZtaEkhb265vsb1+CBK1dqkv uqKN53fqKFPgYUvn+QrAIRxxgjpfk6jfXvbr0TmmXWh0JPer187aT5t5OiWJMFFpyOU7BD Q1/P+D4R52ElpoY6OGEjphriNRHn8mc= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-153-FWjPIzHgOE2K4k17QLnMUw-1; Sun, 08 Sep 2024 21:36:45 -0400 X-MC-Unique: FWjPIzHgOE2K4k17QLnMUw-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B2F641977009; Mon, 9 Sep 2024 01:36:44 +0000 (UTC) Received: from server.redhat.com (unknown [10.72.112.25]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C482819560AA; Mon, 9 Sep 2024 01:36:39 +0000 (UTC) From: Cindy Lu To: lulu@redhat.com, jasowang@redhat.com, mst@redhat.com, michael.christie@oracle.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v1 7/7] vhost: Add new UAPI to support change to task mode Date: Mon, 9 Sep 2024 09:33:46 +0800 Message-ID: <20240909013531.1243525-8-lulu@redhat.com> In-Reply-To: <20240909013531.1243525-1-lulu@redhat.com> References: <20240909013531.1243525-1-lulu@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" Add a new UAPI to support setting the vhost device to use task mode. The user space application needs to use VHOST_SET_ENFORCE_TASK to set the mode. This setting must be set before VHOST_SET_OWNER is set. Signed-off-by: Cindy Lu --- drivers/vhost/vhost.c | 16 +++++++++++++++- include/uapi/linux/vhost.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index bf1e971cb06f..8ed6b3a947a9 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -2340,14 +2340,28 @@ long vhost_dev_ioctl(struct vhost_dev *d, unsigned = int ioctl, void __user *argp) { struct eventfd_ctx *ctx; u64 p; - long r; + long r =3D 0; int i, fd; + bool enforce_task; =20 /* If you are not the owner, you can become one */ if (ioctl =3D=3D VHOST_SET_OWNER) { r =3D vhost_dev_set_owner(d); goto done; } + if (ioctl =3D=3D VHOST_SET_ENFORCE_TASK) { + /* Is there an owner already? */ + if (vhost_dev_has_owner(d)) { + r =3D -EBUSY; + goto done; + } + if (copy_from_user(&kthread, argp, sizeof(enforce_task))) { + r =3D -EFAULT; + goto done; + } + use_kthread =3D enforce_task; + goto done; + } =20 /* You must be the owner to do anything else */ r =3D vhost_dev_check_owner(d); diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index b95dd84eef2d..9853d62d2d34 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h @@ -235,4 +235,6 @@ */ #define VHOST_VDPA_GET_VRING_SIZE _IOWR(VHOST_VIRTIO, 0x82, \ struct vhost_vring_state) + +#define VHOST_SET_ENFORCE_TASK _IOW(VHOST_VIRTIO, 0x83, bool) #endif --=20 2.45.0