From nobody Sun Jul 26 10:07:33 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=1784845881; cv=none; d=zohomail.com; s=zohoarc; b=Mih5HEFmvkFRHgfS7eXLC5KaP86yXxyLX3krMzM2bTTT5LbKJXB/2PXIarAZ1ZzvhQhrbiK3FR+0WB3t8gdGxz9dJmzRPuyU2eu/7dJB3x1Pz0OhUnmj6pC0YoI4+Sa7l9+lbEECcZ5nf5xwEq5ScGGmtLIpyLZB0EYrLPkCfmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845881; 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=ge2is9bxa8QPT8zBxqzfc1g20iEpKmetB42g/gCqBV9aU1ejBgRp1yJNZ/n9R+7J7gcPrluJ0W7RwzsHqIuRzLRXf810aIQ0R8ymh58+0MYfpZsCwQcBD28t/qdZaJecd8dsyeg0tZAkNk+qS4Wo3lqErrF9ZysdytMLOkDyrcU= 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 1784845881607948.891988403861; Thu, 23 Jul 2026 15:31:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1wJ-0004H1-U3; Thu, 23 Jul 2026 18:30:51 -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 1wn1wI-0004Ek-SH for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:30:50 -0400 Received: from mail-yx1-xb12c.google.com ([2607:f8b0:4864:20::b12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wF-0001PI-TK for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:30:49 -0400 Received: by mail-yx1-xb12c.google.com with SMTP id 956f58d0204a3-664ce3000e6so1050572d50.0 for ; Thu, 23 Jul 2026 15:30:47 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:30:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845847; x=1785450647; 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=JLCvQEML2N67nXIbDmvDG83TxL1ORPfo4u/7HMj/AEZDVklpmMi6bI7ZGCX/4Eh7FP 1o9caGa7fY0fG5CT83i1eh51gJ4SxEOkeQTj8niwhOj422PQCHdKmeKXoMr4gh/N0VB1 ouuDd062voUgIIoqkQlvGdg+fGt5ZfSBd9zf3WuS5u+ZX7JSuGV4flq94xQGXKSBp0na c+vKw9ebzlJys5DpqE4IjCavCD/N91SnBOUIXaZFoitpf/1iwA/k65Le2RrhNAMjRwHZ L60wGaR3bTsUzjLgnph38X4K+JoyhSB/U8d/4tvlHvr5bCn6Cb3ArlQz8UTkRCkYWXMS LgZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845847; x=1785450647; 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=AtRFJ1FPvEXetEVdsqKyVdM43aEaUbZJjnA5v9BJJcgtDg9+H1Dz/gH1tkDyoeQImv VkqFzJrTL61s/9yfqlZ26eoIEM3F1Au2yzvnFbieiKEb/mlq2QZdTdz94QgMMBYXyT44 tSn7rQ1NCxtwJiOd9ebHJd8HQOTYpfttogp82N/is9PgHM/ZU7tFCWUuYe/8V+ZFWTE1 ChxnlQqBRSBbburAnAZSeEaWBKVsHMy+Dtt9WAVNeBknuCiTxfZWr7K9fziCLkyG6JE6 5IHbnzrvfBCbi5ryPDCLCKiPmgHz7FsRDAsOszfD/I340KtXGOolXICqMlctVbM1/XSj v6sg== X-Gm-Message-State: AOJu0YxlheW6I4WM7bQFxeMwEzTnmFDYQ1vWVy7rw0S5Ck5uuQU3URqV sVjg2mBa1UJiBRRR5zoeFJEsaUv9PCMU7LXumK3TQu1VRNDOAGu+IfkP X-Gm-Gg: AR+sD13ruYRaVCOHOn8lWFDr9axx6E5EWPhyH/KnSMxey51QoSYrJylikdbqKUWr3Ji KNBmoo2i1QflVcxA4M4tuZI4eh90/Md8o3nEZWqb+z/oM7f6AjsXNuTeObQ4M5TqpTQIc6A6UGO SmfZ2/9Z5IOk58pGcqST81hqyyOeawUI1Ss9HMUNnPd2DZxXZxyYT3N0s3I65QLUx5wJ2Ow6QmT 71ROof/5+F+GqPc1gpT0Ukg+e+Bf72y1KCyi9XJHYjIZBNYNIa7dEtITpjKR5gcZq0+/ZXhS+Oh v1EbX/Ocpb4YLC/6kaoWCKW3iXdg7bzsr/JtEVgZVLpl6kV47+tUOanBGhzw0aGfE4jH+zcVGXY 4KZkWo+MROCpLte7QRHccnmgiIjf8rG4iqyhxD5iEUQI11erchxlPf6CJXy8+xMw6neSqecx+qY 7p3bDzCxs= X-Received: by 2002:a05:690e:2497:b0:668:2353:1585 with SMTP id 956f58d0204a3-668a4bc2664mr970417d50.13.1784845846663; Thu, 23 Jul 2026 15:30:46 -0700 (PDT) From: ConKite Date: Thu, 23 Jul 2026 15:30:00 -0700 Subject: [PATCH RFC 01/15] vhost-user: Consolidate chardev property definitions MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260723-vhost-user-isolated-memory-v1-1-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=8233; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=y46aEYYWs6g66G1yduLOZWbS9jprmJN0wGotjR+n/g4=; b=//WY7dSmSnB3vYw09xpugMmsjQh3QQRotc/Sm/xroedRqBJKHANludIn3yXkteT9VmhDUo2F9 RgBJ+b+nnEZAzVg7m+KzvXlHZiONuJjhqqtLr7tWJGPc6Oif6hkx8wF 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::b12c; envelope-from=connorkite@gmail.com; helo=mail-yx1-xb12c.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: 1784845882995158501 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 Sun Jul 26 10:07:33 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=1784845941; cv=none; d=zohomail.com; s=zohoarc; b=KDeXV0V4hwQseibcUhetMvujSFVCl5U6wWINrx4w4m7uQuKRmDmTo0b42vOPtAAy24d6IYzpTVcGhUVjySvy9eONt3aqwf48H/zUclho+H5bva+Sy/cgUdx4g682qpi9JVcNi2DGZu7kXgsA6XhGLi//FeG6aRaulqevRaTgDng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845941; 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=AVzyy6xZ5ydOSxUHCiFZ8bWfqWfIoo+z7BTzm4kXyz0=; b=LL6fgrcKKl2K8sDtZLQI6ox9W0pSfX3WsTCkBmKWs4oKJ8oDypOxcbMmfAHUaBXqRzML8hzx6yds2xMMc0b1LHrn/EDPScampd553M8JOiTelhaGG9Grj/z0cvezVxFYGMvzxE+IY6as5MQhaFFqpOkSj9vkHwD905HshJ7dmuM= 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 1784845941101270.2207485662385; Thu, 23 Jul 2026 15:32:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1wN-0004KE-6n; Thu, 23 Jul 2026 18:30:55 -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 1wn1wM-0004I7-08 for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:30:54 -0400 Received: from mail-yx1-xb131.google.com ([2607:f8b0:4864:20::b131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wJ-0001Pl-MQ for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:30:53 -0400 Received: by mail-yx1-xb131.google.com with SMTP id 956f58d0204a3-664b05d408bso1015839d50.1 for ; Thu, 23 Jul 2026 15:30:51 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845851; x=1785450651; 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=AVzyy6xZ5ydOSxUHCiFZ8bWfqWfIoo+z7BTzm4kXyz0=; b=NaskgMdBRwjBNWT5uYWg1pNJ0vuI/syhSSvxj62Ha3SiXdEDDXMeTaS1KnuOh05TZA NvxrQUluD8R5zVtayr8SzZCGoe0DY5QWXc2+dQ4Rl9hWzd60a2Wfmg0d2RYHGjEv9e1/ jDkWA/QiB5x76D+6A1NPPA7PMNeTo/6IiAPBS7qZPtN/y8thYVdXSSh3rWzVjJRClJ/p pDkEBe2jpCy46LUch649fhgAyU3xrDXbM6MohZXTaD66OYDPdoszug2hRRapd8eAQ6TS Fbbo2To3K15uIBwj/sBRuw5RR2EBjp9DaNpSEL5vaNnesb/pb8qkcZmaM7WqSyauggbV ka1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845851; x=1785450651; 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=AVzyy6xZ5ydOSxUHCiFZ8bWfqWfIoo+z7BTzm4kXyz0=; b=NYFaXMKR/KgLJr1bv5bn0lEAltG+hrLl2PbVUTebBOJo8/YhOxOXHxjbeTXn1I+rby Sq3cXYwS7b8I4qurVzNW1Kd/UuzCoAeu7G6G0v+XO1u3kWzjk/wUYxGUpIzyDhZsFiFf 5VRYPNYwob73gskA8LMp7nOqFtmB+lrionhBMi6lYVuE10DFdHYG2/GUtZJJbXrJC75W 8dZJG/4A+zweozOUzMWIpF9/tGIrYRxr7D+tqQFDb5bOw7eDsxFh4uZ0UbG7H+xuIto/ TwUyKqz8WbKozCHMzYl6J88ildPTp9xlZxSHqxjlPoxs1GtwWW4xTSwpGzMycl9tMrDa HA/A== X-Gm-Message-State: AOJu0YzH4F+OR8d4zB2cae+HlpbzdMVrxbJTFYTDhzoWro81EFzzgNAa R9yp7t5k6q8GKgsWezIP/tihZ9926V/d27bfIBsj0Ph7johk/B+FqUZI X-Gm-Gg: AR+sD10pDszRatb/54kTlya5IBtYaHAOhDaozBmABDZg3mox16lvdY2CeWVZzSapuNS NHQSZcrjouysC4vjeOsEmdw4o+Qp1JqclZROe++QHj+ET7gRlSZvtTNmUxcdl/tXRoeOGtS40xE cXjvIslCdfUnqN+PvyXc4G+5mOagyDkLFDi+ig0o2Rj68Z654i4bOrIRSPjmq84Ev3ONrgtUtA1 L8Cc8F7MYFe4Fh54nsP9ohCOo7wjX45V0y2EROuG0O1glW2KPmOQI8j3MSf5n54k7hALrNdRM5c SsG7lgb5pF+KZCyXHw5p7AHgC04OuFyIrUSfpWPPCf+JLVqL2NAq5eYbX03qB/5tZsJyuFmuAp3 cLNlzWiA8ToSO30kaqrUqaZsGsrDxC9+uAT8deAMI47bpiGqs+j9FZsFsFSidnoHN2+f1mBy9hC s8+6iXTAc= X-Received: by 2002:a53:a6c5:0:b0:667:b84f:e402 with SMTP id 956f58d0204a3-668a4d72958mr799067d50.50.1784845850482; Thu, 23 Jul 2026 15:30:50 -0700 (PDT) From: ConKite Date: Thu, 23 Jul 2026 15:30:01 -0700 Subject: [PATCH RFC 02/15] 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: <20260723-vhost-user-isolated-memory-v1-2-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=8255; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=XqOLo5frjAV4wg3rR/2wYEwsGon0SXS6Qu2Lm8kDZ9g=; b=igaD/fidgbsGc0CjOz/z1UUNIZCHaMg5VqOMnvLkV9N9Lk5yh9x2BcjZIrVD4lEK0h6wqWSEx vAjAQ9rpNBDCWY1aPyvxOovuk8WLb+r2oJgANcGyZX60CVMnopTsfXQ 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::b131; envelope-from=connorkite@gmail.com; helo=mail-yx1-xb131.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: 1784845942845158500 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 | 1 + hw/display/vhost-user-gpu.c | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/virtio/vhost-user-base.c | 3 ++- hw/virtio/vhost-user-fs.c | 1 + hw/virtio/vhost-user-scmi.c | 1 + hw/virtio/vhost-user-vsock.c | 1 + 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, 15 insertions(+), 1 deletion(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 2e5b3ae1b1..9830dc6c35 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -631,6 +631,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 57360898ca..6d0ede672a 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -659,6 +659,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 5070178dc2..c1a0393220 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -346,6 +346,7 @@ 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_iso= lation, 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 90bd2903db..d2a74a2860 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -409,7 +409,8 @@ 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 209993918a..3d980d814b 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -410,6 +410,7 @@ 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 02dc088ea9..d514d89392 100644 --- a/hw/virtio/vhost-user-scmi.c +++ b/hw/virtio/vhost-user-scmi.c @@ -287,6 +287,7 @@ 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 c2cd376e73..89aa789e22 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -154,6 +154,7 @@ 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 b9bad27c97..707612c3a4 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -277,6 +277,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 Sun Jul 26 10:07:33 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=1784845928; cv=none; d=zohomail.com; s=zohoarc; b=VQoF+5325ePIB9H16cWQleI0Y4nK3rAxfnhgaIg+JEYuMmrr70tKMmnT6d3RdUGNEQh3IfqfcpARDJH/9yrrUEoQ/3HW76moynQgtbQeQ+o6DVQr8ePHLqZBKtDjJza+kCRuSVT+Y95gv/e6P7N+1dfDztwtbKq8VQgfColSV2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845928; 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=dn72UNvpMJmsMe5tRQU7u6qlwqtNn/DM1PthO2EpZ4E=; b=eM7jfM5mEEAfKEMjUmDuUod/8P9yGnenCXHMJ6XW9ArNhFK5zZAvrkV2ku1A4+nPevxInglEgyYMRqknipJHn8BaGyVXRqfB2sXRt5bs3xXZK9aYLF+5EdMqW5d9terwh5KSo3X8xanOiGcD7H72hmi+jKCcGAyXgbvcA928kPs= 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 1784845928487446.0474420903198; Thu, 23 Jul 2026 15:32:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1wS-0004YU-KE; Thu, 23 Jul 2026 18:31: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 1wn1wO-0004Oa-GQ for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:30:56 -0400 Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wM-0001QG-Ty for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:30:56 -0400 Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-7dbcb505578so10172577b3.3 for ; Thu, 23 Jul 2026 15:30:54 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845854; x=1785450654; 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=dn72UNvpMJmsMe5tRQU7u6qlwqtNn/DM1PthO2EpZ4E=; b=ifEoxnG17r485xJldp09YfYpMmugAxhgv628jkRLCcw8Fn+QT4jRlGBR9+DeAJboKN xpijI0aWhWsW+SA9LdXkk0wEMAt5uHhjJM2W5ukWi726kWs3ZENhTd7QYgWsWSXv+Tfq 4kaWd9KG4bsWL9cwXju9DgvjzASUjrF+MQIzYKAFxZlf4SqFc3Yp8WK5NnMHbiJyFfgX f9mWGciW35gsfHx1Y/LfQVzhR3HOZgzxcvsMfVV92NVu3Yfo+IGDagmXB9ClFeB3n6y+ zTg8u1lSk2BrQD2rJi981ZZSgwmT1Y7tB+H0sOS5baOcGqtUVjIyoM+0WoQwRzTcAdEN lYRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845854; x=1785450654; 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=dn72UNvpMJmsMe5tRQU7u6qlwqtNn/DM1PthO2EpZ4E=; b=p+3BsK6JOOb5TxEc9YFnQCZFtWe0lCQRhd8xg0uyRE72GOhYOzIxZxEUBWI4MO74vB UfHGxm2wcdaw4yXP9UGPVSvj9HhSIL/7F0cqAf33edmsmtO1W4W5olrrXehU0nF8Vb4I yymZ2BDx0o9CPpASfNqVp/3y+dfa+JO9ghUfscyFG0pDIpA87pa0gqigGVlOgf+cTX5O Jn/wBR6fX7clvRoXJKOL/pUhcc5f5Zx6Xi6BcYai7P06KWke/ROryU+9d1KEcWRD/Hiq ZxRU8zslgc6w5LpB5FOJ9FZC3c2c5dDzWXAIMCPTgFSy0KRvFJmf5C0ocS2IrGCSkGGc TbKw== X-Gm-Message-State: AOJu0Yw+XT8VON4WcXPtU7bFPwX+Kdz25XULbTbjPPhBMpSd8j/Ag1qE sFuDJTlJT7CGhqBmRbdZ5cTpfF6Q8YrSILeAzgxsA3UhPnXRa7Vc7s2X X-Gm-Gg: AR+sD12KM+6YYdXMhIQqozrHWe5Q55DpvaGm0CurVNIXvC6It9FoLvEkEjv03OfZMFA DnA+FNcFWdfYu5QWKyj0AGXJiC92IO1jKGYD0td+PF9OzS+eroOUmEEkdD4FBQl9dJj0YsoA5h3 siazzx+Cewk2pp5+sxFuJRm5Sj3LZrDRC3XO0o3Yw2ykOT9pgvFgTcBySRdqnUqdER5uvhUHyMI M3YnPuQKv6qahT8Wv4yf/SMPZFraG04KTwFGRrNyWd8WSwTKl2u8+GHr1r6YQP/ye85Kja6kjeQ HgB2jlrkwzFfB0BxFytI2Zo5R0LPk67eZRYEz+B1AFtSXkjFQyZwvkH1ZBrXkjVD90eqqqSXGSs JSsqrjya9tqI40YFs4zgzPm4xM1Hbgy9zYwLqYMRcnzqXJNt3xkjnZ0Od64cSFHsyT/xNSs65e9 6Mac+DvNY= X-Received: by 2002:a05:690c:7343:b0:81e:84dd:213b with SMTP id 00721157ae682-81f4c36f62fmr13959557b3.71.1784845853861; Thu, 23 Jul 2026 15:30:53 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:02 -0700 Subject: [PATCH RFC 03/15] 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: <20260723-vhost-user-isolated-memory-v1-3-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=2812; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=u55pm1DDJmv5TyBlbSFATydrnGuQo+DHFoyjUl5G2XI=; b=TKXB2eR8dH4lHlo1pG799OEHZtgpI+vA0TcqAB661T4YwOkzPCVblVNFBDayPTk2anqinPips qyvcLjbXIxLB5oSrVZfjuyh2gM4AkJZud/hWSQw6WX2d4QaC2o04ymR 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::1133; envelope-from=connorkite@gmail.com; helo=mail-yw1-x1133.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: 1784845928926158500 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 | 22 ++++++++++++++++++++++ qapi/qom.json | 6 +++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-use= r.c index cc478d9902..e0547c5d40 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 @@ -392,6 +393,23 @@ 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); + + 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 +425,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..d7ca1b4203 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -350,11 +350,15 @@ # @chardev: the name of a Unix domain socket character device that # connects to the vhost-user server # +# @memory-isolation: disables access from cryptodev to guest memory. +# (default: false) +# # 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 Sun Jul 26 10:07:33 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=1784845962; cv=none; d=zohomail.com; s=zohoarc; b=E5XKFQoQcBSazbhOo89Q5itDod4qsRj/D67uiiei0oRhcH6pNioAn0ZpS6rDQJHkJAYZKfLniFg/35mYwM8YAeia8/7rGfLHB+AjjV68CuELRyt9QSuIRO8EVrGbeXpqVE48xXuClkVKb9YElKzabczu/yb+tct+0WDNuHHBqB4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845962; 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=RRQE/saYJaaESTpo7p1Xp5FIXQbHxoLdzskT04Eqn0k=; b=hvoKrRoBY0/7kVX8neLWFfJyKMU40BqTUnS6cVbBKnDf3CQJHHtf2jngAZDjkImoNrCr9NseJIp0FJ9PICCLe19I/Z5vZF6Py+Z8Cg8g1FG1/8kda1FRI/GrOgYpSgeauHiLZEWrThFbMq89aDgNNKRirfmlBVEsn+ZeJojnzHg= 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 17848459622581007.5874435554739; Thu, 23 Jul 2026 15:32:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1wU-0004cZ-4Q; Thu, 23 Jul 2026 18:31:02 -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 1wn1wR-0004Z5-R5 for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:00 -0400 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wQ-0001Qm-8e for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:30:59 -0400 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-80c5cb9a888so8517987b3.3 for ; Thu, 23 Jul 2026 15:30:57 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845857; x=1785450657; 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=RRQE/saYJaaESTpo7p1Xp5FIXQbHxoLdzskT04Eqn0k=; b=gzl5LaV9yA7687TEQpsBYeyM6sS/UAEcPF7+agjykjzV3NPH+mHwDNurVPZmwzTL2J Qz4hvJ3xlOU5A/mv28eUdmyABUqc+FJvNfjWlmVQLV/2yGIQ4/TUz21nDJysmEfvpoCO oPxQiPVGms3nVtog0uOTx2Itg9jDOaHksEI/g95Salhq0r8XwhSRUcy38fd4J3sDHE2s JYCi5//IC7PeVl39/sR1tzrBVM3YXeagbg2pKzKeheqOmsPJnEgLZQtyNpQIw8Qnc+ZP X+J1dpvbPnDdCzVBl7EBLBb2mVp0DOo9MnT91RG+eKJqa17hIvw0bVG8fgEtc+ICM86N XtCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845857; x=1785450657; 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=RRQE/saYJaaESTpo7p1Xp5FIXQbHxoLdzskT04Eqn0k=; b=kokchDB3cdYzKfn6Kil/MhJDPH+Ec0lCNSJSMQmZrRgerd+kQWXq+a93dxceJk/laJ vXpUa8pKL2hTP00ghRg1Khwdp3M3MJ1xwi2IW995Q924qXqlQBHvRDtmd4RgAQFaHAvf PiI9Y4NjC5FUfLyGiZGw3v5Sutastcz2M5B5BRUsEtADjybSf2r6SY/34ycOQ7wbE2Ff k6tfHqMnhgzhE4khJxnZZ6DssbWDJ76upEN98Owe9z1uyAu8mhB1J3Bb40baBwNaQlC6 bzfWJhlWkbGpJ6ayrd2gIH80y8qWsBPsoc5JzVpfs4oVmDLNxv6zwJMWDKlbw0xhR2jr aC2w== X-Gm-Message-State: AOJu0YwTU3bQ1boDlw9RZcm63a7p0R7r9JTxyXBA28WrZCWSfCnTTv57 ezg3V+PoG/rG1TNcKuitMAKkMpAxe7lMG79b31a1V2XiOBWiVScHSXht X-Gm-Gg: AR+sD12hwf9rsmwHhL/lE/Xpcv9xq5CIS5DkEMVX0B2zQb4OPGTArxgh0GTp/q3Y/bI xm2TTg2RT1NMY4bwV/GZ75owPl9a1rSzB4ZzO/LUgxqBBAz4f7VATcIcBHUCzd8nD70SkEXaHJQ 2KtpjBY/QfQdkZBS3dIaq1EhcLEP6lyP6z90AD6BtCL/JIfw9O5DrwueiQaD5x7nz+S0T3z830k UeQ3gY3tYo+gBlvyU9aD8XqGA7H6OL3p9Grh3td1X5wt+se/VtnNxHekngrSjaCUcrmZGn4A2RT xsKJuhu7B+QxGjhlFTE0Ky3Z2kbuPhV+m5X48qIym4HHdzWPtVAlD9Cy07FBXHtlmyS0FA5/Jv0 OBt9ZnZSocSn/knCdkHZm0Epk1/tbZ3i3rvG2qAL3SHcr4Aq0cMfbFKD9kJ0HcsmHTxnBMcEZTa f70UMxayc= X-Received: by 2002:a05:690c:3182:b0:81e:782b:72dd with SMTP id 00721157ae682-81f4c13eca6mr16234977b3.13.1784845857145; Thu, 23 Jul 2026 15:30:57 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:03 -0700 Subject: [PATCH RFC 04/15] net/vhost-user: add memory isolation MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260723-vhost-user-isolated-memory-v1-4-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=3194; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=kCaV9zgYB27gebvzRUkQdZHWZmFFifXRqsrHtdiCBbU=; b=0rwPPZPPdLUldxXIPlmWzZZKsluRInnn0dnYpM4AJ/dOhHa4yxaSxJ4BSpQYjWCEEu9du1NIy NSRYlfAYsUBD2crLSqh5DlOL9rL4m+ACeFxCaFF7hB2iYgq71VY6upj 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::1129; envelope-from=connorkite@gmail.com; helo=mail-yw1-x1129.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: 1784845962830158500 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 devices. It will be passed into vhost_user_init() in a future patch. Signed-off-by: Connor Kite --- net/passt.c | 7 +++++++ net/vhost-user.c | 4 ++++ qapi/net.json | 15 +++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/net/passt.c b/net/passt.c index 45440c399b..ce80186883 100644 --- a/net/passt.c +++ b/net/passt.c @@ -735,6 +735,13 @@ int net_init_passt(const Netdev *netdev, const char *n= ame, s->pidfile =3D pidfile; =20 if (netdev->u.passt.has_vhost_user && netdev->u.passt.vhost_user) { + bool memory_isolation G_GNUC_UNUSED =3D false; + + if (netdev->u.passt.has_memory_isolation && + netdev->u.passt.memory_isolation) { + memory_isolation =3D true; + } + if (net_passt_vhost_user_init(s, 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..8fa303f901 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -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 G_GNUC_UNUSED; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER); vhost_user_opts =3D &netdev->u.vhost_user; @@ -476,5 +477,8 @@ 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); } diff --git a/qapi/net.json b/qapi/net.json index 1a6382825c..4588c7014b 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -213,6 +213,9 @@ # # @param: parameter to pass to passt command # +# @memory-isolation: enable memory isolation. Only has effect if +# using vhost-user. (default: false) +# # 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,16 @@ # @queues: number of queues to be created for multiqueue vhost-user # (default: 1) (Since 2.5) # +# @memory-isolation: isolate guest memory from device (default: false) +# # 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 From nobody Sun Jul 26 10:07:33 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=1784845881; cv=none; d=zohomail.com; s=zohoarc; b=E8l0xEQPLzqqt9mCAF0EvP7WTxlZ21I3YVYivmHyRk/8LYCdADXPLuAKDhZry83nbwGXOVIwEBYPun0bExQQHRZ2zQwB281jOTgH0T+WEgEZWZZADcmiNe9/SVwSwMF3HVhdC9fWXO0zrrbLEdZo+VBIsanafjFv9GcsEoQDNS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845881; 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=/jjfgEle2QNh6JABBQuFrx8Xpr2yY+fX3Wnyut93Uas=; b=kYeus40kGpX/ewx9CRiAHD8LWMGJ8bpapqDEGcSbvO90yJCnH+0uxTCejX6zXAEcO5UtUtgIMNYIX3pDImUv48l8XwL1bVLxzJNqiIwpl0S5+WBMJuqC2gw7L3cMBapekQNwCKu2T9fvKb+x7r5ikv2MW35FRcT4I9toeu+1u9U= 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 1784845881320438.372515760953; Thu, 23 Jul 2026 15:31:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1wZ-0004je-AJ; Thu, 23 Jul 2026 18:31:07 -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 1wn1wW-0004f7-1I for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:04 -0400 Received: from mail-yx1-xb130.google.com ([2607:f8b0:4864:20::b130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wT-0001R4-Ta for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:03 -0400 Received: by mail-yx1-xb130.google.com with SMTP id 956f58d0204a3-667ef69424bso1095051d50.2 for ; Thu, 23 Jul 2026 15:31:01 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:31:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845861; x=1785450661; 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=/jjfgEle2QNh6JABBQuFrx8Xpr2yY+fX3Wnyut93Uas=; b=EL1yIK7wx4tUTG28UfXBDE2PWvMXwaxcr7U2RelSRYd80X/JmkQ9G//7ZOTQhVIf4I OmtJUIqtjSK4MGWbn3qCSMDjVtlZRDK6GqZoH3xSG2qNVoLxAR6phZtAat7EC6w9hbUr pu5PfeiMRs1aL70hVzJAkfkvX4yf3HsclsjeiH2lZ488iyGdmC68DtPC3sIPUjxR2AVr 12F9xGNePAPsQhKHTT24VIOsSfw5zBWs09JjU/Pi6NyOTXKaABWVqu2q8d7zM/0X971J lZUTSjZ82clQAbeBzhXu+qO5B1FYH+LyOYC2l4FIyraC2CspSJl6+1M/ahEk7SIUEuhl +sJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845861; x=1785450661; 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=/jjfgEle2QNh6JABBQuFrx8Xpr2yY+fX3Wnyut93Uas=; b=GcPsE0grbK757tqonaSXvyOSFj6IffbakNR89Ce5DsCuL9emPknKYpqWNaYsTdR+et I5nCg1Iu9PVm/kQdBhZVKXvOmSaXsY6J5SKdlMzGAnZF0OhZUA4A88qXN2WgGjnYrqGW 4Z8iAI2yHt3NJBsbFAIBKlLmh6fr1QgIylSxFL24FCt/UqELhPCjctFBW3p39BSVe5Nw A8EJelm6Xv7iGbS8p+FyvJusJ3dEYWJkKl7nRkSNHS3h6/NKjJRSLqn0wF9vLvOZSBqY jxE06KSpeFmUIfgh3h4c+XHhaJvEn7AmcXfqVjXZ0kD4XgSjDKhdQcWD71787CK/cpeX hGAg== X-Gm-Message-State: AOJu0Yxpfeltu+EZjYLzpU4t8AFUz39Q6RLibY3pOQa67z1TXiie33Qc YlffrT3nezSu6dhWhQx5EoljOuVFC4zd+mE/quXjUOygXVBGUJsOegfy X-Gm-Gg: AR+sD11wN8yO5IHrp7P9pXSVJVCzS7031Spw5MCKzmYReV8uQIDBUD6XLbWGraZiGsf AFiU8UzRzgxtrAJC7WWn6xfNnYBLGGbw4g1KJfNAYMAhg+JHb7HEIZX3Q/VId07xust5tQ/HqUs jA9vM4fZ1fIHkZTc6cPWf1ce2NCcIiLXdbJKf5EGixNbNhcFH9cXPkivChPNI0MH25BFoooXa26 3c0ZzE7PhVMNDl9GRGbFpZlnBCwh0HraAO+hSuHbBaUjCDjrI4WZQyqqIrdy2YvxoYjEQq8ScUu EN9c7FTP8hpJyUMyjyhgK3Xwpop6GYuOnRPhiN23aA3rzeP94CwAQJSf/YvCFKaXbRQdDcdBgSI 2hUXo8KHuzOjvoFhkW8wwwZpL+MSCKr39tZ2m8oxWDGWcwaysoAONpoK0vHwm8Fhlz3YUxTP/YE nGoc7TFgutT7bjc4TX5Q== X-Received: by 2002:a05:690c:6606:b0:80d:a249:4854 with SMTP id 00721157ae682-81f4c1ff813mr16496237b3.17.1784845860602; Thu, 23 Jul 2026 15:31:00 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:04 -0700 Subject: [PATCH RFC 05/15] 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: <20260723-vhost-user-isolated-memory-v1-5-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=12759; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=e0y3nCskpzkZj4kyMOzgDnBn6vCXRdmOknYla343ncU=; b=9XNaHkONueEdA25B/5J+uN0TnlB4RppQdOFG/3neXY5pVon5glSxUn9WVvpNe4x60XkvBStE0 6N0ri5d0aWHCjA0+jMHDIrLqNnDEV0Hq8XS3sfqWk4Wh5zRn4z+BkYQ 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::b130; envelope-from=connorkite@gmail.com; helo=mail-yx1-xb130.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: 1784845883028158500 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 | 13 ++++++++----- net/vhost-user.c | 9 +++++---- 15 files changed, 43 insertions(+), 23 deletions(-) diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-use= r.c index e0547c5d40..328d7fbdfe 100644 --- a/backends/cryptodev-vhost-user.c +++ b/backends/cryptodev-vhost-user.c @@ -214,7 +214,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, s->memory_isolation, err= p)) { 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 9830dc6c35..5c1a19eb50 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, + s->memory_isolation, errp)) { return; } =20 diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 6d0ede672a..b44c989f58 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -625,7 +625,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, g->memory_isolation, + errp) < 0) { return; } =20 diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index c1a0393220..5a19182f2b 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, + vs->conf.memory_isolation, 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 d2a74a2860..11864a3f08 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, + vub->memory_isolation, errp)) { return; } =20 diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 3d980d814b..07ff2a35e0 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, + fs->conf.memory_isolation, errp)) { return; } =20 diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c index d514d89392..2c1dbb723e 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, + scmi->memory_isolation, errp)) { return; } =20 diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 89aa789e22..33ab3b69e6 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, + vsock->conf.memory_isolation, errp)) { return; } =20 diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 517cc4ca71..f296b63fb9 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -3118,13 +3118,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..72b5787efe 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: disables device access to guest memory * @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 ce80186883..a3021f37ef 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 @@ -735,14 +738,14 @@ int net_init_passt(const Netdev *netdev, const char *= name, s->pidfile =3D pidfile; =20 if (netdev->u.passt.has_vhost_user && netdev->u.passt.vhost_user) { - bool memory_isolation G_GNUC_UNUSED =3D false; + bool memory_isolation =3D false; =20 if (netdev->u.passt.has_memory_isolation && - netdev->u.passt.memory_isolation) { + netdev->u.passt.memory_isolation) { memory_isolation =3D true; } =20 - if (net_passt_vhost_user_init(s, errp) =3D=3D -1) { + 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 8fa303f901..722ab20228 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,7 +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 G_GNUC_UNUSED; + bool memory_isolation; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER); vhost_user_opts =3D &netdev->u.vhost_user; @@ -480,5 +480,6 @@ int net_init_vhost_user(const Netdev *netdev, const cha= r *name, memory_isolation =3D vhost_user_opts->has_memory_isolation ? vhost_user_opts->memory_isolation : false; =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 Sun Jul 26 10:07:33 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=1784845883; cv=none; d=zohomail.com; s=zohoarc; b=DL/pA+ZvqM0ejhBZHFuNGB1QQq1w+czQyKsUC4lkl2GHrjHGMRCDImliPstsk9h0M0FdzpYyCoTshR9Uy8meDsZhx8AgcDWeRh2Fw2vXst5m8qNH9x8AW7ogGy8gQZYunhjPaTUut204jZYRm4oWjibcQjgGeviU/i8DDU7LKbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845883; 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=NcYm30w4l7Vli4IAxyKgucSKPfeiorfv7ej3+wDF8Ng=; b=nM4OdUzZ4Wx/7UjY4GAZxizL8Uo0arXsoRdx/z8AvUpm87vdHFD46gelrgXn9XYseMarjGip5eapl16zQy0dkDu6kmntwQvxkfl3Ul/dFrQ48zhWO2lGz3naLBVKT9rpQjMg5belpFB6+q+nif3xnwiDN/emEvrmnDkmMNHtjzE= 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 1784845883405391.8514009703222; Thu, 23 Jul 2026 15:31:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1wa-0004mE-MS; Thu, 23 Jul 2026 18:31:08 -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 1wn1wZ-0004k1-Ie for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:07 -0400 Received: from mail-yw1-x112e.google.com ([2607:f8b0:4864:20::112e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wX-0001Rf-Bx for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:07 -0400 Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-81eb41c1f1aso10182227b3.2 for ; Thu, 23 Jul 2026 15:31:04 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.31.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:31:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845864; x=1785450664; 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=NcYm30w4l7Vli4IAxyKgucSKPfeiorfv7ej3+wDF8Ng=; b=XcHxAtIQ7sbAsA1pypNc1v/cq+CXSi62xRDXm7afKUZ5YEyG0pt+OzlH+cdXyfoiWY LZLV0QvI+8sJjjYcN1XCf1eYxD5dlbzLr/HR67Ds/JowZiHibVTlld/6+VLXQZcj5BmJ g5SAeMrGvpTphjf10JloDiOXg5NVMEnbAWO5unn8Nf+eMVPFeZTEnbbn3mjGMRbaYf6D a27DlGetCD0e+bjiy4cnhAUZ+Ylha2mZNoyNTWXM5UD5lo2jvxjUh7w8GwvFbF4yUueU /tX4ZkN49TkI/2OWWaObt9EIR+BLveSOTXl8c8L5/NoXmmffvRwthJCwzgmT1lOqrsP0 /2Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845864; x=1785450664; 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=NcYm30w4l7Vli4IAxyKgucSKPfeiorfv7ej3+wDF8Ng=; b=snOJZD8fM7hyjm4Gxh5taxZzfFKMg0CEbrnNfzIDcYI0lMloQVlDGsHTUBJwdRtTRJ ceSOyxnJlPBxN13pv5XgoJlmGKV604BlmAOjjQfiPE/frElITlE2dYNYfV/FTtmgwa9e ACmAhIQSJwHkO1shzEUT6mhdx9hla27HmOWg0MlTOYNec6iDvykWXHIkYmg/AZIhKl61 ufoveL15vc7+kFFIkWhoeAsAioqxrX5NUv6DnvesyvXC0EYkP13z9Bvb6rJRQpm9OM/d IJYpCQO+gPwf1ZW5Ioma/Q060xnj8hRHMGxKx3/LHhNbm72t2SKDTL8VWW/sohH3NvnU cLog== X-Gm-Message-State: AOJu0YwN6darADeD6oPKKfJNRJgFQSGcoDyBu/r75CgXtQ9TDmIfwm7A PzBSP5zYBT1lkXDu8XoVN+G1/pYBbAUN1zLLGNYyaIh+KDc14IetoJNN X-Gm-Gg: AR+sD11uSVUBXXSVNz7ayVhdsCkpFjHX2rhQDxcyjBuvqvN+77juUF4YK/aHFQe9ehv AIKsDQvOSQ2nIOKKYEroJY0axyrRp3uYh1NNIlNF7dtzidZPJsXKqGlDGOKRx+Mvdu9zBmrTgih 0skYMpKplzG/1EMgj8EIbOzaVtLn4vJ+vBszbblEPjAHUHKIKZSI1uSAPNMfknlSLVeoJwmwtZN TW8j+GD9Qc7G24IMs9TcBvL59GGs2JC9xyGam+gcqYStzo4vBCr3TLd6l46VyYE2q3pqK/4AWAj 0SQPWq6d9kpImvSP30EMzQvpKlJ7xosESzm7kVepRL3BWbjGp7LKRXYCttjw/jGh4WnBBqTGq1g VuoijIlkU0DOIhnVzjdnqOZrMufTLrsayM39izmX0KULoHDXg6FZ9sWcKxirsRMj2b3MYlthUjl vt2ZvJ2rU= X-Received: by 2002:a05:690c:23c1:b0:81e:9bcf:3331 with SMTP id 00721157ae682-81f4c308803mr15470147b3.50.1784845864063; Thu, 23 Jul 2026 15:31:04 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:05 -0700 Subject: [PATCH RFC 06/15] 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: <20260723-vhost-user-isolated-memory-v1-6-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=1380; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=4NYTmMM/tKQClf8Rfwd0s8ArOE7KiiEH3lfBWfSv8GE=; b=phRfMm78NGRBj6uBF6zMDcCEhyCfeowKCx4+ej3y94dVfM5n66RXMSPbK+UaifHytU6Sc8h5I VlIfEHiwhCVBrikoJ+SbUFScNgv+jfy0OCahLgR2lVACw5+ssxMOwlp 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::112e; envelope-from=connorkite@gmail.com; helo=mail-yw1-x112e.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: 1784845884543158500 Add a wrapper to iova-tree to call g_tree_foreach. Provies a means to execute some function on each node of the iova-tree. Signed-off-by: Connor Kite --- include/qemu/iova-tree.h | 13 +++++++++++++ util/iova-tree.c | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/include/qemu/iova-tree.h b/include/qemu/iova-tree.h index 14e82a22d5..4d77f4dc57 100644 --- a/include/qemu/iova-tree.h +++ b/include/qemu/iova-tree.h @@ -161,4 +161,17 @@ 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 + * @data: an argument passed to func + * + * Wrapper to call g_tree_foreach on underlying g_tree + * + * 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 Sun Jul 26 10:07:33 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=1784845898; cv=none; d=zohomail.com; s=zohoarc; b=Up+NFd8e+HSQsndNC6NcXW9u3fRtq4uQlG/i0RlVIQNJbA6u9Us6eZFTmTafHLwml6ZYWE4/XmefLHYBpM0pOe7v9PbkVUAJn3cY+4+VOV9MMd/Yc2ycrE0KbJWlnUMov+1GhBL0O9W9qh2eXLm48TD8PrY30au06v5NVLqJJAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845898; 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=0mhSD+dGlrr16JyRhT612XgJdqAQYtisMHkX7vK1jo8=; b=HxhM6wH3yy/kE0owfmXgpUHhNGfBSFj2lY/E4quH/K855tPvfgJkb88aaV5QW/liQ8Re1MpVLXep6ULTU99gbpY3EajkpiaN7KQpDlAhBlvlTVOz30IH9xJaeof9x6X2D5prPqmMTGM0gKkDyM3lP0FLQO27zYLmnaVlgtMiiYE= 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 1784845898497267.5934298668467; Thu, 23 Jul 2026 15:31:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1we-0004ox-UA; Thu, 23 Jul 2026 18:31:12 -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 1wn1wd-0004oF-4r for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:11 -0400 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wb-0001SG-Ml for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:10 -0400 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-81e86df8987so10768947b3.3 for ; Thu, 23 Jul 2026 15:31:09 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845868; x=1785450668; 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=0mhSD+dGlrr16JyRhT612XgJdqAQYtisMHkX7vK1jo8=; b=V/ta2K6ExA8jE+q0p63YNPXcwmDT/lEl0FF8BcoHapYgA5V+fp2m24GsTyFtbmslDC l7qoc4cPSX3PQLG2jNBY2XwVDUpNDD8DJ6Dk0BXKaCdkkcSzWgwIeNOA1X90V6zHmH/G FND15VTLkbcBAdSi80Ocs07wR1LhNBX8laupVu5Lqi2ZN6XlBKfXl4EW1jHBGlu7JPnw ghRtHu5AH4pmhCTSoM/Txw/9ibuWO2zPVYJfycMSHQ1+zQ7fWxKejphucpXiK/Yd0ZoR nD9Q4cVw4CuC6VQIYmocBQqaOQVRTBoMHC0TVE44Wv8kyi74ugSz6Nsn65LHnoasQtSK K8Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845868; x=1785450668; 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=0mhSD+dGlrr16JyRhT612XgJdqAQYtisMHkX7vK1jo8=; b=ZYxlt9U2HFLxnzUF+lsYT4NPQR8NFg3boE6B6B2Ako8mmIpd7KPqrY5LJWwQIEuneK 0YTaD5taYoK6hmult33A79cWfCqZrESGj1nAMyhjPp0X9TbgvKQ/Mt+fSilomljSDO5q RP1G3ualLqWCe1y0t+ULj2Xb5Yyo7l2OiUZg5+jSPOEMFOxUnGrp2e9Vdel9u+Ko+Lv5 iDjotjR5B9WjBGQ57MZPmSe1Y/HOTsRvul9S+h+IBWFkABDwlRN1v36V1IDbirKa2r7z 3gdL/Y89E/lRpTZb5EjCK9VYlkVEW+rfuZVq2q4wZx34Pa3agKb58iCinMu4tmoHY4Rj 5x9A== X-Gm-Message-State: AOJu0Yy+wj3U4ET4j8Xv0iIOYC6AinafHZyJ5AaJdDS0nXWe74z6nL3t G32Qg3JXezIBs3BjXw3R1RUprlsTWhqCjcxIhzTFbhwomLPNdJDLJolZ X-Gm-Gg: AR+sD10xaOLO7f5WIh4EzFsFtPLYesJzYLa2345xw7saCnyJNaiGlsdSES6bo26T+qT bm234Rf1fcjQ/wYpIxgZy3E6FmfxNA8kNUv8paWygzrqbG7UbDxgf+ZxMtEkUR6xD11jkOnlc3y pRt0ZgvWbtwTH3Is6fZgDfIgYdRa27YDK1QqBa/zJ0lTpvABxj0tfxJxwZqC/eKUhyyXi19eR73 8EGO/IR9Ag/WN/Xvsw4gd0ct2amFZyFL3G/+//7oPXTCuRn4TO+JnGfrkRKlTo7L41M+/wLm6qV qGJftjukj1pIap/pqLZqcIv4FBOFOVTNpW4wx9tmLIw1VWAvUwc/mpi0LDjS1x7R0GaovXZfye8 cHSRWEt3mAyrarDka+YTPqw2mLC1posN1MF0CZ4nKb1L4l0E0R17cAbVFhnRAieMHFeA+LJQTcF kVCma2uTE= X-Received: by 2002:a05:690c:600c:b0:81d:6eec:fe22 with SMTP id 00721157ae682-81f4c31fc3bmr16487457b3.44.1784845868465; Thu, 23 Jul 2026 15:31:08 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:06 -0700 Subject: [PATCH RFC 07/15] hw/virtio: iova_tree_foreach wrapper MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260723-vhost-user-isolated-memory-v1-7-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=1785; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=Yoe4ouzD+Ga6/WRjo8rrhPx85XUfhnHf/hoKZtpa4Yk=; b=SHFDvD0FHkAmxfuGP0PJ+XhJubxb/9Wsa2vNeIpQYm30SiB9dn47KOyhBUjqLUHJCQAMZpONh 2Odk2TK5fDCBU7bFrC04DFy3SRr5uW7vINzO/2fA8K0BupPKKrrCzXL 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::112b; envelope-from=connorkite@gmail.com; helo=mail-yw1-x112b.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: 1784845900591158500 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 | 3 +++ 2 files changed, 18 insertions(+) diff --git a/hw/virtio/vhost-iova-tree.c b/hw/virtio/vhost-iova-tree.c index fa4147b773..d8206379bf 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 false return value ends traver= sal + * @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..f3b7c48cb9 100644 --- a/hw/virtio/vhost-iova-tree.h +++ b/hw/virtio/vhost-iova-tree.h @@ -29,5 +29,8 @@ 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 Sun Jul 26 10:07:33 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=1784845960; cv=none; d=zohomail.com; s=zohoarc; b=UHvkAnDFeLh9oiqHEc/AOrQ2XyMDRi1il6zP0ZsZUAvpTOLdv+0n/0d1qAJwCVF/txk5JMmMEV3FwHA3IMJOn3dQg6r1XXMaL8Q1vjV9eD8WbS83LcVGn1GbceqPfjk8dVdpTgmeeFati7T+Wo5ThfLrBqQfX0Thcgl1unwDdOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845960; 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=ylndD1RfSjtAui3jJeAFAbrXgRT2PYj5papIJW82wSE=; b=dkpfzfPlINQCk2pTi+5wX148ygiK+s3YB4f+YTiZY39xKxTYYhqGS+WH2VJDeg38nCr7w2SjK29x1/GMvOcxui9SRhhfcefLvvagbd6nLWZ9dacJTbCnWcglonE8dGSAzL9QpHShfaUaUFn0LhqTZkXZJ9zTIlQc2RyFpfEVdwU= 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 1784845960101821.8054157151228; Thu, 23 Jul 2026 15:32:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1wl-0004u1-4u; Thu, 23 Jul 2026 18:31:19 -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 1wn1wh-0004qu-FJ for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:15 -0400 Received: from mail-yw1-x112d.google.com ([2607:f8b0:4864:20::112d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1we-0001Sg-UD for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:15 -0400 Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-81ea0b7d137so7036457b3.2 for ; Thu, 23 Jul 2026 15:31:12 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845872; x=1785450672; 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=ylndD1RfSjtAui3jJeAFAbrXgRT2PYj5papIJW82wSE=; b=IX4yY04mMDb9HDofWBog6hBtvAA6SxwunYrqTyBo/yRfxp+ut/hWWIldUkISyIiGtn minZPTzpyX/6iG8Ijp0vYb2IUipxlJDMo+4MfFZEpax6KLZ792onnVoqDtOeaD1iJGRZ lHCHnib427xxdmcxVwzIu4AC3t+MrSzBxxH6tOxMO5J+90mCBHpxFdbelUFdmmXQwJSB HxduME+0dSouLeF9+mAaCnuwNQda4pww2xF5txhyQxWpDeGHNaeJqzjaKkhL0g8xVgp9 iwrmFSvj+EFPMxpyUh52+FIhtZQyPMhM+FqsFqEwnRCW+c4SILHxjRozgq/s9SsNerh6 aPaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845872; x=1785450672; 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=ylndD1RfSjtAui3jJeAFAbrXgRT2PYj5papIJW82wSE=; b=LeIE7tNffQT2SAyE9V1bcrlDOS7VktfNH+B2XphLbS7oaq4d2U3wFzeKKsaL61KmOp AEfVAJ90UEd2kO4Nu3WsIq5Dh/OOMUAJn3QF+XsfFsMbZbRyoyTmjdHp0GE7GGdWMnnl FJ9A6txC+zdE6bG7hGsJ5QgzH2UsasDv3HBitqOQjqG087rieqxoLaWg7xdZrcBPAPLv 89ZjKgqJG3s99qnmrz4+N70fzVLmxdunxRB5dPnaaIlAkEwxBPKMuykXt+2RH+D9RbL3 +Hxbe5l++Bk2bh8hcBfnuF7j2N0rpDx8kARKaZcV/Unsx0Vos08AFQGwpajVKhe4rFTo sIww== X-Gm-Message-State: AOJu0Yyrsjs+bB8WUX1NMlJ4FAbPfkMz6HVylXrAJNrPTSUjILbKJpjv eABGsfvkbzamSUdBwFh+wUyLf+EBj63EuyE7yx6keusAqNT5ystcDLNr X-Gm-Gg: AR+sD12p8fNEEY+mlhaXD816w66FB1IBY9KuSjt0hAJtA4WGPQkI4d922gZ2wUMtaWm evvAPYA0PJQa/fXULQ5rt2YTQplB3B7EdId5TnifM5k2jpn/dY4FjDWJ7gbAwbtvw4hyoHQVCVx cG7SCxD+uReoidXCoiMacjykgTxEYFiSK2yRWdoHjacM6uu89b/OHvIV13uc2pYItrno8b9AM7C Hb8gUtm+v8Nm2cXekJkJ0CVMgvdCjUtstUM5ZyEbBcyQP/ux8LEBT16hfexUBiqZBjnuU8FrbvA fTwnv3qLIu9qyTr6EYYpBbKnfWu6a5VQmDc0kXQd7Hzn7GisgouXpLSopg/pEmjdYCu43Z3ddXq Z+YFSw0GUtn/Xn087x8OBBFMfwvVTELsWM067qdkLcurpBDKMYTDvzEICwjgNL4lFMsb343l+pr +Nox4R0rXAz8yaFm1bLw== X-Received: by 2002:a05:690c:4b0d:b0:81c:c77b:3546 with SMTP id 00721157ae682-81f4c20e739mr14265437b3.21.1784845871777; Thu, 23 Jul 2026 15:31:11 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:07 -0700 Subject: [PATCH RFC 08/15] hw/virtio/vhost-shadow-virtqueue: used handler MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260723-vhost-user-isolated-memory-v1-8-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=2085; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=BA6x/hUTVMBTeCNDEULOcGlNa3xXcwfyjSTX82F/bvE=; b=7VfH4IA82HBRppUZ24zMa8oz1EFKQW87j2JcXhb+DAvu5J9rymFlCfor8xdKNfIFK5cl2i6Ds uyK7/eO1cXHDFKikVsmgO5gLq1g741DLSV+rBgLH3+eJYxsNttpni4o 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::112d; envelope-from=connorkite@gmail.com; helo=mail-yw1-x112d.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: 1784845960806158500 Adds a handler 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 | 4 ++++ hw/virtio/vhost-shadow-virtqueue.h | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index bcb7f2ffc7..eb86c1ee37 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -669,6 +669,10 @@ static void vhost_svq_flush(VhostShadowVirtqueue *svq, break; } =20 + if (svq->ops && svq->ops->used_handler) { + svq->ops->used_handler(svq, elem, svq->ops_opaque); + } + 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..ccfeee36d7 100644 --- a/hw/virtio/vhost-shadow-virtqueue.h +++ b/hw/virtio/vhost-shadow-virtqueue.h @@ -56,8 +56,22 @@ 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 + */ +typedef int (*VirtQueueUsedCallback)(VhostShadowVirtqueue *svq, + VirtQueueElement *elem, + void *vq_callback_opaque); + typedef struct VhostShadowVirtqueueOps { VirtQueueAvailCallback avail_handler; + VirtQueueUsedCallback used_handler; } VhostShadowVirtqueueOps; =20 /* Shadow virtqueue to relay notifications */ --=20 2.43.0 From nobody Sun Jul 26 10:07:33 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=1784845928; cv=none; d=zohomail.com; s=zohoarc; b=XT3WBIbTGS4chS941tBaDTrMavxsX6BIOXiQFac1+dCxQG+fef24CiB//TmjkHekajKdKv+vDqw14IXEgQbNFzglivSvp9gDQY9uV1UybyFzspPgf8q4NotnxYZ7y+mKb5x6ivdpCOAytvQoK5hwjgCe4ttN95Er1aTbT+f7kRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845928; 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=3daCLJ1kp7Y+iaqF144Ru8UeiZ4TA3+qTjsGJpJy0rA=; b=hjyLW8h2pd3lI2bVojZvUNk1QE26uWRZRaBle6IwMkq0VNrCW5D7rDBRMIY3q/Uujv65EgaNtU+2yIuy98JoALGdjXyjUrrb8V+lsbCTv3LKmzNZyJwOk/gUrr6XU04H6ktfkfS4SGPq3L1ZyFkzAL8VD1A0D4PmSxThi4zJJeA= 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 1784845928626243.39677792308976; Thu, 23 Jul 2026 15:32:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1wn-0004yv-LC; Thu, 23 Jul 2026 18:31:22 -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 1wn1wj-0004sk-Te for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:18 -0400 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wi-0001T9-9a for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:17 -0400 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-81e6f0b4610so8057007b3.2 for ; Thu, 23 Jul 2026 15:31:15 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845875; x=1785450675; 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=3daCLJ1kp7Y+iaqF144Ru8UeiZ4TA3+qTjsGJpJy0rA=; b=JYm9QQgyM5B1wbX3K+gpxBgJPnLd6sKHHh8gxuaBQNn8M9SNLAWF9lp5G7ptYqMjQL U+JTkWCzeOlR7qneUbqVz8Zr/GvYCuajyx+TwkbbnG8AWlwj0YHGFu1UfiS0pAHlpWq4 tY7KB1xn9G0s842pJdUYAY2bW78JThq1EAajViqVoC+IT5ouWqYGOilfdvaKWmXUubZP T2lJuZl6JC0GO2ILs+YYHrinq92oiirIbW933Kb5aTGToQulk7YfyUrz3Xnqxol4frKC op+/tlDuOZfwFQRTReYqLrCQAG939bhezDOEkou9jE+NZcCJQQaq6joB1AvICoXL92kh UX8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845875; x=1785450675; 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=3daCLJ1kp7Y+iaqF144Ru8UeiZ4TA3+qTjsGJpJy0rA=; b=GgEJ/KK4m7T7f0oSIpJJQ3jxV9rI4HZgD7kazZbbkaKEW/OvlWbwHuNRrBm7dAAACN 5Xm7BWDeBuatEkR3PWMCSkDK96ttFn3k+qrePgXyRHED3+GQGEnUUy2PSAqz3/FkL6Jj jWFLvEL8iBsA+mEqelK2Lqgf2Cxhae+zfEAdvYICwTO5jq60V84Z7pF905qQuPBz04Q/ HJDZWkD6gHNUOh2xWwqzOHjFky/5SI9wXgq5NbS6jwAfUSkW7S/A+2Ykqsa6Kj67h/UB p9uFSahC1pX9geigmRSc814ECpNr3410jKxqD9/Iq3ZEZQE1axc+edIcWlF50SjpSzhr LHHg== X-Gm-Message-State: AOJu0YwYQ5ES94j+6gLP7goZYqKU8F1CQvkBfJHSgBdAO/h6diV7xPIO fuLQ1pTEB9U1HT4O5hMfn3Q9uCjT9tMLIdXiGSuWheWcrIBGgKTHdIF9 X-Gm-Gg: AR+sD11ak1wTrQ48LzAUVe6yW4dSduSEyvx78sJJOYu/RCLyAFbjV36zIZW3Jh0e9nO 2XiKAW/cW0g5d8JpG6HA4MzoGpUdNrlDkXkji0roZ8z/wQNK4m5es/MbgZfB6xaoGPHaT/yTiJ2 6rurDDD1bu2+Rg9YopllTpJiMJbD0q6dE+XXvk/piTL96bwnzD1ebuO4XVMvgQmhVqUxZpkNUaW 6aIv1/67Zpga8FiOR9PUZdafElRqQGhY/9IuN3lOa2SJ/rzICEvAYlzFPGvthHpDxi3jvz2oVSO P6nNg+UHbYm5y9LvP3pv/WVB3HQeCRYpzVUxs1U9Q2JwXeoDETjz8vNSROvmf7vzCfnK+n2bSAs XMkEym7jQ90bSIxahbA4j3UZyTwA2/9RdpN7JIYj7OPh5PP12PYLfQ1gMWlzqaDfBljI+u52f1e 0OtSXSOXOD4YtBD7N9xw== X-Received: by 2002:a05:690c:c4e4:b0:81e:edfb:3194 with SMTP id 00721157ae682-81f4c351402mr14830007b3.59.1784845875169; Thu, 23 Jul 2026 15:31:15 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:08 -0700 Subject: [PATCH RFC 09/15] 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: <20260723-vhost-user-isolated-memory-v1-9-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=3241; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=jUAZQS3R6KxjXedQOFVXhZurjmT2dN3NOYDdWrU4F2s=; b=IWJbWb4oHeq4FxWn0jL2j3GKcWqBbUU4hHnG/ZyZI07odrLByCvEjJtwoFfYsgny3mm4atw8s /1LXUxIIArRCuPgCozwIugnJKZV1NTK95p5EDr/SbrWDmNMoWG6Tvc6 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::1132; envelope-from=connorkite@gmail.com; helo=mail-yw1-x1132.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: 1784845930748158500 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 | 22 +++++++++++++++------- hw/virtio/vhost-shadow-virtqueue.h | 3 +++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index eb86c1ee37..9e3c359f50 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -857,14 +857,21 @@ 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)); + } 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; @@ -929,6 +936,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 ccfeee36d7..39f69e6455 100644 --- a/hw/virtio/vhost-shadow-virtqueue.h +++ b/hw/virtio/vhost-shadow-virtqueue.h @@ -148,6 +148,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*/ + hwaddr *base_addr; } VhostShadowVirtqueue; =20 bool vhost_svq_valid_features(uint64_t features, Error **errp); --=20 2.43.0 From nobody Sun Jul 26 10:07:33 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=1784845949; cv=none; d=zohomail.com; s=zohoarc; b=NT8GT8PUl2TqllD1LMboil8u7nidMj9RNO89kwWXv3JXtrYZTfeTJe5ARuFSG3FxhXVybMyOUS2Mtcbd9M8lAbNpIJjY+OGeTqaZ3ynG1v05OsFaeqUNmWGrDwia1IaneVDgg5oRt7c+ZKUQyjpIuhoDAJVsz7ArAyKZCET/lKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845949; 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=ylRn09y+xnzIXfbeVocInrK2nRf4OiszJaVCpi6B21A=; b=XiGjEKwwv8LmiG0SBtxrpPXSVPEXP88+b8BCrmfwWfjFMRwrbY/qZurRhdLWr2x+8gmwmAt7dU17i43LlWu81y16g+gCiq+1CXRNXzd0L3l0/1tjrl499x4Xhf2knmotQBvAxjWNW1xol9/Luv/aC2b3s/EoBbPUkB6x2XtS2fk= 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 1784845949928138.74104805599518; Thu, 23 Jul 2026 15:32:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1x7-0005AZ-Id; Thu, 23 Jul 2026 18:31: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 1wn1wt-00054P-To for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:28 -0400 Received: from mail-yw1-x112f.google.com ([2607:f8b0:4864:20::112f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wl-0001Tb-BL for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:20 -0400 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-81ed073fed0so11628757b3.0 for ; Thu, 23 Jul 2026 15:31:19 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845878; x=1785450678; 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=ylRn09y+xnzIXfbeVocInrK2nRf4OiszJaVCpi6B21A=; b=jxL0mPej/CmVNqf9dgJXGeOKWoZJkpzM5NFs8LkkTzsI8i1KwvESu7O6cjiEErf/c6 CBA4rlDY9WbL55H8L2UlKyra2rusRlRjE5wdg46TiX+veT4kuc+bxX0DTdWDA9K1u0sm clrn1X6zFI+0JQDCO08JWhudx/85RMV8ooko1+yh36KtL4BeAa3W4q9twpOLoVTeeSQr VEk7w8TQrMoykNbA6FXN757bsxu3dCTTFxFpqL4JymUBkyHqhaWlWjR2h8AL/dewkocO NeCdfQ7WIgrjuXJQKXvwZhhl0RwAGcAODWaGs3EdcSAwxac+QNXyCLhrn3ZHEu2RPDxe uVjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845878; x=1785450678; 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=ylRn09y+xnzIXfbeVocInrK2nRf4OiszJaVCpi6B21A=; b=NtEqzgttOIAVvsrAAl0jMvl3G3M6qWQfFnjeI85x+4M+onxwmzMAYXh2KPO2lyTe2q rLVMQPFTCrvXN57fxyu01LU+dzStQVOAnwnRw87nyQ2Bc+qqc0U3QlNdi8vHYkpsvK+9 0rWDO07BNjtnNScfDujg2HJZs5h3Sp+mn4ZNrl370DjIJz3wt89G0uAvzjsgh/4YPkdU CHoHrmq7OsYAnb1nbrQDj0FzZTYiCY9QBVImtAx2Bdu6vJYfLPxyaCiGgUkNHgS6ciwX NJHHdIzPpTeAo19AlaGOgDqdzXsX0qgUcXMmkWp6KFn74rD5cJTVrPF0bPpP4V61wIQI D+sA== X-Gm-Message-State: AOJu0YzPVXiUjTlm3guorCUFFN6KKJCujh/6lZJSMSTAtnjdn/cugZQ3 UoM58afxpRehZi0VkMZ/D5tvWSlthw3Gt7HTLw70pFxQbJM+9UxhaYVu X-Gm-Gg: AR+sD10pVayv++LwE3dSBHhFdTJB92IbisNEMkb44jYXYNRGeveP9Nr4aaEy5YnClFf kffU8SYgG4AnI69ly+WZ3cGdNeV7vhe4KGmaiP2Qwp/83F3hCxNtPOHfJXtG1JTInUmmCLx1eWI 3pD7aKGhO4ejDFCsrnhcZOsS69X8NvAqYFl2uQMLv8QyB7E7+AJAZyv5+1Bc+4tHP+qCayY/fgA oL/akAho7bRvYNYMw1QeR+rxLksPCFBe1egmJHHrAT87LANEpGafmkZrRPDulVs2EBMkxmuhYRB +hRDLLVez9EC8m6SPnf9V67jfWB99CMdauBzenoQgnLmdoSL0Y1rNUCV4Nh0Sq0DwRgJxwMQoDU osZTV0USkbQIW1duZOj3pJqqrvatug89d37mnaYYpWtjSg0bZF84A1yahFFMlU/2WkvhpfGj4D+ BFL65w45M= X-Received: by 2002:a05:690c:3389:b0:81e:fd36:ff73 with SMTP id 00721157ae682-81f4c15ffc8mr15595487b3.5.1784845878437; Thu, 23 Jul 2026 15:31:18 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:09 -0700 Subject: [PATCH RFC 10/15] hw/virtio/vhost-shadow-virtqueue: range boundary in translation MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260723-vhost-user-isolated-memory-v1-10-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=1603; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=04f7EERf9vN/x+nrTxJ0MQEJIkC9u9fbifj56dOif+M=; b=i0fxAoQx7q77vNmc1kVFBCgRpGEUX6uEbuCl2hfAM5HOMSgGi3rgs4fhCEYoklxivGZougSSo 5KxRK6PnQIJCIWR78oY8lUaZCs3lbAecaSUbGRqQRgxdv8E1xNkqEzQ 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::112f; envelope-from=connorkite@gmail.com; helo=mail-yw1-x112f.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: 1784845950808158500 iova-tree expects inclusive range sizing when maps are allocated or searche= d. Currently, svqs use exclusive sizing when searching their vhost-iova-tree for a match to the region to be translated. This could lead to errors if the region to be translated is at the edge of an iova region. Fix this by reducing `needle.size` by 1 in vhost_svq_translate_addr to bring then it line with DMAMap and iova-tree convention. Signed-off-by: Connor Kite --- hw/virtio/vhost-shadow-virtqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-vi= rtqueue.c index 9e3c359f50..20e5c7d2f1 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -104,14 +104,14 @@ static bool vhost_svq_translate_addr(const VhostShado= wVirtqueue *svq, /* Search the GPA->IOVA tree */ needle =3D (DMAMap) { .translated_addr =3D gpas[i], - .size =3D iovec[i].iov_len, + .size =3D iovec[i].iov_len - 1, /* Inclusive */ }; map =3D vhost_iova_tree_find_gpa(svq->iova_tree, &needle); } else { /* Search the IOVA->HVA tree */ needle =3D (DMAMap) { .translated_addr =3D (hwaddr)(uintptr_t)iovec[i].iov_base, - .size =3D iovec[i].iov_len, + .size =3D iovec[i].iov_len - 1, /* Inclusive */ }; map =3D vhost_iova_tree_find_iova(svq->iova_tree, &needle); } --=20 2.43.0 From nobody Sun Jul 26 10:07:33 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=1784845951; cv=none; d=zohomail.com; s=zohoarc; b=Aw3GiXsfM3c3EfORndVpW516CgOBdFryCvnuWTqeRRBDCu9tkF6yPkFo7eRvPUkdKCaI3BswEiOZgtilVqGoj+NPHe44aQ8rZcZI6MuyvYWJ0NDRaXt7OTmpVggt2SfBMPoUYc+UEffjEhgxmbOnpxq4EjYH913jrcATy8B89fU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845951; 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=K2yffjOSvF7DKJc73OqN7e50BGgio3XnC3khWPJsclE=; b=AqPkF3EPtRaSaLIYcyKLjo/FrvJsVhAKGeFiTg9yflBC8T9vv/VuNt8Hb3I/4EdPVm3CYrCjvoMxiOxYrOo39rNOOjsC38AN4wD9NcmjNwXWIzEX3VjmnSz89sA2njROuYU5D/R8wu5V3vo5HQ305PiTuFLRtaVMURPSJLQzrqo= 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 1784845951497645.658995151492; Thu, 23 Jul 2026 15:32:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1xo-0005iB-2D; Thu, 23 Jul 2026 18:32:24 -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 1wn1wv-00055R-Hy for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:29 -0400 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wt-0001Tn-MJ for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:29 -0400 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-80cebd41372so10794047b3.3 for ; Thu, 23 Jul 2026 15:31:22 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845882; x=1785450682; 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=K2yffjOSvF7DKJc73OqN7e50BGgio3XnC3khWPJsclE=; b=XlozkjfSSOaV0m15bu33w42D2E/N60PCYwrwHqml5cPCpun+wtV++MZsrZyZ2KCbzC crSwt8gdQVg2sYJqQQSfkub2iJegTRdsCINDuYgG/f5NjjgnA0OmrexSMTgoRfl/z33U 9rNNs1EDncMAu2pN0piWMuSHef1EU5ZUyg6ImoCOJY0FoXf9XKVpeNDXx099+rVdHc2O m7wvYGylkcl5c5QwRFrcAGIeEBz257s9IT5x27ZMw60ShRk6rKNqva5RB2xtdTqNDF33 wfo8ci5TSOtEnVFTva0G0hWxHn88ryEV4byl5kIbk3D6mB7NntmNXW0mjJRO/VbVltIQ B0bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845882; x=1785450682; 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=K2yffjOSvF7DKJc73OqN7e50BGgio3XnC3khWPJsclE=; b=Z7LiJ1rYBbDq6oUXyZJbM30QvvvDCpzzMRHt+PiYt8cUt1q6UBc9384t5dSGsvFk7h 78AabO3uGU6SZIH5X6eF87sctSlp3SIY42lFLXlULu3XcdiRJe4nX8bLM2iuupDcv5G/ Hwp1oqaRU5s1PMV7Nmes3zwEKiKeieeCr+a6zzMBQ8v2sCTfGU2auOy0+nwK6mV0Z4z0 iPi2NRmpAbOcT2E4Ch26jtCsAKg5YjPSBShcJ6GQrNidq7JmhnP9DzVxPdHKqSVJNblZ c3IwMQt5NR6SXw/Hk1FZqzefpTr55uTGQvWN21qBnRkRu2weU4uwxuao+aohXtAjH+Rv O1Uw== X-Gm-Message-State: AOJu0YxnmPTVrbJ4BJcgFs8Hg8EybrhLSbL+3TxKtXJUtPT/0oFYNUaO ydKW+VlHt34JoNA9DbTKdFCYK6HmBwDDMUa/WYT6S8t7MxhvL93dfvib X-Gm-Gg: AR+sD11N5frcsHgSwm+0IT/X/2d1XtUFefO6S614x/ZCAYgmYR5bstMv97Ybx8b3VDc 2tvy8D/Eho2BW+iGPQxaA07a9O4a1RqheDzq5vdoZN23sCRPs5hlsCZbHQWsp+OS1DsqCwobfSU 5wppCDyoncxsfGRhyphj4iyxLyy7I6pRAZ8oeeSVmOgG+Xj272GucutO/Jt9rAB0ILtOjlW3Tfw axUQkO1iSuk7ddtZqwiWI11yvPy/KyvYAt3kySYlm+gr1zQdzRqoposslxTIiuhYHZ1BKkuJhns 5sfSf8d4fq5NZiAcg6jLp8gaBp4G+7/q2TdCKjpEnqd19AdxEAQZF5UvQEdVFSCFBvRUaC23PAg hmSIo16wlkr+5rHCfpvh5vRNGIDcrzXY/yTqgX/2O2mZ/2Uup8E8Wc2kJI0InptXb4IIVpMY/K6 QAHEZ7NAQ= X-Received: by 2002:a05:690c:6f0c:b0:80d:66b2:852 with SMTP id 00721157ae682-81f4c30bf1bmr16154247b3.44.1784845881639; Thu, 23 Jul 2026 15:31:21 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:10 -0700 Subject: [PATCH RFC 11/15] 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: <20260723-vhost-user-isolated-memory-v1-11-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=6829; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=wDscEQxvQqYDZSfNPahD+DjyKJ1NxmTiWn45TwBb6QE=; b=CJBOJE+xeUrGOcOb0j1TMC/d/upLE8YRQ1ckKJaYNdC/WEZqJNmR6hP/uMpLdIVbgQQT72fZk /+ilUmq3t0wBqEgT68PxM+KMmkpBKIL4XbZU2459hbbQ9BZRoTOIlhX 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::1129; envelope-from=connorkite@gmail.com; helo=mail-yw1-x1129.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: 1784845952942158500 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 | 129 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 129 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index f296b63fb9..710cf966f8 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,13 @@ static VhostUserMsg m __attribute__ ((unused)); /* The version of the protocol we support */ #define VHOST_USER_VERSION (0x1) =20 +typedef struct IsolationRegion { + uint64_t base_addr; + uint64_t vring_base_addr; + uint64_t size; + int iso_fd; +} IsolationRegion; + struct vhost_user { struct vhost_dev *dev; /* Shared between vhost devs of the same virtio device */ @@ -353,6 +362,10 @@ struct vhost_user { * by the backend (see @features). */ uint64_t protocol_features; + + /* Isolated memory data*/ + struct IsolationRegion iso_memory; + VhostIOVATree *iso_iova_tree; }; =20 struct scrub_regions { @@ -1109,6 +1122,121 @@ static int vhost_user_set_mem_table_postcopy(struct= vhost_dev *dev, return 0; } =20 +/* TODO: Is there any notifier cleanup required here?*/ +static void cleanup_isolation_regions(struct vhost_dev *dev) +{ + struct vhost_user *u =3D dev->opaque; + if (u->iso_memory.base_addr) { + vhost_iova_tree_delete(u->iso_iova_tree); + u->iso_iova_tree =3D NULL; + memset(&u->iso_memory, 0, sizeof(IsolationRegion)); + qemu_memfd_free((gpointer) u->iso_memory.base_addr, u->iso_memory.= size, + u->iso_memory.iso_fd); + u->iso_memory.base_addr =3D 0; + } +} + +__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; + uint64_t buffer_reg_size =3D 0; + DMAMap newEntry =3D { + .perm =3D IOMMU_RW + }; + g_autoptr(GArray) buffer_regions =3D + g_array_new(FALSE, TRUE, sizeof(DMAMap)); + + msg->hdr.request =3D VHOST_USER_SET_MEM_TABLE; + + /* In case of reset, clear old regions*/ + if (u->iso_memory.base_addr !=3D 0) { + cleanup_isolation_regions(dev); + vhost_iova_tree_delete(u->iso_iova_tree); + } + + /* Gather information for bounce buffers to be mapped */ + for (int i =3D 0; i < nregions; i++) { + struct vhost_memory_region *dev_region =3D &dev->mem->regions[i]; + hwaddr size =3D ROUND_UP(dev_region->memory_size, + qemu_real_host_page_size()); + newEntry.translated_addr =3D dev_region->guest_phys_addr; + newEntry.size =3D size - 1; + buffer_reg_size +=3D size; + g_array_append_val(buffer_regions, newEntry); + } + + int num; + size_t desc_size; + size_t avail_size; + size_t driver_area_size; + size_t device_area_size; + size_t total_vring_size =3D 0; + size_t total_mmap_size; + + /* Get space required for all vrings */ + for (int j =3D 0; j < dev->nvqs; j++) { + num =3D virtio_queue_get_num(dev->vdev, dev->vq_index + j); + desc_size =3D sizeof(vring_desc_t) * num; + avail_size =3D offsetof(vring_avail_t, ring[num]) + + sizeof(uint16_t); + driver_area_size =3D ROUND_UP(desc_size + avail_size, + qemu_real_host_page_size()); + device_area_size =3D ROUND_UP(offsetof(vring_used_t, ring[num]) + + sizeof(uint16_t), + qemu_real_host_page_size()); + total_vring_size +=3D driver_area_size + device_area_size; + } + + total_mmap_size =3D buffer_reg_size + total_vring_size; + + /* Allocate and map an anonymous file to hold the isolation region */ + u->iso_memory.base_addr =3D (uint64_t) qemu_memfd_alloc("iso_r", + total_mmap_size, + F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL, + &u->iso_memory.iso_fd, &err); + u->iso_memory.size =3D total_mmap_size; + + if (err) { + error_report_err(err); + cleanup_isolation_regions(dev); + return -1; + } + + uint64_t last_addr =3D int128_get64(int128_add(u->iso_memory.base_addr, + total_mmap_size - 1)); + + /* + * Instantiates iova tree sized to map bounce buffers and vrings to the + * isolation region in host va. + */ + u->iso_iova_tree =3D vhost_iova_tree_new(u->iso_memory.base_addr, last= _addr); + + assert(&u->iso_memory.iso_fd >=3D 0); + DMAMap *map; + DMAMap vring_map =3D { + .perm =3D IOMMU_RW, + .size =3D total_vring_size - 1, + /*vrings are allocated on tree first, so will be assigned base add= r*/ + .translated_addr =3D u->iso_memory.base_addr + }; + + vhost_iova_tree_map_alloc(u->iso_iova_tree, &vring_map, + vring_map.translated_addr); + u->iso_memory.vring_base_addr =3D vring_map.iova; + for (int i =3D 0; i < buffer_regions->len; i++) { + map =3D &g_array_index(buffer_regions, DMAMap, i); + vhost_iova_tree_map_alloc_gpa(u->iso_iova_tree, map, + map->translated_addr); + } + + return 0; +} + static int vhost_user_set_mem_table(struct vhost_dev *dev, struct vhost_memory *mem) { @@ -2681,6 +2809,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 Sun Jul 26 10:07:33 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=1784845979; cv=none; d=zohomail.com; s=zohoarc; b=mtDh1Pw7LxLxQ+46BpeErmsKS0vCC6/t/XbMB8PKpTVd7E0msl6+h+MeHmRpRCX6+PfcwQByrA3han/xbk186DLGYj327+hBsJqrg8C4vzSKnwh0lQTQcoi1dEVa2M3UTQYIlV0dqhkCBrV3HnpM2q8JCk47IiTn+CNNXn3F5mQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845979; 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=7g695DoaNeoeNqj+3zVdxB0K+XyGWJGyI59c0QJ8p1g=; b=L7ZY/VI8BxXTF78WS8jfVjrDZhm0oZgUAc67yuiY6Ck29URLesb704dxsA1bV8tiLZU1ukAnmyk/c1TYQasNlz+A+mjzMtjHngksCAV8gFBrqgX1fZz1ilxaOFhTcjhPW7TUDazmmIGpVBMXBwn3GlPDFkXGQb4w2nFkqxBKWcc= 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 178484597987577.09156816005316; Thu, 23 Jul 2026 15:32:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1xr-000629-CR; Thu, 23 Jul 2026 18:32:27 -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 1wn1wy-000579-6m for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:34 -0400 Received: from mail-yw1-x1136.google.com ([2607:f8b0:4864:20::1136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wt-0001Tx-Nv for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:30 -0400 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-81ec29f1d07so9905927b3.1 for ; Thu, 23 Jul 2026 15:31:25 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845885; x=1785450685; 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=7g695DoaNeoeNqj+3zVdxB0K+XyGWJGyI59c0QJ8p1g=; b=dq7XHKfua4R+QgGcx8uZ1Z1HQKdwA2Zgunh7lBqwonIgtF63viIsHuInqQwBobac4x Ooh9RdH0kg4rvt8aaR6m5p76vZ+PANyj00Ywg1N+5ncBFJLevPMWKUbcsqXPoPH6ZCa0 eWdicdum757OfqRQnVlDBC6uY5YJT5u4DhJHH7ngix6TiGAwPvVo+X0aW76eSiKRxg0K YJjoxmSxleZlwwsVlBzQBoemThc11M3S9MiZr32HDBOvyqNfCOIQwS8XU+6u+iRezB8z Wfv3Pk6fBxsN0/7XfwARn/O9dnSYRa1NChlvGaXIVWTLkdXe+2M8KFCzrPodTGk4D9xs E7ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845885; x=1785450685; 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=7g695DoaNeoeNqj+3zVdxB0K+XyGWJGyI59c0QJ8p1g=; b=IqQXl+luTO3uxWVEaSlD5aEOVICgqd+ghvs9cyKxH2zZhRSr6AMdOE3h6lIHvel2q4 g8lje6yY/acthjliKZvAhCImBF0HHcudS73U96gFdE+Jjl5ua75k2U5podI2YvJiYjrS kAgDowG7U0bA+Yi/x39UURlQLUOTBwXIa5PwT+fFfEaFd/vfFI94yQso8eOv6C6A2kw7 a7DABZTTQoha5nufAj2dTElDHiZiwLiYe9WUNTQoZRfDmt+uScKw0X8/77PGZ5EIrA3g oHIDuT7cjtUQK1ZZgdfT/bzAhWGJ9fr/QyY/MB31huPWhJr6Lk176a1lXYAIvARuwqoZ UwXA== X-Gm-Message-State: AOJu0Yy7+goBaV8hOB0wSyKrSJIB7vIPBY+A3J9kD8b2nkFPpJZM+yV6 A/DaFj8If3zuJiA7qttBWtQXqb5SpLw6RcE8MRPnVuvyGLwujJpgK2IK X-Gm-Gg: AR+sD10UJM/pXSd455Q4N6e+Zb7xLRmUBNoA3qfka7JU2M/XFMzir84JhpLlyzBZRKZ WrB31OFvjfnUw7WGa3E9wXIwg16dZT4rSnNS7xXZ0XpjRfc4n6Zet6OlsNrotpZe36G/R4EGq5S jfccd5DKpAmdGsjD0b3hfPbQPCRJ+VvYtPFTJhMYxiojNzkwTCfuM9GxDCOH72T5OWRDQFcn8uo ydGhZf8AsgB3H4KH+3rk8lxqaYiZHsW+URllwGyMXSN1syrq5OgW1eO5+x4WvS+AtXjwDW9LLTP Cd0caKuev0AED59dkzRXyTpiZj88LBm+TsPtfANL6vqe3PQPM0sjbSWtKXq0uXqR2bOJDbyjcGC fU0+KE6kxL7bqG4gaJbCwDOc3E4dTnKCDz2qcaIy8zXH8vo7GsqXMcDLdBUWFE3AOU0h7bbht+C ntxUJZ/Zw= X-Received: by 2002:a05:690c:278a:b0:81f:2825:dfe with SMTP id 00721157ae682-81f4c2f355emr15747807b3.36.1784845884775; Thu, 23 Jul 2026 15:31:24 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:11 -0700 Subject: [PATCH RFC 12/15] 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: <20260723-vhost-user-isolated-memory-v1-12-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=4517; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=z+Lm2PsZk3LkweDB1zsNiYheTgHWbAa+oQgnW46zMuo=; b=pAp4Enx1zJP2EmdbaCYBM7rhebwhPIOXdD1Yc0E2HneL3odB9pvotznN3IuY7YEaMfZ6Z4Xvw SENASOV6t7FB6hpNXkSnX5kK1VCIllzRwx1gCdT9gw6vMRQYk77jHMP 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::1136; envelope-from=connorkite@gmail.com; helo=mail-yw1-x1136.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: 1784845980985158500 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 | 80 ++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 710cf966f8..acabfb7f1c 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -625,6 +625,21 @@ static void vhost_user_fill_msg_region(struct vhost_de= v *dev, dst->mmap_offset =3D mmap_offset; } =20 +static void vhost_user_fill_msg_region_iso(VhostUserMemoryRegion *dst, + const struct vhost_user *u, + const struct vhost_memory_region + *iova_reg) +{ + assert(u !=3D NULL && dst !=3D NULL && iova_reg !=3D NULL); + uint64_t offset; + + offset =3D iova_reg->userspace_addr - u->iso_memory.base_addr; + dst->userspace_addr =3D iova_reg->userspace_addr; + dst->memory_size =3D iova_reg->memory_size; + dst->guest_phys_addr =3D iova_reg->userspace_addr; + dst->mmap_offset =3D offset; +} + static int vhost_user_fill_set_mem_table_msg(struct vhost_user *u, struct vhost_dev *dev, VhostUserMsg *msg, @@ -1136,7 +1151,33 @@ static void cleanup_isolation_regions(struct vhost_d= ev *dev) } } =20 -__attribute__((unused)) +struct iova_tree_traversal_args { + VhostUserMsg *msg; + struct vhost_user *u; + int *fds; + size_t *fd_num; +}; + +static gboolean vhost_user_iova_tree_traverse_funct(gpointer key, + gpointer value, + gpointer data) +{ + struct iova_tree_traversal_args *args =3D data; + struct vhost_memory_region msg_region; + VhostUserMemoryRegion region_buffer; + DMAMap *map =3D key; + args->fds[*args->fd_num] =3D args->u->iso_memory.iso_fd; + + msg_region.guest_phys_addr =3D map->iova; + msg_region.memory_size =3D map->size + 1; + msg_region.userspace_addr =3D map->iova; + vhost_user_fill_msg_region_iso(®ion_buffer, args->u, &msg_region); + args->msg->payload.memory.regions[*args->fd_num] =3D region_buffer; + (*args->fd_num)++; + + return false; +} + static int init_isolation_regions(struct vhost_dev *dev, VhostUserMsg *msg, int *fds, size_t *fd_num) @@ -1234,6 +1275,24 @@ static int init_isolation_regions(struct vhost_dev *= dev, map->translated_addr); } =20 + struct iova_tree_traversal_args args =3D { + .fd_num =3D fd_num, + .fds =3D fds, + .msg =3D msg, + .u =3D u + }; + + vhost_iova_tree_foreach(u->iso_iova_tree, + vhost_user_iova_tree_traverse_funct, &args); + + msg->payload.memory.nregions =3D *fd_num; + + assert(*fd_num !=3D 0); + + 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 @@ -1241,6 +1300,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; @@ -1268,6 +1328,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 Sun Jul 26 10:07:33 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=1784845987; cv=none; d=zohomail.com; s=zohoarc; b=SwKka07PtmVDwAXl1wtzSBqHzInNV+MTOhE7JfQpstUEhE+hD4wQ4CV/gP3mHWyoTq2UuQcEeDHkValCmEjBMKuh0rIXQLjSdqWUB5HEQu2dAL8HVMA4v9Hek4BQj+GkoypdRLAS+B/VkmI26Dpg2FbDuRLxMfA4M+d+kPGrAWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845987; 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=1QFQi4UgZC12C/rG3wGbIoCAr9m0fHFGugO6XfGTbqc=; b=bEkrA0mXQC4Cb5IeQSZk6xjqyIWoLyHkDKWiNuf2eTLdX5opO9G/sMZNx6ouewbVNzaiPhfip41v1zu/K20W06MGeyvpbRJEMxnZ8aps+plDM2opJ/EEzkSwYtFCCmOtHUPGGSBAgIiJ3e7Ha5Xg1dcXoA0mB9L0v0l4z5yb8qY= 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 1784845987906462.41450940191373; Thu, 23 Jul 2026 15:33:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1xq-00061w-KA; Thu, 23 Jul 2026 18:32:27 -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 1wn1wy-000576-6P for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:34 -0400 Received: from mail-yx1-xb12c.google.com ([2607:f8b0:4864:20::b12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wv-0001UT-DL for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:30 -0400 Received: by mail-yx1-xb12c.google.com with SMTP id 956f58d0204a3-667b0ced2d3so1083336d50.2 for ; Thu, 23 Jul 2026 15:31:29 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:31:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845888; x=1785450688; 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=1QFQi4UgZC12C/rG3wGbIoCAr9m0fHFGugO6XfGTbqc=; b=iHhzpPp19foWlaW/RPcFyhJP7lN1NHu2qPUuLWFitN4DVYP4zrSC3XqNHFTcXR1hQs jV1owfGCpPnvGusKiAEn7dnd6MyVMqiFcKo+6datBEtQ2Pk5xIPmO1PptkPyCMbvVBpq htfdVtfUCxqFQRgnKqp9bwFDYN9ryHwni3TRqqqke2OaalF1AfjVLM8vy1H+ntZJ6Gmq DOb6sjIGlJPUHFVj1YJeyPpbivHOTwtCk3/pbxRPOqgXgIWvGQ+tbmCgSIL2MhHuZKHL tGYctitxSKndOQ7QNO0oMTG+SAKW1eLjecyjjUhWVDxl9Lbk4uRcBBdEzzo1h1mu1tC1 j0LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845888; x=1785450688; 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=1QFQi4UgZC12C/rG3wGbIoCAr9m0fHFGugO6XfGTbqc=; b=XRSqwTUqHdSbF09vuOe3SQq3P1RmaKpGQ0ywff3b5blNtiBwyAPBewFC1uN63LsUY7 gtwttqTR2eHb1FNpSmg01v1RHEyYHkwZNBm1oA+6dXNA1gIG0Uja6caVoe6LGZLF0Aah Uck+TLMMaqB7vhWfCu8Jm4AXXGiqsGmgKsAfM4OyU8WZwdv2k5kJo7d1p1+qi3pcSz5K 6q4GjdiEvl8t2cEI244siw6HcAXY2TPlDMdJhWoIF0rBxRvUkj7lJ9HqyjOPXLwzM9/U UF47VjSzdP6gJKXt2zmbOen30o1/Cq3RBy4i39ugnB9aRyx1kJy9CoIVSldsHRKOSPik 2xcQ== X-Gm-Message-State: AOJu0YyG7MZyNdi/jiNFAfRNfaWZ/YxBjurLhr1UPsq6oNV1/IH2eT/D mvse08Gad8kcwhE5bgGG7pEzc6l+WDbXe82rE8Z6thSmAPD/LHzo8xAdz6nU2xbY X-Gm-Gg: AR+sD13mh9CgzKro+XlcUvlg+aI0VDqx1H68knwIJmN4mHAUx8G8W1vyeRozW+y1Rh0 RGRD907BiLaMqurjlfciNylKoQzEYgdSzFz1PAvJjIXq/fe48xjPGnwtgjOyC3twPFXYV/8vdux FTljMXv9gmhNIevqgGE3/jIz1F9Qv1SaHWtLCoUIcbjl9wz5avBoC+/+WxWOkoxerJY7Rm76YHe AR+FDbpbPmDoAaNuojJt6GQ2R/PnOklgTbHfR1gl8E7sj3gVRj298ssKnIHIo+t57zBBAbNIHUv 6VwL6hOmYayzJG3cpcWi4nVoykyHDpFHgJwsqFjkLTPmMOAU1FfZXOH/Gi4yYF5SznMmz26oeMS ZU/PCOEsY5otAj2wdfrL7ypblIwPAtGakI+gP9o6SefU/tSnPgDGWBfjNELFPFzv41Zrjy3ZL/r 5MVupEjII= X-Received: by 2002:a05:690e:440d:b0:667:8b90:3577 with SMTP id 956f58d0204a3-668a503789dmr898097d50.105.1784845888389; Thu, 23 Jul 2026 15:31:28 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:12 -0700 Subject: [PATCH RFC 13/15] 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: <20260723-vhost-user-isolated-memory-v1-13-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=4076; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=0C4OJBARAj4ugns9dH114UzMJ3emOVC06QOHSGg7dNA=; b=7Cr+Jh0PFvuHJMvhUkVdgwIL9XxTyQhNW5PzLn4DD5mzQ22Oj5OWhm8yQ2gn2Pvw9DNYMooA8 kVNl3CHuhXLDYIjyQp9zQdrRK2hiNrOOX2s3bPryNXpCM6/k9kMzka3 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::b12c; envelope-from=connorkite@gmail.com; helo=mail-yx1-xb12c.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: 1784845988959158501 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 | 54 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 54 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index acabfb7f1c..75858289a2 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" @@ -365,7 +366,9 @@ struct vhost_user { =20 /* Isolated memory data*/ struct IsolationRegion iso_memory; + GPtrArray *shadow_vqs; VhostIOVATree *iso_iova_tree; + bool svqs_allocated; }; =20 struct scrub_regions { @@ -1693,6 +1696,24 @@ static int vhost_set_vring_file(struct vhost_dev *de= v, static int vhost_user_set_vring_kick(struct vhost_dev *dev, struct vhost_vring_file *file) { + struct vhost_user *u =3D dev->opaque; + int svq_idx =3D file->index - dev->vq_index; + if (u->user->memory_isolation) { + VhostShadowVirtqueue *svq =3D g_ptr_array_index(u->shadow_vqs, + svq_idx); + vhost_svq_set_svq_kick_fd(svq, file->fd); + + if (svq->hdev_kick.initialized =3D=3D false) { + int r =3D event_notifier_init(&svq->hdev_kick, 0); + if (r) { + error_report("Failed to create kick event notifier"); + return r; + } + } + + file->fd =3D event_notifier_get_fd(&svq->hdev_kick); + } + int ret =3D vhost_set_vring_file(dev, VHOST_USER_SET_VRING_KICK, file); if (ret < 0) { return ret; @@ -1721,6 +1742,24 @@ 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) { + struct vhost_user *u =3D dev->opaque; + int svq_idx =3D file->index - dev->vq_index; + if (u->user->memory_isolation) { + VhostShadowVirtqueue *svq =3D g_ptr_array_index(u->shadow_vqs, + svq_idx); + vhost_svq_set_svq_call_fd(svq, file->fd); + + if (svq->hdev_call.initialized =3D=3D false) { + int r =3D event_notifier_init(&svq->hdev_call, 0); + if (r) { + error_report("Failed to create call event notifier"); + return r; + } + } + + file->fd =3D event_notifier_get_fd(&svq->hdev_call); + } + return vhost_set_vring_file(dev, VHOST_USER_SET_VRING_CALL, file); } =20 @@ -2715,6 +2754,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->shadow_vqs =3D g_ptr_array_new_full(dev->nvqs, vhost_svq_free); + for (int i =3D 0; i < dev->nvqs; i++) { + VhostShadowVirtqueue *svq; + svq =3D vhost_svq_new(NULL, NULL); + g_ptr_array_add(u->shadow_vqs, svq); + } +} + static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, Error **errp) { @@ -2859,6 +2909,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 --=20 2.43.0 From nobody Sun Jul 26 10:07:33 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=1784845985; cv=none; d=zohomail.com; s=zohoarc; b=JLLGVATK9ZFidDiVULKirMuywwWZizbj8J7ky0wXMN/3KEFIw7DomQcIKiEMKRgv1NXar+5qz/GiSbhimMK3QlsejDmlMitfgpHQX0agHVu8b4cjKKlMiH/L5ERWdUVEpNhmOHgBljV6jQq4H9/R4AgRiDW0Siq0cC6ga8pQnRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845985; 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=GKRiouieuWI1DwlbrQ7+GSIDGiapIP1YbqHrv02aXj4=; b=jgZxiy76eDjK/yEoBBbQ6mRo9PMaHMHFvxBa/lVOKdpuiU9JvZs7v7SETGh+IoGcz66nwNBxJCPb3wSISZj9SlAz7fm0PBKFq2N95GgUjkHtr3oM7kcLe+0ZaLFBiwrQvWHC2tqjcB7pAXjoHHSiGNqEbRX1qBPdGuHWVVXtkvw= 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 1784845985572593.9170359968304; Thu, 23 Jul 2026 15:33:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1xp-0005vw-0l; Thu, 23 Jul 2026 18:32:25 -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 1wn1x0-00058q-F7 for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:35 -0400 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1wy-0001VW-Jv for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:34 -0400 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-80dc4a68e4aso9925727b3.0 for ; Thu, 23 Jul 2026 15:31:32 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:31:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845892; x=1785450692; 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=GKRiouieuWI1DwlbrQ7+GSIDGiapIP1YbqHrv02aXj4=; b=HLW7l4FJ2kR3iH/wuj4vjGvkn3+7elKixqrxiwtSr4THGWO72KEq/bGk3IRuJxNdKR hfkqeKZ7UXGJJfJ3Z4L7BDwrVglIH/0bUCDBj2p1S/9+0w6bK7PP9526RtCj+CDJ7G/I Q8fvjn3HWAQrJaaZlwawxLhM4//nzrcB32Q94vvtXQUQbdwbg2kTdh0Q/HqysuIiWipS ZDF8y1C5qKeazPCNOlWeLGLyKzLUXgtnsA2xxrGKiOV/winQIYeK1D74qbAZDrMPiG1t U/mjaPAtzbN3Nw8mK7wZBq4jh399Cs5xmQ/hUdFEVclh3XSM2lGR+R1XZy6H6OoFm5qA 42qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845892; x=1785450692; 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=GKRiouieuWI1DwlbrQ7+GSIDGiapIP1YbqHrv02aXj4=; b=CY22VIe8qeI3aLKcZhkANLH859RsGBYdTImqbHKSNMFwTugG1mm+Yz31iz4ev8UNxN QHN0uQYjtCwTAbhQcKcC1dqzbQvB4pcQwe85Tf9i5FJBETE3/QYajxMSTMleVzMqunIR CI9Mq6LyIWY9TEXWVnWgRtLoIh5hrGfOk/0FbL6Ni7j0BG0wWwzBHjXs8DYi3BiWkOhZ W+R4FrAjxivRZ8nQDYtdu47boNaJaDOI2k4TGBWBXBEc/WeFeHdTnm3Dg8uxVT46/nuA p27tdkLuIw9uGQB5iy3kB5EURHLVjXQBG8+U4nJBj0xB74O0yNfzST/HxpwiOWv9u+KA YhWA== X-Gm-Message-State: AOJu0Yyyg4G0SiAahZgJDSOoLu5l1MbY5LFqdtKlwTpi/J1ekAUoqgpC K4S0thV9KxG8dS6Cdihf1bw8SL7m3x2xJ5YSDvS2xMwdv5kO2qWAAigW X-Gm-Gg: AR+sD11gCDlFz9NXSY1GcfuK7RHmmuT738yiSFYVQq0cmfPPvfI36ZT5RFdFQlZ+NZX LyxJt+aKCS84L82N/A/7gxfxNrheS/rWBNabMW57xIGNTTzP/3adfYsuDZ5mF4TQrGl9IYM+xBs mapPjaiTSktAarmdE+V5X+4jzClS5D3Z70BPbIWQU6BDjdWkp0p82tLqmjcfMJId3zCiEHbV2Ev tD4d6QVyKhIvOVM5rrsBHOa4BUCfFLbM4OfPedw1/JIx3PSfz/ynyu4pbKnLYF3y3LcXqJkKR9b x+Q3kjeq9Z0IHmubquidI6FEYML8DJqOM61PibX7o44JW1xaU64EgSl8hy8poKza+0o2tlaFvAg e+WmstwrLpXAWL7leb3cJ5dizNrOKzYgSCoVqz0XxpiQ5qhsupuFrFILvH02os1YR9qGDAFWy+N JD0g0/djw= X-Received: by 2002:a05:690c:9a13:b0:80c:85c6:898f with SMTP id 00721157ae682-81f4c385c3cmr17699887b3.62.1784845891600; Thu, 23 Jul 2026 15:31:31 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:13 -0700 Subject: [PATCH RFC 14/15] 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: <20260723-vhost-user-isolated-memory-v1-14-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=7740; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=xEeRhGfcKFx4bZNfrfgaBAeG54f3UIPcnr2JwcHSaLI=; b=VzOWwZdOmRpBpOwUSyJ1rwROwiQiEWqNy3EW+u9gkPrYwZlbAlRWoUYraUqQK9Fn3BTl94e7d hzYa7doD71DA7T+oDrfN0eQ5QP9hEWzssolfhzJrOpyjbl88vMHSY2j 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::1132; envelope-from=connorkite@gmail.com; helo=mail-yw1-x1132.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: 1784845986967158500 - 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-user.c | 167 +++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 166 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 75858289a2..e65f877f9a 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1299,6 +1299,97 @@ static int init_isolation_regions(struct vhost_dev *= dev, return 0; } =20 +static int vhost_user_memory_lookup(struct vhost_dev *dev, hwaddr gpa, + hwaddr *hva) +{ + int i; + hwaddr offset; + + for (i =3D 0; i < dev->mem->nregions; i++) { + struct vhost_memory_region *reg =3D dev->mem->regions + i; + + if (gpa >=3D reg->guest_phys_addr && + reg->guest_phys_addr + reg->memory_size > gpa) { + offset =3D gpa - reg->guest_phys_addr; + *hva =3D reg->userspace_addr + offset; + return 0; + } + } + + return -EFAULT; +} + +static int vhost_user_svq_handle_used(VhostShadowVirtqueue *svq, + VirtQueueElement *elem, + void *opaque) +{ + hwaddr hva; + int r; + struct vhost_dev *dev =3D opaque; + + for (int i =3D 0; i < elem->in_num; i++) { + r =3D vhost_user_memory_lookup(dev, elem->in_addr[i], &hva); + if (r < 0) { + return r; + } + + memcpy((void *) hva, elem->in_sg[i].iov_base, elem->in_sg[i].iov_l= en); + elem->in_sg[i].iov_base =3D (void *) hva; + } + + for (int i =3D 0; i < elem->out_num; i++) { + r =3D vhost_user_memory_lookup(dev, elem->out_addr[i], &hva); + if (r < 0) { + return r; + } + + memcpy((void *) hva, elem->out_sg[i].iov_base, elem->out_sg[i].iov= _len); + elem->out_sg[i].iov_base =3D (void *) hva; + } + + return 0; +} + +static int vhost_user_svq_handle_avail(VhostShadowVirtqueue *svq, + VirtQueueElement *elem, + void *opaque) +{ + hwaddr offset; + const DMAMap *map; + DMAMap needle; + hwaddr *iova_base; + + 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); + offset =3D needle.translated_addr - map->translated_addr; + iova_base =3D (void *)(map->iova + offset); + + elem->out_sg[i].iov_base =3D iova_base; + memcpy(iova_base, elem->out_sg[i].iov_base, needle.size + 1); + } + + 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); + offset =3D needle.translated_addr - map->translated_addr; + iova_base =3D (void *)(map->iova + offset); + + elem->in_sg[i].iov_base =3D iova_base; + memcpy(iova_base, elem->in_sg[i].iov_base, needle.size + 1); + } + + vhost_svq_add(svq, elem->out_sg, elem->out_num, elem->out_addr, + elem->in_sg, elem->in_num, elem->in_addr, elem); + + return 0; +} + + + + static int vhost_user_set_mem_table(struct vhost_dev *dev, struct vhost_memory *mem) { @@ -1772,6 +1863,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; + VhostUserMsg msg =3D { .hdr.request =3D VHOST_USER_SET_VRING_ADDR, .hdr.flags =3D VHOST_USER_VERSION, @@ -1779,6 +1872,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) { + if (!u->svqs_allocated) { + return 0; + } + + int svq_idx =3D addr->index - dev->vq_index; + VhostShadowVirtqueue *svq =3D g_ptr_array_index(u->shadow_vqs, + svq_idx); + + struct vhost_vring_addr svq_addr =3D { + .avail_user_addr =3D (uint64_t)(uintptr_t)svq->vring.avail, + .desc_user_addr =3D (uint64_t)(uintptr_t)svq->vring.desc, + .used_user_addr =3D (uint64_t)(uintptr_t)svq->vring.used, + .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 @@ -2754,13 +2866,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_handler =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->shadow_vqs =3D g_ptr_array_new_full(dev->nvqs, vhost_svq_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->shadow_vqs, svq); } } @@ -3466,8 +3583,56 @@ void vhost_user_async_close(DeviceState *d, } } =20 +static bool vhost_user_svqs_start(struct vhost_dev *dev) +{ + struct vhost_user *u =3D dev->opaque; + uint64_t vring_base =3D u->iso_memory.vring_base_addr; + u->svqs_allocated =3D true; + + for (int i =3D 0; i < u->shadow_vqs->len; i++) { + VirtQueue *vq =3D virtio_get_queue(dev->vdev, dev->vq_index + i); + VhostShadowVirtqueue *svq =3D g_ptr_array_index(u->shadow_vqs, i); + svq->base_addr =3D (hwaddr *) vring_base; + vhost_svq_start(svq, dev->vdev, vq, u->iso_iova_tree); + + struct vhost_vring_addr addr =3D { + .index =3D dev->vq_index + i, + .desc_user_addr =3D vring_base, + .avail_user_addr =3D vring_base + sizeof(vring_desc_t) * + svq->vring.num, + .used_user_addr =3D vring_base + vhost_svq_driver_area_size(sv= q) + }; + + vhost_user_set_vring_addr(dev, &addr); + + vring_base +=3D vhost_svq_device_area_size(svq) + + vhost_svq_driver_area_size(svq); + } + + return false; +} + +static void vhost_user_svqs_stop(struct vhost_dev *dev) +{ + struct vhost_user *u =3D dev->opaque; + + for (int i =3D 0; i < u->shadow_vqs->len; i++) { + vhost_svq_stop(g_ptr_array_index(u->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 (started) { + vhost_user_svqs_start(dev); + } else { + 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 Sun Jul 26 10:07:33 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=1784845961; cv=none; d=zohomail.com; s=zohoarc; b=N8HjOUC75qlzYlwl+j/eRKKXu3cVBMxszzlicp/ILva32Dt0PtycaKfyGpwSJPJ7sHg19haFeP/KPdwOVZHvIDZ7AgdPvy5+hy9+XWY23dLo+y6bAWqt+MUazBS5t+31Ifz7cZpsH8p4f0ka+diUEqMolxVTUdJ+x6TXVsjUS2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784845961; 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=wsH8kj/3dWv6cLIAPdQqtziw/Fcf/VIereTmaACRGrU=; b=LLV3L5iKhSXpnoIW8Oj7+QlXhIqWLYt1QDAOKpTmbyMHoipwxqlGsUGh6aiYUU3QwH0UkFnbmrV30PcMtLJDRv20qZaY+gzsL8C3NQ5PPiKZj79KCS97kwbwuGrxoqhsB+QvtSpcnSx1uMKy1OQsDJQsh+G92RRRZCMTcrQeIAc= 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 1784845961215859.1893419018464; Thu, 23 Jul 2026 15:32:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wn1xp-0005y0-7h; Thu, 23 Jul 2026 18:32:25 -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 1wn1x3-0005D5-Az for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:37 -0400 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wn1x1-0001W7-Pv for qemu-devel@nongnu.org; Thu, 23 Jul 2026 18:31:37 -0400 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-81ef8255cccso9579447b3.0 for ; Thu, 23 Jul 2026 15:31:35 -0700 (PDT) Received: from [127.0.1.1] ([2600:1700:e140:14d0:446f:49ff:37bd:d45a]) by smtp.gmail.com with ESMTPSA id 00721157ae682-81f33c3c1c5sm35766777b3.17.2026.07.23.15.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 15:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784845895; x=1785450695; 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=wsH8kj/3dWv6cLIAPdQqtziw/Fcf/VIereTmaACRGrU=; b=s52DGFvYW0L6VFYgbFawu57yhBYWC+CvQ1ET4aeZ0BdPYeDEXE8qURWcYv+GcyrjWi O5XBDLkWtfqo0cpKZLVwgcSY30NN9ux/9SEJt9ga/5lF+VoiwTuJ4TJl3bGBC7jGBual 3CUdo8MATKfjt4ro6UDjoYEMxlkoty/jdAZCt14+AebZIRavWC+AplKJSmmVulBheVRE fV1VqTlbBZZ3HAPF1y4m2JM91cr3qdfeSBY+WhVroaLTKJ1/2VL9+vWOOIqNWp0UYeyS dKSEvdrLW7rgldJNi2/RYm3eUEcU2TujZJ6z6Dz3ro5FAhgk7AXbFvqOcyh2Je4laolc G1eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784845895; x=1785450695; 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=wsH8kj/3dWv6cLIAPdQqtziw/Fcf/VIereTmaACRGrU=; b=eysOYviDQmigixnIkDOopJuDtmRVu0/WF3CRyrxGJ0I2PfdQhyMXwjhuQtxXvNX5yw 5hAY0Uty/gxfkv+6Lm1KBgGqqfxR7ZfEmnq/opN6dV6DOJWtaNqc2vIlHKa9tQbcmxQp hDJilHKq1HOoBXMw6h11kG+gDwRc+II5bKjbzUtWAOh/CS1wvJ4RmHnn1RnrCIbNFVPF LKhHvKahL6JPsTVL+pmmlJ0en3O0ojc0Y/73nHy5vys5h+7THOcLsZ5Pc+pWptgbDILK 1GmRoVklN0A0XiJs/WDR/I3kmVY4UuW5w+p7JMDZAdQMHjQBOBbKw890izIkp737vjeE NFmA== X-Gm-Message-State: AOJu0YxtqviOA1mvbdnuR5a+PNSRDzO21zAKZhlY9Zd4E6dwZKEuTa8g hJM2IEI5LVcughU9jznxuaSc5RiMsUCOXvCASn2q/DF8ST8uBgEjrH/0 X-Gm-Gg: AR+sD12U6ySnrdArPIrA7X1lsNPEhSKavXpo3L0w+1KHZn8IUFj1YGCEnbB34EdV0Qr QF8WGPY7ZmXKbx/MmOXTaUubo5K26pyJVmq5rbBFCUkvKC+Qkct8vkVK7Qx0ovDlDVTd95NkaRr vnfHVguyjwKjOuIE9UN4U/PWutOe/JWEvw3JWFnT1kriw0tSGAqOiMDmwYwRT9BXPNKCPJ7DRJx 8tbSgmZFbKUWVJm1NAVT44lAVA9ZCQGBz0ihWg0e7kTHwHtYS4X8APEdmW0tblrifxd3cszTDO6 oo5Jv/Lq+FjFbFhfXBhcX4KEGZoQGwhyAAlcAbZULFAcTI87XyrAmlE/PdAPjDptP31EeBO29wd OVaOO9hNm2Y6ZYJmxNn7rq2bzJIJZrXsF/eviLLk3yTzUFOt64VxCY13Wf5UF9HoplIRWLOrtrC ZNTOf3r6c= X-Received: by 2002:a05:690c:6e0f:b0:81e:fbcd:7d5b with SMTP id 00721157ae682-81f4c322550mr16240747b3.48.1784845894768; Thu, 23 Jul 2026 15:31:34 -0700 (PDT) From: Connor Kite Date: Thu, 23 Jul 2026 15:30:14 -0700 Subject: [PATCH RFC 15/15] hw/virtio/vhost-user: shadow vq cleanup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260723-vhost-user-isolated-memory-v1-15-6b97c439eb28@gmail.com> References: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com> In-Reply-To: <20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@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 , Haixu Cui , 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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784845839; l=1307; i=connorkite@gmail.com; s=20260723; h=from:subject:message-id; bh=pisgaTgm+ZiObME3tqs8+StA8fZGh7Ia1Av4+zrft74=; b=TKTPDfMHj7ZdjHO/ODp2CBOHuJLnh0vD84p1jGP0HewGtInAJEuyxPU1ExLs8Hpdj392t+hFk aqkNu70i+oaA+6Qkgwug3b6ISRANc5tQC0LoyjBr6aCpMgIFECkEtSD 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::1135; envelope-from=connorkite@gmail.com; helo=mail-yw1-x1135.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: 1784845962825158500 Implements functionality to cleanup svqs on cleanup of isolation regions. Signed-off-by: Connor Kite --- hw/virtio/vhost-user.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index e65f877f9a..bb4de78b95 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1140,6 +1140,15 @@ static int vhost_user_set_mem_table_postcopy(struct = vhost_dev *dev, return 0; } =20 +static void vhost_user_svq_cleanup(struct vhost_user *u) +{ + for (int i =3D 0; i < u->shadow_vqs->len; i++) { + vhost_svq_stop(g_ptr_array_index(u->shadow_vqs, i)); + } + + g_ptr_array_free(u->shadow_vqs, true); +} + /* TODO: Is there any notifier cleanup required here?*/ static void cleanup_isolation_regions(struct vhost_dev *dev) { @@ -1147,6 +1156,7 @@ static void cleanup_isolation_regions(struct vhost_de= v *dev) if (u->iso_memory.base_addr) { vhost_iova_tree_delete(u->iso_iova_tree); u->iso_iova_tree =3D NULL; + vhost_user_svq_cleanup(u); memset(&u->iso_memory, 0, sizeof(IsolationRegion)); qemu_memfd_free((gpointer) u->iso_memory.base_addr, u->iso_memory.= size, u->iso_memory.iso_fd); --=20 2.43.0