summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iommu/amd/iommu.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 81c4d7733872..760d5f4623b5 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2909,8 +2909,21 @@ static struct iommu_domain blocked_domain = {
static struct protection_domain identity_domain;
+static int amd_iommu_identity_attach(struct iommu_domain *dom, struct device *dev,
+ struct iommu_domain *old)
+{
+ /*
+ * Don't allow attaching a device to the identity domain if SNP is
+ * enabled.
+ */
+ if (amd_iommu_snp_en)
+ return -EINVAL;
+
+ return amd_iommu_attach_device(dom, dev, old);
+}
+
static const struct iommu_domain_ops identity_domain_ops = {
- .attach_dev = amd_iommu_attach_device,
+ .attach_dev = amd_iommu_identity_attach,
};
void amd_iommu_init_identity_domain(void)