iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Jon Derrick <jonathan.derrick@intel.com>
To: linux-pci@vger.kernel.org, iommu@lists.linux-foundation.org
Cc: Bjorn Helgaas <helgaas@kernel.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Keith Busch <keith.busch@intel.com>,
	Scott Bauer <scott.bauer@intel.com>,
	David Fugate <david.fugate@intel.com>,
	linux-kernel@vger.kernel.org,
	Jon Derrick <jonathan.derrick@intel.com>
Subject: [PATCH v2 4/4] iommu: Prevent VMD child devices from being remapping targets
Date: Thu, 17 Aug 2017 12:10:14 -0600	[thread overview]
Message-ID: <20170817181014.1257-5-jonathan.derrick@intel.com> (raw)
In-Reply-To: <20170817181014.1257-1-jonathan.derrick@intel.com>

VMD child devices must use the VMD endpoint's ID as the requester.
Because of this, there needs to be a way to link the parent VMD
endpoint's iommu group and associated mappings to the VMD child devices
such that attaching and detaching child devices modify the endpoint's
mappings, while preventing early detaching on a singular device removal
or unbinding.

The reassignment of individual VMD child devices devices to VMs is
outside the scope of VMD, but may be implemented in the future. For now
it is best to prevent any such attempts.

This patch prevents VMD child devices from returning an IOMMU, which
prevents it from exposing an iommu_group sysfs directories and allowing
subsequent binding by userspace-access drivers such as VFIO.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
---
 drivers/iommu/intel-iommu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 687f18f..94353a6e 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -901,6 +901,11 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf
 		struct pci_dev *pf_pdev;
 
 		pdev = to_pci_dev(dev);
+
+		/* VMD child devices currently cannot be handled individually */
+		if (is_vmd(pdev->bus))
+			return NULL;
+
 		/* VFs aren't listed in scope tables; we need to look up
 		 * the PF instead to find the IOMMU. */
 		pf_pdev = pci_physfn(pdev);
-- 
2.9.4

  parent reply	other threads:[~2017-08-17 18:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-17 18:10 [PATCH v2 0/4] VMD fixups Jon Derrick
2017-08-17 18:10 ` [PATCH v2 2/4] pci/x86: Move VMD quirks to x86 fixups Jon Derrick
     [not found] ` <20170817181014.1257-1-jonathan.derrick-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-08-17 18:10   ` [PATCH v2 1/4] MAINTAINERS: Add Jonathan Derrick as VMD maintainer Jon Derrick
2017-08-17 18:10   ` [PATCH v2 3/4] x86/PCI: Use is_vmd rather than relying on the domain number Jon Derrick
2017-08-30 19:23   ` [PATCH v2 0/4] VMD fixups Bjorn Helgaas
2017-08-17 18:10 ` Jon Derrick [this message]
     [not found]   ` <20170817181014.1257-5-jonathan.derrick-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-08-18 16:04     ` [PATCH v2 4/4] iommu: Prevent VMD child devices from being remapping targets Bjorn Helgaas
2017-08-18 16:35       ` Robin Murphy
2017-08-24 16:02       ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170817181014.1257-5-jonathan.derrick@intel.com \
    --to=jonathan.derrick@intel.com \
    --cc=david.fugate@intel.com \
    --cc=dwmw2@infradead.org \
    --cc=helgaas@kernel.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=scott.bauer@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).