|
@@ -68,9 +68,11 @@
|
|
#include "qom/qom-qobject.h"
|
|
#include "qom/qom-qobject.h"
|
|
#include "hw/i386/amd_iommu.h"
|
|
#include "hw/i386/amd_iommu.h"
|
|
#include "hw/i386/intel_iommu.h"
|
|
#include "hw/i386/intel_iommu.h"
|
|
|
|
+#include "hw/virtio/virtio-iommu.h"
|
|
|
|
|
|
#include "hw/acpi/ipmi.h"
|
|
#include "hw/acpi/ipmi.h"
|
|
#include "hw/acpi/hmat.h"
|
|
#include "hw/acpi/hmat.h"
|
|
|
|
+#include "hw/acpi/viot.h"
|
|
|
|
|
|
/* These are used to size the ACPI tables for -M pc-i440fx-1.7 and
|
|
/* These are used to size the ACPI tables for -M pc-i440fx-1.7 and
|
|
* -M pc-i440fx-2.0. Even if the actual amount of AML generated grows
|
|
* -M pc-i440fx-2.0. Even if the actual amount of AML generated grows
|
|
@@ -2132,8 +2134,7 @@ dmar_host_bridges(Object *obj, void *opaque)
|
|
PCIBus *bus = PCI_HOST_BRIDGE(obj)->bus;
|
|
PCIBus *bus = PCI_HOST_BRIDGE(obj)->bus;
|
|
|
|
|
|
if (bus && !pci_bus_bypass_iommu(bus)) {
|
|
if (bus && !pci_bus_bypass_iommu(bus)) {
|
|
- pci_for_each_device(bus, pci_bus_num(bus), insert_scope,
|
|
|
|
- scope_blob);
|
|
|
|
|
|
+ pci_for_each_device_under_bus(bus, insert_scope, scope_blob);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2339,7 +2340,7 @@ ivrs_host_bridges(Object *obj, void *opaque)
|
|
PCIBus *bus = PCI_HOST_BRIDGE(obj)->bus;
|
|
PCIBus *bus = PCI_HOST_BRIDGE(obj)->bus;
|
|
|
|
|
|
if (bus && !pci_bus_bypass_iommu(bus)) {
|
|
if (bus && !pci_bus_bypass_iommu(bus)) {
|
|
- pci_for_each_device(bus, pci_bus_num(bus), insert_ivhd, ivhd_blob);
|
|
|
|
|
|
+ pci_for_each_device_under_bus(bus, insert_ivhd, ivhd_blob);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2488,6 +2489,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
|
PCMachineState *pcms = PC_MACHINE(machine);
|
|
PCMachineState *pcms = PC_MACHINE(machine);
|
|
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
|
|
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
|
|
X86MachineState *x86ms = X86_MACHINE(machine);
|
|
X86MachineState *x86ms = X86_MACHINE(machine);
|
|
|
|
+ DeviceState *iommu = pcms->iommu;
|
|
GArray *table_offsets;
|
|
GArray *table_offsets;
|
|
unsigned facs, dsdt, rsdt, fadt;
|
|
unsigned facs, dsdt, rsdt, fadt;
|
|
AcpiPmInfo pm;
|
|
AcpiPmInfo pm;
|
|
@@ -2604,17 +2606,20 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
|
|
build_mcfg(tables_blob, tables->linker, &mcfg, x86ms->oem_id,
|
|
build_mcfg(tables_blob, tables->linker, &mcfg, x86ms->oem_id,
|
|
x86ms->oem_table_id);
|
|
x86ms->oem_table_id);
|
|
}
|
|
}
|
|
- if (x86_iommu_get_default()) {
|
|
|
|
- IommuType IOMMUType = x86_iommu_get_type();
|
|
|
|
- if (IOMMUType == TYPE_AMD) {
|
|
|
|
- acpi_add_table(table_offsets, tables_blob);
|
|
|
|
- build_amd_iommu(tables_blob, tables->linker, x86ms->oem_id,
|
|
|
|
- x86ms->oem_table_id);
|
|
|
|
- } else if (IOMMUType == TYPE_INTEL) {
|
|
|
|
- acpi_add_table(table_offsets, tables_blob);
|
|
|
|
- build_dmar_q35(tables_blob, tables->linker, x86ms->oem_id,
|
|
|
|
- x86ms->oem_table_id);
|
|
|
|
- }
|
|
|
|
|
|
+ if (object_dynamic_cast(OBJECT(iommu), TYPE_AMD_IOMMU_DEVICE)) {
|
|
|
|
+ acpi_add_table(table_offsets, tables_blob);
|
|
|
|
+ build_amd_iommu(tables_blob, tables->linker, x86ms->oem_id,
|
|
|
|
+ x86ms->oem_table_id);
|
|
|
|
+ } else if (object_dynamic_cast(OBJECT(iommu), TYPE_INTEL_IOMMU_DEVICE)) {
|
|
|
|
+ acpi_add_table(table_offsets, tables_blob);
|
|
|
|
+ build_dmar_q35(tables_blob, tables->linker, x86ms->oem_id,
|
|
|
|
+ x86ms->oem_table_id);
|
|
|
|
+ } else if (object_dynamic_cast(OBJECT(iommu), TYPE_VIRTIO_IOMMU_PCI)) {
|
|
|
|
+ PCIDevice *pdev = PCI_DEVICE(iommu);
|
|
|
|
+
|
|
|
|
+ acpi_add_table(table_offsets, tables_blob);
|
|
|
|
+ build_viot(machine, tables_blob, tables->linker, pci_get_bdf(pdev),
|
|
|
|
+ x86ms->oem_id, x86ms->oem_table_id);
|
|
}
|
|
}
|
|
if (machine->nvdimms_state->is_enabled) {
|
|
if (machine->nvdimms_state->is_enabled) {
|
|
nvdimm_build_acpi(table_offsets, tables_blob, tables->linker,
|
|
nvdimm_build_acpi(table_offsets, tables_blob, tables->linker,
|