@@ -32,6 +32,7 @@
#include "hw/pci-host/q35.h"
#include "qapi/error.h"
#include "qapi/visitor.h"
+#include "hw/i386/amd_iommu.h"
/****************************************************************************
* Q35 host
@@ -448,6 +449,19 @@ static void mch_init_dmar(MCHPCIState *mch)
pci_setup_iommu(pci_bus, q35_host_dma_iommu, mch->iommu);
}
+static void mch_init_amdvi(MCHPCIState *mch)
+{
+ AMDVIState *iommu_state;
+ PCIBus *bus = PCI_BUS(qdev_get_parent_bus(DEVICE(mch)));
+ PCIDevice *iommu;
+
+ iommu = pci_create_simple(bus, 0x20, TYPE_AMD_IOMMU_DEVICE);
+
+ iommu_state = AMD_IOMMU_DEVICE(iommu);
+
+ pci_setup_iommu(bus, bridge_host_amdvi, iommu_state);
+}
+
static void mch_realize(PCIDevice *d, Error **errp)
{
int i;
@@ -506,9 +520,14 @@ static void mch_realize(PCIDevice *d, Error **errp)
mch->pci_address_space, &mch->pam_regions[i+1],
PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE);
}
- /* Intel IOMMU (VT-d) */
- if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
- mch_init_dmar(mch);
+
+ MachineState *machine = MACHINE(qdev_get_machine());
+ if (machine->iommu) {
+ if (machine->iommu_type == TYPE_AMD) {
+ mch_init_amdvi(mch);
+ } else {
+ mch_init_dmar(mch);
+ }
}
}
Add AMD IOMMU emulation support to q35 chipset Signed-off-by: David Kiarie <davidkiarie4@gmail.com> --- hw/pci-host/q35.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)