From: Sairaj Kodilkar <[email protected]> Currently, build_amd_iommu() uses "addr" property to build the DeviceID for IOMMU device and advertise it through IVRS. But this property does not encode IOMMU bus number, only the device and function number. This creates an incorrect DeviceID when the IOMMU is attached to a bus other than the default one with bus number 0.
Signed-off-by: Sairaj Kodilkar <[email protected]> Reviewed-by: Alejandro Jimenez <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Message-ID: <[email protected]> --- hw/i386/acpi-build.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 05b68d05a8..a28bb2ec63 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1851,6 +1851,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, AcpiTable table = { .sig = "IVRS", .rev = 1, .oem_id = oem_id, .oem_table_id = oem_table_id }; uint64_t feature_report; + uint16_t iommu_devid = pci_get_bdf(&s->pci->dev); acpi_table_begin(&table, table_data); /* IVinfo - IO virtualization information common to all @@ -1913,9 +1914,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, /* IVHD length */ build_append_int_noprefix(table_data, ivhd_blob->len + 24, 2); /* DeviceID */ - build_append_int_noprefix(table_data, - object_property_get_int(OBJECT(s->pci), "addr", - &error_abort), 2); + build_append_int_noprefix(table_data, iommu_devid, 2); /* Capability offset */ build_append_int_noprefix(table_data, s->pci->capab_offset, 2); /* IOMMU base address */ @@ -1947,10 +1946,9 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, /* IVHD length */ build_append_int_noprefix(table_data, ivhd_blob->len + 40, 2); + /* DeviceID */ - build_append_int_noprefix(table_data, - object_property_get_int(OBJECT(s->pci), "addr", - &error_abort), 2); + build_append_int_noprefix(table_data, iommu_devid, 2); /* Capability offset */ build_append_int_noprefix(table_data, s->pci->capab_offset, 2); /* IOMMU base address */ -- MST
