From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787030053; cv=none; d=zohomail.com; s=zohoarc; b=KylpH3I1gjb1Ifb8yKDi0Dgi8wQ+WjFSnwg1xscZaQOLp5sB3pxQ/aEKJGEsIznsbjYdOzOv+4w44stlSZVrTnxs2z0hgiu7Q4+rz253LgH2dfGsihrf5cD5tSpQFQ0KGuz4FGtUL3uy11vLHeupmKya2uHnSgGhalagj3dlfX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787030053; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AkZeRoc3E17YBp5XADn9w+7xUKDSvBeBFuBZM8xExpk=; b=UHXAjH4VquShsJ1JObLq9oiNQ8R9nnF6JOGW+zIrvjjvaay67jKpVKktT/MtGrF5ZYBP3QTk8L0+0N+KsqcwDLCBjZkzTQQX7HSAUu20XR/nWGO1xzUIOUYhC7RUOjiPXIU7XMaFOWloewNDqC6GPF04tXlTBB1a3VcIxrf49lY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787030053238962.2803461803607; Mon, 17 Aug 2026 22:14:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC7h-00057S-OM; Tue, 18 Aug 2026 01:12:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC7e-00056q-JR for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:27 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC7c-0003iZ-CM for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:26 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-84faf87d19dso4480567b3a.3 for ; Mon, 17 Aug 2026 22:12:23 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029942; x=1787634742; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=AkZeRoc3E17YBp5XADn9w+7xUKDSvBeBFuBZM8xExpk=; b=oG+ChK66vdw67IeirP8USzKrvpf9KzV82kuY7aPUJvjoKeix1mnPYXfJ/7647hj158 tQp7sAs28ma++R7BsbSSonvLfCAn04WGgmbfY2whq1jNGukrGOJQhKiYBd7lnUC4lAN0 HbcOEhGkgzZ604y+9M/eXcrL3BWN9c03ABCb+0JxhDrJmNKLfj/PKZg1U8fBenLul4oq lHhTvX3rTllE7cu5ptRPLBv2TN4AU6Nshi2PdO0M7EOQcuX/uYNmWRgSaPpeRjvoxFIq 8HcUXzK1m9oSO1eGhX0H6yzXDbDyKhBxWKkKg0OKYQFpsNFuNrvAZE4LOpdntIvzdD5I EMRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029942; x=1787634742; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=AkZeRoc3E17YBp5XADn9w+7xUKDSvBeBFuBZM8xExpk=; b=CyOVShd3Pj60489JWXIovmPAxJCepjHFwVOfl+R4c2V1cP9gM2ZKrd7WUv1zM4CPZP YFFAX6eUbhUMnAO0QepmXjaKxj5WUv23Z9JKww9GWsHOLRhnEUurMyOHc0UonsUaiFbl h1rTSEswf128uaG8T6nQC3NAlAtOKfSGc+6zQ0wMY0acx9VdJXfK1/tuB1CohR9DOUwh xrR6var2AWXKeMpEirwYcMmcGRnAQGL1Wz3NPYpBpVSwjBq9r/Wgb3QEVdv7WpMAgpwW zWOScP/pwXQQDpJYSzGPintKwn3U6eEPCZkMe51mNxrh3j99atYqdGe7iqV0bb7isJ8u gu8w== X-Gm-Message-State: AOJu0YwgkggPwAu3e63xj7gyj3fuM6ie2iKIiRGV2kOkp6RpwZY/bKp3 jPKgOt9ttk0C1LlGaFtgjgFRSikQ61GEK2DBpYFiMTQae6BfnlVspYBS X-Gm-Gg: AR+sD12++WlQX4ntHoRDxrGYAa4HgctcGmjZMz6ve9moRUFzIaHFIsz0dK1HkQqC0mw tG4gAo7flTcaa5lhx5E7sWqjo6g6QVCxNhlc+pL/2tCipYJFQXsA9Mb93GwUCOWGLjEaLsYXYZ6 55TTklW9ABNp6//MH7r8ARrOTysXk0jLZRqwlItHZFhXHAPEKAHG2v+RsizLEU0tt7GjgbnVU/C 2J6CoqrTvOvikld+6m/ZMEEJhxHNaiSt3KviYI7zZr2wouOTPD+JNTeiZlgII1z0HkYAfBd/bLv fv1Z/Ou1o2aPRWL98WxvB8MS9tx41WWIHodeB43s/P5K/fqDfWRs9ROavOBEWYW9G4J0lWaYV64 6SOLe3nA6MFcPBxem1T7A6paG5w2Z3WAqeLTEZTnSNTIAmUUA2gof97U6zsKBmG4U9o354MnbqB 980xRVvQxwspxiZxxHbCUlDJZoyCP7w9WjFX4UOjaNLiAHj5WRkL9jgpsVEtS5gVcptUZcgTc= X-Received: by 2002:a05:6a00:3d96:b0:851:8012:c38b with SMTP id d2e1a72fcca58-8518012c611mr22777756b3a.10.1787029942322; Mon, 17 Aug 2026 22:12:22 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:16 -0700 Subject: [PATCH RFC v2 01/13] vhost-user: Consolidate chardev property definitions MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-1-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=8233; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=y46aEYYWs6g66G1yduLOZWbS9jprmJN0wGotjR+n/g4=; b=/WflkskraN4ES9D2WSPAizCPRVsCc0v4+MbDwiiAO/iCI3qYDfgVUf8zepKSO8EByiytIW9ZK odU/jff+RptAg8X1jFangGqsKMl7gc1tv/1bMwgVFCGIgm/Z36CQucb X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=connorkite@gmail.com; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787030053580158500 Move chardev qdev property definitions from children into VHostUserBase. This reduces code duplication and allows children to simply inherit the property during initialization. Signed-off-by: Connor Kite Reviewed-by: Stefan Hajnoczi --- hw/virtio/vhost-user-base.c | 9 +++++++++ hw/virtio/vhost-user-gpio.c | 4 ---- hw/virtio/vhost-user-i2c.c | 5 ----- hw/virtio/vhost-user-input.c | 5 ----- hw/virtio/vhost-user-rng.c | 5 ----- hw/virtio/vhost-user-rtc.c | 4 ---- hw/virtio/vhost-user-snd.c | 1 - hw/virtio/vhost-user-spi.c | 5 ----- hw/virtio/vhost-user-test-device.c | 1 - 9 files changed, 9 insertions(+), 30 deletions(-) diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 478ec68f09..90bd2903db 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -407,9 +407,16 @@ static void vub_device_unrealize(DeviceState *dev) do_vhost_user_cleanup(vdev, vub); } =20 +/*Define common qdev properties. Inherited by all children*/ +static const Property vub_properties[] =3D { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev) +}; + + static void vub_class_init(ObjectClass *klass, const void *data) { VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_CLASS(klass); + DeviceClass *dc =3D DEVICE_CLASS(klass); =20 vdc->realize =3D vub_device_realize; vdc->unrealize =3D vub_device_unrealize; @@ -417,6 +424,8 @@ static void vub_class_init(ObjectClass *klass, const vo= id *data) vdc->get_config =3D vub_get_config; vdc->set_config =3D vub_set_config; vdc->set_status =3D vub_set_status; + + device_class_set_props(dc, vub_properties); } =20 static const TypeInfo vub_types[] =3D { diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index d473f87077..33b8752282 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -14,9 +14,6 @@ #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_gpio.h" =20 -static const Property vgpio_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), -}; =20 static void vgpio_realize(DeviceState *dev, Error **errp) { @@ -42,7 +39,6 @@ static void vu_gpio_class_init(ObjectClass *klass, const = void *data) VHostUserBaseClass *vubc =3D VHOST_USER_BASE_CLASS(klass); =20 dc->vmsd =3D &vu_gpio_vmstate; - device_class_set_props(dc, vgpio_properties); device_class_set_parent_realize(dc, vgpio_realize, &vubc->parent_realize); set_bit(DEVICE_CATEGORY_INPUT, dc->categories); diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index 152b1f6740..3f5427b5b2 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -14,10 +14,6 @@ #include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" =20 -static const Property vi2c_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), -}; - static void vi2c_realize(DeviceState *dev, Error **errp) { VHostUserBase *vub =3D VHOST_USER_BASE(dev); @@ -42,7 +38,6 @@ static void vu_i2c_class_init(ObjectClass *klass, const v= oid *data) VHostUserBaseClass *vubc =3D VHOST_USER_BASE_CLASS(klass); =20 dc->vmsd =3D &vu_i2c_vmstate; - device_class_set_props(dc, vi2c_properties); device_class_set_parent_realize(dc, vi2c_realize, &vubc->parent_realize); set_bit(DEVICE_CATEGORY_INPUT, dc->categories); diff --git a/hw/virtio/vhost-user-input.c b/hw/virtio/vhost-user-input.c index 5cfc5bbb56..8fe6349ffc 100644 --- a/hw/virtio/vhost-user-input.c +++ b/hw/virtio/vhost-user-input.c @@ -7,10 +7,6 @@ #include "qemu/osdep.h" #include "hw/virtio/virtio-input.h" =20 -static const Property vinput_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), -}; - static void vinput_realize(DeviceState *dev, Error **errp) { VHostUserBase *vub =3D VHOST_USER_BASE(dev); @@ -36,7 +32,6 @@ static void vhost_input_class_init(ObjectClass *klass, co= nst void *data) DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->vmsd =3D &vmstate_vhost_input; - device_class_set_props(dc, vinput_properties); device_class_set_parent_realize(dc, vinput_realize, &vubc->parent_realize); set_bit(DEVICE_CATEGORY_INPUT, dc->categories); diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 106c8f211a..664aee403d 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -20,10 +20,6 @@ static const VMStateDescription vu_rng_vmstate =3D { .unmigratable =3D 1, }; =20 -static const Property vrng_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), -}; - static void vu_rng_base_realize(DeviceState *dev, Error **errp) { VHostUserBase *vub =3D VHOST_USER_BASE(dev); @@ -43,7 +39,6 @@ static void vu_rng_class_init(ObjectClass *klass, const v= oid *data) VHostUserBaseClass *vubc =3D VHOST_USER_BASE_CLASS(klass); =20 dc->vmsd =3D &vu_rng_vmstate; - device_class_set_props(dc, vrng_properties); device_class_set_parent_realize(dc, vu_rng_base_realize, &vubc->parent_realize); =20 diff --git a/hw/virtio/vhost-user-rtc.c b/hw/virtio/vhost-user-rtc.c index 88b0c70b90..6d80cb6263 100644 --- a/hw/virtio/vhost-user-rtc.c +++ b/hw/virtio/vhost-user-rtc.c @@ -19,9 +19,6 @@ static const VMStateDescription vu_rtc_vmstate =3D { .unmigratable =3D 1, }; =20 -static const Property vrtc_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), -}; =20 static void vu_rtc_base_realize(DeviceState *dev, Error **errp) { @@ -42,7 +39,6 @@ static void vu_rtc_class_init(ObjectClass *klass, const v= oid *data) VHostUserBaseClass *vubc =3D VHOST_USER_BASE_CLASS(klass); =20 dc->vmsd =3D &vu_rtc_vmstate; - device_class_set_props(dc, vrtc_properties); device_class_set_parent_realize(dc, vu_rtc_base_realize, &vubc->parent_realize); =20 diff --git a/hw/virtio/vhost-user-snd.c b/hw/virtio/vhost-user-snd.c index 7129b77d9c..3663450aed 100644 --- a/hw/virtio/vhost-user-snd.c +++ b/hw/virtio/vhost-user-snd.c @@ -34,7 +34,6 @@ static const VMStateDescription vu_snd_vmstate =3D { }; =20 static const Property vsnd_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), DEFINE_PROP_BIT64("controls", VHostUserBase, parent_obj.host_features, VIRTIO_SND_F_CTLS, false), }; diff --git a/hw/virtio/vhost-user-spi.c b/hw/virtio/vhost-user-spi.c index 707f96c250..fb6168d391 100644 --- a/hw/virtio/vhost-user-spi.c +++ b/hw/virtio/vhost-user-spi.c @@ -15,10 +15,6 @@ #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_spi.h" =20 -static const Property vspi_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), -}; - static void vspi_realize(DeviceState *dev, Error **errp) { VHostUserBase *vub =3D VHOST_USER_BASE(dev); @@ -44,7 +40,6 @@ static void vu_spi_class_init(ObjectClass *klass, const v= oid *data) VHostUserBaseClass *vubc =3D VHOST_USER_BASE_CLASS(klass); =20 dc->vmsd =3D &vu_spi_vmstate; - device_class_set_props(dc, vspi_properties); device_class_set_parent_realize(dc, vspi_realize, &vubc->parent_realize); set_bit(DEVICE_CATEGORY_INPUT, dc->categories); diff --git a/hw/virtio/vhost-user-test-device.c b/hw/virtio/vhost-user-test= -device.c index a2f963fdf6..91e23bf07a 100644 --- a/hw/virtio/vhost-user-test-device.c +++ b/hw/virtio/vhost-user-test-device.c @@ -30,7 +30,6 @@ static const VMStateDescription vud_vmstate =3D { }; =20 static const Property vud_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), DEFINE_PROP_UINT16("virtio-id", VHostUserBase, virtio_id, 0), DEFINE_PROP_UINT32("vq_size", VHostUserBase, vq_size, 64), DEFINE_PROP_UINT32("num_vqs", VHostUserBase, num_vqs, 1), --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787030012; cv=none; d=zohomail.com; s=zohoarc; b=lDF+dJp9vrZ7NCQil7vO+8vIMOShu+PBfGB3ePp+ogXc9xbsgd7zc4dyfnhQ/xvF4fnT+18KwC5iAlkCnen3o0nhmsV+wb78ZOPwCSb0ln/RaUAT7+Z+kpAHQLGOXRvCOyrlQHOfQa3DBv4J1DkOvfO2uXP0HQBTdPgHkFKZzHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787030012; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GF0FtzLMWaPpijge2pYmINjU8s3/LYKiLpVZpt8RABo=; b=aIJbyehvRyM/PLWozR+AZ+YpvoR/j7PVbRDsUXFGlWoINWBIBNORPcmlUN2zuK0eauD9SAgED7eN1RMrZH2rb3wrO0buecAy7a/ASiGNGcaUP7PjpZHHZKqQf3h3RdrG/0ll2ldfaxOilkxVpfMxPTcmcbc059wXnsTR4xMND9U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787030012551760.0044157135326; Mon, 17 Aug 2026 22:13:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC7k-00058N-8f; Tue, 18 Aug 2026 01:12:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC7i-00057u-DP for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:30 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC7e-0003j4-CT for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:29 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-84fa3b14ee1so3080129b3a.0 for ; Mon, 17 Aug 2026 22:12:25 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029945; x=1787634745; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GF0FtzLMWaPpijge2pYmINjU8s3/LYKiLpVZpt8RABo=; b=hvRFUd2uorLAIEJm9U+DnSe+8jChBs8OdAszu6zkd3Mo4dW4w8RoGOnSBnQn0rqMAY o5bQFkvKNwJzeZyIQGTJCWD/JzSg7Rmqpz5xUqIwVMoOuDyHRR3oTv0U2LKueQRyKZjc zvQQt8lg8BGXYeoA51GgobtGJVrrTBOugIGNYxPImE1x0ctH9SforNI/14vStlwRPFOH Nx3JkA9MWdMCwG35tqBQGDo1iz4O3EdBeirfxt5a8uwtFpCzAWmlNjCB2z2qRO4r+10v NElLxCcqDhY02gVq2hshcCbw/JlmkP3xLQD5XfPfm8IvjQHZR96fC8Mbk7bQ0pYRgKhm 0IXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029945; x=1787634745; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=GF0FtzLMWaPpijge2pYmINjU8s3/LYKiLpVZpt8RABo=; b=hs9dQtHhsGS+3Zudh/SIIm1CHSIq6kvweHOD6B/6fq/Qy3yziTZ/KCXeNhumX93qXp uvoM6wtVtJzSRAcTuYsBCdKoLdHbujvOuV26HNOmoEYkEIFDrdpwautxF8Cx1MOzyIiT 8kpHUn9e2sU/RD9N44+Aapq94ey0qSEQjiBZyBr59wI+Ed+e/aLWde4PjVyCkuQdjSCa zeMfjkG/yWnw0U0BsQ80F1s5wnYJCbOo3aqxVIQ9rvhEten3CEyL9T8kmZCQQZ8C/o5m a6ck6R4fHRHxS+sIn4iBMb8F6ktJ/sVpT9Ciu71ih+Zl0QqhJEJXxCnVWqDWpgtzCwyk Wsdw== X-Gm-Message-State: AOJu0YwMr3VxcbcEt8kSxAKAxaozXcrXodDuz9iACK8k+xAFCVrXjc5E UArcpv36mHfwcoQ9zn772M9drEjS44E4/3A3G+sJ9wrB97Mn1sujhtO6 X-Gm-Gg: AR+sD10KGXv7nEyfJxjNyfO2KkkkgqB1+j53OgmZq6tdhk2153YJgSwZ5WLZxDg4qXW 97wCrzYgaRK3Z6bYuN2qo1wiGdZYn7KqN/dF6pUSnuV2db3gZZ3JiHgoFDhb0gPtVFXfjXvYE9+ K0E3xUKt0DFqLnTETVPM4LUD0RNDOTLXO/QQRd0q5sC/B5HtOkDMfPi5F6QbJf7KxQ3O8V1SH9L nY/pHqLgpVTcW562QfWylULNRbaPlefXgE9cNDASsD/fLEA9WabEtg2qJP8OO2aJcdxT600W0B9 6ZG7KCN2UbNN0Fov+jw/RXzvITnGcyk7TP2TkIDZ6snke9Qy2bTb+1QuNa6rYZJXvYjeLbjOG9V YVnjy93ig2RnuMPVCtfVktrIHkVb2eHsRuKmZZKfVCogf44F4jE2wvv5uyplG7lvbz34AFlgr4K mreTA7ikSEyhZsGE0M6jxc8we0Jcl8KH4wHy0rIDKCN0Y7MIFVHyUd8Z2yoY0tpFi+kg== X-Received: by 2002:a05:6a00:3763:b0:851:ba04:ca02 with SMTP id d2e1a72fcca58-851ba04da9amr4656750b3a.16.1787029944848; Mon, 17 Aug 2026 22:12:24 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:17 -0700 Subject: [PATCH RFC v2 02/13] util/iova-tree: g_tree_foreach wrapper MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-2-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=1906; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=o7eLAZfdtjRRWSqHEojyG/bzxtWRaxaRR5MzJJtbNk8=; b=Z3tFhfEr1Omnp83Zy3bXpXXEiQIMkob68NNERZBNgm5EjVu9Ykqidco7cjuQ4gnEqs7pgUwhM ELFXw7D56GGCzrXpmI7r68dyx5q3Ot2OBTpnrqhYAOCg7lgJmRrB5TA X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=connorkite@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787030013307158500 Add a wrapper to iova-tree to call g_tree_foreach. Provides a means to execute some function on each node of the iova-tree. Reviewed-by: Stefan Hajnoczi Signed-off-by: Connor Kite --- include/qemu/iova-tree.h | 21 +++++++++++++++++++++ util/iova-tree.c | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/include/qemu/iova-tree.h b/include/qemu/iova-tree.h index 14e82a22d5..a1938e36a1 100644 --- a/include/qemu/iova-tree.h +++ b/include/qemu/iova-tree.h @@ -161,4 +161,25 @@ int iova_tree_alloc_map(IOVATree *tree, DMAMap *map, h= waddr iova_begin, */ void iova_tree_destroy(IOVATree *tree); =20 +/** + * iova_tree_foreach: + * + * @tree: the iova tree to traverse + * @func: the function called at every node. A true return value ends trav= ersal. + * Arguments: + * gpointer key: key of current node + * gpointer value: value of current node + * gpointer data: data passed in at g_tree_foreach call + * Return: gboolean + * @data: an argument passed to func + * + * Wrapper to call g_tree_foreach on the underlying g_tree. g_tree_foreach= will + * traverse through every node of the tree, barring an early return. At ea= ch + * node, g_tree_foreach calls func with pointers to the node key, node val= ue, + * and a pointer to data passed in by the caller. + * + * Return: None + */ +void iova_tree_foreach(IOVATree *tree, GTraverseFunc func, gpointer data); + #endif diff --git a/util/iova-tree.c b/util/iova-tree.c index 5b0c95ff15..2239bb6ae1 100644 --- a/util/iova-tree.c +++ b/util/iova-tree.c @@ -303,3 +303,8 @@ int gpa_tree_insert(IOVATree *tree, const DMAMap *map) =20 return IOVA_OK; } + +void iova_tree_foreach(IOVATree *tree, GTraverseFunc func, gpointer data) +{ + g_tree_foreach(tree->tree, func, data); +} --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787029976; cv=none; d=zohomail.com; s=zohoarc; b=iIn0FrNpeCX4ffXrEZf7aoJ7CTX0bru5q9Cw/jlvLSXRil3sV9Vfb1mwOFga0Ik9XGELmqIgcbtQAIjw1C9UIOB0jfCqI2EvtcSwDFwZhOYwqzwlfCWUnbkcqKYjIBJM9rrsDYMyyDHv9KDMaVJKr8A03TOoNHJwE77te6R4Szk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787029976; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9dnSpwb0dn+bdk24pKhPvPsrY1aMYcRsQf+7mWHImvs=; b=WkrYb1jivVXhZF43aa+gu1eTBsTPu4n1/5B6oUXqqvUHhjm91zIG2DUIJg28WRriBo8NvPjnu4Gbc7HjiUEC4nu/BChMvut/oUJ089XOMRW/b45eJQMTHPOCI+YWHz65ecw+ra3JLT5tGhbK8mMg8cbP6/GvXDzukN549YQaKUY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787029976711640.2281938758916; Mon, 17 Aug 2026 22:12:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC7m-00059V-KK; Tue, 18 Aug 2026 01:12:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC7k-00058P-Bg for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:32 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC7i-0003jt-6A for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:31 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-84f77cc7302so1325487b3a.3 for ; Mon, 17 Aug 2026 22:12:28 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029948; x=1787634748; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9dnSpwb0dn+bdk24pKhPvPsrY1aMYcRsQf+7mWHImvs=; b=tBGbsK3FZnmzLcUctHrjolg+INrQT+lEIbMS7rp3K18cI0vwxtdQduzvdbISbf2oz7 ZcfEga+nSnLZ/QHdgseja/feh3o1FsXUCRh9hXtu9af84pHz6cTumsFm8wfoUO/VhX4z Y1qAJyVp3ltZSZH1er/Skrx/epn7Ou7wOCaZ0mzXdNfh/hIIhwMvN/egC5fyNBZqeoKl FjTSA44o9eZXSoZssn445Lgcxi0zGGxRezeOuXPHMdC2WEK6P7FD3S3LdPlHYw8bOKZU hpG4q2P+SGbsWahFE+BMx7jVodQ6XUCvaKbI+/7dArtJEEF4tJURXjbalBVBytIw/NNT XInw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029948; x=1787634748; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9dnSpwb0dn+bdk24pKhPvPsrY1aMYcRsQf+7mWHImvs=; b=VGThKr+slJArgsfIEGcKd3LqrIpb5FIgqZGFC6BUiU0CU1TWI4uUlynHNjSFPDvEYX 3h7ZGZAXzWC4S4jyWzXpkctOB9GZmL/lnpjlNa/vyOWpGQ8fZhtTgnGiUouOpWPGpGEa S76XXrjUYmE2UtBhP+iW8yYEijtAVizg6oxBNWHvCKvzLP5N6iM7vJeyBN+tOXOzQiL6 t9E48sgO8nXq3lXc7J5kv4cqSY7XvcGIsN5cuS21+yIJI9rCprg/5cQcZNONu0jpkf5K xfx9tohAR4IELp5/GEK/SStFrocTRfK/tsiAgEQMfmWVMA7j+7E6xC5SiVAbhSegwgLf 1y2w== X-Gm-Message-State: AOJu0YxGc/U7NMTTVMe59Wh8U8/YcJPozOhF5WCLLtomKHztdAQieN4J 20hCNiwBXx1q2wJZjduC5NWAZmnABO2aoiGG4DcJmXl0Oh3d2qJ6TP0W X-Gm-Gg: AR+sD11PFA+yz+heI7tgcSVk6/R14grAvtjwJz2Veq3ytiUWF+OqQn/Sfum6dqz8Y07 DiEbeXy0O1M2LQ/U6myAOg7v8+q0bhSyHul69BcRHRXsO2IHfC4322vY+URlRWwnbbD4wyjHTM7 Zcnd+UmzWE1O+UERa0sGQE/go4aTaK9A/imv8/MZwJ0XJj/UGW82BiexTmux7O1d5BQcA8nxDGS 3nN+dlhaAybqdfHjp8aDckArn3d4kGGK3TpY0tIDvxpbfEAbYGW2QVKFHgZugTyIiWkw8MTHsxq O2lGQWL1YGoFp7xEX3zE6+i2unEuu7RUW9rhB3W5HCO0djgE6Kko2oea6xirVUUXr3ddTKiZ6ol T/0AUKsumqR+ZvAkkojiETaZRae3Zopamo27c9NyCpfXJifZAc4CYw08mUy09nsJ+aeVwLSdR+7 J3cmroV3CsWQ2piUyBq2M7YLlaRDXcp596pc2vAY73X/aa5W64HR0AHJHJeW2NuMrtDw== X-Received: by 2002:a05:6a00:808d:b0:847:e2c7:59b6 with SMTP id d2e1a72fcca58-84fde1ce5d1mr31913848b3a.11.1787029947566; Mon, 17 Aug 2026 22:12:27 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:18 -0700 Subject: [PATCH RFC v2 03/13] hw/virtio: iova_tree_foreach wrapper MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-3-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=1780; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=vwbYBaMbgDk4wePAOZ4o3ZHnYy3c61j7iZi/xAaHWVE=; b=wt3JAdEQQY0WOd6NAZCMl2xoPft+pWYzPIfGFmmMVVjmM5AQRpS7XXXxcs7BsebWgzN8hEnWj rBA2T+mhFQfAhf0I2K0qofH4RWgVMouKexIY0LXa5EKULkDz7ZcLkhp X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=connorkite@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787029979708158500 Add a wrapper to vhost-iova-tree that calls iova_tree_foreach on the underlying iova_map. This provides a means to execute some function on each node of the tree. Signed-off-by: Connor Kite --- hw/virtio/vhost-iova-tree.c | 15 +++++++++++++++ hw/virtio/vhost-iova-tree.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/hw/virtio/vhost-iova-tree.c b/hw/virtio/vhost-iova-tree.c index fa4147b773..0a9b38b6f3 100644 --- a/hw/virtio/vhost-iova-tree.c +++ b/hw/virtio/vhost-iova-tree.c @@ -189,3 +189,18 @@ void vhost_iova_tree_remove_gpa(VhostIOVATree *iova_tr= ee, DMAMap map) iova_tree_remove(iova_tree->gpa_iova_map, map); iova_tree_remove(iova_tree->iova_map, map); } + + +/** + * Traverse through the iova tree in sorted order + * + * @tree: The VhostIOVATree + * @func: Function called at every node. A true return value ends travers= al + * @data: An argument passed to func + */ +void vhost_iova_tree_foreach(VhostIOVATree *tree, + GTraverseFunc func, + gpointer data) +{ + iova_tree_foreach(tree->iova_map, func, data); +} diff --git a/hw/virtio/vhost-iova-tree.h b/hw/virtio/vhost-iova-tree.h index 08f63b61cd..c84fd652bd 100644 --- a/hw/virtio/vhost-iova-tree.h +++ b/hw/virtio/vhost-iova-tree.h @@ -29,5 +29,7 @@ const DMAMap *vhost_iova_tree_find_gpa(const VhostIOVATre= e *iova_tree, int vhost_iova_tree_map_alloc_gpa(VhostIOVATree *iova_tree, DMAMap *map, hwaddr taddr); void vhost_iova_tree_remove_gpa(VhostIOVATree *iova_tree, DMAMap map); +void vhost_iova_tree_foreach(VhostIOVATree *tree, GTraverseFunc func, + gpointer data); =20 #endif --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787030064; cv=none; d=zohomail.com; s=zohoarc; b=LS9u9IthuAiprfBvjLDRxo0XIP0Xj50qDszQNRmZOwJ9bGOBOn8uXTT8xvq46e0jJvPmTooKRNKzrTcfXEvqECybwlosR3gvVr3vGjHcp1RXjY87YKmtZH7WnCpd30MdTT/ukyzEEJf1HG4UrwY97IHFaMWafGf/sQ6cGa3kOUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787030064; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SplFjpyfUIiEmMlzq9z3b58IchCXTHYO6ngIxMF/AIo=; b=BGYA5hDqtrpTqXakvPrnTkpMZ5UabxcwH+X8lBl5C6w5HuF3xBBR2g3APTfT1xHh1kgSzBiJUtqQf7twhlHeQ7/bJEMTLDjadfgOriyrPa24YBIETgMjsW5Al30jgzJ41q5bXou8eKmazWLF/HRqOo9t2huRGzA5eL9R+UPK4+8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178703006487397.83183248390958; Mon, 17 Aug 2026 22:14:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC7q-0005AS-2V; Tue, 18 Aug 2026 01:12:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC7o-0005A4-70 for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:36 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC7k-0003kc-4p for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:34 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-8486ac3f347so576408b3a.1 for ; Mon, 17 Aug 2026 22:12:31 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029950; x=1787634750; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SplFjpyfUIiEmMlzq9z3b58IchCXTHYO6ngIxMF/AIo=; b=mSC4cpH5+jIFd1KpNZb7A9CEA/tZ0WF3De8+XO5uD4Z/L12BKRzYpKDiqnm66NWlQa 7ghYh+oy8qhw3X9V3Bi3ije3osu5DaUgq2bj0vX6txyr7V58G+2Z7VoF5YexJ74uMKxA NNrcviEV38oAkX9m4Xiic1q9vytoC7UbChrAfVI3ZSi3ZyCRW5KgoTCND2du54wuGbdR y5YhI1BIL6mDypCP+BZtEfTrzWL9SXh+Ajnv4oi0HMJTRRFhNY0wqrXnTddaOLU/6Tex ZsqdtHH00Mmt8ABfqAxpVwfFsDqw52L/wA8y9/22/zeDM0UMlpV3Tm7FnsEIhZqACfL8 4J/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029950; x=1787634750; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=SplFjpyfUIiEmMlzq9z3b58IchCXTHYO6ngIxMF/AIo=; b=dk2PgeOztSXNi/gSN5cmf7oZuaPxwpkscnfci52N3tLviIXy+LakxggRt8UOae3Yds +ybbHInfIo89E9njPsRmYIKHROb5uTBPNseZ74SfvfF3Ma7fnotJfcdZW6zXgnyT86In 2Jl17xac0Etjcvln+VkePZMYCVqsUOgmMpAZBpp/l3fb7fsVeUmym8FIBFqucF+RwX3A /Hk4D8ZgBEImdw3nuJrt1a8NIzE3FHIrJQN5nXqD2wFH/Eb2DztPw3i/Hdv1V/Uuv08l 6F/xY2cmFaZ8aMoRKYBzmKg+Zpwz1u/JWHeJJrwN6ppqBvBFQeAC3cgPNjbzqe8lyts0 qMpQ== X-Gm-Message-State: AOJu0YwQGiUZiJP7PqCaWyQelwZ3Zk2n/1aMZn6pdgjbzeDpZZGor0Ew zxAbvC6t0RrQ23DkRwTcXKTagka3uHmow4XUwngIBjBlI78iLwe+vuXN X-Gm-Gg: AR+sD11oMTw0wsfZGo5ZKPOdPnNO82JygSC7Ktulm/C681F5pVUXBLvkR0RpiVszYiL VBm4O/pMA69CdLCTnrBC/8WcaUb4Kih2MUG0s9FsWqtxlT6Wnsu2UCLHRzzjohB2wz7e2kA/dRu xP0MmtY/VCdXpCre4ub/71v9LWV1jT4Z6bMH2akBYTgTyRb4pC2UdzgH0WCo6zWnIm1rLr7cSeD 2/kvL1bF5rIboZLPI7//yyXMlQ95yw3eIwo8ce/sbkVRqGtAKT23GE/oqsOgStDTI+ERjSTb2Tc LodtqXK5IFa1QpBAMn0UoX4dqpzc+w3P7oM8bmHxSuVL6AmkNUD6fJtR55TR0iq87ra5+XFm5xp vJJ0lHR+PJbfgp4yveITeLMn4BXMRg6mx9/K9XpsZqXYfQ26Akz7OBo9Z6gt+wEoX5OMhx9+YuB NtUb+dN93CE9E1MGZDtM+zw8ebYhrQZy1/PWINvNFemvYwAbcGNYRiY1pQsJCtGKSYV2lxa7sX7 Mqe X-Received: by 2002:a05:6a21:3a96:b0:3bf:bbad:500e with SMTP id adf61e73a8af0-3cce24fc3bamr3353906637.5.1787029950143; Mon, 17 Aug 2026 22:12:30 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:19 -0700 Subject: [PATCH RFC v2 04/13] hw/virtio/vhost-shadow-virtqueue: used callback MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-4-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=2434; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=HH0SlSvH+q+3nGir6vgptvnX9Dx9KLnOIY0C19/JvF0=; b=4pu5D0cnp4xmAOKz3RDWU/Xos+GwI2mPfbnmu6yDH3gb9L0MxXGupZxCloz5NW3k23uRSdoVi DOmLtpxDokJB5SnhdWlEtuB9sI0MvC9+Jv6t5oUtBm8+S/MOO015cy3 X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=connorkite@gmail.com; helo=mail-pf1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787030065599158500 Adds a callback to shadow virtqueues in order to enable non-default processing of used vring elements from the device. Signed-off-by: Connor Kite --- hw/virtio/vhost-shadow-virtqueue.c | 9 +++++++++ hw/virtio/vhost-shadow-virtqueue.h | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index c8831d52be..496e7e58a3 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -675,6 +675,15 @@ static void vhost_svq_flush(VhostShadowVirtqueue *svq, break; } =20 + if (svq->ops && svq->ops->used_callback) { + int r =3D svq->ops->used_callback(svq, elem, svq->ops_opaq= ue); + + if (r < 0) { + /* VQ or handler is broken. Do not set guest notifier = */ + return; + } + } + if (unlikely(i >=3D svq->vring.num)) { qemu_log_mask(LOG_GUEST_ERROR, "More than %u used buffers obtained in a %u size = SVQ", diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-vi= rtqueue.h index ec16a1e838..fd68319fb7 100644 --- a/hw/virtio/vhost-shadow-virtqueue.h +++ b/hw/virtio/vhost-shadow-virtqueue.h @@ -56,8 +56,24 @@ typedef int (*VirtQueueAvailCallback)(VhostShadowVirtque= ue *svq, VirtQueueElement *elem, void *vq_callback_opaque); =20 +/** + * Callback to handle a used buffer + * + * @svq: Shadow virtqueue + * @elem: Element placed in the queue by the device + * @vq_callback_opaque: Used to pass arguments to callback + * + * Returns 0 if the vq is running as expected. Returns a negative errno on + * failure. The callback should not add used elements to the vq shadowed + * by the svq as that is done separately after the callback returns. + */ +typedef int (*VirtQueueUsedCallback)(VhostShadowVirtqueue *svq, + VirtQueueElement *elem, + void *vq_callback_opaque); + typedef struct VhostShadowVirtqueueOps { VirtQueueAvailCallback avail_handler; + VirtQueueUsedCallback used_callback; } VhostShadowVirtqueueOps; =20 /* Shadow virtqueue to relay notifications */ --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787030069; cv=none; d=zohomail.com; s=zohoarc; b=JbBOQ8MYW0kb3ur/EC50UjNeUX7ZvKfw1zte/KXxv7uwz+tBCp2KUxgRnYhdGnpBA43sWTjfAzlBrZWbrxLYdRXG89ns6v6TE1xEbeT8EF5r9o0ujrFRsMq5QtIFaSmAp2S4nzhJda5PYmfgT3mWUKMwqGKlBw5xZie5sHzoXoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787030069; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5iSPjR4OWYgSwQ/ju8j1WMdGvtILP0xKe6fEY1lq/RU=; b=iLHtKvytXd3fAQzBbkZswNVKvbV/vlfYGTbT40wwl1/g+KRWQkvi7gJXIuEGwxh97BFW0YHIkhwoNlA92r+IuGLzbntVJo5asuQnqLNUWH6TK24GSGN3G+GeK4WZviR3U+Q+aRZgHA89CDM9dLpHFdAhSsOnTqEZD1o2GesbAjE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787030069688240.96043937765683; Mon, 17 Aug 2026 22:14:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC7r-0005BI-8G; Tue, 18 Aug 2026 01:12:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC7q-0005Az-7b for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:38 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC7n-0003lD-F9 for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:37 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-84862b0d5f8so3336564b3a.3 for ; Mon, 17 Aug 2026 22:12:33 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029953; x=1787634753; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5iSPjR4OWYgSwQ/ju8j1WMdGvtILP0xKe6fEY1lq/RU=; b=eSANZ5qpn2H5yPHs5u61RjqhCrn8jYQjKhFCxxK+7Zim/Qz7Ibv5ANuSAzskZakywz dDsv8T1lFBIfvlHqMpUaqEQBACAB8n8/yzIABadhaCGBj2fU9T70liCVQZiZR1OGyFhH FEEkKct2gqA6sB4TYrfX3IeuWbiRIbMqJq8AcUw2mOwDezG9e2SceNPO5VzQqEVjqd9/ Tr/9+6m8lUrTm5SwINpkQjJRUVy8RUpDbPXVSktXUevJ91qKG3Qi00MbHHqAHipnJ7fK TYcCrjv1qYTEry/URTeqezrGUhw9zskgBpD21bj4+aU7OVS4uXyi9VL0o1rYwDSxh21e zuNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029953; x=1787634753; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5iSPjR4OWYgSwQ/ju8j1WMdGvtILP0xKe6fEY1lq/RU=; b=d5wtgU7JBJs6K1LpQI8cR6K33A02FYXKgfGYGxVVwmJLTyWG4IWQBpuIhx8pI75tVB znZt1UajkhUzPHxmE2yJMpE92q8e5LAn7SqHNdApKiOEBsqvwE0ulPejaVGFHvSfK5ir RlMDs+A59RIOCbfhvxs5gqQFheFPVOxSfolFvtJJR6euX06pNnqlGBvJPdIsH1EWC1nQ q6Z3nLNCCzOyovWrQQ+it+D4SAVoiRGEcdWV/trcVSmERvXKei3ZJ9eP055BxeseOyxA 6Gs3nxcq28SLNJsKFYi0byt2vY1SXi/5tI4jp5AgNzF/4SDmdu+BNV/NKSwWnSQP1BLw Hy6g== X-Gm-Message-State: AOJu0YwIocIq0E79xr2Qoia6ObP7a4x03WCfiSvQ9va8lyj1YsO26OQL GxZyXhBHT7I9jft32K/v2eVfRJgndF6tFU4gDbiWpYjL5+KS/r85bFPV X-Gm-Gg: AR+sD12BGxChGzUc8MDi7x3gToI9nZtLkdiy1PzkoLoHxY+DdhUcPv9aYItd70/b8nL rypGoAOgO45v29Pr6tlTcdYS6ViHIr7uD4sOqbUIk5CnXGNg/UoGkd2JgSNBj1ACPEy22Q5wyvp S6e5V6gpUOhYm6QwfXa0ouRKZMFS4rOUwZsll7Wg8/LzxP1ekoOTKf0U7cHPt8spG03jV7S+K5o uSXAOzYaLQre3aIbRfhcqb5iD58t9+bH0ofgdF3o8ZdiOM1Re5e/5fGeRwigNF2J0jNkh93/du9 RzlfOXCRJYO8rfl7LVsFuSW51WnnvMEv6ZPqEobqwA5kPUx5HmEWnlbl7bFwVQ8Htal9driviTv VICcgNqmNB6aKoM+65XVVmtswykZyJoJIVzJzTG72LRv3zH7ob6WgIZigWDQRaz9Ips0nybCNTh zepLFXvyzpzZ3LCgWZMwMQvb3LbGDNERObMy4mNEa0phpbj9flJ1w3auvGFMzsmP2gOg== X-Received: by 2002:a05:6a00:9508:b0:84a:29a7:f3b1 with SMTP id d2e1a72fcca58-84fde12721fmr25945799b3a.16.1787029952715; Mon, 17 Aug 2026 22:12:32 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:20 -0700 Subject: [PATCH RFC v2 05/13] hw/virtio/vhost-shadow-virtqueue: specified vring placement MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-5-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=6847; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=zMLe3YYRkSQNcCO8gpXX8eru8I8FhRevRD5BzLCf9h0=; b=89rGEsgnDJRxANQcPGgrkm/+un/OiboC53ebypLTch0HhTgwjPLd90rOF6xBlNmgXEPieR5tO M3II78hh4MbBjxsLiRFIaMsN7mmmp0N/KQLgNRDJDSzS8Vf8oaBycvV X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=connorkite@gmail.com; helo=mail-pf1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787030071532158500 By default svq vrings are placed in an anonymous memory map. As svqs will be leveraged to enable memory isolation in vhost-user, it is useful to be able to place the vrings in a shared isolation memory region. Adds the option to specify vring placement by providing a vring base address before starting the svq. Signed-off-by: Connor Kite --- hw/virtio/vhost-shadow-virtqueue.c | 69 ++++++++++++++++++++++++++++++++--= ---- hw/virtio/vhost-shadow-virtqueue.h | 8 ++++- 2 files changed, 66 insertions(+), 11 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index 496e7e58a3..f54a61439a 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -812,6 +812,13 @@ size_t vhost_svq_device_area_size(const VhostShadowVir= tqueue *svq) return ROUND_UP(used_size, qemu_real_host_page_size()); } =20 +size_t vhost_svq_vring_total_size(VirtIODevice *vdev, VirtQueue *vq) +{ + VhostShadowVirtqueue svq; + svq.vring.num =3D virtio_queue_get_num(vdev, virtio_get_queue_index(vq= )); + return vhost_svq_driver_area_size(&svq) + vhost_svq_device_area_size(&= svq); +} + /** * Set a new file descriptor for the guest to kick the SVQ and notify for = avail * @@ -842,6 +849,19 @@ void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *s= vq, int svq_kick_fd) } } =20 +/** + * Set vring base address if using fixed locations + * + * @svq: Shadow Virtqueue + * @addr: Points to new base address + */ + + void vhost_svq_set_base_addr(VhostShadowVirtqueue *svq, void *addr) + { + svq->base_addr =3D addr; + } + + /** * Start the shadow virtqueue operation. * @@ -849,8 +869,10 @@ void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *s= vq, int svq_kick_fd) * @vdev: VirtIO device * @vq: Virtqueue to shadow * @iova_tree: Tree to perform descriptors translations + * + * Return 0 on success, -errno on failure */ -void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev, +int vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev, VirtQueue *vq, VhostIOVATree *iova_tree) { size_t desc_size; @@ -868,14 +890,27 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtI= ODevice *vdev, =20 svq->vring.num =3D virtio_queue_get_num(vdev, virtio_get_queue_index(v= q)); svq->num_free =3D svq->vring.num; - svq->vring.desc =3D mmap(NULL, vhost_svq_driver_area_size(svq), - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYM= OUS, - -1, 0); desc_size =3D sizeof(vring_desc_t) * svq->vring.num; - svq->vring.avail =3D (void *)((char *)svq->vring.desc + desc_size); - svq->vring.used =3D mmap(NULL, vhost_svq_device_area_size(svq), - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYM= OUS, - -1, 0); + if (svq->base_addr =3D=3D NULL) { + svq->vring.desc =3D mmap(NULL, vhost_svq_driver_area_size(svq), + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONY= MOUS, + -1, 0); + svq->vring.avail =3D (void *)((char *)svq->vring.desc + desc_size); + svq->vring.used =3D mmap(NULL, vhost_svq_device_area_size(svq), + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONY= MOUS, + -1, 0); + } else { + svq->vring.desc =3D (void *)svq->base_addr; + svq->vring.avail =3D (void *)((char *)svq->vring.desc + desc_size); + svq->vring.used =3D (void *)((char *)svq->base_addr + + vhost_svq_driver_area_size(svq)); + + if ((uint64_t)svq->vring.used + vhost_svq_device_area_size(svq) - = 1 < + (uint64_t)svq->vring.desc) { + error_report("Invalid shadow vring location"); + return -ENOMEM; + } + } svq->desc_state =3D g_new0(SVQDescState, svq->vring.num); if (virtio_vdev_has_feature(svq->vdev, VIRTIO_F_IN_ORDER)) { svq->batch_last.id =3D VIRTIO_RING_NOT_IN_BATCH; @@ -884,6 +919,8 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIOD= evice *vdev, svq->desc_state[i].next =3D i + 1; } } + + return 0; } =20 /** @@ -920,8 +957,19 @@ void vhost_svq_stop(VhostShadowVirtqueue *svq) } svq->vq =3D NULL; g_free(svq->desc_state); - munmap(svq->vring.desc, vhost_svq_driver_area_size(svq)); - munmap(svq->vring.used, vhost_svq_device_area_size(svq)); + + if (!svq->base_addr) { + munmap(svq->vring.desc, vhost_svq_driver_area_size(svq)); + munmap(svq->vring.used, vhost_svq_device_area_size(svq)); + } else{ + if (svq->vring.desc) { + memset(svq->vring.desc, 0, vhost_svq_driver_area_size(svq)); + } + if (svq->vring.used) { + memset(svq->vring.used, 0, vhost_svq_device_area_size(svq)); + } + } + event_notifier_set_handler(&svq->hdev_call, NULL); } =20 @@ -940,6 +988,7 @@ VhostShadowVirtqueue *vhost_svq_new(const VhostShadowVi= rtqueueOps *ops, event_notifier_init_fd(&svq->svq_kick, VHOST_FILE_UNBIND); svq->ops =3D ops; svq->ops_opaque =3D ops_opaque; + svq->base_addr =3D NULL; return svq; } =20 diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-vi= rtqueue.h index fd68319fb7..1e0cc9e5e4 100644 --- a/hw/virtio/vhost-shadow-virtqueue.h +++ b/hw/virtio/vhost-shadow-virtqueue.h @@ -150,6 +150,9 @@ typedef struct VhostShadowVirtqueue { =20 /* Size of SVQ vring free descriptors */ uint16_t num_free; + + /* Location assigned to vrings if not in default anon memory map */ + void *base_addr; } VhostShadowVirtqueue; =20 bool vhost_svq_valid_features(uint64_t features, Error **errp); @@ -169,8 +172,9 @@ void vhost_svq_get_vring_addr(const VhostShadowVirtqueu= e *svq, struct vhost_vring_addr *addr); size_t vhost_svq_driver_area_size(const VhostShadowVirtqueue *svq); size_t vhost_svq_device_area_size(const VhostShadowVirtqueue *svq); +size_t vhost_svq_vring_total_size(VirtIODevice *vdev, VirtQueue *vq); =20 -void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev, +int vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev, VirtQueue *vq, VhostIOVATree *iova_tree); void vhost_svq_stop(VhostShadowVirtqueue *svq); =20 @@ -178,6 +182,8 @@ VhostShadowVirtqueue *vhost_svq_new(const VhostShadowVi= rtqueueOps *ops, void *ops_opaque); =20 void vhost_svq_free(gpointer vq); +void vhost_svq_set_base_addr(VhostShadowVirtqueue *svq, void *addr); + G_DEFINE_AUTOPTR_CLEANUP_FUNC(VhostShadowVirtqueue, vhost_svq_free); =20 #endif --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787029980; cv=none; d=zohomail.com; s=zohoarc; b=crR9aYSg/Rjk9DM55NHAuIGgnfsbDzS+47I6teM1y1R50uAc3Q4y+TNlxeDjKU5HTU5+CuEEMShIZBNsVEVlLxex35VWgNAE7XFdlaVC1A8kCXBBVrZ5dI7W5BREhujTERDPbFr+mlEdr5lRl7bXoVjpKLzFSVDrm0EHCGtpEog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787029980; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uI/bGUOPiZtgA7sRPmLikAJa60Bs+xkxXw4S9cHkhMQ=; b=CkUK6I0opAmUjso4r7RWJn1MmPt3AWhYWmTNX/yJaSNnfwGlIPSL1TwPQzi90eoVL7LcYGP3BAdbZMG+bH26i0gJY+WOh9B+TS18pzSQ50QHIgQWk1JOZcDPwqOxy7aHsab4Ud/I+/P49fnWfQUHRwdUNzUc1JlqcXgw4QRkdYw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787029980354907.4696176401462; Mon, 17 Aug 2026 22:13:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC7t-0005Cl-PS; Tue, 18 Aug 2026 01:12:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC7s-0005BK-2l for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:40 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC7p-0003lp-Au for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:39 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-84830c774a0so3667107b3a.1 for ; Mon, 17 Aug 2026 22:12:36 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029955; x=1787634755; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=uI/bGUOPiZtgA7sRPmLikAJa60Bs+xkxXw4S9cHkhMQ=; b=CzDQY8sx/55smXoq5bI43yoaVEq+z+nfTZPvrNVdnbRDgL0KX8lVaeHQE49vUvl0h+ SsnIFE8a14VW8PZLBLWtbxnT1z3m5RXEead2j/HsWCu2kU7awFclqyvoT5teJjoi+yDe wbUIsxnhTprqjycwQiMJMadvynHfCfxemJ51etBnEGMBZUK3dMa9LaS7hQHV9Woeij0N O2VsXQibzp5qqlzjR/cZMJjVGYke8PhsMq5T3NixZfUDaJzksLRwzm2MjbMkd4BodnWL ZqJK0g6cHK2/ewZlX03d2vVZR6frOPu3mYUg92mRibzEP2SdWgPDi2uH6hYBeJcWmnQU pQrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029955; x=1787634755; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=uI/bGUOPiZtgA7sRPmLikAJa60Bs+xkxXw4S9cHkhMQ=; b=jGT5HsK1GmLrr4pMSR/FPQQBgP0ZXKYItYBkNGv+aUG3kZkAQagJh250F5CN7py9En QkwYqrXm1IghfoVXbhIANSLlU3/GWyqEIaMNnleEgCL8KshFCxwbeWF7AQLwRggo5BlH i+asbsuAtBTLzBycmKYwR4hawHsOFKkwuGXnSpsOjJj6NpDNFkDQnovy4p1eP4sYdmI0 wh8Qg0T2dl7G+ZSEHXBNYLLQZ76dcT7fLyiCoHHEmI1PJL6flOoZN2FLZqU+1AeD6cze cL38Ldc/2zyNfbJs+HcC/KTATD9HU89aVSS3PThdqhp9E/OvaduAgu1JZOuUoccc1TiQ CvxQ== X-Gm-Message-State: AOJu0YxYhWFSmIhMwhLn0Ll9FC7D70lX90HCkBHMkexxaLU1cQYtHJQE NqLTfuEXqfWj0NnB1RegTC2PGHMl9RIPJ+TefvmmVQZPUgMBb4RhjPKE X-Gm-Gg: AR+sD100+QKVccP4h6FWPqnLx3B8boMzL0RnePsuAg0JAPmXodsfOFsHDtrze0uAcmt vwQlZLNJ50QD5yNccExo48vuGizxq++Za/NVJ2LSYQyvjQPdfZV7r/7Oz28qeM2chlq+hm2t9VD pe3O8Yvzwg2hjbn8L9K5N9v6swxCfDF9oQw2SptiJgkDtu0272sUDitkTGXWqwdTspYOgrV/s5o emuO8OgI7alfISKLtZ9JonULgannRaLOc9vV3XclyGaH/lhbS16+OHjwvtRi4Bu1ux8bvzwmZAG E1H0JHKT2SsbXRrFZiAHdVMygffVIO2SO2yrlNfGti7vHM2pI50M/c+L8PCx6BeKSvugMrF3lHe HtqyU7A0/fvL1qGBjUfFsP0RRmAe6yOmeb9bXKTwtdo1EgOi6o9Cxue+uKZ/Oy5NBYhMzQKpkVs atpJ/XKhUsDkQ/IyWh6Mpnm/EwpMqo3WHzcJcq4x1hV7Nm2rGLwmXxIqjLHLuq5kbiMFIAIpWn4 +bM X-Received: by 2002:a05:6a00:4193:b0:847:9315:fb8b with SMTP id d2e1a72fcca58-84fde1500e7mr32736377b3a.6.1787029955327; Mon, 17 Aug 2026 22:12:35 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:21 -0700 Subject: [PATCH RFC v2 06/13] vhost-user: add memory_isolation to VhostUserState MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-6-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=12563; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=CgCmodYY3hh2gpX/jaQuylcKS6MagmlBraNfgqmJ4X0=; b=wHHi3W9jMtEUW9xqnPHbGay0kwhnFDuOGxjd8uOeLr1jwuCApSV29JYjB+ly1riYUfkFEpDoC yXUW9FgBtIPAqjZ8C1cqJ7+5I4PQlz2AFXV6vjYBMLvMxGgYbRmx1ss X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=connorkite@gmail.com; helo=mail-pf1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787029981131158500 Add a memory_isolation bool to the VhostUserState struct. This bool is set within vhost_user_init(), which takes a memory_isolation bool as an argument. Refactor all call locations of vhost_user_init to include the new argument. Signed-off-by: Connor Kite --- backends/cryptodev-vhost-user.c | 2 +- backends/vhost-user.c | 4 ++-- hw/block/vhost-user-blk.c | 3 ++- hw/display/vhost-user-gpu.c | 3 ++- hw/scsi/vhost-user-scsi.c | 3 ++- hw/virtio/vhost-stub.c | 3 ++- hw/virtio/vhost-user-base.c | 3 ++- hw/virtio/vhost-user-fs.c | 3 ++- hw/virtio/vhost-user-scmi.c | 3 ++- hw/virtio/vhost-user-vsock.c | 3 ++- hw/virtio/vhost-user.c | 5 ++++- include/hw/virtio/vhost-user.h | 6 +++++- include/system/vhost-user-backend.h | 3 ++- net/passt.c | 14 ++++++++++---- net/vhost-user.c | 8 +++++--- 15 files changed, 45 insertions(+), 21 deletions(-) diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-use= r.c index cc478d9902..fa1f9b76d3 100644 --- a/backends/cryptodev-vhost-user.c +++ b/backends/cryptodev-vhost-user.c @@ -213,7 +213,7 @@ static void cryptodev_vhost_user_init( } } =20 - if (!vhost_user_init(&s->vhost_user, &s->chr, errp)) { + if (!vhost_user_init(&s->vhost_user, &s->chr, false, errp)) { return; } =20 diff --git a/backends/vhost-user.c b/backends/vhost-user.c index 380d825023..470eba1775 100644 --- a/backends/vhost-user.c +++ b/backends/vhost-user.c @@ -22,13 +22,13 @@ =20 int vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev, - unsigned nvqs, Error **errp) + unsigned nvqs, bool memory_isolation, Error **= errp) { int ret; =20 assert(!b->vdev && vdev); =20 - if (!vhost_user_init(&b->vhost_user, &b->chr, errp)) { + if (!vhost_user_init(&b->vhost_user, &b->chr, memory_isolation, errp))= { return -1; } =20 diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 2e5b3ae1b1..4640d7da04 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -505,7 +505,8 @@ static void vhost_user_blk_device_realize(DeviceState *= dev, Error **errp) return; } =20 - if (!vhost_user_init(&s->vhost_user, &s->chardev, errp)) { + if (!vhost_user_init(&s->vhost_user, &s->chardev, + false, errp)) { return; } =20 diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index cd684d6363..6655585b43 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -663,7 +663,8 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error = **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(g); =20 vhost_dev_set_config_notifier(&g->vhost->dev, &config_ops); - if (vhost_user_backend_dev_init(g->vhost, vdev, 2, errp) < 0) { + if (vhost_user_backend_dev_init(g->vhost, vdev, 2, false, + errp) < 0) { return; } =20 diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 5070178dc2..05bc788304 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -276,7 +276,8 @@ static void vhost_user_scsi_realize(DeviceState *dev, E= rror **errp) return; } =20 - if (!vhost_user_init(&s->vhost_user, &vs->conf.chardev, errp)) { + if (!vhost_user_init(&s->vhost_user, &vs->conf.chardev, + false, errp)) { goto free_virtio; } =20 diff --git a/hw/virtio/vhost-stub.c b/hw/virtio/vhost-stub.c index 7321dc9210..d1e1075a31 100644 --- a/hw/virtio/vhost-stub.c +++ b/hw/virtio/vhost-stub.c @@ -12,7 +12,8 @@ unsigned int vhost_get_free_memslots(void) return UINT_MAX; } =20 -bool vhost_user_init(VhostUserState *user, CharFrontend *chr, Error **errp) +bool vhost_user_init(VhostUserState *user, CharFrontend *chr, + bool memory_isolation, Error **errp) { return false; } diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 90bd2903db..c10851492a 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -317,7 +317,8 @@ static void vub_device_realize(DeviceState *dev, Error = **errp) vub->vhost_user.supports_config =3D true; } =20 - if (!vhost_user_init(&vub->vhost_user, &vub->chardev, errp)) { + if (!vhost_user_init(&vub->vhost_user, &vub->chardev, + false, errp)) { return; } =20 diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 209993918a..34ccbdec10 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -238,7 +238,8 @@ static void vuf_device_realize(DeviceState *dev, Error = **errp) return; } =20 - if (!vhost_user_init(&fs->vhost_user, &fs->conf.chardev, errp)) { + if (!vhost_user_init(&fs->vhost_user, &fs->conf.chardev, + false, errp)) { return; } =20 diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c index 02dc088ea9..bd0ec64daf 100644 --- a/hw/virtio/vhost-user-scmi.c +++ b/hw/virtio/vhost-user-scmi.c @@ -244,7 +244,8 @@ static void vu_scmi_device_realize(DeviceState *dev, Er= ror **errp) =20 vdev->host_features |=3D (1ULL << VIRTIO_SCMI_F_P2A_CHANNELS); =20 - if (!vhost_user_init(&scmi->vhost_user, &scmi->chardev, errp)) { + if (!vhost_user_init(&scmi->vhost_user, &scmi->chardev, + false, errp)) { return; } =20 diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index c2cd376e73..44a90c76ad 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -106,7 +106,8 @@ static void vuv_device_realize(DeviceState *dev, Error = **errp) return; } =20 - if (!vhost_user_init(&vsock->vhost_user, &vsock->conf.chardev, errp)) { + if (!vhost_user_init(&vsock->vhost_user, &vsock->conf.chardev, + false, errp)) { return; } =20 diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 2881cec72d..1c003e4d9d 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -3121,13 +3121,16 @@ static void vhost_user_state_destroy(gpointer data) vhost_user_host_notifier_remove(n, NULL, true); } =20 -bool vhost_user_init(VhostUserState *user, CharFrontend *chr, Error **errp) +bool vhost_user_init(VhostUserState *user, CharFrontend *chr, + bool memory_isolation, + Error **errp) { if (user->chr) { error_setg(errp, "Cannot initialize vhost-user state"); return false; } user->chr =3D chr; + user->memory_isolation =3D memory_isolation; user->memory_slots =3D 0; user->notifiers =3D g_ptr_array_new_full(VIRTIO_QUEUE_MAX / 4, &vhost_user_state_destroy); diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 06c360af18..0eca9b1668 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -66,6 +66,7 @@ typedef struct VhostUserHostNotifier { * @chr: the character backend for the socket * @notifiers: GPtrArray of @VhostUserHostnotifier * @memory_slots: + * @memory_isolation: determines whether data is shared or copied */ typedef struct VhostUserState { CharFrontend *chr; @@ -73,12 +74,14 @@ typedef struct VhostUserState { int memory_slots; bool supports_config; bool supports_inflight_migration; + bool memory_isolation; } VhostUserState; =20 /** * vhost_user_init() - initialise shared vhost_user state * @user: allocated area for storing shared state * @chr: the chardev for the vhost socket + * @memory_isolation: restrict direct access to guest memory from back-end * @errp: error handle * * User can either directly g_new() space for the state or embed @@ -87,7 +90,8 @@ typedef struct VhostUserState { * * Return: true on success, false on error while setting errp. */ -bool vhost_user_init(VhostUserState *user, CharFrontend *chr, Error **errp= ); +bool vhost_user_init(VhostUserState *user, CharFrontend *chr, + bool memory_isolation, Error **errp); =20 /** * vhost_user_cleanup() - cleanup state diff --git a/include/system/vhost-user-backend.h b/include/system/vhost-use= r-backend.h index 3184c8e799..c23f689182 100644 --- a/include/system/vhost-user-backend.h +++ b/include/system/vhost-user-backend.h @@ -41,7 +41,8 @@ struct VhostUserBackend { }; =20 int vhost_user_backend_dev_init(VhostUserBackend *b, VirtIODevice *vdev, - unsigned nvqs, Error **errp); + unsigned nvqs, bool memory_isolation, + Error **errp); void vhost_user_backend_start(VhostUserBackend *b); int vhost_user_backend_stop(VhostUserBackend *b); =20 diff --git a/net/passt.c b/net/passt.c index 45440c399b..35ec6ad6de 100644 --- a/net/passt.c +++ b/net/passt.c @@ -433,7 +433,9 @@ static void passt_vhost_user_event(void *opaque, QEMUCh= rEvent event) } } =20 -static int net_passt_vhost_user_init(NetPasstState *s, Error **errp) +static int net_passt_vhost_user_init(NetPasstState *s, + bool memory_isolation, + Error **errp) { Chardev *chr; int sv[2]; @@ -457,7 +459,8 @@ static int net_passt_vhost_user_init(NetPasstState *s, = Error **errp) =20 s->vhost_user =3D g_new0(struct VhostUserState, 1); if (!qemu_chr_fe_init(&s->vhost_chr, chr, errp) || - !vhost_user_init(s->vhost_user, &s->vhost_chr, errp)) { + !vhost_user_init(s->vhost_user, &s->vhost_chr, memory_isolation, + errp)) { goto err; } =20 @@ -487,7 +490,8 @@ err: return -1; } #else -static int net_passt_vhost_user_init(NetPasstState *s, Error **errp) +static int net_passt_vhost_user_init(NetPasstState *s, bool memory_isolati= on, + Error **errp) { error_setg(errp, "vhost-user support has not been built"); =20 @@ -735,7 +739,9 @@ int net_init_passt(const Netdev *netdev, const char *na= me, s->pidfile =3D pidfile; =20 if (netdev->u.passt.has_vhost_user && netdev->u.passt.vhost_user) { - if (net_passt_vhost_user_init(s, errp) =3D=3D -1) { + bool memory_isolation =3D false; + + if (net_passt_vhost_user_init(s, memory_isolation, errp) =3D=3D -1= ) { qemu_del_net_client(nc); return -1; } diff --git a/net/vhost-user.c b/net/vhost-user.c index 2d0fc49b4d..b6ee9ed297 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -370,7 +370,7 @@ static void net_vhost_user_event(void *opaque, QEMUChrE= vent event) =20 static int net_vhost_user_init(NetClientState *peer, const char *device, const char *name, Chardev *chr, - int queues) + int queues, bool memory_isolation) { Error *err =3D NULL; NetClientState *nc, *nc0 =3D NULL; @@ -390,7 +390,7 @@ static int net_vhost_user_init(NetClientState *peer, co= nst char *device, nc0 =3D nc; s =3D DO_UPCAST(NetVhostUserState, nc, nc); if (!qemu_chr_fe_init(&s->chr, chr, &err) || - !vhost_user_init(user, &s->chr, &err)) { + !vhost_user_init(user, &s->chr, memory_isolation, &err)) { error_report_err(err); goto err; } @@ -459,6 +459,7 @@ int net_init_vhost_user(const Netdev *netdev, const cha= r *name, int queues; const NetdevVhostUserOptions *vhost_user_opts; Chardev *chr; + bool memory_isolation =3D false; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER); vhost_user_opts =3D &netdev->u.vhost_user; @@ -476,5 +477,6 @@ int net_init_vhost_user(const Netdev *netdev, const cha= r *name, return -1; } =20 - return net_vhost_user_init(peer, "vhost_user", name, chr, queues); + return net_vhost_user_init(peer, "vhost_user", name, chr, queues, + memory_isolation); } --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787030074; cv=none; d=zohomail.com; s=zohoarc; b=lPnKyno0jg5Cb09kT5eN7c69tyErg6U90yM77p3cb3+8LYaP0hjd16XCLMn8NNSLglr9ULC6sYVM533kS84QhuQCFTG+2opiaajnBQvDtoW9DUsFt+dAiLOKy9+6OPRn4EJe+viswl7YciwcxOE6VPE9xDLfnouk2X/tqHheSGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787030074; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8wuYe3aPv+YJ4aJ8Ua2kMF85cw3TlH8w6CZl7jDCufE=; b=SpGdQkF4/Y9QQcHIzMfZXprCuuenBwUDGgQtQGvF3EEqgGv/jfboG0cKjI/+YxCTZ0j6T1ikbWIGkn/ECUOjpBFRuj13GVwEcGc4ftczTngX0ddnwZRf2Lj3IHpzGSzL7atTNKSJFbqrwxFwpa46fUGDygK2ZPd/QNsqWIHv9GE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787030074270683.4338242223185; Mon, 17 Aug 2026 22:14:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC7v-0005DG-3I; Tue, 18 Aug 2026 01:12:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC7t-0005CQ-H9 for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:41 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC7r-0003mY-In for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:41 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-84e3007a2b7so3523185b3a.0 for ; Mon, 17 Aug 2026 22:12:39 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029958; x=1787634758; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=8wuYe3aPv+YJ4aJ8Ua2kMF85cw3TlH8w6CZl7jDCufE=; b=MPTbaOyz7Ro1op+PYtuiY/Qie17UT86ym+AFqn5i+bnd7VjrCN0blojku81y5ySpxR XE43ndOW1lBN0kRwS/kBlGuYBtqbW5EzYmHTIrdYiRfHCZrUT2cpMQ0TRU8n6ZsC4SD4 VD8/Hn0ZuKc9OePeV7kXHtDPIDJLII81ufNYdbnBVo3sMrkdFVY7Xlw1MXolZSa4YsuJ lF0TbWWOO5HwC/9NMAirpKGnpJB0+N84o1h9fTdY2bUsDhE0DpFQdB1K+v9kZwS88lAi ej3tPTcvIUjQ/ndvA+9gv/AmNQpzXOHNNAqSn0jwpWOrStbsjbOLtMgmA5bNwuzTPt9n 7xJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029958; x=1787634758; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=8wuYe3aPv+YJ4aJ8Ua2kMF85cw3TlH8w6CZl7jDCufE=; b=KVrRWz9pUstlyiFBkJYOTB44FchXtRBAvvWAgVUx2sc0B3FM8I/Zm1FVmD7/TH0w0O 8uYMNhPldcTkhs3+dd5HH8LH93cnZn+HB53xAeG2CE9iWA2nqP6I7iACU3Z+jCNAS6YC DVIe5GkIIHWzZtI+pdCYXNKkvT34h4wMZ3yiBvGZnQzoXZJSMydEmmil7rQ+gQ0Ud8nQ QMPcONepSMvpdmeZkHOdcDR+o9hzeaYx+C6GrFWbpNvHbcBysxu1VHFAA6k4xYpb3ZG0 Rd9R1fHg/63pt+drzKCG9drxt+RTsPXMBD2rDf6umCP0260hoAf5ADx9ranYyvvXB92S 8xGQ== X-Gm-Message-State: AOJu0YwEJ15Bm5ukIsTw6rQndNsk0TFH0epg91cqkSvweGMDx1yVhBGS rwZRcwTQKjc5+hls6cgoy7s1ITBneDQvarUQjEZj1Dd35Vz/dTBKwOT1 X-Gm-Gg: AR+sD12UhVDl7+f+W7n0NpPYAeK0TUopUB4hT1hx4JGI8eS8HGxgwNE2ePvHKeQWVdE Jwqkd9v6X5YI6qdMWMHlTWlL2FoFCIlXxgfy9ymxoKzVWVifT4hev+X9AbjAHpvZCCdvGObjuFn 17BgKhMS3cNhWtyKCAtkWIk/VQ3Undgz5H0HD07Ix0jif6lbY/T3VeE19oBsGzS71KtlHdRVJX/ ci8sgclmGoIgouZEM4PdPg0fSvGjJr53l7uCztOCLRonz9HjSZbmXnFpkhenM0Rz97Bgv60jRfA fr00l8+S89QBko00jGqSsufeeiP5gassIY5r/ctEFn2CGSKOg8SPtA8sdbVrw9DitRN1IB0oWd+ sUmUtQJ/cJJxvDm41iGLYx6GKoY+AzVISaWUMEreFK/+GJv+3Z730KUJo8GiSjNIZcXC9lwEk6I X4EnqGwWXUhb7+XdcrOR3q88lOf8zZf+UnTUEHgpj7mHD4S7qiIWx46zW1zMiDPffwEA== X-Received: by 2002:a05:6a00:4193:b0:845:e9e8:645c with SMTP id d2e1a72fcca58-84fde11e46amr33116869b3a.6.1787029958217; Mon, 17 Aug 2026 22:12:38 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:22 -0700 Subject: [PATCH RFC v2 07/13] hw/virtio/vhost-user: create isolation region MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-7-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=7145; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=Y8FMqK8tl2z1lXfprKV5PVmmovyeXR0vRWxv7yRJE+M=; b=DaG7i69Lze5UQiIRdjFrHrvlHhMlGExbU4HaxptGfmc+ci4x+2veNzCD3oqlLHpolAAoJQUd6 zh60ilHkTbrAZHEawyGYCD8tg5ozrk3Hu0VChDUafW8BKSBtXlO+1F0 X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=connorkite@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787030075644158501 If memory isolation mode is active for the vhost-user device adds features to: - Gather the size required for bounce buffers and vrings in shared isolation region - Allocate the required space in an anonymous file - Create a vhost-iova-tree with space to map entire isolation region - Map guest memory regions and shared vrings into the tree - Release these resources upon backend cleanup Signed-off-by: Connor Kite --- hw/virtio/vhost-user.c | 136 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 136 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 1c003e4d9d..7e9233e174 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -18,6 +18,7 @@ #include "hw/virtio/vhost-backend.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-net.h" +#include "hw/virtio/vhost-iova-tree.h" #include "chardev/char-fe.h" #include "io/channel-socket.h" #include "system/kvm.h" @@ -25,6 +26,7 @@ #include "qemu/main-loop.h" #include "qemu/uuid.h" #include "qemu/sockets.h" +#include "qemu/memfd.h" #include "system/runstate.h" #include "system/cryptodev.h" #include "migration/postcopy-ram.h" @@ -320,6 +322,17 @@ static VhostUserMsg m __attribute__ ((unused)); /* The version of the protocol we support */ #define VHOST_USER_VERSION (0x1) =20 +/* Memory region shared with back-end when memory-isolation is active */ +typedef struct { + void *shared_mem_addr; /* mapped shared memory */ + VhostIOVATree *tree; /* controls mapping of regions into IOVA space */ + void *vring_hva_addr; /* beginning of vring region in shared memory */ + size_t vring_region_size; /* amount of shared memory reserved for vrin= gs */ + size_t size; /* size of the mapped shared memory */ + int fd; /* descriptor of anonymous file backing shared iso region */ + Int128 iso_iova_offset; /* translation from IOVA to hva of iso region = */ +} IsolationModeCtx; + struct vhost_user { struct vhost_dev *dev; /* Shared between vhost devs of the same virtio device */ @@ -353,6 +366,9 @@ struct vhost_user { * by the backend (see @features). */ uint64_t protocol_features; + + /* Data specfic to isolated memory mode */ + IsolationModeCtx iso_mem_ctx; }; =20 struct scrub_regions { @@ -1112,6 +1128,125 @@ static int vhost_user_set_mem_table_postcopy(struct= vhost_dev *dev, return 0; } =20 +static void cleanup_isolation_regions(struct vhost_dev *dev) +{ + struct vhost_user *u =3D dev->opaque; + if (u->iso_mem_ctx.shared_mem_addr) { + vhost_iova_tree_delete(u->iso_mem_ctx.tree); + qemu_memfd_free(u->iso_mem_ctx.shared_mem_addr, + u->iso_mem_ctx.size, + u->iso_mem_ctx.fd); + memset(&u->iso_mem_ctx, 0, sizeof(IsolationModeCtx)); + } +} + +__attribute__((unused)) +static int init_isolation_regions(struct vhost_dev *dev, + VhostUserMsg *msg, + int *fds, size_t *fd_num) +{ + Error *err =3D NULL; + struct vhost_user *u =3D dev->opaque; + uint32_t nregions =3D dev->mem->nregions; + + g_autofree DMAMap *buffer_regions =3D g_new0(DMAMap, nregions); + size_t buffer_reg_size =3D 0; + size_t total_vring_size =3D 0; + size_t total_mmap_size; + char *reg_name; + uint64_t first_IOVA_addr; + uint64_t last_IOVA_addr; + DMAMap *map; + DMAMap vring_map; + int r; + + msg->hdr.request =3D VHOST_USER_SET_MEM_TABLE; + + /* In case of reset, clear old regions */ + cleanup_isolation_regions(dev); + + /* Gather information for bounce buffers to be mapped */ + for (u_int32_t i =3D 0; i < nregions; i++) { + hwaddr size =3D ROUND_UP(dev->mem->regions[i].memory_size, + qemu_real_host_page_size()); + buffer_regions[i].size =3D size - 1; + buffer_regions[i].perm =3D IOMMU_RW; + + buffer_reg_size +=3D size; + } + + /* Get space required for all vrings */ + for (int i =3D 0; i < dev->nvqs; i++) { + VirtQueue *vq =3D virtio_get_queue(dev->vdev, dev->vq_index + i); + total_vring_size +=3D vhost_svq_vring_total_size(dev->vdev, vq); + } + + total_mmap_size =3D buffer_reg_size + total_vring_size; + u->iso_mem_ctx.size =3D total_mmap_size; + + /* Allocate and map an anonymous file to hold the isolation region */ + reg_name =3D g_strconcat("iso_mem_", dev->vdev->name, NULL); + u->iso_mem_ctx.shared_mem_addr =3D qemu_memfd_alloc(reg_name, + total_mmap_size, + F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_= SEAL, + &u->iso_mem_ctx.fd, &err); + + assert(u->iso_mem_ctx.fd >=3D 0); + g_free(reg_name); + + if (err) { + error_report_err(err); + cleanup_isolation_regions(dev); + return -1; + } + + /* vhost-iova-tree enforces non-zero lower address */ + first_IOVA_addr =3D qemu_real_host_page_size(); + last_IOVA_addr =3D first_IOVA_addr + total_mmap_size - 1; + assert(last_IOVA_addr > first_IOVA_addr); + + /* Use 128-bit operation in case of large negative offset */ + u->iso_mem_ctx.iso_iova_offset =3D + int128_sub(int128_make64((uint64_t)u->iso_mem_ctx.shared_mem_addr), + int128_make64(first_IOVA_addr)); + + /* + * Instantiates iova tree sized to map bounce buffers and vrings to the + * isolation region in host va. + */ + u->iso_mem_ctx.tree =3D + vhost_iova_tree_new(first_IOVA_addr, last_IOVA_addr); + + /* Map vrings into IOVA tree */ + vring_map.perm =3D IOMMU_RW; + vring_map.size =3D total_vring_size - 1; + r =3D vhost_iova_tree_map_alloc(u->iso_mem_ctx.tree, &vring_map, + (hwaddr)u->iso_mem_ctx.shared_mem_addr); + + if (r !=3D IOVA_OK) { + cleanup_isolation_regions(dev); + return r; + } + + u->iso_mem_ctx.vring_hva_addr =3D (void *)int128_get64( + int128_add(int128_make64(vring_map.iov= a), + u->iso_mem_ctx.iso_iova_off= set)); + u->iso_mem_ctx.vring_region_size =3D total_vring_size; + + for (int i =3D 0; i < nregions; i++) { + map =3D &buffer_regions[i]; + r =3D vhost_iova_tree_map_alloc_gpa(u->iso_mem_ctx.tree, map, + dev->mem->regions[i].guest_phys_= addr); + + if (r !=3D IOVA_OK) { + cleanup_isolation_regions(dev); + return r; + } + } + + return 0; +} + static int vhost_user_set_mem_table(struct vhost_dev *dev, struct vhost_memory *mem) { @@ -2684,6 +2819,7 @@ static int vhost_user_backend_cleanup(struct vhost_de= v *dev) g_free(u->region_rb_offset); u->region_rb_offset =3D NULL; u->region_rb_len =3D 0; + cleanup_isolation_regions(dev); g_free(u); dev->opaque =3D 0; =20 --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787030075; cv=none; d=zohomail.com; s=zohoarc; b=kL5bfBb1PkgvLMsjmjqciOrpoHCOTGqzwq0Jfd9FtmiYyOGXdtmOXDFKJOJOlX4B5d8F5tLPL9YsnAoi79yJp+Tp5qKkLFhNiawjgKXEu5z/eOoK0JIsm3jr0tz9Q/irVRgFxph6AyCHC+cKhegvGy87GsmK9pMMBFHJ797oVnw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787030075; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IHrCv6J+A3qCWiBl5PFq1mBDnBGg+HWYNp3CHH4h1QI=; b=ic3LiVXpDiQj+AH7BhZ82WeicdCwn7/YXlZlz4k75iREmMKikCGixlqm6QR1h3yx5Q27MvIQlIEyp7/tyA2yhOnNTVjIy4YhYyASLgWEj+bknZjfA5QfEL0GbGj+XQMUPk/ERawxOqw8DiimZ+eGRxZs9A+aFobtrWAy4oOrm94= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787030075641326.6582570302454; Mon, 17 Aug 2026 22:14:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC7y-0005EK-75; Tue, 18 Aug 2026 01:12:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC7w-0005DY-4D for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:44 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC7u-0003nN-BP for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:43 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-84a2dcede83so5727344b3a.3 for ; Mon, 17 Aug 2026 22:12:42 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029961; x=1787634761; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=IHrCv6J+A3qCWiBl5PFq1mBDnBGg+HWYNp3CHH4h1QI=; b=KyBzCnhXhP0vaA230LVV//JOL05KXDfek8kSK/oNNQSFQaZLeP40vgAvoq98BuVMVp av7cVklpnBV+yhK6ZhPn1OXdhEu37e9Z5ET3sIdMDB2pYSt+lzn9xHqXPmEtyBW0PpLR hfrGsjJrLMacAfRccUHXaizikYhZG7cxy7xdQqHqsw+KX2uzTqqaSQ+YNLgKPnQpDN99 DBQukNmFvRMN4uLQCqUmqxH9bm6cRa0t1WB7X7Wg5Z3HXEV9wTh0OdjyE7s/D5G5aD2v F31TEpxiMNuwEMJtGnqlXntD4gYIhOvWIPVOF6i7CzuiGAP2K4yY/Kiic9SrM3qqlpls V7gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029961; x=1787634761; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=IHrCv6J+A3qCWiBl5PFq1mBDnBGg+HWYNp3CHH4h1QI=; b=LO6XQH3TY5jZu3gZ0T3aWh07Rr6KokfPgctc2FYmGrJDf2iuwORhMXz8T0LJ8r3UZW j7uJ02FhCGN7ADhmCiMVHtpfj1bC/uL8WlKpsXbMh/R0dsgSMy77ZwNJlmzHC2cPiA4f oEajLaG7P6tIuChv11MTQPhiAhOZLPJgqIg+iT/z7kWGOgjQLyK5lAyMi0QYxrw4xusk 5Ido/EgrBrMlK3xpzuraVBXXhCLOgxyjsovlauaVMJ1rSK4fOCsu/QSktosq5phVoa3B E5V4FMSdWvPFUne3oeTBwtSGdl+bYa8WJyvClFQN/VJM81IfyjqRGdfPqX92Fdz3bVUX Vc7w== X-Gm-Message-State: AOJu0YwGtVuJil4dB4EWJ2MXv3jZoihUR5xqlYHaIvk5NLPQxnMj2yNE KF5gHGpZvAv3mJomDo7TLFu5XP06jBAaVAmnxK/sb7tiZF6oqpR9TFbc X-Gm-Gg: AR+sD10cTXuYPgJ2QyOac0UMdeF2Xu/GTVvUcLcEDVO7NB8WnNKVHnbsV35PvEEu5D2 qLDREjFDuSu2jKXyRGJLDSHiRscpgtBH3UZeera9xyJONK9irTkTyVLAr6fV7fo7XMvZaf6nnCP Q8zDYSnnPDoC7FW4IUz9BFZr3Rze374zeb5BiN6nWqx8ojNgdWOYV5MF6rUrFpBPjbdLTny+ATl 8Dgc6+DNr1RP+cs9OnUuKY2oVpIxqzUX7Kc7z+3DOIhf61g4CD4ecLWSKb4bt8b4Q1SoPJtMta8 NCE5HlUMEXic8upGAU1Z08L6w61WknZ8Ia5snmfpYro1H3BxKG5g1uXdRkJuj9h221GLdeY2ZTY X3lfnjdn8jj5lDlR1K/aYsi4txRfRspS1OwL32Xk9CTOKOjWK7+owqFHNXBZs9QLFGNrpncbHmg 4bhhCUbZcBhmVoC91j9EEU9DWANgC0qF1jGtW7u79mizCCyAHzz0KzJWROmqG4wwdY1A== X-Received: by 2002:a05:6a00:3016:b0:848:5540:2377 with SMTP id d2e1a72fcca58-84fde13600amr30938208b3a.17.1787029960971; Mon, 17 Aug 2026 22:12:40 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:23 -0700 Subject: [PATCH RFC v2 08/13] hw/virtio/vhost-user: send isolation regions to device MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-8-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=6051; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=isjwTQ10NMEWzyrtg5QOC8oSS6P/XZ9Z7iPYIanOq+I=; b=FNRuemiXMG2dTKu828vACrnegRFejgIQS9WFd9Yooo1U9kbAgnOpgFkvJOc+vSQs5v6xxBexJ LzmC+iqgmKdBj2XM/hPHzFU/R9ir4emBc58pmw0V2fRnezwj1Iw1iA8 X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=connorkite@gmail.com; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787030077681158500 Adds features to fill a vhost_user_set_mem_table message with the addresses of isolation memory regions corresponding to bounce buffers and vrings. Signed-off-by: Connor Kite --- hw/virtio/vhost-user.c | 118 +++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 117 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 7e9233e174..e1e5cba53d 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1140,7 +1140,77 @@ static void cleanup_isolation_regions(struct vhost_d= ev *dev) } } =20 -__attribute__((unused)) +typedef struct { + VhostUserMsg *msg; + struct vhost_user *u; + int *fds; + size_t fds_size; + uint64_t vring_iova; + size_t vring_size; + bool vring_node_visited; + size_t *idx; +} IOVATreeTraversalArgs; + +static gboolean vhost_user_fill_msg_reg_from_tree(gpointer key, + gpointer value, + gpointer data) +{ + IOVATreeTraversalArgs *args =3D data; + struct vhost_user *u; + VhostUserMsg *msg =3D args->msg; + DMAMap *map =3D key; + uint64_t offset; + + assert(args && key && value); + if (!args->vring_node_visited) { + args->vring_node_visited =3D true; + return false; + } + + u =3D args->u; + assert(*args->idx < args->fds_size); + + args->fds[*args->idx] =3D args->u->iso_mem_ctx.fd; + + /* + * If the number of regions is fixed, it would be wasteful to use one = for + * only the vrings. The first vhost_iova_tree element is always + * reserved for the vrings, so we can simply combine the first and sec= ond + * elements, which are contiguous in IOVA space, when sending regions = to + * the backend. + */ + if (*args->idx =3D=3D 0) { + offset =3D u->iso_mem_ctx.vring_hva_addr - u->iso_mem_ctx.shared_m= em_addr; + msg->payload.memory.regions[*args->idx].userspace_addr =3D + args->vring_iova; + /* + * The size from the iova tree is inclusive, so 1 is added to it. + * args->vring_size is exclusive, so no addition is required. + */ + msg->payload.memory.regions[*args->idx].memory_size =3D + args->vring_size + map->size + 1; + msg->payload.memory.regions[*args->idx].guest_phys_addr =3D + args->vring_iova; + msg->payload.memory.regions[*args->idx].mmap_offset =3D offset; + } else { + /* Use 128 bit operation in unlikely case of negative iso_iova_off= set */ + offset =3D int128_get64(int128_add(int128_make64(map->iova), + u->iso_mem_ctx.iso_iova_offset)) - + (uint64_t)u->iso_mem_ctx.shared_mem_addr; + + msg->payload.memory.regions[*args->idx].userspace_addr =3D map->io= va; + msg->payload.memory.regions[*args->idx].memory_size =3D map->size = + 1; + msg->payload.memory.regions[*args->idx].guest_phys_addr =3D map->i= ova; + msg->payload.memory.regions[*args->idx].mmap_offset =3D offset; + } + + assert(offset + msg->payload.memory.regions[*args->idx].memory_size <= =3D + u->iso_mem_ctx.size); + (*args->idx)++; + + return false; +} + static int init_isolation_regions(struct vhost_dev *dev, VhostUserMsg *msg, int *fds, size_t *fd_num) @@ -1159,6 +1229,7 @@ static int init_isolation_regions(struct vhost_dev *d= ev, DMAMap *map; DMAMap vring_map; int r; + IOVATreeTraversalArgs trav_args; =20 msg->hdr.request =3D VHOST_USER_SET_MEM_TABLE; =20 @@ -1244,6 +1315,27 @@ static int init_isolation_regions(struct vhost_dev *= dev, } } =20 + *fd_num =3D 0; + trav_args.idx =3D fd_num; + trav_args.fds =3D fds; + trav_args.msg =3D msg; + trav_args.u =3D u; + trav_args.vring_iova =3D vring_map.iova; + trav_args.vring_size =3D total_vring_size; + trav_args.fds_size =3D nregions; + trav_args.vring_node_visited =3D false; + + vhost_iova_tree_foreach(u->iso_mem_ctx.tree, + vhost_user_fill_msg_reg_from_tree, &trav_args); + + msg->payload.memory.nregions =3D *fd_num; + + assert(*fd_num =3D=3D nregions); + + msg->hdr.size =3D sizeof(msg->payload.memory.nregions); + msg->hdr.size +=3D sizeof(msg->payload.memory.padding); + msg->hdr.size +=3D *fd_num * sizeof(VhostUserMemoryRegion); + return 0; } =20 @@ -1251,6 +1343,7 @@ static int vhost_user_set_mem_table(struct vhost_dev = *dev, struct vhost_memory *mem) { struct vhost_user *u =3D dev->opaque; + bool memory_isolation =3D u->user->memory_isolation; int fds[VHOST_MEMORY_BASELINE_NREGIONS]; size_t fd_num =3D 0; bool do_postcopy =3D u->postcopy_listen && u->postcopy_fd.handler; @@ -1262,6 +1355,11 @@ static int vhost_user_set_mem_table(struct vhost_dev= *dev, int ret; =20 if (do_postcopy) { + /* Postcopy is not supported with memory isolation yet */ + if (memory_isolation) { + return -1; + } + /* * Postcopy has enough differences that it's best done in it's own * version @@ -1278,6 +1376,24 @@ static int vhost_user_set_mem_table(struct vhost_dev= *dev, msg.hdr.flags |=3D VHOST_USER_NEED_REPLY_MASK; } =20 + if (memory_isolation) { + ret =3D init_isolation_regions(dev, &msg, fds, &fd_num); + if (ret < 0) { + return ret; + } + + ret =3D vhost_user_write(dev, &msg, fds, fd_num); + if (ret < 0) { + return ret; + } + + if (reply_supported) { + return process_message_reply(dev, &msg); + } + + return 0; + } + if (config_mem_slots) { ret =3D vhost_user_add_remove_regions(dev, &msg, reply_supported, = false); if (ret < 0) { --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787029995; cv=none; d=zohomail.com; s=zohoarc; b=PjQgsaCWnSB6DKjw7Hhq+eDjjIOcIBbn6JgwANl6HVXSiZruWY8Npr1UdDDbiC/cGOzYCEffsNCX7JKK4eybsHDbjPnebnkjCKeq7i645xry5pxH29xdNB4WYeykFEplRxDcg2bUKhe5Q7WzJ3NtLkxI+smHRWaGCUrmUMbmhrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787029995; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mm3IHLFoV1taMjKnzvr28Ku7UY4hQc5i3yvfG4WtmPU=; b=hLFqVXLMnKNIfdEjXAg8bOcCo96t6rPJMdvXhQ6OFeMcEnCuMIqMY7J6NO/lgi/l/lioEVIL0hbST/i02yRRMnRX0U799kzZxNk+I4zDa20wM+8otkdwM2erS/D3CEHtecS/bKUCkf6BjLO0kJr9y6Jsj0qWOTaluFzVIm9FupI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787029995050219.4149085281938; Mon, 17 Aug 2026 22:13:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC80-0005Fb-TV; Tue, 18 Aug 2026 01:12:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC7z-0005F1-J9 for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:47 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC7x-0003o7-Kt for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:47 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-ca97d139d5fso3502087a12.0 for ; Mon, 17 Aug 2026 22:12:45 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029964; x=1787634764; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=mm3IHLFoV1taMjKnzvr28Ku7UY4hQc5i3yvfG4WtmPU=; b=EXtHT12IUrlLdyDnPO0y8gc5+9B01nt6torrElwJjU/pXdt7ajyHTlhdqinV84UMse RiGc1zELT5gVGtZ++Y0RmRAyqWN3C7ChVovcqoTW51ZXcaej7xCn5WdWMaYm/FmooDss 45vQLBucXrhKbE9kjeVgVUp6pgQBDmcWILmhN77l0CF4AXbaUVUBMXx/YBcYVFp3mLCz JcpirdDHTF3d8yVLgDq8S9FLj2nJqDKNTTJblXAsSR0rV+zrArPhkmmCkUfCIphnEUFq 00WDihpnNFb7jsvH/LuZXvB2x62oXm7+oHOA4rSTifQaAyfLplD+bavRSdPp+83CWUS0 oB5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029964; x=1787634764; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mm3IHLFoV1taMjKnzvr28Ku7UY4hQc5i3yvfG4WtmPU=; b=cDkCQUfVDpDAdtKk4z4PN6XFOEhf3+GntD/yQ1/ZGK3Qb6lJE+la8ogLRje+1nKEG6 3DfRapQlsvh7nXyk934qE9YyrylURnhOp0TlX/Ku0p3cKj7zA/ADEADlZX4f/I3L50en fNae8mbpGLsVdZKH6XzrnRkjuioPWj+K/uryoSsVEixnxYYBT9odCO07NvKG6nSZN8vr UdwvNKy1Ds5ltn8IIBrkP8PVTA/P7E9X3M1biQp9fAM55bFsDFZYuSCR/fN3X3NY66vZ NDrh4Re9TGm+HwT7lDqB/1rETROGi0hJzlIwZpQbQRBX2nlZ7MFQ4RhiDjiR2tNNtJuZ XmEQ== X-Gm-Message-State: AOJu0Ywgvf4aPfD+JiiZzSJSEzZUx6oOTkSq/AesWV2GWM1h1KaMRzUK OYMc+vfmS++UgUuTpJPLVNnq3wZDNXTN+8Nv7VvhGjZGi3V0upTaHQte X-Gm-Gg: AR+sD12gu1rw7UU2iO3VdIlm9gf5J2NHSVFZHSoTJXQ4FFjQKpVQnlr/cTwqLZuUSXA +3TqgjvqoYD3MIhGQKn4OG+DT1ZDMoh6Q3fbSj6KXcPshbb8mtJnDtl/NIsaEeeGcQSeXykfAI+ JTVoG/4ldB22r20in4zu8tn18fFKWRsPWpfVgnxdAVc36aG18qfJD9J2zJbChsT6G34Y/1GwqKU /UGT57PBCZ+zWytieS5FzmWCBfVZtP1B6lU0aRDuluAyS52JcaER3PSPNfJydMbZoVHVdC3ZFIz SvEunxciK8nroRMw2CJ8fPpeDiiNkNsR4mtmqkOAOyj7rBZaIE26xZ5bva/gD6ytui95ApGMHcA EG8OIX+pA5Mm85QYsPLQL/UoCCcFdacAz4BiNrm7GIeCEKBUHnmXhiVROv1pmn09VBC5MhIaVki U5BCdhoOG3JfRYcHR2Fo+JGekzv2DXcN6fU81WzZuVhnbwwBzgrw6RkUpU5qK9WfK9cA== X-Received: by 2002:a05:6a00:278b:b0:84e:2f2e:8c4f with SMTP id d2e1a72fcca58-851b877b568mr7241523b3a.10.1787029963893; Mon, 17 Aug 2026 22:12:43 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:24 -0700 Subject: [PATCH RFC v2 09/13] hw/virtio/vhost-user: add shadow virtqueues and eventfd intercepts MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-9-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=9404; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=EM/PjlQw++6DCEU0UaWG6Z1mgIImjSnvKqIHao8jzr4=; b=E3VPFG/PNlIUzUZxtU9++LwDFS+hH3gRp4CoQ/fnJjpf6gmv+Mx2dER69xXBhSKCU5v8SV8OS 0doaRJ/cXw4Di60Rr3WEWoV19lFWLVxLxPsIr7NjE/CpsNZSC8BZZA/ X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=connorkite@gmail.com; helo=mail-pg1-x529.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787029997207158500 Adds shadow virtqueues that will eventually be used to transfer data between device and host via bounce buffers when isolation mode is active. The svqs are initalized, and eventfd assignments are intercepted so that notifications come to svqs first before the guest or backend receive them. Signed-off-by: Connor Kite --- hw/virtio/vhost-user.c | 136 ++++++++++++++++++++++++++++++++++++++++++---= ---- 1 file changed, 119 insertions(+), 17 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index e1e5cba53d..ace328f5eb 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -18,6 +18,7 @@ #include "hw/virtio/vhost-backend.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-net.h" +#include "hw/virtio/vhost-shadow-virtqueue.h" #include "hw/virtio/vhost-iova-tree.h" #include "chardev/char-fe.h" #include "io/channel-socket.h" @@ -331,6 +332,7 @@ typedef struct { size_t size; /* size of the mapped shared memory */ int fd; /* descriptor of anonymous file backing shared iso region */ Int128 iso_iova_offset; /* translation from IOVA to hva of iso region = */ + GPtrArray *shadow_vqs; /* shadow vqs with vrings in iso region*/ } IsolationModeCtx; =20 struct vhost_user { @@ -1128,15 +1130,38 @@ static int vhost_user_set_mem_table_postcopy(struct= vhost_dev *dev, return 0; } =20 -static void cleanup_isolation_regions(struct vhost_dev *dev) +static void vhost_user_svq_cleanup(struct vhost_user *u, bool reset) +{ + VhostShadowVirtqueue *svq; + for (int i =3D 0; i < u->iso_mem_ctx.shadow_vqs->len; i++) { + svq =3D g_ptr_array_index(u->iso_mem_ctx.shadow_vqs, i); + vhost_svq_stop(svq); + event_notifier_cleanup(&svq->hdev_call); + event_notifier_cleanup(&svq->hdev_kick); + } + + if (!reset) { + g_ptr_array_free(u->iso_mem_ctx.shadow_vqs, true); + } +} + +static void cleanup_isolation_regions(struct vhost_dev *dev, bool reset) { struct vhost_user *u =3D dev->opaque; if (u->iso_mem_ctx.shared_mem_addr) { + vhost_user_svq_cleanup(u, reset); vhost_iova_tree_delete(u->iso_mem_ctx.tree); qemu_memfd_free(u->iso_mem_ctx.shared_mem_addr, u->iso_mem_ctx.size, u->iso_mem_ctx.fd); + + GPtrArray *temp =3D u->iso_mem_ctx.shadow_vqs; memset(&u->iso_mem_ctx, 0, sizeof(IsolationModeCtx)); + + if (!reset) { + u->iso_mem_ctx.shadow_vqs =3D temp; + } + } } =20 @@ -1234,7 +1259,7 @@ static int init_isolation_regions(struct vhost_dev *d= ev, msg->hdr.request =3D VHOST_USER_SET_MEM_TABLE; =20 /* In case of reset, clear old regions */ - cleanup_isolation_regions(dev); + cleanup_isolation_regions(dev, true); =20 /* Gather information for bounce buffers to be mapped */ for (u_int32_t i =3D 0; i < nregions; i++) { @@ -1267,7 +1292,7 @@ static int init_isolation_regions(struct vhost_dev *d= ev, =20 if (err) { error_report_err(err); - cleanup_isolation_regions(dev); + cleanup_isolation_regions(dev, false); return -1; } =20 @@ -1295,7 +1320,7 @@ static int init_isolation_regions(struct vhost_dev *d= ev, (hwaddr)u->iso_mem_ctx.shared_mem_addr); =20 if (r !=3D IOVA_OK) { - cleanup_isolation_regions(dev); + cleanup_isolation_regions(dev, false); return r; } =20 @@ -1310,7 +1335,7 @@ static int init_isolation_regions(struct vhost_dev *d= ev, dev->mem->regions[i].guest_phys_= addr); =20 if (r !=3D IOVA_OK) { - cleanup_isolation_regions(dev); + cleanup_isolation_regions(dev, false); return r; } } @@ -1738,11 +1763,49 @@ static int vhost_set_vring_file(struct vhost_dev *d= ev, return 0; } =20 +static int vhost_user_get_vq_index(struct vhost_dev *dev, int idx) +{ + assert(idx >=3D dev->vq_index && idx < dev->vq_index + dev->nvqs); + + return idx; +} + static int vhost_user_set_vring_kick(struct vhost_dev *dev, struct vhost_vring_file *file) { - int ret =3D vhost_set_vring_file(dev, VHOST_USER_SET_VRING_KICK, file); + struct vhost_user *u =3D dev->opaque; + int svq_idx =3D file->index - dev->vq_index; + VhostShadowVirtqueue *svq =3D NULL; + struct vhost_vring_file vr_file =3D *file; + int ret; + + vhost_user_get_vq_index(dev, file->index); /* bounds checking */ + + if (u->user->memory_isolation) { + svq =3D g_ptr_array_index(u->iso_mem_ctx.shadow_vqs, svq_idx); + vhost_svq_set_svq_kick_fd(svq, file->fd); + + if (file->fd !=3D -1) { + if (!svq->hdev_kick.initialized) { + ret =3D event_notifier_init(&svq->hdev_kick, 0); + if (ret < 0) { + event_notifier_cleanup(&svq->hdev_kick); + error_report("Failed to create kick event notifier"); + return ret; + } + } + + vr_file.fd =3D event_notifier_get_fd(&svq->hdev_kick); + } else { + event_notifier_cleanup(&svq->hdev_kick); + } + } + + ret =3D vhost_set_vring_file(dev, VHOST_USER_SET_VRING_KICK, &vr_file); if (ret < 0) { + if (svq !=3D NULL) { + event_notifier_cleanup(&svq->hdev_kick); + } return ret; } =20 @@ -1750,15 +1813,18 @@ static int vhost_user_set_vring_kick(struct vhost_d= ev *dev, * Inject a kick in case the back-end only starts vring processing upon * receiving a kick. The spec suggests this to improve compatibility. */ - if (file->fd !=3D -1) { + if (vr_file.fd !=3D -1) { uint64_t val =3D 1; ssize_t nwritten; =20 do { - nwritten =3D write(file->fd, &val, sizeof(val)); + nwritten =3D write(vr_file.fd, &val, sizeof(val)); } while (nwritten < 0 && errno =3D=3D EINTR); =20 if (nwritten < 0 && errno !=3D EAGAIN /* back-end can already read= */) { + if (svq !=3D NULL) { + event_notifier_cleanup(&svq->hdev_kick); + } return -errno; } } @@ -1769,7 +1835,35 @@ static int vhost_user_set_vring_kick(struct vhost_de= v *dev, static int vhost_user_set_vring_call(struct vhost_dev *dev, struct vhost_vring_file *file) { - return vhost_set_vring_file(dev, VHOST_USER_SET_VRING_CALL, file); + struct vhost_user *u =3D dev->opaque; + int svq_idx =3D file->index - dev->vq_index; + VhostShadowVirtqueue *svq =3D NULL; + struct vhost_vring_file vr_file =3D *file; + int ret; + + vhost_user_get_vq_index(dev, file->index); /* bounds checking */ + + if (u->user->memory_isolation) { + svq =3D g_ptr_array_index(u->iso_mem_ctx.shadow_vqs, svq_idx); + vhost_svq_set_svq_call_fd(svq, file->fd); + + if (file->fd !=3D -1) { + if (!svq->hdev_call.initialized) { + ret =3D event_notifier_init(&svq->hdev_call, 0); + if (ret < 0) { + event_notifier_cleanup(&svq->hdev_call); + error_report("Failed to create call event notifier"); + return ret; + } + } + + vr_file.fd =3D event_notifier_get_fd(&svq->hdev_call); + } else { + event_notifier_cleanup(&svq->hdev_call); + } + } + + return vhost_set_vring_file(dev, VHOST_USER_SET_VRING_CALL, &vr_file); } =20 static int vhost_user_set_vring_err(struct vhost_dev *dev, @@ -2763,6 +2857,17 @@ static int vhost_user_postcopy_notifier(NotifierWith= Return *notifier, return 0; } =20 +static void vhost_user_init_svq(struct vhost_dev *dev, struct vhost_user *= u) +{ + /*Modified from vhost-vdpa*/ + u->iso_mem_ctx.shadow_vqs =3D g_ptr_array_new_full(dev->nvqs, vhost_sv= q_free); + for (int i =3D 0; i < dev->nvqs; i++) { + VhostShadowVirtqueue *svq; + svq =3D vhost_svq_new(NULL, NULL); + g_ptr_array_add(u->iso_mem_ctx.shadow_vqs, svq); + } +} + static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, Error **errp) { @@ -2907,6 +3012,10 @@ static int vhost_user_backend_init(struct vhost_dev = *dev, void *opaque, u->postcopy_notifier.notify =3D vhost_user_postcopy_notifier; postcopy_add_notifier(&u->postcopy_notifier); =20 + if (vus->memory_isolation) { + vhost_user_init_svq(dev, u); + } + return 0; } =20 @@ -2935,20 +3044,13 @@ static int vhost_user_backend_cleanup(struct vhost_= dev *dev) g_free(u->region_rb_offset); u->region_rb_offset =3D NULL; u->region_rb_len =3D 0; - cleanup_isolation_regions(dev); + cleanup_isolation_regions(dev, false); g_free(u); dev->opaque =3D 0; =20 return 0; } =20 -static int vhost_user_get_vq_index(struct vhost_dev *dev, int idx) -{ - assert(idx >=3D dev->vq_index && idx < dev->vq_index + dev->nvqs); - - return idx; -} - static int vhost_user_memslots_limit(struct vhost_dev *dev) { struct vhost_user *u =3D dev->opaque; --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787030053; cv=none; d=zohomail.com; s=zohoarc; b=R2a832boSOaQ53E1Q+SUPBpCj6lCbtDf1rqOePeQTrWONDlQSjAFkssscAap5OyB/UAtyLuRGJWsIWq7glCWTZm3FgjgvHshZFtTC+cK0Qf+zkLSHhiE1yfsLGLJmz24qIaWDPLk+cbCSn6709RxVsZx/vky6WonQBW3dAZCpbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787030053; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Q4geQjhEDcsmapDV/ZLiGXecFcqlx1SUv1jdKP/WSd8=; b=lgQ6P44QC+4lPqj+EhpI5rXmqKLy/IsXKFnvtwUGKeMTaJcMqej6eMu+piNULmfK6bOnfcF7vUqJWtTMSAJ0EybYPP0VhdkEv+k+Hm339ZeofAfxlF7EZ6WeLGFqVXIiKdFdht4z42yJ3CsEq2stwlMIxYgipmmPXHYSKDLMfgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178703005333391.87096996518142; Mon, 17 Aug 2026 22:14:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC84-0005Gr-31; Tue, 18 Aug 2026 01:12:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC82-0005G5-9u for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:50 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC80-0003oi-0J for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:50 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-84eb992a881so3169053b3a.2 for ; Mon, 17 Aug 2026 22:12:47 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029967; x=1787634767; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Q4geQjhEDcsmapDV/ZLiGXecFcqlx1SUv1jdKP/WSd8=; b=KoNoM6PIElgr8rIYOOJg834aLMG2jao+DUHwZdm5QkRF5ptk3VtnoR161hGAw6rA1z IaIZdcXkFp/DvkiZs6G34NlliiG9u3wwbXMsakVz7u2eFpwwJQhoY8gg8Td7qLCmm8n6 hHT4XLAbiFgptTn0TpJgJdxmpdw5qG7sanOFE72oueCmUIL1kHrSwZr69d1UojPhmfne FG0yDfqc6OL4WcoozQbxzSDSw2oJ40Lg9iVYNdBZEjHQ1iB5psNz0TfWz16QzdP7LQnO 6xmdh0lJxx9DEbY2pYkeklr08EpeWPrRjhojVFY9fFJBZRAP3C76+I/I5Y2FFSj/CfOS ve5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029967; x=1787634767; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Q4geQjhEDcsmapDV/ZLiGXecFcqlx1SUv1jdKP/WSd8=; b=WI0+/xXdCOHd6xn/T4EZdPefzDL9I8S5RP3Pz9LljWvG9CCWMxdHwDHOGT/PYOtebM YH7VIm5Vyc0Ra0dVS0vqjDkBYccZIudRKt+ZEqMlrdaX0NcF2rfphi49B3EafY0eJ6AK wvyCU0mO04K+7bKsQW6ArQ1god66IzhnqOvgv8rLehPiluxRiT3VBT6hFFRrv2+zPxVB sPg6qxJNUiylDoJ8KUlcEaRWVhu65LXI0oXPOhljhAjE+3IzgHsr1g5/prwtbUxC2eYm tqBRPtjGriIadKd+oudF6JJwHwlBsDZ3H5XE2l440bCPS8KuX5SWi2ykipXmyxUgSgKD 7/tQ== X-Gm-Message-State: AOJu0YyEWL3xuwPDXBuo7emfmrG3RfzA6Cw6M6kxtIDRqB+qExIAMB3f UAjtJi3lBQQgXmXLu0KxQ1Jn/pHidTLx47HkSMFg5iqzvKNp52Xb6V+z X-Gm-Gg: AR+sD127q5cIqfa6s6fWzpVzVM4U+m2Wd9b413dtA3UsHTXQ3LVTTt9gh9wyXtuDbwO GnqXI/+Kgt036bh7lgc1YdmmawDF1AuYZIuKejIihfzYpk5bFNGRv8DMFzTgXffjVXapZFwlyQ8 0WT2ehF5jES/TJO2w7udhGMorKpNjAW3tvmbbNyImIEGcbwo41mMFEezfKrsLkdygD/eUT9+I9p nvqFETO9kYj+xByXeEULisGWPi5UgMuI4AA9itmxvIMBI1eYB3+ROwkCElwmyLIuKwpIshTfdbG wXBONjhDTD9jo+LFZipM+GZCO60DgozdQV4D4819T6UXK+hEBashHnpWHGr7iKBgQkyRjm8CFIc nwiLb14+Ze1o3nerwjavvow/OGgF1HZ3piSHOO6ksLVYouePUGc5/pWx2LuLpr9ga4s6js3xa+U qa/aWblnWnwfDBym4CR5pg/Ow+Pyp3PdarYyN42R7plRyLYENEoJpdRgyTF31S3THQbA== X-Received: by 2002:a05:6a00:1256:b0:845:e04b:565f with SMTP id d2e1a72fcca58-84fde122876mr28993614b3a.14.1787029966608; Mon, 17 Aug 2026 22:12:46 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:25 -0700 Subject: [PATCH RFC v2 10/13] hw/virtio/vhost-user: handle data movement with shadow vqs MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-10-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=14307; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=bMPw0FwBRsEunQYzzG6BOXyVL5rIEfi5TeDivlNmsxo=; b=l+69CvZv18/AgSDA22GB8a6pNf2J8er2Y8bngQir+ldlLYyWyDZABBr7A+7tpX8JE+L3eSUAL kmnpQ+dTI9/DssO6GBTKNuQcJZwVTjSAiT/L4vaKujaE7mwosTy1fcb X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=connorkite@gmail.com; helo=mail-pf1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787030053443158500 - Add start logic for shadow virtqueues, which sets vring addresses. - Update logic for sending vring addresses to backend to point to the shadow vrings when isolation mode is active. - Implement handlers for intercepted avail and used descriptors. These handlers copy buffer contents between bounce buffers in the isolation region and the buffers made available by the guest - Implement logic to stop svqs Signed-off-by: Connor Kite --- hw/virtio/vhost-shadow-virtqueue.c | 2 +- hw/virtio/vhost-shadow-virtqueue.h | 1 + hw/virtio/vhost-user.c | 292 +++++++++++++++++++++++++++++++++= +++- 3 files changed, 286 insertions(+), 9 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index f54a61439a..80b0828d7c 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -350,7 +350,7 @@ int vhost_svq_add(VhostShadowVirtqueue *svq, const stru= ct iovec *out_sg, } =20 /* Convenience wrapper to add a guest's element to SVQ */ -static int vhost_svq_add_element(VhostShadowVirtqueue *svq, +int vhost_svq_add_element(VhostShadowVirtqueue *svq, VirtQueueElement *elem) { return vhost_svq_add(svq, elem->out_sg, elem->out_num, elem->out_addr, diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-vi= rtqueue.h index 1e0cc9e5e4..10a8db6c39 100644 --- a/hw/virtio/vhost-shadow-virtqueue.h +++ b/hw/virtio/vhost-shadow-virtqueue.h @@ -183,6 +183,7 @@ VhostShadowVirtqueue *vhost_svq_new(const VhostShadowVi= rtqueueOps *ops, =20 void vhost_svq_free(gpointer vq); void vhost_svq_set_base_addr(VhostShadowVirtqueue *svq, void *addr); +int vhost_svq_add_element(VhostShadowVirtqueue *svq, VirtQueueElement *ele= m); =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(VhostShadowVirtqueue, vhost_svq_free); =20 diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index ace328f5eb..ca3aaf7a07 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1364,6 +1364,231 @@ static int init_isolation_regions(struct vhost_dev = *dev, return 0; } =20 +static inline int vhost_user_get_reg_idx(struct vhost_dev *dev, hwaddr gpa) +{ + int i; + struct vhost_memory_region *reg; + + for (i =3D 0; i < dev->mem->nregions; i++) { + reg =3D dev->mem->regions + i; + + if (gpa >=3D reg->guest_phys_addr && + reg->guest_phys_addr + reg->memory_size > gpa) { + return i; + } + } + + return -1; +} + +static int vhost_user_svq_handle_used(VhostShadowVirtqueue *svq, + VirtQueueElement *elem, + void *opaque) +{ + uint64_t offset; + void *dst; + void *src; + size_t len, rem; + void *reg_last_addr; + void *reg_first_addr; + struct vhost_dev *dev =3D opaque; + struct vhost_user *u =3D dev->opaque; + void *shmem_addr =3D u->iso_mem_ctx.shared_mem_addr; + size_t shmem_size =3D u->iso_mem_ctx.size; + const DMAMap *map; + DMAMap needle; + int reg_idx; + + for (int i =3D 0; i < elem->in_num; i++) { + needle.translated_addr =3D elem->in_addr[i]; + needle.size =3D elem->in_sg[i].iov_len - 1; + map =3D vhost_iova_tree_find_gpa(svq->iova_tree, &needle); + + if (!map) { + return -EFAULT; + } + + offset =3D needle.translated_addr - map->translated_addr; + src =3D (void *)int128_get64(int128_add(int128_make64(map->iova + + offset), u->iso_mem_ctx.iso_iova_offset)); + dst =3D elem->in_sg[i].iov_base; + len =3D elem->in_sg[i].iov_len; + + /* Confirm that buffer range is fully within iso region */ + if ((uint64_t)src + len - 1 > (uint64_t)shmem_addr + shmem_size - = 1 || + (uint64_t)src + len <=3D (uint64_t)src || + (uint64_t)src < (uint64_t)shmem_addr) { + + return -EFAULT; + } + + reg_idx =3D vhost_user_get_reg_idx(dev, needle.translated_addr); + if (reg_idx < 0) { + return -EFAULT; + } + + reg_first_addr =3D (void *)dev->mem->regions[reg_idx].userspace_ad= dr; + reg_last_addr =3D (void *)(dev->mem->regions[reg_idx].userspace_ad= dr + + dev->mem->regions[reg_idx].memory_size - 1); + + /* Confirm that hva from elem matches expected vhost memory region= */ + if (dst < reg_first_addr || dst > reg_last_addr) { + return -EFAULT; + } + + /* + * copy buffer contents from shared memory into guest memory. If + * the buffer extends across region boundaries, it must be split a= nd + * copied to the correct regions. + */ + while ((uint64_t)reg_last_addr - (uint64_t)dst + 1 < len) { + rem =3D ((uint64_t)dst + len - 1) - (uint64_t)reg_last_addr; + len -=3D rem; + memcpy(dst, src, len); + + reg_idx++; + if (reg_idx >=3D dev->mem->nregions) { + return -EFAULT; + } + + src =3D (void *)((uint64_t)src + len); + dst =3D (void *)dev->mem->regions[reg_idx].userspace_addr; + len =3D rem; + reg_first_addr =3D (void *)dev->mem->regions[reg_idx].userspac= e_addr; + reg_last_addr =3D (void *)(dev->mem->regions[reg_idx].userspac= e_addr + + dev->mem->regions[reg_idx].memory_size - 1); + } + + memcpy(dst, src, len); + } + + return 0; +} + +static int vhost_user_svq_handle_avail(VhostShadowVirtqueue *svq, + VirtQueueElement *elem, + void *opaque) +{ + hwaddr offset; + const DMAMap *map; + DMAMap needle; + void *dst; + void *src; + void *reg_first_addr; + void *reg_last_addr; + size_t len, rem; + struct vhost_dev *dev =3D opaque; + struct vhost_user *u =3D dev->opaque; + void *shmem_addr =3D u->iso_mem_ctx.shared_mem_addr; + size_t shmem_size =3D u->iso_mem_ctx.size; + int reg_idx; + + for (int i =3D 0; i < elem->out_num; i++) { + needle.translated_addr =3D elem->out_addr[i]; + needle.size =3D elem->out_sg[i].iov_len - 1; + map =3D vhost_iova_tree_find_gpa(svq->iova_tree, &needle); + + if (!map) { + return -EFAULT; + } + + offset =3D needle.translated_addr - map->translated_addr; + dst =3D (void *)int128_get64(int128_add(int128_make64(map->iova + + offset), u->iso_mem_ctx.iso_iova_offset)); + src =3D elem->out_sg[i].iov_base; + len =3D elem->out_sg[i].iov_len; + + /* Confirm that buffer range is fully within iso region */ + if ((uint64_t)dst + len - 1 > (uint64_t)shmem_addr + shmem_size - = 1 || + (uint64_t)dst + len <=3D (uint64_t)dst || + (uint64_t)dst < (uint64_t)shmem_addr) { + + return -EFAULT; + } + + reg_idx =3D vhost_user_get_reg_idx(dev, needle.translated_addr); + if (reg_idx < 0) { + return -EFAULT; + } + + reg_first_addr =3D (void *)dev->mem->regions[reg_idx].userspace_ad= dr; + reg_last_addr =3D (void *)(dev->mem->regions[reg_idx].userspace_ad= dr + + dev->mem->regions[reg_idx].memory_size - 1); + + /* Confirm that hva from elem matches expected vhost memory region= */ + if (src < reg_first_addr || src > reg_last_addr) { + return -EFAULT; + } + + /* + * copy buffer contents from guest memory into shared memory. If + * the buffer extends across region boundaries, it must be split a= nd + * copied from the correct regions. + */ + while ((uint64_t)reg_last_addr - (uint64_t)src + 1 < len) { + rem =3D ((uint64_t)src + len - 1) - (uint64_t)reg_last_addr; + len -=3D rem; + memcpy(dst, src, len); + + reg_idx++; + if (reg_idx >=3D dev->mem->nregions) { + return -EFAULT; + } + + dst =3D (void *)((uint64_t)dst + len); + src =3D (void *)dev->mem->regions[reg_idx].userspace_addr; + len =3D rem; + + reg_first_addr =3D (void *)dev->mem->regions[reg_idx].userspac= e_addr; + reg_last_addr =3D (void *)(dev->mem->regions[reg_idx].userspac= e_addr + + dev->mem->regions[reg_idx].memory_size - 1); + } + + memcpy(dst, src, len); + } + + vhost_svq_add_element(svq, elem); + + return 0; +} + +static int vhost_user_get_vq_index(struct vhost_dev *dev, int idx) +{ + assert(idx >=3D dev->vq_index && idx < dev->vq_index + dev->nvqs); + + return idx; +} + +static int vhost_user_svqs_vring_map(struct vhost_dev *dev) +{ + int ret; + struct vhost_user *u =3D dev->opaque; + void *vring_base =3D u->iso_mem_ctx.vring_hva_addr; + uint64_t vring_last =3D (uint64_t)vring_base + + u->iso_mem_ctx.vring_region_size - 1; + + for (int i =3D 0; i < u->iso_mem_ctx.shadow_vqs->len; i++) { + vhost_user_get_vq_index(dev, dev->vq_index + i); /* bounds checkin= g */ + + VirtQueue *vq =3D virtio_get_queue(dev->vdev, dev->vq_index + i); + VhostShadowVirtqueue *svq =3D + g_ptr_array_index(u->iso_mem_ctx.shadow_vqs, i); + + assert((uint64_t)vring_base + + vhost_svq_vring_total_size(dev->vdev, vq) - 1 <=3D vring_la= st); + + vhost_svq_set_base_addr(svq, vring_base); + ret =3D vhost_svq_start(svq, dev->vdev, vq, u->iso_mem_ctx.tree); + if (ret < 0) { + return ret; + } + vring_base =3D (void *)((uint64_t)vring_base + + vhost_svq_vring_total_size(dev->vdev, vq)); + } + + return 0; +} + static int vhost_user_set_mem_table(struct vhost_dev *dev, struct vhost_memory *mem) { @@ -1407,6 +1632,11 @@ static int vhost_user_set_mem_table(struct vhost_dev= *dev, return ret; } =20 + ret =3D vhost_user_svqs_vring_map(dev); + if (ret < 0) { + return ret; + } + ret =3D vhost_user_write(dev, &msg, fds, fd_num); if (ret < 0) { return ret; @@ -1763,13 +1993,6 @@ static int vhost_set_vring_file(struct vhost_dev *de= v, return 0; } =20 -static int vhost_user_get_vq_index(struct vhost_dev *dev, int idx) -{ - assert(idx >=3D dev->vq_index && idx < dev->vq_index + dev->nvqs); - - return idx; -} - static int vhost_user_set_vring_kick(struct vhost_dev *dev, struct vhost_vring_file *file) { @@ -1875,6 +2098,8 @@ static int vhost_user_set_vring_err(struct vhost_dev = *dev, static int vhost_user_set_vring_addr(struct vhost_dev *dev, struct vhost_vring_addr *addr) { + struct vhost_user *u =3D dev->opaque; + ptrdiff_t offset =3D u->iso_mem_ctx.iso_iova_offset; VhostUserMsg msg =3D { .hdr.request =3D VHOST_USER_SET_VRING_ADDR, .hdr.flags =3D VHOST_USER_VERSION, @@ -1882,6 +2107,25 @@ static int vhost_user_set_vring_addr(struct vhost_de= v *dev, .hdr.size =3D sizeof(msg.payload.addr), }; =20 + if (u->user->memory_isolation) { + int svq_idx; + VhostShadowVirtqueue *svq; + struct vhost_vring_addr svq_addr; + + vhost_user_get_vq_index(dev, addr->index); /* bounds checking */ + svq_idx =3D addr->index - dev->vq_index; + svq =3D g_ptr_array_index(u->iso_mem_ctx.shadow_vqs, + svq_idx); + + svq_addr.avail_user_addr =3D (uint64_t)(uintptr_t)svq->vring.avail= - + offset; + svq_addr.desc_user_addr =3D (uint64_t)(uintptr_t)svq->vring.desc -= offset; + svq_addr.used_user_addr =3D (uint64_t)(uintptr_t)svq->vring.used -= offset; + svq_addr.index =3D addr->index; + + msg.payload.addr =3D svq_addr; + } + /* * wait for a reply if logging is enabled to make sure * backend is actually logging changes @@ -2857,13 +3101,18 @@ static int vhost_user_postcopy_notifier(NotifierWit= hReturn *notifier, return 0; } =20 +static const VhostShadowVirtqueueOps vhost_user_svq_ops =3D { + .avail_handler =3D vhost_user_svq_handle_avail, + .used_callback =3D vhost_user_svq_handle_used +}; + static void vhost_user_init_svq(struct vhost_dev *dev, struct vhost_user *= u) { /*Modified from vhost-vdpa*/ u->iso_mem_ctx.shadow_vqs =3D g_ptr_array_new_full(dev->nvqs, vhost_sv= q_free); for (int i =3D 0; i < dev->nvqs; i++) { VhostShadowVirtqueue *svq; - svq =3D vhost_svq_new(NULL, NULL); + svq =3D vhost_svq_new(&vhost_user_svq_ops, dev); g_ptr_array_add(u->iso_mem_ctx.shadow_vqs, svq); } } @@ -3562,8 +3811,35 @@ void vhost_user_async_close(DeviceState *d, } } =20 +static void vhost_user_svqs_stop(struct vhost_dev *dev) +{ + struct vhost_user *u =3D dev->opaque; + for (int i =3D 0; i < u->iso_mem_ctx.shadow_vqs->len; i++) { + vhost_svq_stop(g_ptr_array_index(u->iso_mem_ctx.shadow_vqs, i)); + } +} + static int vhost_user_dev_start(struct vhost_dev *dev, bool started) { + struct vhost_user *u =3D dev->opaque; + if (u->user->memory_isolation) { + if (vhost_dev_has_iommu(dev)) { + error_report("Memory isolation is not supported with IOMMU ena= bled." + "Please disable one and try again"); + return -1; + } + + if (virtio_vdev_has_feature(dev->vdev, VIRTIO_F_RING_PACKED)) { + error_report("Memory isolation is not supported with packed" + "vrings. Please use split vrings"); + return -1; + } + + if (!started) { + vhost_user_svqs_stop(dev); + } + } + if (!vhost_user_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_STATUS= )) { return 0; } --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787030087; cv=none; d=zohomail.com; s=zohoarc; b=MyaOvHBHsos9kxGP99sdOEmM9tL3tt0ZrLA95JnUZgruLOpZ+cdJDuimfEAnajT87iwERwe6q686mLj4QppRNP6bb+Xk5lVxmLlbNEooFJBVfJ0ZS53sRckk3tgxOzHBgaLxzY0H2iiUz4BQxekrPHHND65a00XZnmWi2BnJqqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787030087; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yDGWIbLiwCQZ5If+WfdVxDr1QS3FHpZI2ZH0Iio93r0=; b=FgnpJd1nPJFvRfCQYoIimkyOcODzgk8nJljQOza8vZh0dFSeFMEmzaR/OLp5wUl+NF9IsOoC0x5Ly2TJglaqYi9tEPSKA3aylsDtjHkIYqekU6dCIJ7S1eruiG9IhifIQDKfUcAuq2DMZg2uKxNeZeJw0tCDQgwp/u9mRADmslc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787030087263269.90109578898625; Mon, 17 Aug 2026 22:14:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC86-0005HQ-Nb; Tue, 18 Aug 2026 01:12:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC85-0005H3-06 for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:53 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC82-0003pS-VN for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:52 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-84a2dcede83so5727459b3a.3 for ; Mon, 17 Aug 2026 22:12:50 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029969; x=1787634769; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yDGWIbLiwCQZ5If+WfdVxDr1QS3FHpZI2ZH0Iio93r0=; b=RdOjIq6d9mZzQ//nAwCJw/JHTb391bYaWB5tBVqWJ6MTXLSOwQaVfc9no1bnKXW/Y8 GzjFTGb2KmpZWamclD8rSHkSjwYwvHz3QN6dBT9YwHku3RHNxLyJ55oQ8rRqr2BEGqky sMMX7MLgENA35wvFGn4cvIwpYMytqVafKhLv2YjG9seBIIOCiNSwJXLEMZmNyZByj1C3 tYrEUOnaBX/mmwPJERHhl7+KB0e1dgEybC7SkZGrTVENyMZ0C2JpyfI+TNnfBgGuzFx0 XltLfLm9H3tuBkFYyPHtrRh/2WWjs6yYMN4XkmIETrfVZ2iQoAjXebOlQrGacLHjsBV/ lmZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029969; x=1787634769; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yDGWIbLiwCQZ5If+WfdVxDr1QS3FHpZI2ZH0Iio93r0=; b=EufEvO26aJz1bO7cLN9oKkV42YXlQueD982RLvZHgGFl+18WMSSokBdmBu/GrZ0+TV zYN/4F2cVyOz20ejIOiTXsU3vwGPmlsZ4wqxmqbR1E2K2tMEIPfvkrWbk6g/y4rIEcg9 72mxrqOsGoteLkn8RlkhAcIrE6QuvdLOJj2YkEjMcdiqbP1Ty13dKqOZH8diD1dOO9xF t5ZPmoiFv1C8nbys1fV++iao5mooezrXeYDAHuy/2Wv9M4jItPWPT0Q0TEk8EzSOCGPB q3L7OttSd5B6AEA2AlKg7FqvEt4dDwJqnvwHrqXMs6U44IBhJmQx7LwcPFFVykRVuMHf xCbA== X-Gm-Message-State: AOJu0Yytji2Ki990TIxrHMCIuSZU2UJNUBqvGuyec+nKtUiNPiv5H2G7 zrPy9tJplgsJly38w6X1plsjTKS5oNV2JktsA5bteHfelaZzhyfNI8nt X-Gm-Gg: AR+sD12iGAg7ef3HQ/2szGA1JxI7QmVeWEwDtUTFtPnMMciy6+wuTBX323hlBpU/s4b x5V2xTPJZU2XUWMcNQNT2Z7MVfc8b4RA3bZNK89GDd/suBhzKqvTFQSXXUnuWG58PWTHsfeDeAk cCzjWHkwiFGlGNYBv/4FPPSWwYVfetwwaE32Puz0oc6KyJW4WNWMUOJooyKc3UgwQoQl812WhYn XbhPbi9eyZNXJd9szBsuKwv482uiS6pu8JQQdIwDR2CQH9fGROT+w5A1mqmO8Kv3S94HHQxJOmW i8GCtqQXUAb1hbjqfvo3uIXmaAnI8LLnex0eAWT0OSGB30C1FJpXKxLxaCmEOfeTK8mefAO/arZ izzm9d9aNkBWt/kOUU9oaMN0VX2AFCUP1n5slOrwcFX5ksWU7Tcb7Ya30SKeIBmxWgaZfsS/eLM 4Qm48BGByhFoAOS3u5d8hBlygnDWJyPBQJrC/RCSqEgznRmhh+SP8axRqpDLmikAJ3vgHbFiR+w AWQ X-Received: by 2002:a05:6a00:4654:b0:848:4faa:480b with SMTP id d2e1a72fcca58-84fddfce887mr29626111b3a.12.1787029969420; Mon, 17 Aug 2026 22:12:49 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:26 -0700 Subject: [PATCH RFC v2 11/13] vhost-user: Add memory-isolation qdev property to vhost-user devices MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-11-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=10639; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=bDY61qv1aUuiJX5AihOusx4h4L9qjegBfYljF7KlWx8=; b=svydToQc3yKwRDJxMF6SXJDj73zDY4NnrZk9gFJeM50qtdYTDTQELdGbLi55zIK2/HyP27xha mBoDB2VpKtOCkPXCeACvJDDlFJSimZQTceBGaSg7jkYVd9WXhMuloXv X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=connorkite@gmail.com; helo=mail-pf1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787030087943158500 In support of future work to add a memory isolation mode to vhost-user devi= ces, a qdev property, "memory-isolation", is added to all vhost-user devices. This= is simply a bool representing whether the mode is active or not. Signed-off-by: Connor Kite Reviewed-by: Stefan Hajnoczi --- hw/block/vhost-user-blk.c | 3 ++- hw/display/vhost-user-gpu.c | 3 ++- hw/scsi/vhost-user-scsi.c | 4 +++- hw/virtio/vhost-user-base.c | 6 ++++-- hw/virtio/vhost-user-fs.c | 4 +++- hw/virtio/vhost-user-scmi.c | 4 +++- hw/virtio/vhost-user-vsock.c | 4 +++- include/hw/virtio/vhost-user-base.h | 1 + include/hw/virtio/vhost-user-blk.h | 1 + include/hw/virtio/vhost-user-fs.h | 1 + include/hw/virtio/vhost-user-scmi.h | 1 + include/hw/virtio/vhost-user-vsock.h | 1 + include/hw/virtio/virtio-gpu.h | 1 + include/hw/virtio/virtio-scsi.h | 1 + 14 files changed, 27 insertions(+), 8 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 4640d7da04..5c1a19eb50 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -506,7 +506,7 @@ static void vhost_user_blk_device_realize(DeviceState *= dev, Error **errp) } =20 if (!vhost_user_init(&s->vhost_user, &s->chardev, - false, errp)) { + s->memory_isolation, errp)) { return; } =20 @@ -632,6 +632,7 @@ static const VMStateDescription vmstate_vhost_user_blk = =3D { =20 static const Property vhost_user_blk_properties[] =3D { DEFINE_PROP_CHR("chardev", VHostUserBlk, chardev), + DEFINE_PROP_BOOL("memory-isolation", VHostUserBlk, memory_isolation, f= alse), DEFINE_PROP_UINT16("num-queues", VHostUserBlk, num_queues, VHOST_USER_BLK_AUTO_NUM_QUEUES), DEFINE_PROP_UINT32("queue-size", VHostUserBlk, queue_size, 128), diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 6655585b43..d8f710ed65 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -663,7 +663,7 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error = **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(g); =20 vhost_dev_set_config_notifier(&g->vhost->dev, &config_ops); - if (vhost_user_backend_dev_init(g->vhost, vdev, 2, false, + if (vhost_user_backend_dev_init(g->vhost, vdev, 2, g->memory_isolation, errp) < 0) { return; } @@ -698,6 +698,7 @@ static struct vhost_dev *vhost_user_gpu_get_vhost(VirtI= ODevice *vdev) =20 static const Property vhost_user_gpu_properties[] =3D { VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf), + DEFINE_PROP_BOOL("memory-isolation", VhostUserGPU, memory_isolation, f= alse), }; =20 static void diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 05bc788304..6f162a7854 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -277,7 +277,7 @@ static void vhost_user_scsi_realize(DeviceState *dev, E= rror **errp) } =20 if (!vhost_user_init(&s->vhost_user, &vs->conf.chardev, - false, errp)) { + vs->conf.memory_isolation, errp)) { goto free_virtio; } =20 @@ -347,6 +347,8 @@ static void vhost_user_scsi_unrealize(DeviceState *dev) =20 static const Property vhost_user_scsi_properties[] =3D { DEFINE_PROP_CHR("chardev", VirtIOSCSICommon, conf.chardev), + DEFINE_PROP_BOOL("memory-isolation", VirtIOSCSICommon, + conf.memory_isolation, false), DEFINE_PROP_UINT32("boot_tpgt", VirtIOSCSICommon, conf.boot_tpgt, 0), DEFINE_PROP_UINT32("num_queues", VirtIOSCSICommon, conf.num_queues, VIRTIO_SCSI_AUTO_NUM_QUEUES), diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index c10851492a..657a7d174a 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -318,7 +318,7 @@ static void vub_device_realize(DeviceState *dev, Error = **errp) } =20 if (!vhost_user_init(&vub->vhost_user, &vub->chardev, - false, errp)) { + vub->memory_isolation, errp)) { return; } =20 @@ -410,7 +410,9 @@ static void vub_device_unrealize(DeviceState *dev) =20 /*Define common qdev properties. Inherited by all children*/ static const Property vub_properties[] =3D { - DEFINE_PROP_CHR("chardev", VHostUserBase, chardev) + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_BOOL("memory-isolation", VHostUserBase, memory_isolation, + false), }; =20 =20 diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 34ccbdec10..5529a8afb0 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -239,7 +239,7 @@ static void vuf_device_realize(DeviceState *dev, Error = **errp) } =20 if (!vhost_user_init(&fs->vhost_user, &fs->conf.chardev, - false, errp)) { + fs->conf.memory_isolation, errp)) { return; } =20 @@ -411,6 +411,8 @@ static const VMStateDescription vuf_backend_vmstate =3D= { =20 static const Property vuf_properties[] =3D { DEFINE_PROP_CHR("chardev", VHostUserFS, conf.chardev), + DEFINE_PROP_BOOL("memory-isolation", VHostUserFS, conf.memory_isolatio= n, + false), DEFINE_PROP_STRING("tag", VHostUserFS, conf.tag), DEFINE_PROP_UINT16("num-request-queues", VHostUserFS, conf.num_request_queues, 1), diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c index bd0ec64daf..b32dc09b0c 100644 --- a/hw/virtio/vhost-user-scmi.c +++ b/hw/virtio/vhost-user-scmi.c @@ -245,7 +245,7 @@ static void vu_scmi_device_realize(DeviceState *dev, Er= ror **errp) vdev->host_features |=3D (1ULL << VIRTIO_SCMI_F_P2A_CHANNELS); =20 if (!vhost_user_init(&scmi->vhost_user, &scmi->chardev, - false, errp)) { + scmi->memory_isolation, errp)) { return; } =20 @@ -288,6 +288,8 @@ static const VMStateDescription vu_scmi_vmstate =3D { =20 static const Property vu_scmi_properties[] =3D { DEFINE_PROP_CHR("chardev", VHostUserSCMI, chardev), + DEFINE_PROP_BOOL("memory-isolation", VHostUserSCMI, memory_isolation, + false), }; =20 static void vu_scmi_class_init(ObjectClass *klass, const void *data) diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 44a90c76ad..7b62290167 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -107,7 +107,7 @@ static void vuv_device_realize(DeviceState *dev, Error = **errp) } =20 if (!vhost_user_init(&vsock->vhost_user, &vsock->conf.chardev, - false, errp)) { + vsock->conf.memory_isolation, errp)) { return; } =20 @@ -155,6 +155,8 @@ static void vuv_device_unrealize(DeviceState *dev) =20 static const Property vuv_properties[] =3D { DEFINE_PROP_CHR("chardev", VHostUserVSock, conf.chardev), + DEFINE_PROP_BOOL("memory-isolation", VHostUserVSock, conf.memory_isola= tion, + false), }; =20 static void vuv_class_init(ObjectClass *klass, const void *data) diff --git a/include/hw/virtio/vhost-user-base.h b/include/hw/virtio/vhost-= user-base.h index d5d2f081ae..29bc40736c 100644 --- a/include/hw/virtio/vhost-user-base.h +++ b/include/hw/virtio/vhost-user-base.h @@ -25,6 +25,7 @@ struct VHostUserBase { uint32_t num_vqs; uint32_t vq_size; /* can't exceed VIRTIO_QUEUE_MAX */ uint32_t config_size; + bool memory_isolation; /* State tracking */ VhostUserState vhost_user; struct vhost_virtqueue *vhost_vq; diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index dee848cfd8..8126447a86 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -30,6 +30,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserBlk, VHOST_USER_BLK) struct VHostUserBlk { VirtIODevice parent_obj; CharFrontend chardev; + bool memory_isolation; int32_t bootindex; struct virtio_blk_config blkcfg; uint16_t num_queues; diff --git a/include/hw/virtio/vhost-user-fs.h b/include/hw/virtio/vhost-us= er-fs.h index 5699ea03a1..bf71990b9c 100644 --- a/include/hw/virtio/vhost-user-fs.h +++ b/include/hw/virtio/vhost-user-fs.h @@ -28,6 +28,7 @@ typedef struct { char *tag; uint16_t num_request_queues; uint16_t queue_size; + bool memory_isolation; } VHostUserFSConf; =20 struct VHostUserFS { diff --git a/include/hw/virtio/vhost-user-scmi.h b/include/hw/virtio/vhost-= user-scmi.h index 30ab0d7ab7..d346b42ed8 100644 --- a/include/hw/virtio/vhost-user-scmi.h +++ b/include/hw/virtio/vhost-user-scmi.h @@ -19,6 +19,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserSCMI, VHOST_USER_SCMI= ); struct VHostUserSCMI { VirtIODevice parent; CharFrontend chardev; + bool memory_isolation; struct vhost_virtqueue *vhost_vqs; struct vhost_dev vhost_dev; VhostUserState vhost_user; diff --git a/include/hw/virtio/vhost-user-vsock.h b/include/hw/virtio/vhost= -user-vsock.h index 5db6938b8b..6288b26fa4 100644 --- a/include/hw/virtio/vhost-user-vsock.h +++ b/include/hw/virtio/vhost-user-vsock.h @@ -21,6 +21,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(VHostUserVSock, VHOST_USER_VSO= CK) =20 typedef struct { CharFrontend chardev; + bool memory_isolation; } VHostUserVSockConf; =20 struct VHostUserVSock { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 220231ec9d..d0de1437f8 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -276,6 +276,7 @@ struct VhostUserGPU { CharFrontend vhost_chr; QemuDmaBuf *dmabuf[VIRTIO_GPU_MAX_SCANOUTS]; bool backend_blocked; + bool memory_isolation; }; =20 #define MAX_SLOTS 4096 diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scs= i.h index b6028bb5cd..47fdc3785c 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -59,6 +59,7 @@ struct VirtIOSCSIConf { char *vhostfd; char *wwpn; CharFrontend chardev; + bool memory_isolation; uint32_t boot_tpgt; IOThread *iothread; IOThreadVirtQueueMappingList *iothread_vq_mapping_list; --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787029994; cv=none; d=zohomail.com; s=zohoarc; b=JRjO25H5Im45lUotJay4Pc9WbiCWFLpQCP/XvlQdfFR0DUORTdAc+nSZQi19aXghFXE3J199papKL1GASpUornmOrUNVYHGxwuAdH+M36iHRx5dMAwjPOHdsHe+jhryhPuv+e8fkLkhGxJWGVQdsK9as5lKwNV0KOCMoCRnpjyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787029994; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YLd2wdLWmGn/myw/YqHvhA2qKd6cbpArYdUl+1k3wFU=; b=A9fzLhzheFg2q42xbF/WDzCRD/ZletIWhdQZQ1dAtB0uf8WR4Gwn5/13EClCjMkrjDULEI8Xh3S81lurI2PgESgr0cRm2TeHmSozZrW6X/vGNleC3Nr4jYzArrhNi8KE3r6if2XO7VAuTc0wpSf0JEIQ8bD99YNBqXnH5j+zbT8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787029994770563.9203008851655; Mon, 17 Aug 2026 22:13:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC89-0005NC-94; Tue, 18 Aug 2026 01:12:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC87-0005Hp-8H for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:55 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC85-0003qG-G4 for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:54 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-84a2dcede83so5727559b3a.3 for ; Mon, 17 Aug 2026 22:12:53 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029972; x=1787634772; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YLd2wdLWmGn/myw/YqHvhA2qKd6cbpArYdUl+1k3wFU=; b=XKVCk7ShT/s+L59SpdBdhHn33068Ki5R5Ji6SxeE+sAIqESa7Vo51nL9xM0ZT3fS62 X4rIpC0VupoRRtK7HGpDvhOxhqGZ82MJeyCWMkgWRYXfscSlVcX+T0gaEINqP20YKdxw 7Cm6WM+VkliHEXcn9b5HQFhNaDdSZ0v2Y0lMCACW3LZj+pm2Vczd0Hl8989alfSIvw2t RvneuNqwm5Ggty4uXhrTYB6VBcMgCCX7HDFZgk7n/AX5FPVXeltBDqYX5UpgRLqWaqTH p2kFGE1HfDyEq4owj/LAp/G1rfi/dNkXEWVLUOySqom/YiWP1AEA9l5WZrlJN3DrvZ3W njKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029972; x=1787634772; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YLd2wdLWmGn/myw/YqHvhA2qKd6cbpArYdUl+1k3wFU=; b=m81j0G4zm0d5vBgvkiPFGtdLvjjP6akKOEV/lEkhposampdgrjjsdeJrLiz2vhkyk4 gUYpH0BA4Bo86AiM4BHZ4KMcWu52Q/7w9I+bejSV+elyjuD2sVaTlW/epBWcnrDx1VTx Km7+/Y4IPbIBw43q8moMqHDfjOJVK62OnNGecrXO73fDuhd8xGweWmiBU+vTyRyHq16W g/wivCtW6gVO/TtfsEE8JyFgyQ4r4l+0zQ8bQX802upqeLyjJXFhKhk75S/0enitOwBR vJ4WK6JB9Z1mVbQO11vuGAmyFmqPFTfZWbZZGGil4beuOZvnysYFcpKMm52/zYQyfjnm TWQw== X-Gm-Message-State: AOJu0Yyjtk8eUMvRRw/EJYCxp/oOWMW9B+9vjVAYP61JHTb/K4gyN+gM wJ9tNJ/TA39vqbyLzscM9wHF4o4dF5gdYke5lNvv4eji9hOhNtIMHV3b X-Gm-Gg: AR+sD1287rQ+2kpjMrLWi4PKNx/NsWayINURcXaCjugx4rYZMO9YTMyWUCB8NBFPXs2 9Bn39Za8AQ3dPLXQeuuIChBOaIbvp2QzSCsD7SKsuHTQmNR8ckx9YyTXEwP5eqsOMqXMIcJQ3cJ Zwt4FsxGNTr1SIymvFORx+7IVHyUEkao4CTQSNn/7rv0F416eL6nz+a9lXYE94Ma5y8VS8hLl3u AoRrNZxvu2YfI7K9oklkVNr1a/dkoMr0w2rdG8RIU3vC60KC437bQ5ELmf+yrZ9zukE2DvCgSkP TAMfEQrjqH4gpGJR6g8D26i0Q1RgFijfuTJAj83iWKZm3oBCTa3Fy8Am3CE/GyjUReRvLA69kBF M4QfIsqRwP7ebZeMhJqR/JIQOeInVYK6hOdqohVUUAcqj9F9IGrJiQkJkniqtdVUGKPyFT2CQLQ HvDXMQSb4a9XIM7qSBwYQLvy69gKGGooJl/AF8mqL2PXc0pY4KT2IIAfCTgMUyUJ/Hf1GbIDUGh cgI X-Received: by 2002:a05:6a00:2e99:b0:84e:7ec:aa42 with SMTP id d2e1a72fcca58-84fddfce17amr29977836b3a.10.1787029972164; Mon, 17 Aug 2026 22:12:52 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:27 -0700 Subject: [PATCH RFC v2 12/13] backends/cryptodev-vhost-user: add memory isolation bool MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-12-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=3359; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=eS7iavmbL0ampAG6cVubHx6sNBExzuvb7v9JapDYYmM=; b=QQC2OuLiUfEcGY5CpgdYwdIVlG/TPTJH7ZlmxUHZmp1sA4tGb7tfTiqnQlBPGifcZORQ+JMwD 6K2JrArn0J5Ct+0HPw1nnvuKpOOZIgruSX4qtfleJJy8I0Q4U1EiBIx X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=connorkite@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787029995338158500 Add a memory_isolation property to CryptoDevBackendVhostUser and add add it as an optional member of CryptodevVhostUserProperties in qapi. This is needed to be able to specify memory isolation for cryptodev-vhost-user objects, and the bool will eventually be passed to vhost_user_init() in a future patch. Signed-off-by: Connor Kite --- backends/cryptodev-vhost-user.c | 28 +++++++++++++++++++++++++++- qapi/qom.json | 8 +++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-use= r.c index fa1f9b76d3..be8631446b 100644 --- a/backends/cryptodev-vhost-user.c +++ b/backends/cryptodev-vhost-user.c @@ -49,6 +49,7 @@ struct CryptoDevBackendVhostUser { CharFrontend chr; char *chr_name; bool opened; + bool memory_isolation; CryptoDevBackendVhost *vhost_crypto[MAX_CRYPTO_QUEUE_NUM]; }; =20 @@ -213,7 +214,7 @@ static void cryptodev_vhost_user_init( } } =20 - if (!vhost_user_init(&s->vhost_user, &s->chr, false, errp)) { + if (!vhost_user_init(&s->vhost_user, &s->chr, s->memory_isolation, err= p)) { return; } =20 @@ -392,6 +393,27 @@ static void cryptodev_vhost_user_finalize(Object *obj) g_free(s->chr_name); } =20 +static void cryptodev_vhost_user_set_mem_isolation(Object *obj, bool value, + Error **errp) +{ + CryptoDevBackendVhostUser *s =3D + CRYPTODEV_BACKEND_VHOST_USER(obj); + + if (s->opened) { + error_setg(errp, "Property 'memory-isolation' can no longer be set= "); + } else{ + s->memory_isolation =3D value; + } +} + +static bool cryptodev_vhost_user_get_mem_isolation(Object *obj, Error **er= rp) +{ + CryptoDevBackendVhostUser *s =3D + CRYPTODEV_BACKEND_VHOST_USER(obj); + + return s->memory_isolation; +} + static void cryptodev_vhost_user_class_init(ObjectClass *oc, const void *data) { @@ -407,6 +429,10 @@ cryptodev_vhost_user_class_init(ObjectClass *oc, const= void *data) cryptodev_vhost_user_get_chardev, cryptodev_vhost_user_set_chardev); =20 + object_class_property_add_bool(oc, "memory-isolation", + cryptodev_vhost_user_get_mem_isolation, + cryptodev_vhost_user_set_mem_isolation); + } =20 static const TypeInfo cryptodev_vhost_user_info =3D { diff --git a/qapi/qom.json b/qapi/qom.json index c55776af7d..1024027195 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -350,11 +350,17 @@ # @chardev: the name of a Unix domain socket character device that # connects to the vhost-user server # +# @memory-isolation: disable direct access from vhost-user back-end +# to guest memory. The back-end will instead access data via +# bounce buffers residing in the QEMU virtual address space. +# (default: false) (Since 11.2) +# # Since: 2.12 ## { 'struct': 'CryptodevVhostUserProperties', 'base': 'CryptodevBackendProperties', - 'data': { 'chardev': 'str' }, + 'data': { 'chardev': 'str', + '*memory-isolation': 'bool' }, 'if': 'CONFIG_VHOST_CRYPTO' } =20 ## --=20 2.43.0 From nobody Mon Sep 28 00:49:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1787030049; cv=none; d=zohomail.com; s=zohoarc; b=ZDXuPEoB+Jh+hGZMNaswoeJp1yiM7TAxoGxUD1jaF0x/eyoHun9OhYAAng8rSe63JPkfb4GNvOyrjgA+SO3qVVLCB3ts/WQ4Qt8kFLbVeEZI/ucTubbT/DUuy6FHJznRxCwc5b8ceFfjHllURGseI3tNuKyqMEfY4o8/wvdIs98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787030049; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6J8o1AExw8TA5IVqQ+lEqAQiF7xrSW0tFYRCpllyDsY=; b=hqjYluM9R7CEDwi/bjWYTxjO6e32ujs/wcOdgI0TRjV15oup9rGpHYKs9jz8F2gj5AgzHO1Ik/jlL8VdhLlMD/UacUAQ3/nNusai5FYnc8OnFVz3tNGMzCn95DOFxN+OEDHmUZHZQGC8tstrxTkFMYH+VcFUgXFFYDXI6ZS09Ok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1787030049190692.1529856943198; Mon, 17 Aug 2026 22:14:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wwC8C-0005Rh-5e; Tue, 18 Aug 2026 01:13:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wwC8A-0005O7-2B for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:58 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wwC88-0003r9-BY for qemu-devel@nongnu.org; Tue, 18 Aug 2026 01:12:57 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-cbb7926836eso2998608a12.3 for ; Mon, 17 Aug 2026 22:12:55 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:d043:a40d:25c1:432c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-851b6fc0e84sm1031160b3a.43.2026.08.17.22.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 22:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787029975; x=1787634775; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6J8o1AExw8TA5IVqQ+lEqAQiF7xrSW0tFYRCpllyDsY=; b=lnhp3RU/N86Hk+dWTOU2sssIYc2nv2pXQuhLl/q6pDeEgD2s1k94Us5AF08Df0hFwh WedBlpvMxZhqPbGrb7Ed3+scU4cT5i4sQUc8megUm9weKN+dujGu290YG+COCK66e5Z7 f6Cy5dCOHdWxgj/lNvKvdp60oEOhRh8PrJj+YQSRqeRjsuSQm3Ajw53Rzv2GR3Wmw6bm Nt4KLIgTXJOWYmtCw41OtNjEzq6qHAbzej7ShK6fR30AQW1XOvnwPrGiIDznN4nOql0Z v/yn+yLt1TlQHyeGYGXHWK5Lo4v3FpIFgolJVqWYjB2hXBVZYdrY7qvmT9APyW1W6LVr hDKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787029975; x=1787634775; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=6J8o1AExw8TA5IVqQ+lEqAQiF7xrSW0tFYRCpllyDsY=; b=KKGn/zdYUqfiiEqAoELxnGpgBORNJQNxXog7Uva+ODZTobllc2qTJzY5QKFYiXngtq 9MjXd+uPcBdbSQp2NPdvd6DW44Jw64g8s/8N4zdbLTVCWenh45ltV4fhHoT1XdjLBngw l+ZbHKPBdFbxamv29QujjrSAW7hsRN9S+VtR4wBi+ZSQ77aLCCJt8d2RDwQ6FYuKBnW+ hr1MZU5KY6qDMCUNqN4eLtvvkuJEZ43IDCXqf+C9g8GZNP7WjQrFkFzhz2c3fGhJxiSN MMa7nmzXHgW654iPDN1b7uIORqOjXgEcOyFroSYVnke5KaohOc/CAWEJGS/f8o8p62sR iPxQ== X-Gm-Message-State: AOJu0YwNLaRgZQFS4BRccJ3WhNGzYIergLRuI2p5573+ixs0iBgE2KY+ xOH3tagS6xOXXhjkfZ350pT0Y2Dd8r3octRRe9kOh3W5Oh8HVdvpdNv3 X-Gm-Gg: AR+sD13PO0yzUeIksNItB6oPpqla+QhroeRgp2BppMdhAjfxNqcz4Ok0AtDRnJlyWUM SWUveSPcnN82AioWVJemqDygOWnNBCZD9dO/HSOmKt8kMC6nLwzvVoHJsYdu4pGEz1gzs5Ck+CI CsyGRkwoKZDwbP1C+A/RHRLyubliJ0dJ/abJzd2Eet2vbv1jtqz7cX3H9ybnQ4+cATfLBxzB+J4 xVW/g6bBNySJRCSi4oSZnSv4TuCIPwqy7xd/1NWPEogRNeFEBRHLk2SQnWFPhSCMNoE+jqMncLe LZdgDgY8wv4jIt29s6fdWdxyvZb8lYz2bzMnTtzpx/goPdXz2VTbiRfK4Hx8igbNP6DZS0mXUrJ LPaaLrG3QWhGr3GjTHfvxvkHKBltpO34i0SU7lfNkHzjWALweqVNH0cMthhiy8Va05kph3NbUWd HxYpdjTk3fY7spGn4SfZUsWoqxIdTk+8jMsm8z3HMLgC3bq2nhkzYzAXA2ULgedndhs8g= X-Received: by 2002:a05:6a00:950f:b0:84c:4b58:2cec with SMTP id d2e1a72fcca58-84fde3dcf0amr31788880b3a.15.1787029974889; Mon, 17 Aug 2026 22:12:54 -0700 (PDT) From: Connor Kite Date: Mon, 17 Aug 2026 22:12:28 -0700 Subject: [PATCH RFC v2 13/13] net/vhost-user: add memory isolation MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260817-vhost-user-isolated-memory-v2-13-948aae960abb@gmail.com> References: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> In-Reply-To: <20260817-vhost-user-isolated-memory-v2-0-948aae960abb@gmail.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Stefano Garzarella , =?utf-8?q?Alex_Benn=C3=A9e?= , Viresh Kumar , Gerd Hoffmann , Mathieu Poirier , Manos Pitsidianakis , Raphael Norwitz , Kevin Wolf , Hanna Reitz , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , Milan Zamazal , Akihiko Odaki , Dmitry Osipenko , qemu-block@nongnu.org, virtio-fs@lists.linux.dev, "Gonglei (Arei)" , zhenwei pi , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eric Blake , Markus Armbruster , Jason Wang , Peter Xu , =?utf-8?q?Eugenio_P=C3=A9rez?= , Alyssa Ross , Demi Marie Obenour , Connor Kite , 20260817233147.2867623-1-connorkite@gmail.com X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787029936; l=2866; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=c1m9/46t7T/yFXDXSgz1vdQxYZX3+5KvcmxIw/DGGZM=; b=0OBe+eR1e1pPM+zCBkIkB6miAajDaB38ytMDFbdnB9eJvtfYmOO9BXrKbFt1bsCkL8dbpqiAh mlqwoGnl/VzARSTOyl20AImpQij7EOtVhDZS+xLZvgRjJACXJyRYvKI X-Developer-Key: i=connorkite@gmail.com; a=ed25519; pk=xg/3N8AntFCYogaIgN5NC/KkT7UlZB6ktPIRliJ3hv4= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=connorkite@gmail.com; helo=mail-pg1-x52d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1787030049515158501 Add a memory-isolation property to NetdevPassOptions and NetDevVhostUserOptions in net.json. This property will be used for vhost-user devices to disable access to guest memory from vhost-user backends. Signed-off-by: Connor Kite --- net/passt.c | 5 +++++ net/vhost-user.c | 3 +++ qapi/net.json | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/net/passt.c b/net/passt.c index 35ec6ad6de..7bcd47ad32 100644 --- a/net/passt.c +++ b/net/passt.c @@ -741,6 +741,11 @@ int net_init_passt(const Netdev *netdev, const char *n= ame, if (netdev->u.passt.has_vhost_user && netdev->u.passt.vhost_user) { bool memory_isolation =3D false; =20 + if (netdev->u.passt.has_memory_isolation && + netdev->u.passt.memory_isolation) { + memory_isolation =3D true; + } + if (net_passt_vhost_user_init(s, memory_isolation, errp) =3D=3D -1= ) { qemu_del_net_client(nc); return -1; diff --git a/net/vhost-user.c b/net/vhost-user.c index b6ee9ed297..bd33decadf 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -477,6 +477,9 @@ int net_init_vhost_user(const Netdev *netdev, const cha= r *name, return -1; } =20 + memory_isolation =3D vhost_user_opts->has_memory_isolation ? + vhost_user_opts->memory_isolation : false; + return net_vhost_user_init(peer, "vhost_user", name, chr, queues, memory_isolation); } diff --git a/qapi/net.json b/qapi/net.json index 1a6382825c..add7cb5408 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -213,6 +213,9 @@ # # @param: parameter to pass to passt command # +# @memory-isolation: isolate guest memory from vhost-user back-end +# (default: false) (Since 11.2) +# # Since: 10.1 ## { 'struct': 'NetdevPasstOptions', @@ -250,7 +253,8 @@ '*ipv6': 'bool', '*tcp-ports': ['PasstPortForward'], '*udp-ports': ['PasstPortForward'], - '*param': ['PasstParameter'] }, + '*param': ['PasstParameter'], + '*memory-isolation': 'bool'}, 'if': 'CONFIG_PASST' } =20 ## @@ -685,13 +689,17 @@ # @queues: number of queues to be created for multiqueue vhost-user # (default: 1) (Since 2.5) # +# @memory-isolation: isolate guest memory from vhost-user back-end +# (default: false) (Since 11.2) +# # Since: 2.1 ## { 'struct': 'NetdevVhostUserOptions', 'data': { - 'chardev': 'str', - '*vhostforce': 'bool', - '*queues': 'int' } } + 'chardev': 'str', + '*vhostforce': 'bool', + '*queues': 'int', + '*memory-isolation': 'bool' } } =20 ## # @NetdevVhostVDPAOptions: --=20 2.43.0