Skip to contentSkip to conversation

iommu/intel: Exclude devices using RMRRs from IOMMU API domains

PATCH RESEND Superseded Alex Williamson 2 participants 3 messages Jun 12, 2014 – Jun 13, 2014 IOMMU

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 iommu/intel: Exclude devices using RMRRs from IOMMU API domains

The user of the IOMMU API domain expects to have full control of the IOVA space for the domain. RMRRs are fundamentally incompatible with that idea. We can neither map the RMRR into the IOMMU API domain, nor can we guarantee that the device won't continue DMA with the area described by the RMRR as part of the new domain. Therefore we must prevent such devices from being used by the IOMMU API.

---

I didn't see any actionable items from the last posting of this, so re-posting unchanged.

 drivers/iommu/intel-iommu.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/iommu/intel-iommu.c +15 -0
index c4f11c0..41db805 100644
@@ -4171,6 +4171,21 @@ static int intel_iommu_attach_device(struct iommu_domain *domain,
 	int addr_width;
 	u8 bus, devfn;
 
+	/*
+	 * With IOMMU API domains we don't have the freedom to insert RMRR
+	 * entries into the domain mapping, the IOMMU API user expects full
+	 * control of the IOVA space of the device.  We also have no ability
+	 * to shutdown whatever back channel operations occur through the
+	 * RMRR.  Therefore our only option is to prevent devices making use
+	 * of RMRRs from being used by the IOMMU API.  As usual we exempt
+	 * USB devices since their RMRR support is largely historical.
+	 */
+	if (device_has_rmrr(dev) && (!dev_is_pci(dev) ||
+	    (to_pci_dev(dev)->class >> 8) != PCI_CLASS_SERIAL_USB)) {
+		dev_warn(dev, "Device is ineligible for IOMMU domain attach due to platform RMRR requirement.  Contact your platform vendor.\n");
+		return -EPERM;
+	}
+
 	/* normally dev is not mapped */
 	if (unlikely(domain_context_mapped(dev))) {
 		struct dmar_domain *old_domain;
#1 lore raw
Quoted 7 lines · Alex Williamson

The user of the IOMMU API domain expects to have full control of the IOVA space for the domain. RMRRs are fundamentally incompatible with that idea. We can neither map the RMRR into the IOMMU API domain, nor can we guarantee that the device won't continue DMA with the area described by the RMRR as part of the new domain. Therefore we must prevent such devices from being used by the IOMMU API.

Quoted 5 lines

---

I didn't see any actionable items from the last posting of this, so re-posting unchanged.

That also wants a Cc:stable, I suppose.

I note we now have two copies of the 'device has RMRR and we actually care' logic, where the latter clause is really just "is it USB".

Is it worth consolidating that into a macro that's used in both places, in case the check does get more complicated? Are other devices going to start getting added to the class of "we don't need the RMRRs to persist and we *do* want to be able to assign them"... or is that just needlessly overcomplicating it at this stage?

Signature · 2 lines
David Woodhouse                            Open Source Technology Centre
[email protected]                              Intel Corporation
#2 lore raw
Quoted 16 lines · David Woodhouse
Quoted 7 lines · Alex Williamson

The user of the IOMMU API domain expects to have full control of the IOVA space for the domain. RMRRs are fundamentally incompatible with that idea. We can neither map the RMRR into the IOMMU API domain, nor can we guarantee that the device won't continue DMA with the area described by the RMRR as part of the new domain. Therefore we must prevent such devices from being used by the IOMMU API.

Quoted 5 lines

---

I didn't see any actionable items from the last posting of this, so re-posting unchanged.

That also wants a Cc:stable, I suppose.

Quoted 8 lines

I note we now have two copies of the 'device has RMRR and we actually care' logic, where the latter clause is really just "is it USB".

Is it worth consolidating that into a macro that's used in both places, in case the check does get more complicated? Are other devices going to start getting added to the class of "we don't need the RMRRs to persist and we *do* want to be able to assign them"... or is that just needlessly overcomplicating it at this stage?

v2 sent with a single function used in both places. I suppose time will tell if we need to start whitelisting other devices, I'm actually a bit nervous what vendors will start hiding in USB RMRRs if they know we handle them differently. We can always add platform or device specific quirks when we find out about vendors finding new ways to be creative. Thanks,

Alex