From nobody Thu May 9 02:22:42 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1621914798; cv=none; d=zohomail.com; s=zohoarc; b=LXL9rd/XrzmxQ+qM0J1d4M/4dhCyZZjRdNU+U2MuaTxW+Mf2VSI9pWrfx3VKluY5fVkFhspi4QTYHrFJfD/SwsVc6TK56J3+hi62jdeI6aWbBLXyb3MUKQPIffS9tTw8r8N/nQLKWwWVCEAHcnIJe0kNpOWmPClOu5t56NNSgDQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621914798; h=Content-Type: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=fiRvEFY3hxaFndll+CkEp16cvesStK3ZUsRmTanX3XM=; b=iVUvts6jZxSEe18G5crJNdJLHWE1id6LlaW/t+Gq5OMUOPiGKSWPxWtcpr1w5UDnDQggZ+uy4PQ+GrwWGkCqLBUTZ41gU7YB8vbyxt1m4cImW1/+K2HAk01+z/B+zTWJuPs0queJChi2WkGs3QlFZQ0npGkJPb+CXRLqQ3ymmD0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621914798106495.00073949554917; Mon, 24 May 2021 20:53:18 -0700 (PDT) Received: from localhost ([::1]:50958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llO85-00069Z-2X for importer2@patchew.org; Mon, 24 May 2021 23:53:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5L-0006OL-IO; Mon, 24 May 2021 23:50:27 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:4580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5H-0001qd-FY; Mon, 24 May 2021 23:50:27 -0400 Received: from dggems704-chm.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Fq0R320wDzmbJQ; Tue, 25 May 2021 11:47:59 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggems704-chm.china.huawei.com (10.3.19.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:12 +0800 Received: from huawei.com (10.174.185.226) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:11 +0800 From: Wang Xingang To: , , , , , , , , , , Subject: [PATCH v4 1/8] hw/pci/pci_host: Allow bypass iommu for pci host Date: Tue, 25 May 2021 03:49:58 +0000 Message-ID: <1621914605-14724-2-git-send-email-wangxingang5@huawei.com> X-Mailer: git-send-email 2.6.4.windows.1 In-Reply-To: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> References: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.185.226] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.32; envelope-from=wangxingang5@huawei.com; helo=szxga06-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xieyingtai@huawei.com, wangxingang5@huawei.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang This add a bypass_iommu property for pci host, which indicates whether devices attached to the pci root bus will bypass iommu. In pci_device_iommu_address_space(), add a bypass_iommu check to avoid getting iommu address space for devices bypass iommu. Signed-off-by: Xingang Wang Reviewed-by: Eric Auger --- hw/pci/pci.c | 18 +++++++++++++++++- hw/pci/pci_host.c | 2 ++ include/hw/pci/pci.h | 1 + include/hw/pci/pci_host.h | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 377084f1a8..27d588e268 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -416,6 +416,22 @@ const char *pci_root_bus_path(PCIDevice *dev) return rootbus->qbus.name; } =20 +bool pci_bus_bypass_iommu(PCIBus *bus) +{ + PCIBus *rootbus =3D bus; + PCIHostState *host_bridge; + + if (!pci_bus_is_root(bus)) { + rootbus =3D pci_device_root_bus(bus->parent_dev); + } + + host_bridge =3D PCI_HOST_BRIDGE(rootbus->qbus.parent); + + assert(host_bridge->bus =3D=3D rootbus); + + return host_bridge->bypass_iommu; +} + static void pci_root_bus_init(PCIBus *bus, DeviceState *parent, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, @@ -2718,7 +2734,7 @@ AddressSpace *pci_device_iommu_address_space(PCIDevic= e *dev) =20 iommu_bus =3D parent_bus; } - if (iommu_bus && iommu_bus->iommu_fn) { + if (!pci_bus_bypass_iommu(bus) && iommu_bus && iommu_bus->iommu_fn) { return iommu_bus->iommu_fn(bus, iommu_bus->iommu_opaque, devfn); } return &address_space_memory; diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index 8ca5fadcbd..2768db53e6 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -222,6 +222,8 @@ const VMStateDescription vmstate_pcihost =3D { static Property pci_host_properties_common[] =3D { DEFINE_PROP_BOOL("x-config-reg-migration-enabled", PCIHostState, mig_enabled, true), + DEFINE_PROP_BOOL("pci-host-bypass-iommu", PCIHostState, + bypass_iommu, false), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 6be4e0c460..f4d51b672b 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -480,6 +480,7 @@ void pci_for_each_bus(PCIBus *bus, =20 PCIBus *pci_device_root_bus(const PCIDevice *d); const char *pci_root_bus_path(PCIDevice *dev); +bool pci_bus_bypass_iommu(PCIBus *bus); PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn); int pci_qdev_find_device(const char *id, PCIDevice **pdev); void pci_bus_get_w64_range(PCIBus *bus, Range *range); diff --git a/include/hw/pci/pci_host.h b/include/hw/pci/pci_host.h index 52e038c019..c6f4eb4585 100644 --- a/include/hw/pci/pci_host.h +++ b/include/hw/pci/pci_host.h @@ -43,6 +43,7 @@ struct PCIHostState { uint32_t config_reg; bool mig_enabled; PCIBus *bus; + bool bypass_iommu; =20 QLIST_ENTRY(PCIHostState) next; }; --=20 2.19.1 From nobody Thu May 9 02:22:42 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1621914711; cv=none; d=zohomail.com; s=zohoarc; b=L83PmYh95H0a0F6xo7rzTvnlQdKLKY3AAbzbx99jkS5ao7nwsOK+h6hd4qrRcP7Y0twRE51PtyI5i6GA5vcyuVhIUDybntQgc1FPaV1luPAXOnpb3/9BbgxCjO94+tgJvUGOgB6TiACkpwvtxOj0RagwGUfVqr5y0E0Lb4xFsQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621914711; h=Content-Type: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=5gvbLBcM2WX63xP0E4zZD91eWteoQgf1xN24Fppy9lo=; b=nYNfNRCjRE1/01ukC079VC6B7VZql8McPvsm0E0706hC8va7NeboBWMgZX1eu2cMCMIzsotzGBcwOPHqTBSCv/Suy6VM9ETiDFc1i2LhfE/XxrrTbczPzJVq1cGg1uqSJtrdWriL8qgBZx3+g4YNPScQzI/JytSTikN9+SFV0vw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621914711404915.2299151821082; Mon, 24 May 2021 20:51:51 -0700 (PDT) Received: from localhost ([::1]:42884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llO6g-0000q9-DT for importer2@patchew.org; Mon, 24 May 2021 23:51:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5K-0006NA-Vl; Mon, 24 May 2021 23:50:26 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:4579) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5H-0001ki-KW; Mon, 24 May 2021 23:50:26 -0400 Received: from dggems701-chm.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Fq0Qx0GlwzmbJK; Tue, 25 May 2021 11:47:53 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggems701-chm.china.huawei.com (10.3.19.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:13 +0800 Received: from huawei.com (10.174.185.226) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:12 +0800 From: Wang Xingang To: , , , , , , , , , , Subject: [PATCH v4 2/8] hw/pxb: Add a bypass iommu property Date: Tue, 25 May 2021 03:49:59 +0000 Message-ID: <1621914605-14724-3-git-send-email-wangxingang5@huawei.com> X-Mailer: git-send-email 2.6.4.windows.1 In-Reply-To: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> References: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.185.226] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.32; envelope-from=wangxingang5@huawei.com; helo=szxga06-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xieyingtai@huawei.com, wangxingang5@huawei.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang This add a bypass_iommu property for pci_expander_bridge. The property can be used as: qemu -device pxb-pcie,bus_nr=3D0x10,addr=3D0x1,bypass_iommu=3Dtrue Signed-off-by: Xingang Wang Reviewed-by: Eric Auger --- hw/pci-bridge/pci_expander_bridge.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expand= er_bridge.c index aedded1064..7112dc3062 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -57,6 +57,7 @@ struct PXBDev { =20 uint8_t bus_nr; uint16_t numa_node; + bool bypass_iommu; }; =20 static PXBDev *convert_to_pxb(PCIDevice *dev) @@ -255,6 +256,7 @@ static void pxb_dev_realize_common(PCIDevice *dev, bool= pcie, Error **errp) bus->map_irq =3D pxb_map_irq_fn; =20 PCI_HOST_BRIDGE(ds)->bus =3D bus; + PCI_HOST_BRIDGE(ds)->bypass_iommu =3D pxb->bypass_iommu; =20 pxb_register_bus(dev, bus, &local_err); if (local_err) { @@ -301,6 +303,7 @@ static Property pxb_dev_properties[] =3D { /* Note: 0 is not a legal PXB bus number. */ DEFINE_PROP_UINT8("bus_nr", PXBDev, bus_nr, 0), DEFINE_PROP_UINT16("numa_node", PXBDev, numa_node, NUMA_NODE_UNASSIGNE= D), + DEFINE_PROP_BOOL("bypass_iommu", PXBDev, bypass_iommu, false), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.19.1 From nobody Thu May 9 02:22:42 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1621914724; cv=none; d=zohomail.com; s=zohoarc; b=P0PZ78fT1CrX8HtnEqByg6Szl+QlmFrGRYQhNcUwc98o1DizLGu/CNARQVfWiiA89FHsDrhq6mUx9m7Epg/lss8KjNHww2LjkSCE4Uomnl9SuD1gLFfUaGeS2jAwb6UvHWxg4MvRPTh2IDpRqGB3zAvuF3PcyvihSYvv3DAcJ+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621914724; h=Content-Type: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=3ZjghSdA+PTnHNRUrz0IR1SDnIYDrTmMV6zO5jAQe6o=; b=nclI7Zz1Fyp9YdX+L9lng1c3vCZEl8lOpvo64bhgjDZFVCFLSK3yMhpI1zgmPuEvnZjqr5XW/HFcvPEiTgX+mbrImfBDbsQwu5suofyO29SLRa/8n/ZRrPYQCv6VE5dRhUw0tWXDwnYTF/BGrXIwtdB3FRV8hiFZSJ0se9EsXvU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621914724582162.0775884880743; Mon, 24 May 2021 20:52:04 -0700 (PDT) Received: from localhost ([::1]:44342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llO6t-0001nT-J7 for importer2@patchew.org; Mon, 24 May 2021 23:52:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5L-0006Nb-8J; Mon, 24 May 2021 23:50:27 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:4578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5H-0001kj-7r; Mon, 24 May 2021 23:50:26 -0400 Received: from dggems702-chm.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Fq0Qx54VVzmbJL; Tue, 25 May 2021 11:47:53 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:13 +0800 Received: from huawei.com (10.174.185.226) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:12 +0800 From: Wang Xingang To: , , , , , , , , , , Subject: [PATCH v4 3/8] hw/arm/virt: Add a machine option to bypass iommu for primary bus Date: Tue, 25 May 2021 03:50:00 +0000 Message-ID: <1621914605-14724-4-git-send-email-wangxingang5@huawei.com> X-Mailer: git-send-email 2.6.4.windows.1 In-Reply-To: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> References: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.185.226] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.32; envelope-from=wangxingang5@huawei.com; helo=szxga06-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xieyingtai@huawei.com, wangxingang5@huawei.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang This add a bypass_iommu option for arm virt machine, the option can be used in this manner: qemu -machine virt,iommu=3Dsmmuv3,bypass_iommu=3Dtrue Signed-off-by: Xingang Wang --- hw/arm/virt.c | 26 ++++++++++++++++++++++++++ include/hw/arm/virt.h | 1 + 2 files changed, 27 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 840758666d..49d8a801ed 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1364,6 +1364,7 @@ static void create_pcie(VirtMachineState *vms) } =20 pci =3D PCI_HOST_BRIDGE(dev); + pci->bypass_iommu =3D vms->bypass_iommu; vms->bus =3D pci->bus; if (vms->bus) { for (i =3D 0; i < nb_nics; i++) { @@ -2319,6 +2320,21 @@ static void virt_set_iommu(Object *obj, const char *= value, Error **errp) } } =20 +static bool virt_get_bypass_iommu(Object *obj, Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + return vms->bypass_iommu; +} + +static void virt_set_bypass_iommu(Object *obj, bool value, + Error **errp) +{ + VirtMachineState *vms =3D VIRT_MACHINE(obj); + + vms->bypass_iommu =3D value; +} + static CpuInstanceProperties virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) { @@ -2656,6 +2672,13 @@ static void virt_machine_class_init(ObjectClass *oc,= void *data) "Set the IOMMU type. " "Valid values are none and smmuv= 3"); =20 + object_class_property_add_bool(oc, "bypass_iommu", + virt_get_bypass_iommu, + virt_set_bypass_iommu); + object_class_property_set_description(oc, "bypass_iommu", + "Set on/off to enable/disable " + "bypass_iommu for primary bus"); + object_class_property_add_bool(oc, "ras", virt_get_ras, virt_set_ras); object_class_property_set_description(oc, "ras", @@ -2723,6 +2746,9 @@ static void virt_instance_init(Object *obj) /* Default disallows iommu instantiation */ vms->iommu =3D VIRT_IOMMU_NONE; =20 + /* The primary bus is attached to iommu by default */ + vms->bypass_iommu =3D false; + /* Default disallows RAS instantiation */ vms->ras =3D false; =20 diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 921416f918..82bceadb82 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -147,6 +147,7 @@ struct VirtMachineState { OnOffAuto acpi; VirtGICType gic_version; VirtIOMMUType iommu; + bool bypass_iommu; VirtMSIControllerType msi_controller; uint16_t virtio_iommu_bdf; struct arm_boot_info bootinfo; --=20 2.19.1 From nobody Thu May 9 02:22:42 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1621914952; cv=none; d=zohomail.com; s=zohoarc; b=kq5ck/2iKTTeSrf1gnAfnowHPnyu7P/qemDpsb4RQloDFZws7onloj+0S1sjdC6AsL6fcL9XOdsz1eKxyNcfYGJIbGAtzZsP+EUxP1eJpV5WRqiynhyL8UKDuZKYqwSjrtwwTQYU741Y6qgX4HRA6Kz+53XZWzrsRfsq2xBqNMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621914952; h=Content-Type: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=zQR7K/NC1gheAO/fMZ2ct1/gGP49dbdki15kBTMeN6o=; b=lH6OeIZq7mEDvSfAhtv/VIxieA8cth5IRFmWJwchiHVJjn5wcG2uYa4j1AFjGV6Dak0z5LZtETWz6k/JAhED9Olx0MuQX8+dqzgCGCidriz3mmiMdZFkt89aaVh85qpSmiVLJ6tb8NSzRZtJzLQd2lxJFqPKy9GhN0+FCZKpIl0= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621914952503547.3019376637178; Mon, 24 May 2021 20:55:52 -0700 (PDT) Received: from localhost ([::1]:58836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llOAZ-0002xZ-FH for importer2@patchew.org; Mon, 24 May 2021 23:55:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5N-0006Ry-CF; Mon, 24 May 2021 23:50:29 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:3635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5H-0001kk-QM; Mon, 24 May 2021 23:50:29 -0400 Received: from dggems703-chm.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Fq0QL73dLzBwKr; Tue, 25 May 2021 11:47:22 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggems703-chm.china.huawei.com (10.3.19.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:14 +0800 Received: from huawei.com (10.174.185.226) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:13 +0800 From: Wang Xingang To: , , , , , , , , , , Subject: [PATCH v4 4/8] hw/i386: Add a pc machine option to bypass iommu for primary bus Date: Tue, 25 May 2021 03:50:01 +0000 Message-ID: <1621914605-14724-5-git-send-email-wangxingang5@huawei.com> X-Mailer: git-send-email 2.6.4.windows.1 In-Reply-To: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> References: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.185.226] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.35; envelope-from=wangxingang5@huawei.com; helo=szxga07-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xieyingtai@huawei.com, wangxingang5@huawei.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang Add a bypass_iommu pc machine option to bypass iommu translation for the primary root bus. The option can be used as manner: qemu-system-x86_64 -machine q35,bypass_iommu=3Dtrue Signed-off-by: Xingang Wang --- hw/i386/pc.c | 18 ++++++++++++++++++ hw/pci-host/q35.c | 1 + include/hw/i386/pc.h | 1 + 3 files changed, 20 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 8cfaf216e7..865a6e4c7a 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1530,6 +1530,20 @@ static void pc_machine_set_hpet(Object *obj, bool va= lue, Error **errp) pcms->hpet_enabled =3D value; } =20 +static bool pc_machine_get_bypass_iommu(Object *obj, Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + + return pcms->bypass_iommu; +} + +static void pc_machine_set_bypass_iommu(Object *obj, bool value, Error **e= rrp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + + pcms->bypass_iommu =3D value; +} + static void pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) @@ -1629,6 +1643,7 @@ static void pc_machine_initfn(Object *obj) #ifdef CONFIG_HPET pcms->hpet_enabled =3D true; #endif + pcms->bypass_iommu =3D false; =20 pc_system_flash_create(pcms); pcms->pcspk =3D isa_new(TYPE_PC_SPEAKER); @@ -1753,6 +1768,9 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) object_class_property_add_bool(oc, "hpet", pc_machine_get_hpet, pc_machine_set_hpet); =20 + object_class_property_add_bool(oc, "bypass_iommu", + pc_machine_get_bypass_iommu, pc_machine_set_bypass_iommu); + object_class_property_add(oc, PC_MACHINE_MAX_FW_SIZE, "size", pc_machine_get_max_fw_size, pc_machine_set_max_fw_size, NULL, NULL); diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 2eb729dff5..ade05a5539 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -64,6 +64,7 @@ static void q35_host_realize(DeviceState *dev, Error **er= rp) s->mch.address_space_io, 0, TYPE_PCIE_BUS); PC_MACHINE(qdev_get_machine())->bus =3D pci->bus; + pci->bypass_iommu =3D PC_MACHINE(qdev_get_machine())->bypass_iommu; qdev_realize(DEVICE(&s->mch), BUS(pci->bus), &error_fatal); } =20 diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 1522a3359a..10a464744a 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -45,6 +45,7 @@ typedef struct PCMachineState { bool sata_enabled; bool pit_enabled; bool hpet_enabled; + bool bypass_iommu; uint64_t max_fw_size; =20 /* NUMA information: */ --=20 2.19.1 From nobody Thu May 9 02:22:42 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1621914731; cv=none; d=zohomail.com; s=zohoarc; b=gnwSs7EMUpA3IhcJufrG6/dP/7eCYB51+KMJD11NTDLgu9ug+KeXRNZuS0mN8/1b/g0Aw5DTX3o7j2drWa/a33Jzo1BEan73BdKd1bo/AnEHZAWnwncj5UA4WF2hhOm8gA8OVgtoKPzzXZeHZqZz3PwRr9OmIBOOd0QOGdT+IC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621914731; h=Content-Type: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=x3ztTNwnEVDR1zX0ncgI5HmZ/rS46TaKV507kJXXJHo=; b=e+AnVuzfv46YTILM4nmHWyXS1TCv8SYSgwObyELcydS6Ij/Xy8+AKoVLxbgYUq5u/ZcuOxxFsF3aPwUzf0sg31vX+FOfwUmzLbpk0LecHBzQYYIdVxHflgthHAnvgjl5nWz1kwIDu612Q50XpuR031G+7y/5AKj3Oqe01LmhUBw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621914731169776.5196423836005; Mon, 24 May 2021 20:52:11 -0700 (PDT) Received: from localhost ([::1]:45128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llO70-0002Kx-6R for importer2@patchew.org; Mon, 24 May 2021 23:52:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5L-0006Of-O0; Mon, 24 May 2021 23:50:27 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3433) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5H-0001lO-Ht; Mon, 24 May 2021 23:50:27 -0400 Received: from dggems705-chm.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Fq0PV6RKqzP0HX; Tue, 25 May 2021 11:46:38 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggems705-chm.china.huawei.com (10.3.19.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:14 +0800 Received: from huawei.com (10.174.185.226) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:14 +0800 From: Wang Xingang To: , , , , , , , , , , Subject: [PATCH v4 5/8] hw/pci: Add pci_bus_range to get bus number range Date: Tue, 25 May 2021 03:50:02 +0000 Message-ID: <1621914605-14724-6-git-send-email-wangxingang5@huawei.com> X-Mailer: git-send-email 2.6.4.windows.1 In-Reply-To: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> References: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.185.226] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.191; envelope-from=wangxingang5@huawei.com; helo=szxga05-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xieyingtai@huawei.com, wangxingang5@huawei.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang This helps to get the bus number range of a pci bridge hierarchy. Signed-off-by: Xingang Wang Reviewed-by: Eric Auger --- hw/pci/pci.c | 15 +++++++++++++++ include/hw/pci/pci.h | 1 + 2 files changed, 16 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 27d588e268..7f18ea5ef5 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -537,6 +537,21 @@ int pci_bus_num(PCIBus *s) return PCI_BUS_GET_CLASS(s)->bus_num(s); } =20 +void pci_bus_range(PCIBus *bus, int *min_bus, int *max_bus) +{ + int i; + *min_bus =3D *max_bus =3D pci_bus_num(bus); + + for (i =3D 0; i < ARRAY_SIZE(bus->devices); ++i) { + PCIDevice *dev =3D bus->devices[i]; + + if (dev && PCI_DEVICE_GET_CLASS(dev)->is_bridge) { + *min_bus =3D MIN(*min_bus, dev->config[PCI_SECONDARY_BUS]); + *max_bus =3D MAX(*max_bus, dev->config[PCI_SUBORDINATE_BUS]); + } + } +} + int pci_bus_numa_node(PCIBus *bus) { return PCI_BUS_GET_CLASS(bus)->numa_node(bus); diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index f4d51b672b..d0f4266e37 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -450,6 +450,7 @@ static inline PCIBus *pci_get_bus(const PCIDevice *dev) return PCI_BUS(qdev_get_parent_bus(DEVICE(dev))); } int pci_bus_num(PCIBus *s); +void pci_bus_range(PCIBus *bus, int *min_bus, int *max_bus); static inline int pci_dev_bus_num(const PCIDevice *dev) { return pci_bus_num(pci_get_bus(dev)); --=20 2.19.1 From nobody Thu May 9 02:22:43 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1621914998; cv=none; d=zohomail.com; s=zohoarc; b=Jg4gAeA40gXxjFs9X8UWMSrh7242pVqFnqN5C4TmJZLVWb8hPSdr0ImoxG89AvVvQNTk0WDVJcL8FVCaXDc2HO9bJT7WbseziZBYlq8j385Ac4zJU59Oc22yPX4+E16Z1ut34kvCZEKepb8O9JXJCeZP64L1hIpW8EjzAxJkny4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621914998; h=Content-Type: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=64oQvLoBU3lxESrzrnGJUzEBrMcArzgzrLpVM739ofA=; b=D0gGGA8eWN9uQolj5GUiY4IVm3i8PlEiv9VK7sFxrw//wTuRyntZtFM126omGYzHX6H/Y3vRFyRvzvjaqBpVyHn/oCha7lYDGb83cRX0GyQ4Xvd2s5HO7DZqZYmVTAuXkQt5TlBmZ2ifZp15pPk/2SI/lNBgn78C/xN7HeZY1+o= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621914998668462.7820954081143; Mon, 24 May 2021 20:56:38 -0700 (PDT) Received: from localhost ([::1]:33678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llOBJ-00054h-L8 for importer2@patchew.org; Mon, 24 May 2021 23:56:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5N-0006T6-Nf; Mon, 24 May 2021 23:50:29 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3628) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5J-0001sg-5j; Mon, 24 May 2021 23:50:29 -0400 Received: from dggems706-chm.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Fq0QW5cZmzwTKc; Tue, 25 May 2021 11:47:31 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggems706-chm.china.huawei.com (10.3.19.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:15 +0800 Received: from huawei.com (10.174.185.226) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:14 +0800 From: Wang Xingang To: , , , , , , , , , , Subject: [PATCH v4 6/8] hw/arm/virt-acpi-build: Add explicit IORT idmap for smmuv3 node Date: Tue, 25 May 2021 03:50:03 +0000 Message-ID: <1621914605-14724-7-git-send-email-wangxingang5@huawei.com> X-Mailer: git-send-email 2.6.4.windows.1 In-Reply-To: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> References: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.185.226] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.191; envelope-from=wangxingang5@huawei.com; helo=szxga05-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xieyingtai@huawei.com, wangxingang5@huawei.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang This add explicit IORT idmap info according to pci root bus number range, and only add smmu idmap for those which does not bypass iommu. For idmap directly to ITS node, this split the whole RID mapping to smmu idmap and its idmap. So this should cover the whole idmap for through/bypass SMMUv3 node. Signed-off-by: Xingang Wang --- hw/arm/virt-acpi-build.c | 135 +++++++++++++++++++++++++++++++++------ 1 file changed, 116 insertions(+), 19 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 60fe2e65a7..f63a57dcfa 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -44,6 +44,7 @@ #include "hw/acpi/tpm.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" +#include "hw/pci/pci_bus.h" #include "hw/pci-host/gpex.h" #include "hw/arm/virt.h" #include "hw/mem/nvdimm.h" @@ -237,16 +238,82 @@ static void acpi_dsdt_add_tpm(Aml *scope, VirtMachine= State *vms) aml_append(scope, dev); } =20 +/* Build the iort ID mapping to SMMUv3 for a given PCI host bridge */ +static int +iort_host_bridges(Object *obj, void *opaque) +{ + GArray *idmap_blob =3D opaque; + + if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) { + PCIBus *bus =3D PCI_HOST_BRIDGE(obj)->bus; + + if (bus && !pci_bus_bypass_iommu(bus)) { + int min_bus, max_bus; + pci_bus_range(bus, &min_bus, &max_bus); + + AcpiIortIdMapping idmap =3D { + .input_base =3D min_bus << 8, + .id_count =3D (max_bus - min_bus + 1) << 8, + }; + g_array_append_val(idmap_blob, idmap); + } + } + + return 0; +} + +static int iort_idmap_compare(gconstpointer a, gconstpointer b) +{ + AcpiIortIdMapping *idmap_a =3D (AcpiIortIdMapping *)a; + AcpiIortIdMapping *idmap_b =3D (AcpiIortIdMapping *)b; + + return idmap_a->input_base - idmap_b->input_base; +} + static void build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { - int nb_nodes, iort_start =3D table_data->len; - AcpiIortIdMapping *idmap; + int i, nb_nodes, rc_map_count, iort_start =3D table_data->len; + AcpiIortIdMapping *idmap, *range; AcpiIortItsGroup *its; AcpiIortTable *iort; AcpiIortSmmu3 *smmu; size_t node_size, iort_node_offset, iort_length, smmu_offset =3D 0; AcpiIortRC *rc; + GArray *smmu_idmap_ranges =3D + g_array_new(false, true, sizeof(AcpiIortIdMapping)); + GArray *its_idmap_ranges =3D + g_array_new(false, true, sizeof(AcpiIortIdMapping)); + + object_child_foreach_recursive(object_get_root(), + iort_host_bridges, smmu_idmap_ranges); + + g_array_sort(smmu_idmap_ranges, iort_idmap_compare); + + AcpiIortIdMapping next_range =3D { + .input_base =3D 0, + }; + + /* + * Build the iort ID mapping to ITS directly, + * split the whole RID input range by RID mapping to SMMU node + */ + for (i =3D 0; i < smmu_idmap_ranges->len; i++) { + idmap =3D &g_array_index(smmu_idmap_ranges, AcpiIortIdMapping, i); + + if (next_range.input_base < idmap->input_base) { + next_range.id_count =3D idmap->input_base - next_range.input_b= ase; + g_array_append_val(its_idmap_ranges, next_range); + } + + next_range.input_base =3D idmap->input_base + idmap->id_count; + } + + /* Append the last ITS ID mapping */ + if (next_range.input_base < 0xFFFF) { + next_range.id_count =3D 0xFFFF - next_range.input_base; + g_array_append_val(its_idmap_ranges, next_range); + } =20 iort =3D acpi_data_push(table_data, sizeof(*iort)); =20 @@ -280,13 +347,13 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) =20 /* SMMUv3 node */ smmu_offset =3D iort_node_offset + node_size; - node_size =3D sizeof(*smmu) + sizeof(*idmap); + node_size =3D sizeof(*smmu) + sizeof(*idmap) * smmu_idmap_ranges->= len; iort_length +=3D node_size; smmu =3D acpi_data_push(table_data, node_size); =20 smmu->type =3D ACPI_IORT_NODE_SMMU_V3; smmu->length =3D cpu_to_le16(node_size); - smmu->mapping_count =3D cpu_to_le32(1); + smmu->mapping_count =3D cpu_to_le32(smmu_idmap_ranges->len); smmu->mapping_offset =3D cpu_to_le32(sizeof(*smmu)); smmu->base_address =3D cpu_to_le64(vms->memmap[VIRT_SMMU].base); smmu->flags =3D cpu_to_le32(ACPI_IORT_SMMU_V3_COHACC_OVERRIDE); @@ -295,23 +362,32 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) smmu->sync_gsiv =3D cpu_to_le32(irq + 2); smmu->gerr_gsiv =3D cpu_to_le32(irq + 3); =20 - /* Identity RID mapping covering the whole input RID range */ - idmap =3D &smmu->id_mapping_array[0]; - idmap->input_base =3D 0; - idmap->id_count =3D cpu_to_le32(0xFFFF); - idmap->output_base =3D 0; /* output IORT node is the ITS group node (the first node) */ - idmap->output_reference =3D cpu_to_le32(iort_node_offset); + for (i =3D 0; i < smmu_idmap_ranges->len; i++) { + idmap =3D &smmu->id_mapping_array[i]; + range =3D &g_array_index(smmu_idmap_ranges, AcpiIortIdMapping,= i); + + idmap->input_base =3D cpu_to_le32(range->input_base); + idmap->id_count =3D cpu_to_le32(range->id_count); + idmap->output_base =3D cpu_to_le32(range->input_base); + idmap->output_reference =3D cpu_to_le32(iort_node_offset); + } } =20 /* Root Complex Node */ - node_size =3D sizeof(*rc) + sizeof(*idmap); + if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { + rc_map_count =3D smmu_idmap_ranges->len + its_idmap_ranges->len; + } else { + rc_map_count =3D 1; + } + + node_size =3D sizeof(*rc) + sizeof(*idmap) * rc_map_count; iort_length +=3D node_size; rc =3D acpi_data_push(table_data, node_size); =20 rc->type =3D ACPI_IORT_NODE_PCI_ROOT_COMPLEX; rc->length =3D cpu_to_le16(node_size); - rc->mapping_count =3D cpu_to_le32(1); + rc->mapping_count =3D cpu_to_le32(rc_map_count); rc->mapping_offset =3D cpu_to_le32(sizeof(*rc)); =20 /* fully coherent device */ @@ -319,20 +395,41 @@ build_iort(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) rc->memory_properties.memory_flags =3D 0x3; /* CCA =3D CPM =3D DCAS = =3D 1 */ rc->pci_segment_number =3D 0; /* MCFG pci_segment */ =20 - /* Identity RID mapping covering the whole input RID range */ - idmap =3D &rc->id_mapping_array[0]; - idmap->input_base =3D 0; - idmap->id_count =3D cpu_to_le32(0xFFFF); - idmap->output_base =3D 0; - if (vms->iommu =3D=3D VIRT_IOMMU_SMMUV3) { /* output IORT node is the smmuv3 node */ - idmap->output_reference =3D cpu_to_le32(smmu_offset); + for (i =3D 0; i < smmu_idmap_ranges->len; i++) { + idmap =3D &rc->id_mapping_array[i]; + range =3D &g_array_index(smmu_idmap_ranges, AcpiIortIdMapping,= i); + + idmap->input_base =3D cpu_to_le32(range->input_base); + idmap->id_count =3D cpu_to_le32(range->id_count); + idmap->output_base =3D cpu_to_le32(range->input_base); + idmap->output_reference =3D cpu_to_le32(smmu_offset); + } + + /* output IORT node is the ITS group node (the first node) */ + for (i =3D 0; i < its_idmap_ranges->len; i++) { + idmap =3D &rc->id_mapping_array[smmu_idmap_ranges->len + i]; + range =3D &g_array_index(its_idmap_ranges, AcpiIortIdMapping, = i); + + idmap->input_base =3D cpu_to_le32(range->input_base); + idmap->id_count =3D cpu_to_le32(range->id_count); + idmap->output_base =3D cpu_to_le32(range->input_base); + idmap->output_reference =3D cpu_to_le32(iort_node_offset); + } } else { + /* Identity RID mapping covering the whole input RID range */ + idmap =3D &rc->id_mapping_array[0]; + idmap->input_base =3D cpu_to_le32(0); + idmap->id_count =3D cpu_to_le32(0xFFFF); + idmap->output_base =3D cpu_to_le32(0); /* output IORT node is the ITS group node (the first node) */ idmap->output_reference =3D cpu_to_le32(iort_node_offset); } =20 + g_array_free(smmu_idmap_ranges, true); + g_array_free(its_idmap_ranges, true); + /* * Update the pointer address in case table_data->data moves during ab= ove * acpi_data_push operations. --=20 2.19.1 From nobody Thu May 9 02:22:43 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1621914949; cv=none; d=zohomail.com; s=zohoarc; b=EPXZXdAA66r8NbC/SopMhqKFfWxeE9nGTT2lAlj+AOQ5VOOhjX8cmPj8bAGSIoRI4j+qB8xohyHt47lEOqH5DqRBG3hYB3wFRkxQ8R0gUy+xhHkE503I24wZjGoLN0Bz0Cdi9ZiQvLQZ89Le81L/CkL6sOQDQL9kvBjhctR/huU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621914949; h=Content-Type: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=ttNxtPT9BPKx7pA/I6D2cYW8tNbSsUyYvafzz4gytkc=; b=OuKZuS0e8emB1WcvdZOFia6D6XAp7HEYaUu+rSz4bzKnelePKZvn5qjeqK8a6RHLRb7p9DIVh+YxPGjDihDKdXJAO+GtALYvb78MmBjUc955ICkwFEzYfrcZJxWIPpXtkaxQiyuRoBhS13XjE0kezSY70/dVm9sPdplDNcZcPWE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621914949354143.66090377903038; Mon, 24 May 2021 20:55:49 -0700 (PDT) Received: from localhost ([::1]:58430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llOAW-0002hQ-89 for importer2@patchew.org; Mon, 24 May 2021 23:55:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5N-0006RH-2q; Mon, 24 May 2021 23:50:29 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:4581) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5I-0001s8-3b; Mon, 24 May 2021 23:50:28 -0400 Received: from dggems704-chm.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Fq0R52CSZzmbJl; Tue, 25 May 2021 11:48:01 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggems704-chm.china.huawei.com (10.3.19.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:16 +0800 Received: from huawei.com (10.174.185.226) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:15 +0800 From: Wang Xingang To: , , , , , , , , , , Subject: [PATCH v4 7/8] hw/i386/acpi-build: Add explicit scope in DMAR table Date: Tue, 25 May 2021 03:50:04 +0000 Message-ID: <1621914605-14724-8-git-send-email-wangxingang5@huawei.com> X-Mailer: git-send-email 2.6.4.windows.1 In-Reply-To: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> References: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.185.226] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.32; envelope-from=wangxingang5@huawei.com; helo=szxga06-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xieyingtai@huawei.com, wangxingang5@huawei.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang In DMAR table, the drhd is set to cover all pci devices when intel_iommu is on. This patch add explicit scope data, including only the pci devices that go through iommu. Signed-off-by: Xingang Wang --- hw/i386/acpi-build.c | 68 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 80bee00da6..e839527184 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1991,6 +1991,56 @@ build_srat(GArray *table_data, BIOSLinker *linker, M= achineState *machine) x86ms->oem_table_id); } =20 +/* + * Insert DMAR scope for PCI bridges and endpoint devcie + */ +static void +insert_scope(PCIBus *bus, PCIDevice *dev, void *opaque) +{ + GArray *scope_blob =3D opaque; + AcpiDmarDeviceScope *scope =3D NULL; + + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) { + /* Dmar Scope Type: 0x02 for PCI Bridge */ + build_append_int_noprefix(scope_blob, 0x02, 1); + } else { + /* Dmar Scope Type: 0x01 for PCI Endpoint Device */ + build_append_int_noprefix(scope_blob, 0x01, 1); + } + + /* length */ + build_append_int_noprefix(scope_blob, + sizeof(*scope) + sizeof(scope->path[0]), 1); + /* reserved */ + build_append_int_noprefix(scope_blob, 0, 2); + /* enumeration_id */ + build_append_int_noprefix(scope_blob, 0, 1); + /* bus */ + build_append_int_noprefix(scope_blob, pci_bus_num(bus), 1); + /* device */ + build_append_int_noprefix(scope_blob, PCI_SLOT(dev->devfn), 1); + /* function */ + build_append_int_noprefix(scope_blob, PCI_FUNC(dev->devfn), 1); +} + +/* For a given PCI host bridge, walk and insert DMAR scope */ +static int +dmar_host_bridges(Object *obj, void *opaque) +{ + GArray *scope_blob =3D opaque; + + if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) { + PCIBus *bus =3D PCI_HOST_BRIDGE(obj)->bus; + + if (bus && !pci_bus_bypass_iommu(bus)) { + pci_for_each_device(bus, pci_bus_num(bus), insert_scope, + scope_blob); + } + } + + return 0; +} + /* * VT-d spec 8.1 DMA Remapping Reporting Structure * (version Oct. 2014 or later) @@ -2010,6 +2060,15 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, /* Root complex IOAPIC use one path[0] only */ size_t ioapic_scope_size =3D sizeof(*scope) + sizeof(scope->path[0]); IntelIOMMUState *intel_iommu =3D INTEL_IOMMU_DEVICE(iommu); + GArray *scope_blob =3D g_array_new(false, true, 1); + + /* + * A PCI bus walk, for each PCI host bridge. + * Insert scope for each PCI bridge and endpoint device which + * is attached to a bus with iommu enabled. + */ + object_child_foreach_recursive(object_get_root(), + dmar_host_bridges, scope_blob); =20 assert(iommu); if (x86_iommu_ir_supported(iommu)) { @@ -2023,8 +2082,9 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linker= , const char *oem_id, /* DMAR Remapping Hardware Unit Definition structure */ drhd =3D acpi_data_push(table_data, sizeof(*drhd) + ioapic_scope_size); drhd->type =3D cpu_to_le16(ACPI_DMAR_TYPE_HARDWARE_UNIT); - drhd->length =3D cpu_to_le16(sizeof(*drhd) + ioapic_scope_size); - drhd->flags =3D ACPI_DMAR_INCLUDE_PCI_ALL; + drhd->length =3D + cpu_to_le16(sizeof(*drhd) + ioapic_scope_size + scope_blob->len); + drhd->flags =3D 0; /* Don't include all pci device */ drhd->pci_segment =3D cpu_to_le16(0); drhd->address =3D cpu_to_le64(Q35_HOST_BRIDGE_IOMMU_ADDR); =20 @@ -2038,6 +2098,10 @@ build_dmar_q35(GArray *table_data, BIOSLinker *linke= r, const char *oem_id, scope->path[0].device =3D PCI_SLOT(Q35_PSEUDO_DEVFN_IOAPIC); scope->path[0].function =3D PCI_FUNC(Q35_PSEUDO_DEVFN_IOAPIC); =20 + /* Add scope found above */ + g_array_append_vals(table_data, scope_blob->data, scope_blob->len); + g_array_free(scope_blob, true); + if (iommu->dt_supported) { atsr =3D acpi_data_push(table_data, sizeof(*atsr)); atsr->type =3D cpu_to_le16(ACPI_DMAR_TYPE_ATSR); --=20 2.19.1 From nobody Thu May 9 02:22:43 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1621914784; cv=none; d=zohomail.com; s=zohoarc; b=YQRt7b5mj/ufKdwhyMkIBFj3WSRFqzT4wn4Jiob1T24bHaKgrkcWpYWL8gRO8zeUHprZLy3Lo6sZMwuuvBrocKCOsv3tORc6xLSZddEcSBFzIfzSseUtEiWBPwAvWfXTqCUIXK4b6jawNpp3+Sea19n/0hP6CokIzLndiBCl/ec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621914784; h=Content-Type: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=i74ZS+e+LcczdsprclCVWDD67UNEmBD9BtiedK3MwME=; b=GGt1bd9dzn3xa/QmD+Iqw4BnS7FfE4D2MKCdcgj2dj2x99gLYjql1ElixYNRC3REGoHUHM+mMFDpJyKDnTT0Ico0nDdnOAaTb0V4drGazf6DhFsRmQCqPavJMZ5c4eIzIYMwX7zvfv5QK+Loi5XrGxD+Uy3jK8z0as36nrAd5Ww= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621914784801598.1481078256129; Mon, 24 May 2021 20:53:04 -0700 (PDT) Received: from localhost ([::1]:49826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1llO7r-0005Pl-RV for importer2@patchew.org; Mon, 24 May 2021 23:53:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5M-0006PW-43; Mon, 24 May 2021 23:50:28 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3434) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llO5H-0001nF-Qs; Mon, 24 May 2021 23:50:27 -0400 Received: from dggems701-chm.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Fq0PX5VylzP0J3; Tue, 25 May 2021 11:46:40 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggems701-chm.china.huawei.com (10.3.19.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:16 +0800 Received: from huawei.com (10.174.185.226) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 11:50:16 +0800 From: Wang Xingang To: , , , , , , , , , , Subject: [PATCH v4 8/8] hw/i386/acpi-build: Add bypass_iommu check when building IVRS table Date: Tue, 25 May 2021 03:50:05 +0000 Message-ID: <1621914605-14724-9-git-send-email-wangxingang5@huawei.com> X-Mailer: git-send-email 2.6.4.windows.1 In-Reply-To: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> References: <1621914605-14724-1-git-send-email-wangxingang5@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.185.226] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.191; envelope-from=wangxingang5@huawei.com; helo=szxga05-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xieyingtai@huawei.com, wangxingang5@huawei.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xingang Wang When building IVRS table, only devices which go through iommu will be scanned, and the corresponding ivhd will be inserted. Signed-off-by: Xingang Wang --- hw/i386/acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e839527184..d3ef485fa4 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2232,7 +2232,7 @@ ivrs_host_bridges(Object *obj, void *opaque) if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) { PCIBus *bus =3D PCI_HOST_BRIDGE(obj)->bus; =20 - if (bus) { + if (bus && !pci_bus_bypass_iommu(bus)) { pci_for_each_device(bus, pci_bus_num(bus), insert_ivhd, ivhd_b= lob); } } --=20 2.19.1