From patchwork Thu Aug 17 18:10:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Derrick X-Patchwork-Id: 802842 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xYDnH6MVMz9sPt for ; Fri, 18 Aug 2017 04:11:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753431AbdHQSLb (ORCPT ); Thu, 17 Aug 2017 14:11:31 -0400 Received: from mga09.intel.com ([134.134.136.24]:13743 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753898AbdHQSL1 (ORCPT ); Thu, 17 Aug 2017 14:11:27 -0400 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Aug 2017 11:11:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,389,1498546800"; d="scan'208";a="138830405" Received: from eremita.lm.intel.com ([10.232.112.28]) by orsmga005.jf.intel.com with ESMTP; 17 Aug 2017 11:11:26 -0700 From: Jon Derrick To: , Cc: Bjorn Helgaas , David Woodhouse , Keith Busch , Scott Bauer , David Fugate , , Jon Derrick Subject: [PATCH v2 4/4] iommu: Prevent VMD child devices from being remapping targets Date: Thu, 17 Aug 2017 12:10:14 -0600 Message-Id: <20170817181014.1257-5-jonathan.derrick@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170817181014.1257-1-jonathan.derrick@intel.com> References: <20170817181014.1257-1-jonathan.derrick@intel.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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 Acked-by: Bjorn Helgaas --- 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);