diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c index 1d49c3030..f084a6bf3 100644 --- a/hypervisor/arch/x86/vtd.c +++ b/hypervisor/arch/x86/vtd.c @@ -205,7 +205,7 @@ static inline uint16_t vmid_to_domainid(uint16_t vm_id) } static int32_t dmar_register_hrhd(struct dmar_drhd_rt *dmar_unit); -static struct dmar_drhd_rt *device_to_dmaru(uint16_t segment, uint8_t bus, uint8_t devfun); +static struct dmar_drhd_rt *device_to_dmaru(uint8_t bus, uint8_t devfun); static int32_t register_hrhd_units(void) { struct dmar_drhd_rt *drhd_rt; @@ -553,7 +553,7 @@ static struct dmar_drhd_rt *ioapic_to_dmaru(uint16_t ioapic_id, union pci_bdf *s return dmar_unit; } -static struct dmar_drhd_rt *device_to_dmaru(uint16_t segment, uint8_t bus, uint8_t devfun) +static struct dmar_drhd_rt *device_to_dmaru(uint8_t bus, uint8_t devfun) { struct dmar_drhd_rt *dmar_unit = NULL; uint32_t i, j; @@ -561,10 +561,6 @@ static struct dmar_drhd_rt *device_to_dmaru(uint16_t segment, uint8_t bus, uint8 for (j = 0U; j < platform_dmar_info->drhd_count; j++) { dmar_unit = &dmar_drhd_units[j]; - if (dmar_unit->drhd->segment != segment) { - continue; - } - for (i = 0U; i < dmar_unit->drhd->dev_cnt; i++) { if ((dmar_unit->drhd->devices[i].bus == bus) && (dmar_unit->drhd->devices[i].devfun == devfun)) { @@ -572,7 +568,6 @@ static struct dmar_drhd_rt *device_to_dmaru(uint16_t segment, uint8_t bus, uint8 } } - /* found exact one or the one which has the same segment number with INCLUDE_PCI_ALL set */ if ((i != dmar_unit->drhd->dev_cnt) || ((dmar_unit->drhd->flags & DRHD_FLAG_INCLUDE_PCI_ALL_MASK) != 0U)) { break; } @@ -1049,7 +1044,7 @@ static void dmar_resume(struct dmar_drhd_rt *dmar_unit) dmar_enable_intr_remapping(dmar_unit); } -static int32_t add_iommu_device(struct iommu_domain *domain, uint16_t segment, uint8_t bus, uint8_t devfun) +static int32_t add_iommu_device(struct iommu_domain *domain, uint8_t bus, uint8_t devfun) { struct dmar_drhd_rt *dmar_unit; struct dmar_entry *root_table; @@ -1066,7 +1061,7 @@ static int32_t add_iommu_device(struct iommu_domain *domain, uint16_t segment, u sid.fields.bus = bus; sid.fields.devfun = devfun; - dmar_unit = device_to_dmaru(segment, bus, devfun); + dmar_unit = device_to_dmaru(bus, devfun); if (dmar_unit == NULL) { pr_err("no dmar unit found for device: %x:%x.%x", bus, sid.bits.d, sid.bits.f); ret = -EINVAL; @@ -1164,7 +1159,7 @@ static int32_t add_iommu_device(struct iommu_domain *domain, uint16_t segment, u return ret; } -static int32_t remove_iommu_device(const struct iommu_domain *domain, uint16_t segment, uint8_t bus, uint8_t devfun) +static int32_t remove_iommu_device(const struct iommu_domain *domain, uint8_t bus, uint8_t devfun) { struct dmar_drhd_rt *dmar_unit; struct dmar_entry *root_table; @@ -1176,7 +1171,7 @@ static int32_t remove_iommu_device(const struct iommu_domain *domain, uint16_t s union pci_bdf sid; int32_t ret = 0; - dmar_unit = device_to_dmaru(segment, bus, devfun); + dmar_unit = device_to_dmaru(bus, devfun); sid.fields.bus = bus; sid.fields.devfun = devfun; @@ -1302,11 +1297,11 @@ int32_t move_pt_device(const struct iommu_domain *from_domain, struct iommu_doma if (bus_local < CONFIG_IOMMU_BUS_NUM) { if (from_domain != NULL) { - status = remove_iommu_device(from_domain, 0U, bus, devfun); + status = remove_iommu_device(from_domain, bus, devfun); } if ((status == 0) && (to_domain != NULL)) { - status = add_iommu_device(to_domain, 0U, bus, devfun); + status = add_iommu_device(to_domain, bus, devfun); } } else { status = -EINVAL; @@ -1373,7 +1368,7 @@ int32_t dmar_assign_irte(struct intr_source intr_src, union dmar_ir_entry irte, int32_t ret = 0; if (intr_src.is_msi) { - dmar_unit = device_to_dmaru(0U, (uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun); + dmar_unit = device_to_dmaru((uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun); sid.value = intr_src.src.msi.value; trigger_mode = 0x0UL; } else { @@ -1417,7 +1412,7 @@ void dmar_free_irte(struct intr_source intr_src, uint16_t index) union pci_bdf sid; if (intr_src.is_msi) { - dmar_unit = device_to_dmaru(0U, (uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun); + dmar_unit = device_to_dmaru((uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun); } else { dmar_unit = ioapic_to_dmaru(intr_src.src.ioapic_id, &sid); }