qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC RESEND PATCH 1/4] pci: Add PCI_BUS_IOMMU property


From: Wang Xingang
Subject: Re: [RFC RESEND PATCH 1/4] pci: Add PCI_BUS_IOMMU property
Date: Thu, 11 Mar 2021 19:59:59 +0800
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1

Hi Eric,

On 2021/3/10 18:25, Auger Eric wrote:
Hi Xingang,

On 2/27/21 9:33 AM, Wang Xingang wrote:
From: Xingang Wang <wangxingang5@huawei.com>

This Property can be useful to check whether this bus is attached to iommu.

Strictly speaking this is not a Property (QEMU property) but a flag

Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
---
  include/hw/pci/pci_bus.h | 13 +++++++++++++
  1 file changed, 13 insertions(+)

diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index 347440d42c..42109e8a06 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -24,6 +24,8 @@ enum PCIBusFlags {
      PCI_BUS_IS_ROOT                                         = 0x0001,
      /* PCIe extended configuration space is accessible on this bus */
      PCI_BUS_EXTENDED_CONFIG_SPACE                           = 0x0002,
+    /* Iommu is enabled on this bus */
s/Iommu/IOMMU here and elsewhere
+    PCI_BUS_IOMMU                                           = 0x0004,
  };
struct PCIBus {
@@ -63,4 +65,15 @@ static inline bool 
pci_bus_allows_extended_config_space(PCIBus *bus)
      return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
  }
+static inline bool pci_bus_has_iommu(PCIBus *bus)
+{
+    PCIBus *root_bus = bus;
+
+    while (root_bus && !pci_bus_is_root(root_bus)) {
+        root_bus = pci_get_bus(root_bus->parent_dev);
+    }
+
+    return !!(root_bus->flags & PCI_BUS_IOMMU);
+}
+
  #endif /* QEMU_PCI_BUS_H */

Eric

.


Thanks, i will fix this.

Xingang

.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]