[RFC PATCH 4/6] mm: Add iommu_mm field to mm_struct

From: Tina Zhang
Date: Thu Jul 06 2023 - 21:35:24 EST


The iommu_mm field has all the information needed for managing sva domain
1:1 with mm pasid. Add it to the mm_struct as the sva-related field and
use default_iommu_mm to initialize init_mm pasid.

Signed-off-by: Tina Zhang <tina.zhang@xxxxxxxxx>
---
include/linux/mm_types.h | 2 ++
mm/init-mm.c | 1 +
2 files changed, 3 insertions(+)

diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 306a3d1a0fa65..bb00caa078335 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -581,6 +581,7 @@ struct mm_cid {
#endif

struct kioctx_table;
+struct iommu_mm_data;
struct mm_struct {
struct {
struct maple_tree mm_mt;
@@ -773,6 +774,7 @@ struct mm_struct {

#ifdef CONFIG_IOMMU_SVA
u32 pasid;
+ struct iommu_mm_data *iommu_mm;
#endif
#ifdef CONFIG_KSM
/*
diff --git a/mm/init-mm.c b/mm/init-mm.c
index efa97b57acfd8..c43b7d0347312 100644
--- a/mm/init-mm.c
+++ b/mm/init-mm.c
@@ -44,6 +44,7 @@ struct mm_struct init_mm = {
.cpu_bitmap = CPU_BITS_NONE,
#ifdef CONFIG_IOMMU_SVA
.pasid = IOMMU_PASID_INVALID,
+ .iommu_mm = &default_iommu_mm,
#endif
INIT_MM_CONTEXT(init_mm)
};
--
2.34.1