Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752233AbdHGHdd (ORCPT ); Mon, 7 Aug 2017 03:33:33 -0400 Received: from ozlabs.ru ([107.173.13.209]:50890 "EHLO ozlabs.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751869AbdHGHda (ORCPT ); Mon, 7 Aug 2017 03:33:30 -0400 From: Alexey Kardashevskiy To: linuxppc-dev@lists.ozlabs.org Cc: Alexey Kardashevskiy , David Gibson , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Yongji Xie , Eric Auger , Kyle Mahlkuch , Alex Williamson , Jike Song , Bjorn Helgaas , Robin Murphy , Joerg Roedel , Arvind Yadav , Benjamin Herrenschmidt , David Woodhouse , Kirti Wankhede , Mauricio Faria de Oliveira , Neo Jia , Paul Mackerras , Vlad Tsyrklevich , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v5 3/5] iommu/intel/amd: Set IOMMU_GROUP_CAP_ISOLATE_MSIX if IRQ remapping is enabled Date: Mon, 7 Aug 2017 17:25:46 +1000 Message-Id: <20170807072548.3023-4-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170807072548.3023-1-aik@ozlabs.ru> References: <20170807072548.3023-1-aik@ozlabs.ru> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1806 Lines: 54 This sets IOMMU_GROUP_CAP_ISOLATE_MSIX to a group if IRQ remapping is enabled. For Intel, this checks disable_sourceid_checking in addition; AMD ignores the "nosid" kernel parameters. Here is some background on how the isolation works: On Intel VT-d [1], there is an Interrupt Remapping Table, one entry per interrupt, has a source-id (i.e. BDFN) of allowed device. On AMD IOMMU [2], there is a Device Table, each entry is indexed by DevideID which is BDFN. [1] 9.10 Interrupt Remapping Table Entry (IRTE) for Remapped Interrupts https://www.intel.com/content/dam/www/public/us/en/documents/product-specifications/vt-directed-io-spec.pdf [2] "2.2 Data Structures" and "2.2.5 Interrupt Remapping Tables" https://support.amd.com/TechDocs/48882_IOMMU.pdf Signed-off-by: Alexey Kardashevskiy --- drivers/iommu/amd_iommu.c | 3 +++ drivers/iommu/intel-iommu.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 688e77576e5a..d55fcbf3267e 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -470,6 +470,9 @@ static void init_iommu_group(struct device *dev) if (IS_ERR(group)) return; + if (irq_remapping_enabled) + iommu_group_set_caps(group, 0, IOMMU_GROUP_CAP_ISOLATE_MSIX); + iommu_group_put(group); } diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index b7e670a7c243..3896c2d44bfa 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5233,6 +5233,9 @@ static int intel_iommu_add_device(struct device *dev) if (IS_ERR(group)) return PTR_ERR(group); + if (irq_remapping_enabled && !disable_sourceid_checking) + iommu_group_set_caps(group, 0, IOMMU_GROUP_CAP_ISOLATE_MSIX); + iommu_group_put(group); return 0; } -- 2.11.0