[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230621235508.113949-14-suravee.suthikulpanit@amd.com>
Date: Wed, 21 Jun 2023 18:55:00 -0500
From: Suravee Suthikulpanit <suravee.suthikulpanit@....com>
To: <linux-kernel@...r.kernel.org>, <iommu@...ts.linux.dev>,
<kvm@...r.kernel.org>
CC: <joro@...tes.org>, <robin.murphy@....com>, <yi.l.liu@...el.com>,
<alex.williamson@...hat.com>, <jgg@...dia.com>,
<nicolinc@...dia.com>, <baolu.lu@...ux.intel.com>,
<eric.auger@...hat.com>, <pandoh@...gle.com>,
<kumaranand@...gle.com>, <jon.grimm@....com>,
<santosh.shukla@....com>, <vasant.hegde@....com>,
<jay.chen@....com>, <joseph.chung@....com>,
"Suravee Suthikulpanit" <suravee.suthikulpanit@....com>
Subject: [RFC PATCH 13/21] iommu/amd: Introduce vIOMMU command-line option
To disable vIOMMU feature, specify option "amd_iommu=viommu_disable".
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@....com>
---
drivers/iommu/amd/amd_iommu.h | 2 ++
drivers/iommu/amd/amd_iommu_types.h | 1 +
drivers/iommu/amd/init.c | 10 ++++++++++
3 files changed, 13 insertions(+)
diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h
index c9dfa4734801..a65d22384ab8 100644
--- a/drivers/iommu/amd/amd_iommu.h
+++ b/drivers/iommu/amd/amd_iommu.h
@@ -46,6 +46,8 @@ void amd_iommu_debugfs_setup(struct amd_iommu *iommu);
static inline void amd_iommu_debugfs_setup(struct amd_iommu *iommu) {}
#endif
+extern bool amd_iommu_viommu;
+
/* Needed for interrupt remapping */
extern int amd_iommu_prepare(void);
extern int amd_iommu_enable(void);
diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h
index aa16a7079b5c..019a9182df87 100644
--- a/drivers/iommu/amd/amd_iommu_types.h
+++ b/drivers/iommu/amd/amd_iommu_types.h
@@ -96,6 +96,7 @@
#define FEATURE_GAM_VAPIC (1ULL<<21)
#define FEATURE_GIOSUP (1ULL<<48)
#define FEATURE_EPHSUP (1ULL<<50)
+#define FEATURE_VIOMMU (1ULL<<55)
#define FEATURE_SNP (1ULL<<63)
#define FEATURE_GATS_5LEVEL 1ULL
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index 6a045a187971..4dd9f09e16c4 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -194,6 +194,9 @@ bool amdr_ivrs_remap_support __read_mostly;
bool amd_iommu_force_isolation __read_mostly;
+/* VIOMMU enabling flag */
+bool amd_iommu_viommu = true;
+
/*
* AMD IOMMU allows up to 2^16 different protection domains. This is a bitmap
* to know which ones are already in use.
@@ -2154,6 +2157,9 @@ static void print_iommu_info(void)
if (iommu->features & FEATURE_SNP)
pr_cont(" SNP");
+ if (iommu->features & FEATURE_VIOMMU)
+ pr_cont(" vIOMMU");
+
pr_cont("\n");
}
}
@@ -2166,6 +2172,8 @@ static void print_iommu_info(void)
pr_info("V2 page table enabled (Paging mode : %d level)\n",
amd_iommu_gpt_level);
}
+ if (amd_iommu_viommu)
+ pr_info("AMD-Vi: vIOMMU enabled\n");
}
static int __init amd_iommu_init_pci(void)
@@ -3402,6 +3410,8 @@ static int __init parse_amd_iommu_options(char *str)
amd_iommu_pgtable = AMD_IOMMU_V1;
} else if (strncmp(str, "pgtbl_v2", 8) == 0) {
amd_iommu_pgtable = AMD_IOMMU_V2;
+ } else if (strncmp(str, "viommu_disable", 14) == 0) {
+ amd_iommu_viommu = false;
} else {
pr_notice("Unknown option - '%s'\n", str);
}
--
2.34.1
Powered by blists - more mailing lists