From: Suravee Suthikulpanit via iommu <iommu@lists.linux-foundation.org>
To: <iommu@lists.linux-foundation.org>
Cc: thomas.lendacky@amd.com, ashish.kalra@amd.com,
vasant.hegde@amd.com, robin.murphy@arm.com
Subject: [PATCH v2 6/7] iommu/amd: Do not support IOMMU_DOMAIN_IDENTITY after SNP is enabled
Date: Wed, 15 Jun 2022 20:55:40 -0500 [thread overview]
Message-ID: <20220616015541.11207-7-suravee.suthikulpanit@amd.com> (raw)
In-Reply-To: <20220616015541.11207-1-suravee.suthikulpanit@amd.com>
Once SNP is enabled (by executing SNP_INIT command), IOMMU can no longer
support the passthrough domain (i.e. IOMMU_DOMAIN_IDENTITY).
The SNP_INIT command is called early in the boot process, and would fail
if the kernel is configure to default to passthrough mode.
After the system is already booted, users can try to change IOMMU domain
type of a particular IOMMU group. In this case, the IOMMU driver needs to
check the SNP-enable status and return failure when requesting to change
domain type to identity.
Therefore, return failure when trying to allocate identity domain.
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
---
drivers/iommu/amd/iommu.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 4f4571d3ff61..d8a6df423b90 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2119,6 +2119,15 @@ static struct iommu_domain *amd_iommu_domain_alloc(unsigned type)
{
struct protection_domain *domain;
+ /*
+ * Since DTE[Mode]=0 is prohibited on SNP-enabled system,
+ * default to use IOMMU_DOMAIN_DMA[_FQ].
+ */
+ if (amd_iommu_snp_en && (type == IOMMU_DOMAIN_IDENTITY)) {
+ pr_warn("Cannot allocate identity domain due to SNP\n");
+ return NULL;
+ }
+
domain = protection_domain_alloc(type);
if (!domain)
return NULL;
--
2.32.0
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2022-06-16 1:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 1:55 [PATCH v2 0/7] iommu/amd: Enforce IOMMU restrictions for SNP-enabled system Suravee Suthikulpanit via iommu
2022-06-16 1:55 ` [PATCH v2 1/7] iommu/amd: Warn when found inconsistency EFR mask Suravee Suthikulpanit via iommu
2022-06-16 1:55 ` [PATCH v2 2/7] iommu/amd: Process all IVHDs before enabling IOMMU features Suravee Suthikulpanit via iommu
2022-06-16 1:55 ` [PATCH v2 3/7] iommu/amd: Introduce an iommu variable for tracking SNP support status Suravee Suthikulpanit via iommu
2022-06-16 1:55 ` [PATCH v2 4/7] iommu/amd: Introduce function to check and enable SNP Suravee Suthikulpanit via iommu
2022-06-22 7:55 ` Suthikulpanit, Suravee via iommu
2022-06-22 8:35 ` Robin Murphy
2022-06-22 11:00 ` Suthikulpanit, Suravee via iommu
2022-06-16 1:55 ` [PATCH v2 5/7] iommu/amd: Set translation valid bit only when IO page tables are in use Suravee Suthikulpanit via iommu
2022-06-16 1:55 ` Suravee Suthikulpanit via iommu [this message]
2022-06-22 8:39 ` [PATCH v2 6/7] iommu/amd: Do not support IOMMU_DOMAIN_IDENTITY after SNP is enabled Robin Murphy
2022-06-16 1:55 ` [PATCH v2 7/7] iommu/amd: Do not support IOMMUv2 APIs when " Suravee Suthikulpanit via iommu
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=20220616015541.11207-7-suravee.suthikulpanit@amd.com \
--to=iommu@lists.linux-foundation.org \
--cc=ashish.kalra@amd.com \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=thomas.lendacky@amd.com \
--cc=vasant.hegde@amd.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