qemu/include/hw/virtio/virtio-iommu.h
<<
>>
Prefs
   1/*
   2 * virtio-iommu device
   3 *
   4 * Copyright (c) 2020 Red Hat, Inc.
   5 *
   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.
   9 *
  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
  13 * more details.
  14 *
  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/>.
  17 *
  18 */
  19
  20#ifndef QEMU_VIRTIO_IOMMU_H
  21#define QEMU_VIRTIO_IOMMU_H
  22
  23#include "standard-headers/linux/virtio_iommu.h"
  24#include "hw/virtio/virtio.h"
  25#include "hw/pci/pci.h"
  26#include "qom/object.h"
  27#include "qapi/qapi-types-virtio.h"
  28#include "system/host_iommu_device.h"
  29
  30#define TYPE_VIRTIO_IOMMU "virtio-iommu-device"
  31#define TYPE_VIRTIO_IOMMU_PCI "virtio-iommu-pci"
  32OBJECT_DECLARE_SIMPLE_TYPE(VirtIOIOMMU, VIRTIO_IOMMU)
  33
  34#define TYPE_VIRTIO_IOMMU_MEMORY_REGION "virtio-iommu-memory-region"
  35
  36typedef struct IOMMUDevice {
  37    void         *viommu;
  38    PCIBus       *bus;
  39    int           devfn;
  40    IOMMUMemoryRegion  iommu_mr;
  41    AddressSpace  as;
  42    MemoryRegion root;          /* The root container of the device */
  43    MemoryRegion bypass_mr;     /* The alias of shared memory MR */
  44    GList *resv_regions;
  45    GList *host_resv_ranges;
  46} IOMMUDevice;
  47
  48typedef struct IOMMUPciBus {
  49    PCIBus       *bus;
  50    IOMMUDevice  *pbdev[]; /* Parent array is sparse, so dynamically alloc */
  51} IOMMUPciBus;
  52
  53struct VirtIOIOMMU {
  54    VirtIODevice parent_obj;
  55    VirtQueue *req_vq;
  56    VirtQueue *event_vq;
  57    struct virtio_iommu_config config;
  58    uint64_t features;
  59    GHashTable *as_by_busptr;
  60    GHashTable *host_iommu_devices;
  61    IOMMUPciBus *iommu_pcibus_by_bus_num[PCI_BUS_MAX];
  62    PCIBus *primary_bus;
  63    ReservedRegion *prop_resv_regions;
  64    uint32_t nr_prop_resv_regions;
  65    GTree *domains;
  66    QemuRecMutex mutex;
  67    GTree *endpoints;
  68    bool boot_bypass;
  69    Notifier machine_done;
  70    bool granule_frozen;
  71    GranuleMode granule_mode;
  72    uint8_t aw_bits;
  73};
  74
  75#endif
  76