4 * Copyright (c) 2020 Red Hat, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2 or later, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef QEMU_VIRTIO_IOMMU_H
21 #define QEMU_VIRTIO_IOMMU_H
23 #include "standard-headers/linux/virtio_iommu.h"
24 #include "hw/virtio/virtio.h"
25 #include "hw/pci/pci.h"
27 #define TYPE_VIRTIO_IOMMU "virtio-iommu-device"
28 #define TYPE_VIRTIO_IOMMU_PCI "virtio-iommu-device-base"
29 #define VIRTIO_IOMMU(obj) \
30 OBJECT_CHECK(VirtIOIOMMU, (obj), TYPE_VIRTIO_IOMMU)
32 #define TYPE_VIRTIO_IOMMU_MEMORY_REGION "virtio-iommu-memory-region"
34 typedef struct IOMMUDevice
{
38 IOMMUMemoryRegion iommu_mr
;
42 typedef struct IOMMUPciBus
{
44 IOMMUDevice
*pbdev
[]; /* Parent array is sparse, so dynamically alloc */
47 typedef struct VirtIOIOMMU
{
48 VirtIODevice parent_obj
;
51 struct virtio_iommu_config config
;
53 GHashTable
*as_by_busptr
;
54 IOMMUPciBus
*iommu_pcibus_by_bus_num
[PCI_BUS_MAX
];
56 ReservedRegion
*reserved_regions
;
57 uint32_t nb_reserved_regions
;