From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
joro@8bytes.org, will@kernel.org, robin.murphy@arm.com,
jean-philippe@linaro.org, zhukeqian1@huawei.com
Cc: alex.williamson@redhat.com, jacob.jun.pan@linux.intel.com,
yi.l.liu@intel.com, kevin.tian@intel.com, ashok.raj@intel.com,
maz@kernel.org, peter.maydell@linaro.org, vivek.gautam@arm.com,
shameerali.kolothum.thodi@huawei.com, wangxingang5@huawei.com,
jiangkunkun@huawei.com, yuzenghui@huawei.com,
nicoleotsuka@gmail.com, chenxiang66@hisilicon.com,
sumitg@nvidia.com, nicolinc@nvidia.com, vdumpa@nvidia.com,
zhangfei.gao@linaro.org, zhangfei.gao@gmail.com,
lushenming@huawei.com, vsethi@nvidia.com
Subject: [RFC v16 9/9] iommu/smmuv3: Disallow nested mode in presence of HW MSI regions
Date: Wed, 27 Oct 2021 12:44:28 +0200 [thread overview]
Message-ID: <20211027104428.1059740-10-eric.auger@redhat.com> (raw)
In-Reply-To: <20211027104428.1059740-1-eric.auger@redhat.com>
Nested mode currently is not compatible with HW MSI reserved regions.
Indeed MSI transactions targeting those MSI doorbells bypass the SMMU.
This would require the guest to also bypass those ranges but the guest
has no information about them.
Let's check nested mode is not attempted in such configuration.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 23 +++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index ddfc069c10ae..12e7d7920f27 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -2488,6 +2488,23 @@ static void arm_smmu_detach_dev(struct arm_smmu_master *master)
arm_smmu_install_ste_for_dev(master);
}
+static bool arm_smmu_has_hw_msi_resv_region(struct device *dev)
+{
+ struct iommu_resv_region *region;
+ bool has_msi_resv_region = false;
+ LIST_HEAD(resv_regions);
+
+ iommu_get_resv_regions(dev, &resv_regions);
+ list_for_each_entry(region, &resv_regions, list) {
+ if (region->type == IOMMU_RESV_MSI) {
+ has_msi_resv_region = true;
+ break;
+ }
+ }
+ iommu_put_resv_regions(dev, &resv_regions);
+ return has_msi_resv_region;
+}
+
static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
{
int ret = 0;
@@ -2545,6 +2562,12 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
ret = -EINVAL;
goto out_unlock;
}
+ /* Nested mode is not compatible with MSI HW reserved regions */
+ if (smmu_domain->stage == ARM_SMMU_DOMAIN_NESTED &&
+ arm_smmu_has_hw_msi_resv_region(dev)) {
+ ret = -EINVAL;
+ goto out_unlock;
+ }
master->domain = smmu_domain;
--
2.26.3
next prev parent reply other threads:[~2021-10-27 10:47 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-27 10:44 [RFC v16 0/9] SMMUv3 Nested Stage Setup (IOMMU part) Eric Auger
2021-10-27 10:44 ` [RFC v16 1/9] iommu: Introduce attach/detach_pasid_table API Eric Auger
2021-12-06 10:48 ` Joerg Roedel
2021-12-07 10:22 ` Eric Auger
2021-12-08 2:44 ` Lu Baolu
2021-12-08 7:33 ` Eric Auger
2021-12-08 12:56 ` Jason Gunthorpe
2021-12-08 17:20 ` Jean-Philippe Brucker
2021-12-08 18:31 ` Jason Gunthorpe
2021-12-09 2:58 ` Tian, Kevin
[not found] ` <BN9PR11MB527624080CB9302481B74C7A8C709@BN9PR11MB5276.namprd11.prod.outlook.com>
2021-12-09 3:59 ` Tian, Kevin
2021-12-09 16:08 ` Jason Gunthorpe
2021-12-10 8:56 ` Tian, Kevin
2021-12-10 13:23 ` Jason Gunthorpe
2021-12-11 3:57 ` Tian, Kevin
2021-12-16 20:48 ` Jason Gunthorpe
2022-01-04 2:42 ` Tian, Kevin
2021-12-11 5:18 ` Tian, Kevin
2021-12-09 7:50 ` Eric Auger
2021-12-09 15:40 ` Jason Gunthorpe
2021-12-09 16:37 ` Eric Auger
2021-12-09 3:21 ` Tian, Kevin
2021-12-09 9:44 ` Eric Auger
2021-12-09 8:31 ` Eric Auger
2021-10-27 10:44 ` [RFC v16 2/9] iommu: Introduce iommu_get_nesting Eric Auger
2021-10-27 10:44 ` [RFC v16 3/9] iommu/smmuv3: Allow s1 and s2 configs to coexist Eric Auger
2021-10-27 10:44 ` [RFC v16 4/9] iommu/smmuv3: Get prepared for nested stage support Eric Auger
2021-10-27 10:44 ` [RFC v16 5/9] iommu/smmuv3: Implement attach/detach_pasid_table Eric Auger
2021-10-27 10:44 ` [RFC v16 6/9] iommu/smmuv3: Allow stage 1 invalidation with unmanaged ASIDs Eric Auger
2021-10-27 10:44 ` [RFC v16 7/9] iommu/smmuv3: Implement cache_invalidate Eric Auger
2021-10-27 10:44 ` [RFC v16 8/9] iommu/smmuv3: report additional recoverable faults Eric Auger
2021-10-27 10:44 ` Eric Auger [this message]
2021-12-03 12:27 ` [RFC v16 0/9] SMMUv3 Nested Stage Setup (IOMMU part) Zhangfei Gao
2021-12-07 10:27 ` Eric Auger
2021-12-07 10:35 ` Zhangfei Gao
2021-12-07 11:06 ` Eric Auger
2021-12-08 13:33 ` Shameerali Kolothum Thodi
2021-12-03 13:13 ` Sumit Gupta
2021-12-07 10:28 ` Eric Auger
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=20211027104428.1059740-10-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=ashok.raj@intel.com \
--cc=chenxiang66@hisilicon.com \
--cc=eric.auger.pro@gmail.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe@linaro.org \
--cc=jiangkunkun@huawei.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=lushenming@huawei.com \
--cc=maz@kernel.org \
--cc=nicoleotsuka@gmail.com \
--cc=nicolinc@nvidia.com \
--cc=peter.maydell@linaro.org \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=sumitg@nvidia.com \
--cc=vdumpa@nvidia.com \
--cc=vivek.gautam@arm.com \
--cc=vsethi@nvidia.com \
--cc=wangxingang5@huawei.com \
--cc=will@kernel.org \
--cc=yi.l.liu@intel.com \
--cc=yuzenghui@huawei.com \
--cc=zhangfei.gao@gmail.com \
--cc=zhangfei.gao@linaro.org \
--cc=zhukeqian1@huawei.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