iommu/amd: Add SNP page mode 0 support
Subsystems (2)
Vasant Hegde
maintainerPATCH 1/1 iommu/amd: Add SNP page mode 0 support
Newer AMD IOMMUs supports DTE[Mode]=0 for SNP-enabled system. This is detected using new feature bit (EFR2[SNP_Page_Mode_0_Sup]). If this feature is enabled, then IOMMU supports:
- Passthrough mode (i.e. iommu=pt)
- amd_iommu=pgtbl_v2: Forcing Linux DMA-API to use IOMMU v2 page table
- Setting up device for SVA mode in the host.
--- drivers/iommu/amd/amd_iommu_types.h | 4 +++ drivers/iommu/amd/init.c | 42 ++++++++++++++++++++--------- drivers/iommu/amd/iommu.c | 11 +++++--- 3 files changed, 40 insertions(+), 17 deletions(-)
drivers/iommu/amd/amd_iommu_types.h +4 -0
@@ -113,6 +113,7 @@#define FEATURE_SNPAVICSUP_GAM (x) \ (FIELD_GET(FEATURE_SNPAVICSUP, x) == 0x1)#define FEATURE_HT_RANGE_IGNORE BIT_ULL(11) +#define FEATURE_SNP_PAGE_MODE0_SUP BIT_ULL(13)#define FEATURE_NUM_INT_REMAP_SUP GENMASK_ULL(9, 8)#define FEATURE_NUM_INT_REMAP_SUP_2K (x) \
@@ -416,6 +417,9 @@ extern bool amd_iommu_dump; pr_info(format, ## arg); \ }while (0 ); +/* SNP page mode 0 support */ +extern bool amd_iommu_snp_mode0_sup; +/* global flag if IOMMUs cache non-present entries */ extern bool amd_iommu_np_cache;/* Only true if all IOMMUs support device IOTLBs */
drivers/iommu/amd/init.c +29 -13
65 lines not on this page · raw message
drivers/iommu/amd/iommu.c +7 -4
@@ -2910,9 +2910,9 @@ static int amd_iommu_identity_attach(struct iommu_domain *dom, struct device *de {/* * Don't allow attaching a device to the identity domain if SNP is -* enabled. +* enabled and SNP Mode0 support is not present. */ -if (amd_iommu_snp_en) +if (amd_iommu_snp_en && !amd_iommu_snp_mode0_sup)return -EINVAL ;return amd_iommu_attach_device (dom, dev, old);
@@ -3164,8 +3164,11 @@ static int amd_iommu_def_domain_type(struct device *dev)if (cc_platform_has (CC_ATTR_MEM_ENCRYPT ))return 0 ; -/* DTE[Mode]=0 is prohibited when SNP is enabled */ -if (amd_iommu_snp_en) +/* +* DTE[Mode]=0 is prohibited when SNP is enabled and SNP +* Mode 0 is not supported. +*/ +if (amd_iommu_snp_en && !amd_iommu_snp_mode0_sup)return 0 ;return IOMMU_DOMAIN_IDENTITY ;
Signature · 1 line
2.31.1
Vasant Hegde
maintainerQuoted 10 lines · Vasant Hegde
Newer AMD IOMMUs supports DTE[Mode]=0 for SNP-enabled system. This is detected using new feature bit (EFR2[SNP_Page_Mode_0_Sup]). If this feature is enabled, then IOMMU supports:
- Passthrough mode (i.e. iommu=pt)
- amd_iommu=pgtbl_v2: Forcing Linux DMA-API to use IOMMU v2 page table
- Setting up device for SVA mode in the host.Signed-off-by Vasant Hegde <[email protected]>Reviewed-by Suravee Suthikulpanit <[email protected]>Tested-by Amandeep Kaur Longia <[email protected]>
Missed to mention. This patch applies on top of
https://lore.kernel.org/linux-iommu/[email protected]/T/#t
-Vasant
Jörg Rödel
maintainerHi Vasant,
Quoted 3 lines · Vasant Hegde
Missed to mention. This patch applies on top of
Please include this into the repost of the above patch-set and base the series on the amd/amd-vi branch.
Thanks,
Joerg
Vasant Hegde
maintainerJoerg,
Quoted 9 lines · Jörg Rödel
Hi Vasant,
Quoted 3 lines · Vasant Hegde
Missed to mention. This patch applies on top of
Please include this into the repost of the above patch-set and base the series on the amd/amd-vi branch.
Sorry. I missed to send it as single series. I have rebased and sent v2 as separate patch.
-Vasant