From nobody Fri May 17 11:05:14 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1682906617; cv=none; d=zohomail.com; s=zohoarc; b=IetO3/fNyD1m93Upao0Q56Ig2BUgTaustFB71MAsLfNuEJ+KIrZ+86RMFeQED9von1/56XQ3TD0iw8GOYhA74J7I3SwNgTg4HQQ/LWnYO1pFDWYbU2kX/bPA24wZvTJofSLtAj4CDaCJvvIWRUS3lHvty/nTgyVoYgfChFYKQVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682906617; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Uu05r/+K3irfDIVs7fuNdmkBiFU8/kzPnfrcMrQcERY=; b=Rykr0j4wNZIB9ev7gyqypMbKFJ+iZ6ix0jTGLLBhE6miJfWa0bRy0pKKfU43YRvTt+PbU3YKmosMNBvyenDCsA0YNA6LA81qojcvSZcRRu8LcrXV9l14zPvGa4gSnPbnh0Jmfdqxt4v6/Ko4x0VQvMZ/mcuxTTtX6lMYgVxor8I= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16829066176811010.9720331465754; Sun, 30 Apr 2023 19:03:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ptIsA-0003pb-14; Sun, 30 Apr 2023 22:02:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptIs6-0003p8-Gz for qemu-devel@nongnu.org; Sun, 30 Apr 2023 22:02:37 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ptIs3-0003Ek-Q7 for qemu-devel@nongnu.org; Sun, 30 Apr 2023 22:02:33 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4edcc885d8fso2507385e87.1 for ; Sun, 30 Apr 2023 19:02:31 -0700 (PDT) Received: from vp-pc.. (109-252-127-135.nat.spd-mgts.ru. [109.252.127.135]) by smtp.gmail.com with ESMTPSA id w7-20020ac254a7000000b004efe73ee01fsm3783271lfk.306.2023.04.30.19.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Apr 2023 19:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1682906550; x=1685498550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Uu05r/+K3irfDIVs7fuNdmkBiFU8/kzPnfrcMrQcERY=; b=Z4iV/adCxTqovc3jUUQpRrj6SxHjxVJsC7xhMSUNFu7JIfUmwHCppfdGKC5Ihs6T3b ng3Bx40r+hJNPFuaagJx9GeF5ZHmvJ24AkxqpaI4vSptaFZ7hqCNEENKL7FKk6hH149s bNMTZiRqf2tqWr0W+X0XtMYj5dpngK2a/eT+VYEizTnqYvLEePGZqfxVsSLhRbw1QWAi Er/J/Tnoq8s24GFzqfs6K7yfNXpfq2oUJmK0ryVKu4roigp/dOIJlu8noSEJ5J0q+Kao 2yZcdF2mXN83rFmBxg0VLWwpZvnNarBLTK7oLi/UOWXgLPaElL0jCYI4JyRRBN+1v4JD edBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682906550; x=1685498550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uu05r/+K3irfDIVs7fuNdmkBiFU8/kzPnfrcMrQcERY=; b=cFPVlLUa5LuAMhqKJiziZLBv4XSXYYEMnnacVj4cc+sOiQ24KkNlwC5rNMtjcyIVTr AfVIBAwMdGcI4y/eAcGmA1sFj7SdvSktyCYBnJmQ0cFYibVwPMfAbACjxfwWTN+StaJH Rkd4GwA//ds72tZsT0tPE3+tw3KR+oerGaxsXpXU9XL688GesCuusdbWnI1azz9q/vIj yO+gT0Gw3nahk2c+QBKaz+F/J94fpAsH38pROD90+w4H38184/LQwjvRAgKYERAe19VS i6TuCnT/dk/YO/6Edsym2afYaOYjHm7QZzx+CFG6xlWaqJMd8N1/Z6TQExlek2GmEDpt vKkQ== X-Gm-Message-State: AC+VfDy/kdGSTdlr3FUVjnt8KvwKcdSR/M/4Er1vI4SGWQW5grDj9WYe bVGqbjIeVV1OrfBdgz6os7EHyg== X-Google-Smtp-Source: ACHHUZ51URhgEBgB1Z5BziqDBmOb0w3F3USll/JoB4mbowkntLDJTrI9vgeUOslBSmoLfrxTsBr/ZQ== X-Received: by 2002:ac2:446f:0:b0:4dd:9fd8:3a36 with SMTP id y15-20020ac2446f000000b004dd9fd83a36mr3246542lfl.1.1682906549953; Sun, 30 Apr 2023 19:02:29 -0700 (PDT) From: Viktor Prutyanov To: mst@redhat.com, jasowang@redhat.com, peterx@redhat.com, marcel.apfelbaum@gmail.com Cc: qemu-devel@nongnu.org, viktor@daynix.com, yan@daynix.com, yuri.benditovich@daynix.com Subject: [RFC PATCH v2 1/4] pci: add handling of Enable bit in ATS Control Register Date: Mon, 1 May 2023 05:02:18 +0300 Message-Id: <20230501020221.188376-2-viktor@daynix.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230501020221.188376-1-viktor@daynix.com> References: <20230501020221.188376-1-viktor@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::129; envelope-from=viktor@daynix.com; helo=mail-lf1-x129.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1682906618668100006 Content-Type: text/plain; charset="utf-8" According to PCIe Address Translation Services specification 5.1.3., ATS Control Register has Enable bit to enable/disable ATS. A trigger function is called at the Enable bit change, so that PCIe devices can handle ATS enable/disable. Signed-off-by: Viktor Prutyanov --- hw/pci/pcie.c | 22 ++++++++++++++++++++++ include/hw/pci/pcie.h | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index b8c24cf45f..14ac1b0fb9 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1063,6 +1063,28 @@ void pcie_ats_init(PCIDevice *dev, uint16_t offset, = bool aligned) pci_set_word(dev->wmask + dev->exp.ats_cap + PCI_ATS_CTRL, 0x800f); } =20 +void pcie_ats_config_write(PCIDevice *dev, uint32_t address, + uint32_t val, int len, + void (*trigger_func)(PCIDevice *dev, bool enabl= e)) +{ + uint32_t off; + uint16_t ats_cap =3D dev->exp.ats_cap; + + if (!ats_cap || address < ats_cap) { + return; + } + off =3D address - ats_cap; + if (off >=3D PCI_EXT_CAP_ATS_SIZEOF) { + return; + } + + if (range_covers_byte(off, len, PCI_ATS_CTRL + 1)) { + if (trigger_func) { + trigger_func(dev, !!(val & PCI_ATS_CTRL_ENABLE)); + } + } +} + /* ACS (Access Control Services) */ void pcie_acs_init(PCIDevice *dev, uint16_t offset) { diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 3cc2b15957..f5571527d3 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -146,4 +146,9 @@ void pcie_cap_slot_unplug_cb(HotplugHandler *hotplug_de= v, DeviceState *dev, Error **errp); void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); + +void pcie_ats_config_write(PCIDevice *dev, uint32_t address, + uint32_t val, int len, + void (*trigger_func)(PCIDevice *dev, bool enabl= e)); + #endif /* QEMU_PCIE_H */ --=20 2.35.1 From nobody Fri May 17 11:05:14 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1682906617; cv=none; d=zohomail.com; s=zohoarc; b=QBBnYYr2Hk+gJDxXVKXuqfYDeLs9Qkg/0Zh3mc4E2Z9jS5ExUFL2DePsD2uvx4GtmW3PK0AJ5b9i8iBQfa+KSWEi8nJrEwIeQr+EpYPTI5HqKMG63HHMYks7LeZc6O5z8AgZwJb37XTuETduo2wGrdXj9KXATIMkI5MEs9a9q+s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682906617; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WiA/euj4PFXBRIwa4M7EpDNxjGMJvdT31Ee4wXwhwlA=; b=M3ONZZPmIv8uTokgB6pC3hGvG2o/1egAnoA/ryaoRVX5tbc0CVq33SBtyvohjWvLwMWJ4TA6sO6KGdJZn6fvRWknewvcgjP13tlUcR2q+RcbiAdqNwKQIbwU399ILjh8w08v7gJ0LoWP2WUEAKthEOencOHe24znHAInGDX9mZA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682906617721672.4065081028276; Sun, 30 Apr 2023 19:03:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ptIsL-0003rN-Pm; Sun, 30 Apr 2023 22:02:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptIsJ-0003qz-Uk for qemu-devel@nongnu.org; Sun, 30 Apr 2023 22:02:48 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ptIs4-0003Eu-4I for qemu-devel@nongnu.org; Sun, 30 Apr 2023 22:02:47 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4ec81773cf7so2428014e87.2 for ; Sun, 30 Apr 2023 19:02:31 -0700 (PDT) Received: from vp-pc.. (109-252-127-135.nat.spd-mgts.ru. [109.252.127.135]) by smtp.gmail.com with ESMTPSA id w7-20020ac254a7000000b004efe73ee01fsm3783271lfk.306.2023.04.30.19.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Apr 2023 19:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1682906550; x=1685498550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WiA/euj4PFXBRIwa4M7EpDNxjGMJvdT31Ee4wXwhwlA=; b=eUDOJwOvptzIkhSKcOaZe0JfwRYZWJ3+e+2ha2Ykyaulbv0np04oVk9LydGaljfScJ l/0lBDQ/Nf1gwRLmsBXF37aBfDKl3bb+E7QOv5vWq4TirhMSUDyiJ9lgWv1kdS82wCDz /lj+E2ToSkVW+qsrRefAnPSbG8/IsKufQE6hBBJEYFsJtyeL7XH1iWoNnSdIBonOhTUP ve4elyjIBHmRsV/b7BmvJUFlGRVWK7ySNArn8XbFSKXdt4+bRSs3KBOJoX5Zw/aYWxxl 9H5b6PkX7fAhljqzdjQcdvwLbfnfOdyRrzIUrZgKArh9K9Tw+Aq3l6Ai166onk/A3sQ6 cesQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682906550; x=1685498550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WiA/euj4PFXBRIwa4M7EpDNxjGMJvdT31Ee4wXwhwlA=; b=kTgmcc5K+Py+nR9wAKRTMh5a4XxYwy/1veaITgUOGMtJemkndmvyBYajaz+Vmkqa0H gEtTc0yOObnq+BzSiYWsJ4n7MKC5+oGEjAkngelemqGBDnu08tnhSfTeUVFoZbuyjFr/ luEfjrsxSNeJjKG6YZD8QDbW8YEkA+YJ5EaxcSpWIPA1cbmxy2tUkTywLK34tLzd2bdh CCMRbIB0+4g5URLwk3w9iaGK3UAkOXp0MJ+oC+SvPnJ1kKtXpFcAD/m1SDm+im25e2eG kr6Nu7mPyRgFrWUS/5l9N2oFLVf2cSVZGUPtZhcfIOIPdED9L2ywAfUC89hBYOvW5RKo UNyw== X-Gm-Message-State: AC+VfDzy6sHnG6kip/OrTzpaClo43Q7bMHbiqT9SAmTPyBR5bpE6hhYB BDsamsmROzMuDqD7bTLyrRibbISH8YwffSsmSLt55Q== X-Google-Smtp-Source: ACHHUZ7RrjBVxeiPnTBHmSCCLMfrXxm/8TnBZ0vXSriedUL3e/jPW6RvfN0do8qBW9XDI9H/K5jKMA== X-Received: by 2002:ac2:599b:0:b0:4f1:1e31:96a9 with SMTP id w27-20020ac2599b000000b004f11e3196a9mr341106lfn.51.1682906550658; Sun, 30 Apr 2023 19:02:30 -0700 (PDT) From: Viktor Prutyanov To: mst@redhat.com, jasowang@redhat.com, peterx@redhat.com, marcel.apfelbaum@gmail.com Cc: qemu-devel@nongnu.org, viktor@daynix.com, yan@daynix.com, yuri.benditovich@daynix.com Subject: [RFC PATCH v2 2/4] virtio-pci: add handling of ATS and Device-TLB enable Date: Mon, 1 May 2023 05:02:19 +0300 Message-Id: <20230501020221.188376-3-viktor@daynix.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230501020221.188376-1-viktor@daynix.com> References: <20230501020221.188376-1-viktor@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::132; envelope-from=viktor@daynix.com; helo=mail-lf1-x132.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 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: 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1682906618651100005 Content-Type: text/plain; charset="utf-8" Guest may enable or disable PCI ATS and, accordingly, Device-TLB for the device. Add a flag and a trigger function to handle Device-TLB enable/disable in VirtIO devices and hook it to ATS enable/disable for PCI transport. Signed-off-by: Viktor Prutyanov --- hw/virtio/virtio-pci.c | 17 +++++++++++++++++ include/hw/virtio/virtio.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 247325c193..ccd8c4efa1 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -716,6 +716,18 @@ virtio_address_space_read(VirtIOPCIProxy *proxy, hwadd= r addr, } } =20 +static void virtio_pci_ats_ctrl_trigger(PCIDevice *pci_dev, bool enable) +{ + VirtIOPCIProxy *proxy =3D VIRTIO_PCI(pci_dev); + VirtIODevice *vdev =3D virtio_bus_get_device(&proxy->bus); + VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); + + vdev->device_iotlb_enabled =3D enable; + + if (k->toggle_device_iotlb) + k->toggle_device_iotlb(vdev, enable); +} + static void virtio_write_config(PCIDevice *pci_dev, uint32_t address, uint32_t val, int len) { @@ -729,6 +741,11 @@ static void virtio_write_config(PCIDevice *pci_dev, ui= nt32_t address, pcie_cap_flr_write_config(pci_dev, address, val, len); } =20 + if (proxy->flags & VIRTIO_PCI_FLAG_ATS) { + pcie_ats_config_write(pci_dev, address, val, len, + virtio_pci_ats_ctrl_trigger); + } + if (range_covers_byte(address, len, PCI_COMMAND)) { if (!(pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { virtio_set_disabled(vdev, true); diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index f236e94ca6..83d07bb6b7 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -155,6 +155,7 @@ struct VirtIODevice QLIST_HEAD(, VirtQueue) *vector_queues; QTAILQ_ENTRY(VirtIODevice) next; EventNotifier config_notifier; + bool device_iotlb_enabled; }; =20 struct VirtioDeviceClass { @@ -212,6 +213,7 @@ struct VirtioDeviceClass { const VMStateDescription *vmsd; bool (*primary_unplug_pending)(void *opaque); struct vhost_dev *(*get_vhost)(VirtIODevice *vdev); + void (*toggle_device_iotlb)(VirtIODevice *vdev, bool enable); }; =20 void virtio_instance_init_common(Object *proxy_obj, void *data, --=20 2.35.1 From nobody Fri May 17 11:05:14 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1682906617; cv=none; d=zohomail.com; s=zohoarc; b=gA+IcToaoFBkvDvqacEeS/aNKys1wKOlLgDijueZKHtCN+31TNLIFWHVEZ7fHtLDrtjfxukBJX0wXacII8TM2cGTV+BhL1xX81VrskFh2ks2raPEUYY0BZyalCOsjjPau4dhedEjg8/2ly/sBz3UkFMVZxz+4gvzhNM1ctc5JaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682906617; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KuoPIrbz1UnCVJ8I8IFQYEA36M+uyHB848AT63FYSIs=; b=FxwFcYneYc9V5g1N2YgArr4szXMaQlriS8p5z568nJGYygBnrtn+AVfpqSWjhngZ7ONyAs39h1yN3LKDEhnC2vTrWyjVnnE4VCwqHmWx8Zskn68d4WghxgIC86tMxo4MFmTFfjG0lXC494gEJIHaL443cplYJWgxvGK3H3e4cg8= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682906617783785.2495891701662; Sun, 30 Apr 2023 19:03:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ptIsL-0003rJ-KG; Sun, 30 Apr 2023 22:02:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptIsK-0003rB-Np for qemu-devel@nongnu.org; Sun, 30 Apr 2023 22:02:48 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ptIs4-0003F2-TN for qemu-devel@nongnu.org; Sun, 30 Apr 2023 22:02:48 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4f00d3f98deso20385450e87.0 for ; Sun, 30 Apr 2023 19:02:32 -0700 (PDT) Received: from vp-pc.. (109-252-127-135.nat.spd-mgts.ru. [109.252.127.135]) by smtp.gmail.com with ESMTPSA id w7-20020ac254a7000000b004efe73ee01fsm3783271lfk.306.2023.04.30.19.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Apr 2023 19:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1682906551; x=1685498551; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KuoPIrbz1UnCVJ8I8IFQYEA36M+uyHB848AT63FYSIs=; b=ZdCwltOjv/kuXG00GxuWlDXQ8GLJCD91tv09ilFXZt2ojpAQBvTIYXyxSIdsKGlk2N y5ZB4SIYSNU/tx3uQ5JOMXDH6bYCVUe6MxnZwPlGRyXj70QcehMLu5C85FvD8Yxv81Sw cLt+eLeIu0roGPib/EOUuvCnJc/99NGF1Z/7Evs3KreS5zDYk3dQ/Z8WG72OtHiVhIaW v7kF5Ebbdz0zyLRpV52ranf2KuGogau/tbAai0yMWVtQ5+yPqDRbp04QJRqq9lKXmc50 ZoUKn5b7puG6G+z2TE9RZEuGqzx6omRoICyzTIENNa9BOwcJ8Y/yIE0i+Iyl80Exh5kS VLzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682906551; x=1685498551; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KuoPIrbz1UnCVJ8I8IFQYEA36M+uyHB848AT63FYSIs=; b=gzApO2/Sv40Q540TGAu9YFUXV0DiYk2hicC6wPAT7s7hGTHGBPWrgHof+pGaQ+WLZE FdEZHB8OSzEFeJTQ/T0+vgu82+jnjGHkPED+tK3JXdzA340yMsdRiw0QgrbzVanRbOrk vCxLQi9zJcUSkZx47ze4VrBiHSFidggP3Ois9HjioUHQX+McXyc75K+AF/M6RATuvAtm FSyLoUaVizsiAJlImB7m0n2Dre8JiiUf+187v4DuPR18YgB702aOljiAZqz+dPnEyyRt mG+r7RWuWPuk5TYzrlKnG6MWpxaEiM2EW2vURfigborq5eMp6+7OS+/iC7OrpP5PiOmf coqQ== X-Gm-Message-State: AC+VfDzoJ2NI6fABzYkUn/8hoElAn30DFNJb4iFh8++m/MBNt888fWKF TsgJbs6lqZYHkK/m1ZuzKNDIVA== X-Google-Smtp-Source: ACHHUZ5PpOTuCEJTCVxyN8+K+je0fKZWw4xFI9F/zssk9yXYq619muLQwMgQRP8zOa5JuYQuxaSEXA== X-Received: by 2002:a05:6512:3906:b0:4ed:c6d5:bd0 with SMTP id a6-20020a056512390600b004edc6d50bd0mr3119134lfu.3.1682906551279; Sun, 30 Apr 2023 19:02:31 -0700 (PDT) From: Viktor Prutyanov To: mst@redhat.com, jasowang@redhat.com, peterx@redhat.com, marcel.apfelbaum@gmail.com Cc: qemu-devel@nongnu.org, viktor@daynix.com, yan@daynix.com, yuri.benditovich@daynix.com Subject: [RFC PATCH v2 3/4] vhost: register and change IOMMU flag depending on Device-TLB state Date: Mon, 1 May 2023 05:02:20 +0300 Message-Id: <20230501020221.188376-4-viktor@daynix.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230501020221.188376-1-viktor@daynix.com> References: <20230501020221.188376-1-viktor@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::132; envelope-from=viktor@daynix.com; helo=mail-lf1-x132.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1682906619783100014 Content-Type: text/plain; charset="utf-8" The guest can disable or never enable Device-TLB. In these cases, it can't be used even if enabled in QEMU. So, check Device-TLB state before registering IOMMU notifier and select unmap flag depending on that. Also, implement a way to change IOMMU notifier flag if Device-TLB state is changed. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=3D2001312 Signed-off-by: Viktor Prutyanov --- hw/virtio/vhost-backend.c | 6 ++++++ hw/virtio/vhost.c | 26 ++++++++++++++++++++++++-- include/hw/virtio/vhost-backend.h | 4 ++++ include/hw/virtio/vhost.h | 1 + 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 8e581575c9..30eb71fb83 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -297,6 +297,11 @@ static void vhost_kernel_set_iotlb_callback(struct vho= st_dev *dev, qemu_set_fd_handler((uintptr_t)dev->opaque, NULL, NULL, NULL); } =20 +static void vhost_kernel_toggle_device_iotlb(struct vhost_dev *dev, int en= able) +{ + vhost_toggle_device_iotlb(dev, enable); +} + const VhostOps kernel_ops =3D { .backend_type =3D VHOST_BACKEND_TYPE_KERNEL, .vhost_backend_init =3D vhost_kernel_init, @@ -328,6 +333,7 @@ const VhostOps kernel_ops =3D { .vhost_vsock_set_running =3D vhost_kernel_vsock_set_running, .vhost_set_iotlb_callback =3D vhost_kernel_set_iotlb_callback, .vhost_send_device_iotlb_msg =3D vhost_kernel_send_device_iotlb_ms= g, + .vhost_toggle_device_iotlb =3D vhost_kernel_toggle_device_iotlb, }; #endif =20 diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index a266396576..1bfcc6d263 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -796,7 +796,9 @@ static void vhost_iommu_region_add(MemoryListener *list= ener, iommu_idx =3D memory_region_iommu_attrs_to_index(iommu_mr, MEMTXATTRS_UNSPECIFIED); iommu_notifier_init(&iommu->n, vhost_iommu_unmap_notify, - IOMMU_NOTIFIER_DEVIOTLB_UNMAP, + dev->vdev->device_iotlb_enabled ? + IOMMU_NOTIFIER_DEVIOTLB_UNMAP : + IOMMU_NOTIFIER_UNMAP, section->offset_within_region, int128_get64(end), iommu_idx); @@ -804,7 +806,8 @@ static void vhost_iommu_region_add(MemoryListener *list= ener, iommu->iommu_offset =3D section->offset_within_address_space - section->offset_within_region; iommu->hdev =3D dev; - ret =3D memory_region_register_iommu_notifier(section->mr, &iommu->n, = NULL); + ret =3D memory_region_register_iommu_notifier(section->mr, &iommu->n, + dev->vdev->device_iotlb_enabled ? NULL : &error_fatal); if (ret) { /* * Some vIOMMUs do not support dev-iotlb yet. If so, try to use t= he @@ -841,6 +844,25 @@ static void vhost_iommu_region_del(MemoryListener *lis= tener, } } =20 +void vhost_toggle_device_iotlb(struct vhost_dev *dev, bool enable) +{ + struct vhost_iommu *iommu; + int ret; + + QLIST_FOREACH(iommu, &dev->iommu_list, iommu_next) { + memory_region_unregister_iommu_notifier(iommu->mr, &iommu->n); + iommu->n.notifier_flags =3D enable ? + IOMMU_NOTIFIER_DEVIOTLB_UNMAP : IOMMU_NOTIFIER_UNMAP; + ret =3D memory_region_register_iommu_notifier(iommu->mr, &iommu->n, + enable ? NULL : &error_fatal); + if (ret) { + iommu->n.notifier_flags =3D IOMMU_NOTIFIER_UNMAP; + memory_region_register_iommu_notifier(iommu->mr, &iommu->n, + &error_fatal); + } + } +} + static int vhost_virtqueue_set_addr(struct vhost_dev *dev, struct vhost_virtqueue *vq, unsigned idx, bool enable_log) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index ec3fbae58d..f8e9660a96 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -133,6 +133,9 @@ typedef int (*vhost_set_config_call_op)(struct vhost_de= v *dev, =20 typedef void (*vhost_reset_status_op)(struct vhost_dev *dev); =20 +typedef void (*vhost_toggle_device_iotlb_op)(struct vhost_dev *dev, + int enabled); + typedef struct VhostOps { VhostBackendType backend_type; vhost_backend_init vhost_backend_init; @@ -181,6 +184,7 @@ typedef struct VhostOps { vhost_force_iommu_op vhost_force_iommu; vhost_set_config_call_op vhost_set_config_call; vhost_reset_status_op vhost_reset_status; + vhost_toggle_device_iotlb_op vhost_toggle_device_iotlb; } VhostOps; =20 int vhost_backend_update_device_iotlb(struct vhost_dev *dev, diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index a52f273347..b3f585c6cd 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -320,6 +320,7 @@ bool vhost_has_free_slot(void); int vhost_net_set_backend(struct vhost_dev *hdev, struct vhost_vring_file *file); =20 +void vhost_toggle_device_iotlb(struct vhost_dev *dev, bool enable); int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int writ= e); =20 int vhost_virtqueue_start(struct vhost_dev *dev, struct VirtIODevice *vdev, --=20 2.35.1 From nobody Fri May 17 11:05:14 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1682906617; cv=none; d=zohomail.com; s=zohoarc; b=Pv4hucBZJFPJscCrKB0X6Cww8XVHJjuCshLo6qtQxYKegtHC5IROfVum0fqYQCYpx7UOQUyc+QsZCFSnTlN5/gqUIFbAg9m1NbMfj5Y9F1xab8BCmqA3OUPU2NcaKRIzzhT4UrrzgEmjCzU3rOthu8OP/eFdyzGpOXM6WlxSK88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1682906617; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3Ndat+FBo1b63fMAzLq7S3YsnsowwHK/srih+mHf+b8=; b=VT1J+e1JgKnwrNVrkoQSuB13eG+bAREDmq1Dph485T9nljnY71Tx8ctzGVKRN18rhJdHhavpfomBY7Bwj3MTK3lyrCCqay4180DQmQnU1Ghd4ChAvfNgz9UdKi9xHHS9H9Ph8XNn2+LKh1P2/TgbPX1xYqApCom4hM386X4GPfY= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1682906617785386.30948856920384; Sun, 30 Apr 2023 19:03:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ptIsB-0003qO-7y; Sun, 30 Apr 2023 22:02:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptIs6-0003p9-PR for qemu-devel@nongnu.org; Sun, 30 Apr 2023 22:02:37 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ptIs5-0003Fn-B5 for qemu-devel@nongnu.org; Sun, 30 Apr 2023 22:02:34 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4edc7cc6f46so2500644e87.1 for ; Sun, 30 Apr 2023 19:02:33 -0700 (PDT) Received: from vp-pc.. (109-252-127-135.nat.spd-mgts.ru. [109.252.127.135]) by smtp.gmail.com with ESMTPSA id w7-20020ac254a7000000b004efe73ee01fsm3783271lfk.306.2023.04.30.19.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Apr 2023 19:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20221208.gappssmtp.com; s=20221208; t=1682906552; x=1685498552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3Ndat+FBo1b63fMAzLq7S3YsnsowwHK/srih+mHf+b8=; b=fDkcM1jvrtIdIT8IQS+xNs70QCMxJg1d76ylWOB1YBy/H1lIhOmTxeScX2ECu3OcPb WUx5ocAy5O0rVX32jonp+TBnsGyWiyP7NMIpfoT/LaT1xFNVypP390O3tUb31UGfPjHH 4FjEXMg7ySzk4EEzp5gFMlrJw1Xs7NpiD5Vo+2DNJ1/EZRfJZRkcMaq7uJ9aK3u7duy2 KNxxYXj8oZRjatISp//bLpTfiLBJlwc5qIXRQDweXAWiXtdRxsPdHy8nzKTx8nBpmelU UcN1EOaifibY2113BltN5Vvl9jPuwQueP7KD0VbiaWQe2h9ygS1q+cgbLv8cWiJ/3Z3a LJ9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682906552; x=1685498552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3Ndat+FBo1b63fMAzLq7S3YsnsowwHK/srih+mHf+b8=; b=OGu6mdIDvoJlltLKUq3+dYKREaE8goHKEQl/1iwi7ZuRytbwejCI7HBvZ2yglKtduU PPQ04/sv5T860TkkhdF+URxB7+MagUuvTMvyU+CkynDyAcAz0Cdlpt5Om72kqfpYWTZ9 IeVByaqscLB9Y7fKvAhZNapibrsyh96ibzFICUG7i+3knESe1Krw6pbUnb+MGt6j+6SH dKP1lgwZJnmtvUhNH0lxlr8rFhuYbGsZbBXYM/jtgFHaEbccY0h6486tGcfEHIEXO9vc kY6pEV4DtPb5tg7dSanXwCC023cd5tQfMMhKbAk37ZzbZk1UXFTl3jyvtxMatP3ez2cz kAEA== X-Gm-Message-State: AC+VfDxAHDIJ4aY/+m3A/OhjSvzYCCQ+NDTZ24B6Ud8+V8ACb/fbDEZP LP1hGRXDxqeVGxK0Mo/bZ+dTRw== X-Google-Smtp-Source: ACHHUZ7y2VSq9wB+JUwIzVhJxVdecJ5sd2hAvVzRHuszZhy75UUC3wG34n+Akg/zReOSLfiFMs3sew== X-Received: by 2002:ac2:5613:0:b0:4ef:f1f4:14db with SMTP id v19-20020ac25613000000b004eff1f414dbmr3531285lfd.16.1682906551977; Sun, 30 Apr 2023 19:02:31 -0700 (PDT) From: Viktor Prutyanov To: mst@redhat.com, jasowang@redhat.com, peterx@redhat.com, marcel.apfelbaum@gmail.com Cc: qemu-devel@nongnu.org, viktor@daynix.com, yan@daynix.com, yuri.benditovich@daynix.com Subject: [RFC PATCH v2 4/4] virtio-net: pass Device-TLB enable/disable events to vhost Date: Mon, 1 May 2023 05:02:21 +0300 Message-Id: <20230501020221.188376-5-viktor@daynix.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230501020221.188376-1-viktor@daynix.com> References: <20230501020221.188376-1-viktor@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: none client-ip=2a00:1450:4864:20::132; envelope-from=viktor@daynix.com; helo=mail-lf1-x132.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 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 @daynix-com.20221208.gappssmtp.com) X-ZM-MESSAGEID: 1682906619763100013 Content-Type: text/plain; charset="utf-8" If vhost is enabled for virtio-net, Device-TLB enable/disable events must be passed to vhost for proper IOMMU unmap flag selection. Signed-off-by: Viktor Prutyanov --- hw/net/vhost_net.c | 11 +++++++++++ hw/net/virtio-net.c | 8 ++++++++ include/net/vhost_net.h | 2 ++ 3 files changed, 21 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index c4eecc6f36..2364c8de99 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -552,6 +552,17 @@ int vhost_net_set_mtu(struct vhost_net *net, uint16_t = mtu) return vhost_ops->vhost_net_set_mtu(&net->dev, mtu); } =20 +void vhost_net_toggle_device_iotlb(struct vhost_dev *dev, bool enable) +{ + const VhostOps *vhost_ops =3D dev->vhost_ops; + + if (!vhost_ops->vhost_toggle_device_iotlb) { + return; + } + + vhost_ops->vhost_toggle_device_iotlb(dev, enable); +} + void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc, int vq_index) { diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 53e1c32643..e6851b885c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3843,6 +3843,13 @@ static struct vhost_dev *virtio_net_get_vhost(VirtIO= Device *vdev) return &net->dev; } =20 +static void virtio_net_toggle_device_iotlb(VirtIODevice *vdev, + bool enable) +{ + if (vdev->vhost_started) + vhost_net_toggle_device_iotlb(virtio_net_get_vhost(vdev), enable); +} + static const VMStateDescription vmstate_virtio_net =3D { .name =3D "virtio-net", .minimum_version_id =3D VIRTIO_NET_VM_VERSION, @@ -3948,6 +3955,7 @@ static void virtio_net_class_init(ObjectClass *klass,= void *data) vdc->vmsd =3D &vmstate_virtio_net_device; vdc->primary_unplug_pending =3D primary_unplug_pending; vdc->get_vhost =3D virtio_net_get_vhost; + vdc->toggle_device_iotlb =3D virtio_net_toggle_device_iotlb; } =20 static const TypeInfo virtio_net_info =3D { diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index c37aba35e6..36d527f321 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -56,4 +56,6 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetCl= ientState *nc, int vq_index); =20 void vhost_net_save_acked_features(NetClientState *nc); + +void vhost_net_toggle_device_iotlb(struct vhost_dev *dev, bool enable); #endif --=20 2.35.1