From patchwork Wed Oct 26 18:01:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 9398001 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 068A660231 for ; Wed, 26 Oct 2016 18:02:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C60C829C0C for ; Wed, 26 Oct 2016 18:02:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB27929C0E; Wed, 26 Oct 2016 18:02:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9473529C0C for ; Wed, 26 Oct 2016 18:02:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934806AbcJZSBo (ORCPT ); Wed, 26 Oct 2016 14:01:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45558 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932334AbcJZSBk (ORCPT ); Wed, 26 Oct 2016 14:01:40 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32796148D8; Wed, 26 Oct 2016 18:01:35 +0000 (UTC) Received: from gimli.home (ovpn-116-188.phx2.redhat.com [10.3.116.188]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9QI1Ysj020887; Wed, 26 Oct 2016 14:01:34 -0400 Subject: [PATCH 4/5] iommu: Move REQ_ACS_FLAGS out to header and rename From: Alex Williamson To: linux-pci@vger.kernel.org Cc: bhelgaas@google.com, Joerg Roedel , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Date: Wed, 26 Oct 2016 12:01:34 -0600 Message-ID: <20161026180134.23495.27520.stgit@gimli.home> In-Reply-To: <20161026175156.23495.12980.stgit@gimli.home> References: <20161026175156.23495.12980.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 26 Oct 2016 18:01:35 +0000 (UTC) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow other parts of the kernel to see which PCI ACS flags the IOMMU layer considers necessary for isolation. Signed-off-by: Alex Williamson Cc: Joerg Roedel --- drivers/iommu/iommu.c | 18 +++++------------- include/linux/iommu.h | 11 +++++++++++ 2 files changed, 16 insertions(+), 13 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index b06d935..f73e6f4 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -610,16 +610,6 @@ static struct iommu_group *get_pci_alias_group(struct pci_dev *pdev, unsigned long *devfns); /* - * To consider a PCI device isolated, we require ACS to support Source - * Validation, Request Redirection, Completer Redirection, and Upstream - * Forwarding. This effectively means that devices cannot spoof their - * requester ID, requests and completions cannot be redirected, and all - * transactions are forwarded upstream, even as it passes through a - * bridge where the target device is downstream. - */ -#define REQ_ACS_FLAGS (PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF) - -/* * For multifunction devices which are not isolated from each other, find * all the other non-isolated functions and look for existing groups. For * each function, we also need to look for aliases to or from other devices @@ -631,13 +621,14 @@ static struct iommu_group *get_pci_function_alias_group(struct pci_dev *pdev, struct pci_dev *tmp = NULL; struct iommu_group *group; - if (!pdev->multifunction || pci_acs_enabled(pdev, REQ_ACS_FLAGS)) + if (!pdev->multifunction || + pci_acs_enabled(pdev, IOMMU_REQ_PCI_ACS_FLAGS)) return NULL; for_each_pci_dev(tmp) { if (tmp == pdev || tmp->bus != pdev->bus || PCI_SLOT(tmp->devfn) != PCI_SLOT(pdev->devfn) || - pci_acs_enabled(tmp, REQ_ACS_FLAGS)) + pci_acs_enabled(tmp, IOMMU_REQ_PCI_ACS_FLAGS)) continue; group = get_pci_alias_group(tmp, devfns); @@ -765,7 +756,8 @@ struct iommu_group *pci_device_group(struct device *dev) if (!bus->self) continue; - if (pci_acs_path_enabled(bus->self, NULL, REQ_ACS_FLAGS)) + if (pci_acs_path_enabled(bus->self, NULL, + IOMMU_REQ_PCI_ACS_FLAGS)) break; pdev = bus->self; diff --git a/include/linux/iommu.h b/include/linux/iommu.h index a35fb8b..23f4d1d 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -131,6 +131,17 @@ struct iommu_dm_region { int prot; }; +/* + * To consider a PCI device isolated, we require ACS to support Source + * Validation, Request Redirection, Completer Redirection, and Upstream + * Forwarding. This effectively means that devices cannot spoof their + * requester ID, requests and completions cannot be redirected, and all + * transactions are forwarded upstream, even as it passes through a + * bridge where the target device is downstream. + */ +#define IOMMU_REQ_PCI_ACS_FLAGS (PCI_ACS_SV | PCI_ACS_RR | \ + PCI_ACS_CR | PCI_ACS_UF) + #ifdef CONFIG_IOMMU_API /**