Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753589AbdHKSZ5 (ORCPT ); Fri, 11 Aug 2017 14:25:57 -0400 Received: from foss.arm.com ([217.140.101.70]:48500 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752850AbdHKSZ4 (ORCPT ); Fri, 11 Aug 2017 14:25:56 -0400 Subject: Re: [PATCH 3/3] iommu: prevent VMD child devices from being remapping targets To: Jon Derrick , linux-pci@vger.kernel.org, iommu@lists.linux-foundation.org Cc: linux-kernel@vger.kernel.org, Keith Busch , Bjorn Helgaas , David Fugate , David Woodhouse , Scott Bauer References: <20170807195713.10963-1-jonathan.derrick@intel.com> <20170807195713.10963-3-jonathan.derrick@intel.com> From: Robin Murphy Message-ID: Date: Fri, 11 Aug 2017 19:25:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170807195713.10963-3-jonathan.derrick@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1822 Lines: 45 On 07/08/17 20:57, Jon Derrick wrote: > VMD child devices must use the VMD endpoint's ID as the DMA source. > Because of this, there needs to be a way to link the parent VMD > endpoint's DMAR domain to the VMD child devices' DMAR domain such that > attaching and detaching child devices modify the endpoint's DMAR mapping > and prevents early detaching. That sounds like either pci_device_group() needs modifying, or perhaps that intel-iommu needs its own extended iommu_ops::device_group implementation, to ensure that VMD child devices get put in the same group as their parent - if they share requester IDs they can't feasibly be attached to different domains anyway. Robin. > This is outside the scope of VMD, so disable binding child devices to > prevent unforeseen issues. This functionality may be implemented in the > future. > > This patch prevents VMD child devices from returning an IOMMU, which > prevents it from exposing iommu_group sysfs directories and subsequent > binding by userspace-access drivers such as VFIO. > > Signed-off-by: Jon Derrick > --- > 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..651a6cd 100644 > --- a/drivers/iommu/intel-iommu.c > +++ b/drivers/iommu/intel-iommu.c > @@ -905,6 +905,11 @@ static struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devf > * the PF instead to find the IOMMU. */ > pf_pdev = pci_physfn(pdev); > dev = &pf_pdev->dev; > + > + /* VMD child devices currently cannot be handled individually */ > + if (pci_bus_is_vmd(pdev->bus)) > + return NULL; > + > segment = pci_domain_nr(pdev->bus); > } else if (has_acpi_companion(dev)) > dev = &ACPI_COMPANION(dev)->dev; >