Skip to content

Commit d3aedf9

Browse files
LuBaolujoergroedel
authored andcommitted
iommu/vt-d: Remove rmrr check in domain attaching device path
The core code now prevents devices with RMRR regions from being assigned to user space. There is no need to check for this condition in individual drivers. Remove it to avoid duplicate code. Signed-off-by: Lu Baolu <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent a48ce36 commit d3aedf9

File tree

1 file changed

+0
-58
lines changed

1 file changed

+0
-58
lines changed

drivers/iommu/intel/iommu.c

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2487,30 +2487,6 @@ static int dmar_domain_attach_device(struct dmar_domain *domain,
24872487
return 0;
24882488
}
24892489

2490-
static bool device_has_rmrr(struct device *dev)
2491-
{
2492-
struct dmar_rmrr_unit *rmrr;
2493-
struct device *tmp;
2494-
int i;
2495-
2496-
rcu_read_lock();
2497-
for_each_rmrr_units(rmrr) {
2498-
/*
2499-
* Return TRUE if this RMRR contains the device that
2500-
* is passed in.
2501-
*/
2502-
for_each_active_dev_scope(rmrr->devices,
2503-
rmrr->devices_cnt, i, tmp)
2504-
if (tmp == dev ||
2505-
is_downstream_to_pci_bridge(dev, tmp)) {
2506-
rcu_read_unlock();
2507-
return true;
2508-
}
2509-
}
2510-
rcu_read_unlock();
2511-
return false;
2512-
}
2513-
25142490
/**
25152491
* device_rmrr_is_relaxable - Test whether the RMRR of this device
25162492
* is relaxable (ie. is allowed to be not enforced under some conditions)
@@ -2540,34 +2516,6 @@ static bool device_rmrr_is_relaxable(struct device *dev)
25402516
return false;
25412517
}
25422518

2543-
/*
2544-
* There are a couple cases where we need to restrict the functionality of
2545-
* devices associated with RMRRs. The first is when evaluating a device for
2546-
* identity mapping because problems exist when devices are moved in and out
2547-
* of domains and their respective RMRR information is lost. This means that
2548-
* a device with associated RMRRs will never be in a "passthrough" domain.
2549-
* The second is use of the device through the IOMMU API. This interface
2550-
* expects to have full control of the IOVA space for the device. We cannot
2551-
* satisfy both the requirement that RMRR access is maintained and have an
2552-
* unencumbered IOVA space. We also have no ability to quiesce the device's
2553-
* use of the RMRR space or even inform the IOMMU API user of the restriction.
2554-
* We therefore prevent devices associated with an RMRR from participating in
2555-
* the IOMMU API, which eliminates them from device assignment.
2556-
*
2557-
* In both cases, devices which have relaxable RMRRs are not concerned by this
2558-
* restriction. See device_rmrr_is_relaxable comment.
2559-
*/
2560-
static bool device_is_rmrr_locked(struct device *dev)
2561-
{
2562-
if (!device_has_rmrr(dev))
2563-
return false;
2564-
2565-
if (device_rmrr_is_relaxable(dev))
2566-
return false;
2567-
2568-
return true;
2569-
}
2570-
25712519
/*
25722520
* Return the required default domain type for a specific device.
25732521
*
@@ -4180,12 +4128,6 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,
41804128
struct device_domain_info *info = dev_iommu_priv_get(dev);
41814129
int ret;
41824130

4183-
if (domain->type == IOMMU_DOMAIN_UNMANAGED &&
4184-
device_is_rmrr_locked(dev)) {
4185-
dev_warn(dev, "Device is ineligible for IOMMU domain attach due to platform RMRR requirement. Contact your platform vendor.\n");
4186-
return -EPERM;
4187-
}
4188-
41894131
if (info->domain)
41904132
device_block_translation(dev);
41914133

0 commit comments

Comments
 (0)