Skip to content

Commit f1ca707

Browse files
superm1joergroedel
authored andcommitted
iommu/amd: Indicate whether DMA remap support is enabled
Bit 1 of the IVFS IVInfo field indicates that IOMMU has been used for pre-boot DMA protection. Export this capability to allow other places in the kernel to be able to check for it on AMD systems. Link: https://www.amd.com/system/files/TechDocs/48882_IOMMU.pdf Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Robin Murphy <robin.murphy@arm.com> Link: https://lore.kernel.org/r/ce7627fa1c596878ca6515dd9d4381a45b6ee38c.1650878781.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 86eaf4a commit f1ca707

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

drivers/iommu/amd/amd_iommu_types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@
407407
/* IOMMU IVINFO */
408408
#define IOMMU_IVINFO_OFFSET 36
409409
#define IOMMU_IVINFO_EFRSUP BIT(0)
410+
#define IOMMU_IVINFO_DMA_REMAP BIT(1)
410411

411412
/* IOMMU Feature Reporting Field (for IVHD type 10h */
412413
#define IOMMU_FEAT_GASUP_SHIFT 6
@@ -449,6 +450,9 @@ extern struct irq_remap_table **irq_lookup_table;
449450
/* Interrupt remapping feature used? */
450451
extern bool amd_iommu_irq_remap;
451452

453+
/* IVRS indicates that pre-boot remapping was enabled */
454+
extern bool amdr_ivrs_remap_support;
455+
452456
/* kmem_cache to get tables with 128 byte alignement */
453457
extern struct kmem_cache *amd_iommu_irq_cache;
454458

drivers/iommu/amd/init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ u32 amd_iommu_max_pasid __read_mostly = ~0;
182182

183183
bool amd_iommu_v2_present __read_mostly;
184184
static bool amd_iommu_pc_present __read_mostly;
185+
bool amdr_ivrs_remap_support __read_mostly;
185186

186187
bool amd_iommu_force_isolation __read_mostly;
187188

@@ -326,6 +327,8 @@ static void __init early_iommu_features_init(struct amd_iommu *iommu,
326327
{
327328
if (amd_iommu_ivinfo & IOMMU_IVINFO_EFRSUP)
328329
iommu->features = h->efr_reg;
330+
if (amd_iommu_ivinfo & IOMMU_IVINFO_DMA_REMAP)
331+
amdr_ivrs_remap_support = true;
329332
}
330333

331334
/* Access to l1 and l2 indexed register spaces */

drivers/iommu/amd/iommu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,8 @@ static bool amd_iommu_capable(enum iommu_cap cap)
21552155
return (irq_remapping_enabled == 1);
21562156
case IOMMU_CAP_NOEXEC:
21572157
return false;
2158+
case IOMMU_CAP_PRE_BOOT_PROTECTION:
2159+
return amdr_ivrs_remap_support;
21582160
default:
21592161
break;
21602162
}

0 commit comments

Comments
 (0)