The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [RESEND PATCH] iommu/intel: Exclude devices using RMRRs from IOMMU API domains
@ 2014-06-12 16:35 Alex Williamson
  2014-06-13 14:34 ` David Woodhouse
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Williamson @ 2014-06-12 16:35 UTC (permalink / raw)
  To: iommu, dwmw2; +Cc: chegu_vinod, linux-kernel

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.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

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(+)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index c4f11c0..41db805 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -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;


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH] iommu/intel: Exclude devices using RMRRs from IOMMU API domains
  2014-06-12 16:35 [RESEND PATCH] iommu/intel: Exclude devices using RMRRs from IOMMU API domains Alex Williamson
@ 2014-06-13 14:34 ` David Woodhouse
  2014-06-13 16:35   ` Alex Williamson
  0 siblings, 1 reply; 3+ messages in thread
From: David Woodhouse @ 2014-06-13 14:34 UTC (permalink / raw)
  To: Alex Williamson; +Cc: iommu, chegu_vinod, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1319 bytes --]

On Thu, 2014-06-12 at 10:35 -0600, Alex Williamson wrote:
> 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.
> 
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
> 
> 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?

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5745 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RESEND PATCH] iommu/intel: Exclude devices using RMRRs from IOMMU API domains
  2014-06-13 14:34 ` David Woodhouse
@ 2014-06-13 16:35   ` Alex Williamson
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2014-06-13 16:35 UTC (permalink / raw)
  To: David Woodhouse; +Cc: iommu, chegu_vinod, linux-kernel

On Fri, 2014-06-13 at 15:34 +0100, David Woodhouse wrote:
> On Thu, 2014-06-12 at 10:35 -0600, Alex Williamson wrote:
> > 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.
> > 
> > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> > ---
> > 
> > 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?

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-13 16:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-12 16:35 [RESEND PATCH] iommu/intel: Exclude devices using RMRRs from IOMMU API domains Alex Williamson
2014-06-13 14:34 ` David Woodhouse
2014-06-13 16:35   ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox