Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2194494/?format=api
{ "id": 2194494, "url": "http://patchwork.ozlabs.org/api/patches/2194494/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260209073908.2125178-2-vsementsov@yandex-team.ru/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260209073908.2125178-2-vsementsov@yandex-team.ru>", "list_archive_url": null, "date": "2026-02-09T07:38:58", "name": "[01/10] vhost: move IOTLB functions from vhost-backend.c to vhost.c", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "0ef9ac0e4a776035cd9867df04c4cac6b65782ed", "submitter": { "id": 84116, "url": "http://patchwork.ozlabs.org/api/people/84116/?format=api", "name": "Vladimir Sementsov-Ogievskiy", "email": "vsementsov@yandex-team.ru" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260209073908.2125178-2-vsementsov@yandex-team.ru/mbox/", "series": [ { "id": 491471, "url": "http://patchwork.ozlabs.org/api/series/491471/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=491471", "date": "2026-02-09T07:38:57", "name": "vhost-user: VHOST_USER_PROTOCOL_F_GPA_ADDRESSES", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/491471/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2194494/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2194494/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=yandex-team.ru header.i=@yandex-team.ru\n header.a=rsa-sha256 header.s=default header.b=ISHpSFt3;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)", "mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net;\n dkim=pass header.i=@yandex-team.ru" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4f8c7P0vd3z1xtr\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 09 Feb 2026 18:40:49 +1100 (AEDT)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1vpLrn-0000oQ-Bg; Mon, 09 Feb 2026 02:39:31 -0500", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <vsementsov@yandex-team.ru>)\n id 1vpLre-0000mi-Aj\n for qemu-devel@nongnu.org; Mon, 09 Feb 2026 02:39:22 -0500", "from forwardcorp1d.mail.yandex.net\n ([2a02:6b8:c41:1300:1:45:d181:df01])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <vsementsov@yandex-team.ru>)\n id 1vpLrb-0004fS-AX\n for qemu-devel@nongnu.org; Mon, 09 Feb 2026 02:39:21 -0500", "from mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net\n (mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net\n [IPv6:2a02:6b8:c42:65a0:0:640:e1de:0])\n by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id CBE3F80751;\n Mon, 09 Feb 2026 10:39:13 +0300 (MSK)", "from vsementsov-lin (unknown [2a02:6bf:8080:129::1:13])\n by mail-nwsmtp-smtp-corp-main-56.klg.yp-c.yandex.net (smtpcorp/Yandex) with\n ESMTPSA id BdLXu72As8c0-caXWZhEF; Mon, 09 Feb 2026 10:39:13 +0300" ], "X-Yandex-Fwd": "1", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru;\n s=default; t=1770622753;\n bh=3kxGtFXbKikU8OlPh4Hj+Z2jzgQgrrcTkLfiKZ+gvMU=;\n h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From;\n b=ISHpSFt3/iOXd4SIspG3+CCv69dnxFPLDjm9TwN31tPByqWKAx/BRvZylaGM1JPzK\n eo/8+cUkvufGxAS+f2j9gYjPp6DtWwOOZvdy70JjCG7Dx3DomBIbIbKCcOvuv9Nk8q\n n57EpKFyv5on3uG8TWaU7NyWNDMU5ZzuEOrmLUzc=", "From": "Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>", "To": "mst@redhat.com", "Cc": "sgarzare@redhat.com, qemu-devel@nongnu.org, vsementsov@yandex-team.ru,\n d-tatianin@yandex-team.ru", "Subject": "[PATCH 01/10] vhost: move IOTLB functions from vhost-backend.c to\n vhost.c", "Date": "Mon, 9 Feb 2026 10:38:58 +0300", "Message-ID": "<20260209073908.2125178-2-vsementsov@yandex-team.ru>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<20260209073908.2125178-1-vsementsov@yandex-team.ru>", "References": "<20260209073908.2125178-1-vsementsov@yandex-team.ru>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=2a02:6b8:c41:1300:1:45:d181:df01;\n envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net", "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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,\n 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 <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "Move and rename vhost_backend_update_device_iotlb(),\nvhost_backend_invalidate_device_iotlb(), and\nvhost_backend_handle_iotlb_msg() from vhost-backend.c to vhost.c.\nvhost-backend.c is actually about vhost-kernel backend. But these\nfunctions are shared with vhost-user, so let's move them into\ngeneric place. Moreover, two of three functions becomes static as\nthey are used only in vhost.c.\n\nSigned-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>\n---\n hw/virtio/vhost-backend.c | 82 +----------------------------\n hw/virtio/vhost-user.c | 2 +-\n hw/virtio/vhost.c | 85 +++++++++++++++++++++++++++++--\n include/hw/virtio/vhost-backend.h | 11 ----\n include/hw/virtio/vhost.h | 2 +\n 5 files changed, 86 insertions(+), 96 deletions(-)", "diff": "diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c\nindex 4367db0d95..fea88afc39 100644\n--- a/hw/virtio/vhost-backend.c\n+++ b/hw/virtio/vhost-backend.c\n@@ -298,7 +298,7 @@ static void vhost_kernel_iotlb_read(void *opaque)\n break;\n }\n \n- vhost_backend_handle_iotlb_msg(dev, &msg.iotlb);\n+ vhost_handle_iotlb_msg(dev, &msg.iotlb);\n }\n } else {\n struct vhost_msg msg;\n@@ -313,7 +313,7 @@ static void vhost_kernel_iotlb_read(void *opaque)\n break;\n }\n \n- vhost_backend_handle_iotlb_msg(dev, &msg.iotlb);\n+ vhost_handle_iotlb_msg(dev, &msg.iotlb);\n }\n }\n }\n@@ -392,81 +392,3 @@ const VhostOps kernel_ops = {\n .vhost_send_device_iotlb_msg = vhost_kernel_send_device_iotlb_msg,\n };\n #endif\n-\n-int vhost_backend_update_device_iotlb(struct vhost_dev *dev,\n- uint64_t iova, uint64_t uaddr,\n- uint64_t len,\n- IOMMUAccessFlags perm)\n-{\n- struct vhost_iotlb_msg imsg;\n-\n- imsg.iova = iova;\n- imsg.uaddr = uaddr;\n- imsg.size = len;\n- imsg.type = VHOST_IOTLB_UPDATE;\n-\n- switch (perm) {\n- case IOMMU_RO:\n- imsg.perm = VHOST_ACCESS_RO;\n- break;\n- case IOMMU_WO:\n- imsg.perm = VHOST_ACCESS_WO;\n- break;\n- case IOMMU_RW:\n- imsg.perm = VHOST_ACCESS_RW;\n- break;\n- default:\n- return -EINVAL;\n- }\n-\n- if (dev->vhost_ops && dev->vhost_ops->vhost_send_device_iotlb_msg)\n- return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);\n-\n- return -ENODEV;\n-}\n-\n-int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev,\n- uint64_t iova, uint64_t len)\n-{\n- struct vhost_iotlb_msg imsg;\n-\n- imsg.iova = iova;\n- imsg.size = len;\n- imsg.type = VHOST_IOTLB_INVALIDATE;\n-\n- if (dev->vhost_ops && dev->vhost_ops->vhost_send_device_iotlb_msg)\n- return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);\n-\n- return -ENODEV;\n-}\n-\n-int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,\n- struct vhost_iotlb_msg *imsg)\n-{\n- int ret = 0;\n-\n- if (unlikely(!dev->vdev)) {\n- error_report(\"Unexpected IOTLB message when virtio device is stopped\");\n- return -EINVAL;\n- }\n-\n- switch (imsg->type) {\n- case VHOST_IOTLB_MISS:\n- ret = vhost_device_iotlb_miss(dev, imsg->iova,\n- imsg->perm != VHOST_ACCESS_RO);\n- break;\n- case VHOST_IOTLB_ACCESS_FAIL:\n- /* FIXME: report device iotlb error */\n- error_report(\"Access failure IOTLB message type not supported\");\n- ret = -ENOTSUP;\n- break;\n- case VHOST_IOTLB_UPDATE:\n- case VHOST_IOTLB_INVALIDATE:\n- default:\n- error_report(\"Unexpected IOTLB message type\");\n- ret = -EINVAL;\n- break;\n- }\n-\n- return ret;\n-}\ndiff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c\nindex e820c5cb93..c750b32617 100644\n--- a/hw/virtio/vhost-user.c\n+++ b/hw/virtio/vhost-user.c\n@@ -1906,7 +1906,7 @@ static gboolean backend_read(QIOChannel *ioc, GIOCondition condition,\n \n switch (hdr.request) {\n case VHOST_USER_BACKEND_IOTLB_MSG:\n- ret = vhost_backend_handle_iotlb_msg(dev, &payload.iotlb);\n+ ret = vhost_handle_iotlb_msg(dev, &payload.iotlb);\n break;\n case VHOST_USER_BACKEND_CONFIG_CHANGE_MSG:\n ret = vhost_user_backend_handle_config_change(dev);\ndiff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c\nindex 9bf932eaf9..3ee353dce0 100644\n--- a/hw/virtio/vhost.c\n+++ b/hw/virtio/vhost.c\n@@ -916,14 +916,92 @@ static void vhost_region_addnop(MemoryListener *listener,\n vhost_region_add_section(dev, section);\n }\n \n+static int vhost_update_device_iotlb(struct vhost_dev *dev,\n+ uint64_t iova, uint64_t uaddr,\n+ uint64_t len,\n+ IOMMUAccessFlags perm)\n+{\n+ struct vhost_iotlb_msg imsg;\n+\n+ imsg.iova = iova;\n+ imsg.uaddr = uaddr;\n+ imsg.size = len;\n+ imsg.type = VHOST_IOTLB_UPDATE;\n+\n+ switch (perm) {\n+ case IOMMU_RO:\n+ imsg.perm = VHOST_ACCESS_RO;\n+ break;\n+ case IOMMU_WO:\n+ imsg.perm = VHOST_ACCESS_WO;\n+ break;\n+ case IOMMU_RW:\n+ imsg.perm = VHOST_ACCESS_RW;\n+ break;\n+ default:\n+ return -EINVAL;\n+ }\n+\n+ if (dev->vhost_ops && dev->vhost_ops->vhost_send_device_iotlb_msg) {\n+ return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);\n+ }\n+\n+ return -ENODEV;\n+}\n+\n+static int vhost_invalidate_device_iotlb(struct vhost_dev *dev,\n+ uint64_t iova, uint64_t len)\n+{\n+ struct vhost_iotlb_msg imsg;\n+\n+ imsg.iova = iova;\n+ imsg.size = len;\n+ imsg.type = VHOST_IOTLB_INVALIDATE;\n+\n+ if (dev->vhost_ops && dev->vhost_ops->vhost_send_device_iotlb_msg) {\n+ return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);\n+ }\n+\n+ return -ENODEV;\n+}\n+\n+int vhost_handle_iotlb_msg(struct vhost_dev *dev, struct vhost_iotlb_msg *imsg)\n+{\n+ int ret = 0;\n+\n+ if (unlikely(!dev->vdev)) {\n+ error_report(\"Unexpected IOTLB message when virtio device is stopped\");\n+ return -EINVAL;\n+ }\n+\n+ switch (imsg->type) {\n+ case VHOST_IOTLB_MISS:\n+ ret = vhost_device_iotlb_miss(dev, imsg->iova,\n+ imsg->perm != VHOST_ACCESS_RO);\n+ break;\n+ case VHOST_IOTLB_ACCESS_FAIL:\n+ /* FIXME: report device iotlb error */\n+ error_report(\"Access failure IOTLB message type not supported\");\n+ ret = -ENOTSUP;\n+ break;\n+ case VHOST_IOTLB_UPDATE:\n+ case VHOST_IOTLB_INVALIDATE:\n+ default:\n+ error_report(\"Unexpected IOTLB message type\");\n+ ret = -EINVAL;\n+ break;\n+ }\n+\n+ return ret;\n+}\n+\n static void vhost_iommu_unmap_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)\n {\n struct vhost_iommu *iommu = container_of(n, struct vhost_iommu, n);\n struct vhost_dev *hdev = iommu->hdev;\n hwaddr iova = iotlb->iova + iommu->iommu_offset;\n \n- if (vhost_backend_invalidate_device_iotlb(hdev, iova,\n- iotlb->addr_mask + 1)) {\n+ if (vhost_invalidate_device_iotlb(hdev, iova, iotlb->addr_mask + 1)) {\n error_report(\"Fail to invalidate device iotlb\");\n }\n }\n@@ -1306,8 +1384,7 @@ int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write)\n len = MIN(iotlb.addr_mask + 1, len);\n iova = iova & ~iotlb.addr_mask;\n \n- ret = vhost_backend_update_device_iotlb(dev, iova, uaddr,\n- len, iotlb.perm);\n+ ret = vhost_update_device_iotlb(dev, iova, uaddr, len, iotlb.perm);\n if (ret) {\n trace_vhost_iotlb_miss(dev, 4);\n error_report(\"Fail to update device iotlb\");\ndiff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h\nindex ff94fa1734..57497e197a 100644\n--- a/include/hw/virtio/vhost-backend.h\n+++ b/include/hw/virtio/vhost-backend.h\n@@ -222,17 +222,6 @@ typedef struct VhostOps {\n vhost_check_device_state_op vhost_check_device_state;\n } VhostOps;\n \n-int vhost_backend_update_device_iotlb(struct vhost_dev *dev,\n- uint64_t iova, uint64_t uaddr,\n- uint64_t len,\n- IOMMUAccessFlags perm);\n-\n-int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev,\n- uint64_t iova, uint64_t len);\n-\n-int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,\n- struct vhost_iotlb_msg *imsg);\n-\n int vhost_user_gpu_set_socket(struct vhost_dev *dev, int fd);\n \n int vhost_user_get_shared_object(struct vhost_dev *dev, unsigned char *uuid,\ndiff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h\nindex 54862f9b44..b292e9f0fe 100644\n--- a/include/hw/virtio/vhost.h\n+++ b/include/hw/virtio/vhost.h\n@@ -403,6 +403,8 @@ int vhost_dev_set_inflight(struct vhost_dev *dev,\n int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size,\n struct vhost_inflight *inflight);\n bool vhost_dev_has_iommu(struct vhost_dev *dev);\n+int vhost_handle_iotlb_msg(struct vhost_dev *dev, struct vhost_iotlb_msg *imsg);\n+\n \n static inline bool vhost_dev_has_feature(struct vhost_dev *dev,\n uint64_t feature)\n", "prefixes": [ "01/10" ] }