mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 13:37:10 +00:00
hv: vtd: check bus limit when add/remove device
Check bus limit when add/remove device in iommu. Tracked-On: #2743 Signed-off-by: Binbin Wu <binbin.wu@intel.com>
This commit is contained in:
parent
3e5bccd755
commit
0a9aeaa10e
@ -959,6 +959,11 @@ static int32_t remove_iommu_device(const struct iommu_domain *domain, uint16_t s
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (dmar_unit->drhd->ignore) {
|
||||
dev_dbg(ACRN_DBG_IOMMU, "device is ignored :0x%x:%x.%x", bus, pci_slot(devfun), pci_func(devfun));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
root_table = (struct dmar_root_entry *)hpa2hva(dmar_unit->root_table_addr);
|
||||
root_entry = root_table + bus;
|
||||
|
||||
@ -1057,6 +1062,11 @@ int32_t assign_iommu_device(struct iommu_domain *domain, uint8_t bus, uint8_t de
|
||||
|
||||
/* TODO: check if the device assigned */
|
||||
|
||||
if ((uint16_t)bus >= CONFIG_IOMMU_BUS_NUM) {
|
||||
pr_err("bus 0x%x out of range", bus);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (vm0_domain != NULL) {
|
||||
status = remove_iommu_device(vm0_domain, 0U, bus, devfun);
|
||||
if (status != 0) {
|
||||
@ -1071,6 +1081,11 @@ int32_t unassign_iommu_device(const struct iommu_domain *domain, uint8_t bus, ui
|
||||
{
|
||||
int32_t status = 0;
|
||||
|
||||
if ((uint16_t)bus >= CONFIG_IOMMU_BUS_NUM) {
|
||||
pr_err("bus 0x%x out of range", bus);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* TODO: check if the device assigned */
|
||||
status = remove_iommu_device(domain, 0U, bus, devfun);
|
||||
if (status != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user