Hi Xingang,

On 2/27/21 9:33 AM, Wang Xingang wrote:
> From: Xingang Wang <wangxinga...@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 <wangxinga...@huawei.com>
> Signed-off-by: Jiahui Cen <cenjia...@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


Reply via email to