public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] Move SEV-SNP initialization to ccp driver
@ 2026-03-02 19:13 Tycho Andersen
  2026-03-02 19:13 ` [PATCH 01/11] x86/snp: drop support for SNP hotplug Tycho Andersen
                   ` (10 more replies)
  0 siblings, 11 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

The SEV firmware has support for disabling SNP when doing a
SNP_SHUTDOWN_EX, which will turn off the SNPEn bit. If setting SNPEn is
also delayed until module load, this means that we can control the
lifecycle of SNP enablement with module load and unload. This way, the
SNP checks are only done while the module is actually loaded.

Tom Lendacky (3):
  x86/snp: Keep the RMP table bookkeeping area mapped
  x86/snp: Create a function to clear/zero the RMP
  crypto: ccp - Update HV_FIXED page states to allow freeing of memory

Tycho Andersen (AMD) (8):
  x86/snp: drop support for SNP hotplug
  x86/snp: drop WBINVD before setting SNPEn
  x86/snp: create snp_prepare_for_snp_init()
  x86/snp, crypto: move SNP init to ccp driver
  x86/snp, crypto: move HSAVE_PA setup to arch/
  x86/snp: allow disabling MFDM
  x86/snp: create snp_x86_shutdown()
  crypto: ccp - implement SNP x86 shutdown

 arch/x86/include/asm/sev.h   |   4 +
 arch/x86/virt/svm/sev.c      | 148 +++++++++++++++++++----------------
 drivers/crypto/ccp/sev-dev.c |  65 ++++++++-------
 include/linux/psp-sev.h      |   4 +-
 4 files changed, 125 insertions(+), 96 deletions(-)


base-commit: 11439c4635edd669ae435eec308f4ab8a0804808
-- 
2.53.0


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 01/11] x86/snp: drop support for SNP hotplug
  2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
@ 2026-03-02 19:13 ` Tycho Andersen
  2026-03-02 19:56   ` Tom Lendacky
                     ` (2 more replies)
  2026-03-02 19:13 ` [PATCH 02/11] x86/snp: Keep the RMP table bookkeeping area mapped Tycho Andersen
                   ` (9 subsequent siblings)
  10 siblings, 3 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

During an SNP_INIT(_EX), the SEV firmware checks that all CPUs have SNPEn
set, and fails if they do not. As such, it does not make sense to have
offline CPUs: the firmware will fail initialization because of the offlined
ones that the kernel did not initialize.

Futher, there is a bug: SNP_INIT(_EX) require MFDM to be set in addition to
SNPEn which the previous hotplug code did not do. Since
k8_check_syscfg_dram_mod_en() enforces this be cleared, hotplug wouldn't
work.

Drop the hotplug code. Collapse the __{mfd,snp}__enable() wrappers into
their non-__ versions, since the cpu number argument is no longer needed.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 arch/x86/virt/svm/sev.c | 24 ++++--------------------
 1 file changed, 4 insertions(+), 20 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index a4f3a364fb65..1446011c6337 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -130,33 +130,26 @@ static unsigned long snp_nr_leaked_pages;
 #undef pr_fmt
 #define pr_fmt(fmt)	"SEV-SNP: " fmt
 
-static int __mfd_enable(unsigned int cpu)
+static __init void mfd_enable(void *arg)
 {
 	u64 val;
 
 	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
-		return 0;
+		return;
 
 	rdmsrq(MSR_AMD64_SYSCFG, val);
 
 	val |= MSR_AMD64_SYSCFG_MFDM;
 
 	wrmsrq(MSR_AMD64_SYSCFG, val);
-
-	return 0;
 }
 
-static __init void mfd_enable(void *arg)
-{
-	__mfd_enable(smp_processor_id());
-}
-
-static int __snp_enable(unsigned int cpu)
+static __init void snp_enable(void *arg)
 {
 	u64 val;
 
 	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
-		return 0;
+		return;
 
 	rdmsrq(MSR_AMD64_SYSCFG, val);
 
@@ -164,13 +157,6 @@ static int __snp_enable(unsigned int cpu)
 	val |= MSR_AMD64_SYSCFG_SNP_VMPL_EN;
 
 	wrmsrq(MSR_AMD64_SYSCFG, val);
-
-	return 0;
-}
-
-static __init void snp_enable(void *arg)
-{
-	__snp_enable(smp_processor_id());
 }
 
 static void __init __snp_fixup_e820_tables(u64 pa)
@@ -553,8 +539,6 @@ int __init snp_rmptable_init(void)
 	on_each_cpu(snp_enable, NULL, 1);
 
 skip_enable:
-	cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/rmptable_init:online", __snp_enable, NULL);
-
 	/*
 	 * Setting crash_kexec_post_notifiers to 'true' to ensure that SNP panic
 	 * notifier is invoked to do SNP IOMMU shutdown before kdump.
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 02/11] x86/snp: Keep the RMP table bookkeeping area mapped
  2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
  2026-03-02 19:13 ` [PATCH 01/11] x86/snp: drop support for SNP hotplug Tycho Andersen
@ 2026-03-02 19:13 ` Tycho Andersen
  2026-03-06 15:55   ` Borislav Petkov
  2026-03-02 19:13 ` [PATCH 03/11] x86/snp: Create a function to clear/zero the RMP Tycho Andersen
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: Tom Lendacky <thomas.lendacky@amd.com>

In prep for delayed SNP initialization and disablement on shutdown, the
RMP will need to be cleared each time SNP is disabled. Maintain the
the mapping to the RMP bookkeeping area to avoid mapping and unmapping it
each time and any possible errors that may arise from that.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 arch/x86/virt/svm/sev.c | 40 +++++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 1446011c6337..232a385f11cb 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -117,6 +117,8 @@ static u64 rmp_segment_mask;
 
 static u64 rmp_cfg;
 
+static void *rmp_bookkeeping __ro_after_init;
+
 /* Mask to apply to a PFN to get the first PFN of a 2MB page */
 #define PFN_PMD_MASK	GENMASK_ULL(63, PMD_SHIFT - PAGE_SHIFT)
 
@@ -246,23 +248,6 @@ void __init snp_fixup_e820_tables(void)
 	}
 }
 
-static bool __init clear_rmptable_bookkeeping(void)
-{
-	void *bk;
-
-	bk = memremap(probed_rmp_base, RMPTABLE_CPU_BOOKKEEPING_SZ, MEMREMAP_WB);
-	if (!bk) {
-		pr_err("Failed to map RMP bookkeeping area\n");
-		return false;
-	}
-
-	memset(bk, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
-
-	memunmap(bk);
-
-	return true;
-}
-
 static bool __init alloc_rmp_segment_desc(u64 segment_pa, u64 segment_size, u64 pa)
 {
 	u64 rst_index, rmp_segment_size_max;
@@ -480,10 +465,22 @@ static bool __init setup_segmented_rmptable(void)
 static bool __init setup_rmptable(void)
 {
 	if (rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED) {
-		return setup_segmented_rmptable();
+		if (!setup_segmented_rmptable())
+			return false;
 	} else {
-		return setup_contiguous_rmptable();
+		if (!setup_contiguous_rmptable())
+			return false;
 	}
+
+	rmp_bookkeeping = memremap(probed_rmp_base, RMPTABLE_CPU_BOOKKEEPING_SZ, MEMREMAP_WB);
+	if (!rmp_bookkeeping) {
+		pr_err("Failed to map RMP bookkeeping area\n");
+		free_rmp_segment_table();
+
+		return false;
+	}
+
+	return true;
 }
 
 /*
@@ -514,10 +511,7 @@ int __init snp_rmptable_init(void)
 		goto skip_enable;
 
 	/* Zero out the RMP bookkeeping area */
-	if (!clear_rmptable_bookkeeping()) {
-		free_rmp_segment_table();
-		return -ENOSYS;
-	}
+	memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
 
 	/* Zero out the RMP entries */
 	for (i = 0; i < rst_max_index; i++) {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 03/11] x86/snp: Create a function to clear/zero the RMP
  2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
  2026-03-02 19:13 ` [PATCH 01/11] x86/snp: drop support for SNP hotplug Tycho Andersen
  2026-03-02 19:13 ` [PATCH 02/11] x86/snp: Keep the RMP table bookkeeping area mapped Tycho Andersen
@ 2026-03-02 19:13 ` Tycho Andersen
  2026-03-02 19:13 ` [PATCH 04/11] x86/snp: drop WBINVD before setting SNPEn Tycho Andersen
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: Tom Lendacky <thomas.lendacky@amd.com>

In prep for delayed SNP initialization and disablement on shutdown, create
a function, snp_clear_rmp(), that clears the RMP bookkeeping area and the
RMP entries.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 arch/x86/virt/svm/sev.c | 41 +++++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 232a385f11cb..e7fbbf1cdf8e 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -248,6 +248,32 @@ void __init snp_fixup_e820_tables(void)
 	}
 }
 
+static void snp_clear_rmp(void)
+{
+	unsigned int i;
+	u64 val;
+
+	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
+		return;
+
+	/* Clearing the RMP while SNP is enabled will cause an exception */
+	rdmsrq(MSR_AMD64_SYSCFG, val);
+	if (WARN_ON_ONCE(val & MSR_AMD64_SYSCFG_SNP_EN))
+		return;
+
+	memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
+
+	for (i = 0; i < rst_max_index; i++) {
+		struct rmp_segment_desc *desc;
+
+		desc = rmp_segment_table[i];
+		if (!desc)
+			continue;
+
+		memset(desc->rmp_entry, 0, desc->size);
+	}
+}
+
 static bool __init alloc_rmp_segment_desc(u64 segment_pa, u64 segment_size, u64 pa)
 {
 	u64 rst_index, rmp_segment_size_max;
@@ -490,7 +516,6 @@ static bool __init setup_rmptable(void)
  */
 int __init snp_rmptable_init(void)
 {
-	unsigned int i;
 	u64 val;
 
 	if (WARN_ON_ONCE(!cc_platform_has(CC_ATTR_HOST_SEV_SNP)))
@@ -510,19 +535,7 @@ int __init snp_rmptable_init(void)
 	if (val & MSR_AMD64_SYSCFG_SNP_EN)
 		goto skip_enable;
 
-	/* Zero out the RMP bookkeeping area */
-	memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
-
-	/* Zero out the RMP entries */
-	for (i = 0; i < rst_max_index; i++) {
-		struct rmp_segment_desc *desc;
-
-		desc = rmp_segment_table[i];
-		if (!desc)
-			continue;
-
-		memset(desc->rmp_entry, 0, desc->size);
-	}
+	snp_clear_rmp();
 
 	/* Flush the caches to ensure that data is written before SNP is enabled. */
 	wbinvd_on_all_cpus();
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 04/11] x86/snp: drop WBINVD before setting SNPEn
  2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
                   ` (2 preceding siblings ...)
  2026-03-02 19:13 ` [PATCH 03/11] x86/snp: Create a function to clear/zero the RMP Tycho Andersen
@ 2026-03-02 19:13 ` Tycho Andersen
  2026-03-02 20:00   ` Tom Lendacky
  2026-03-02 19:13 ` [PATCH 05/11] x86/snp: create snp_prepare_for_snp_init() Tycho Andersen
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

WBINVD is required before SNP_INIT(_EX), but not before setting SNPEn,
since the ccp driver already does its own WBINVD before SNP_INIT (and this
one would be too early for that anyway...).

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 arch/x86/virt/svm/sev.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index e7fbbf1cdf8e..258e67ba7415 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -537,9 +537,6 @@ int __init snp_rmptable_init(void)
 
 	snp_clear_rmp();
 
-	/* Flush the caches to ensure that data is written before SNP is enabled. */
-	wbinvd_on_all_cpus();
-
 	/* MtrrFixDramModEn must be enabled on all the CPUs prior to enabling SNP. */
 	on_each_cpu(mfd_enable, NULL, 1);
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 05/11] x86/snp: create snp_prepare_for_snp_init()
  2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
                   ` (3 preceding siblings ...)
  2026-03-02 19:13 ` [PATCH 04/11] x86/snp: drop WBINVD before setting SNPEn Tycho Andersen
@ 2026-03-02 19:13 ` Tycho Andersen
  2026-03-02 20:03   ` Tom Lendacky
  2026-03-02 19:13 ` [PATCH 06/11] x86/snp, crypto: move SNP init to ccp driver Tycho Andersen
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

In preparation for delayed SNP initialization, create a function
snp_prepare_for_snp_init() that does the necessary architecture setup.
Export this function for the ccp module to allow it to do the setup as
necessary.

Also move {mfd,snp}_enable out of the __init section, since these will be
called later.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 arch/x86/include/asm/sev.h |  2 ++
 arch/x86/virt/svm/sev.c    | 46 ++++++++++++++++++++++----------------
 2 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
index 0e6c0940100f..0bcd89d4fe90 100644
--- a/arch/x86/include/asm/sev.h
+++ b/arch/x86/include/asm/sev.h
@@ -661,6 +661,7 @@ static inline void snp_leak_pages(u64 pfn, unsigned int pages)
 {
 	__snp_leak_pages(pfn, pages, true);
 }
+void snp_prepare_for_snp_init(void);
 #else
 static inline bool snp_probe_rmptable_info(void) { return false; }
 static inline int snp_rmptable_init(void) { return -ENOSYS; }
@@ -677,6 +678,7 @@ static inline void __snp_leak_pages(u64 pfn, unsigned int npages, bool dump_rmp)
 static inline void snp_leak_pages(u64 pfn, unsigned int npages) {}
 static inline void kdump_sev_callback(void) { }
 static inline void snp_fixup_e820_tables(void) {}
+static inline void snp_prepare_for_snp_init(void) {}
 #endif
 
 #endif
diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 258e67ba7415..8f50538baf7b 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -132,7 +132,7 @@ static unsigned long snp_nr_leaked_pages;
 #undef pr_fmt
 #define pr_fmt(fmt)	"SEV-SNP: " fmt
 
-static __init void mfd_enable(void *arg)
+static void mfd_enable(void *arg)
 {
 	u64 val;
 
@@ -146,7 +146,7 @@ static __init void mfd_enable(void *arg)
 	wrmsrq(MSR_AMD64_SYSCFG, val);
 }
 
-static __init void snp_enable(void *arg)
+static void snp_enable(void *arg)
 {
 	u64 val;
 
@@ -509,6 +509,30 @@ static bool __init setup_rmptable(void)
 	return true;
 }
 
+void snp_prepare_for_snp_init(void)
+{
+	u64 val;
+
+	/*
+	 * Check if SEV-SNP is already enabled, this can happen in case of
+	 * kexec boot.
+	 */
+	rdmsrq(MSR_AMD64_SYSCFG, val);
+	if (val & MSR_AMD64_SYSCFG_SNP_EN)
+		return;
+
+	snp_clear_rmp();
+
+	/*
+	 * MtrrFixDramModEn is not shared between threads on a core,
+	 * therefore it must be set on all CPUs prior to enabling SNP.
+	 */
+	on_each_cpu(mfd_enable, NULL, 1);
+
+	on_each_cpu(snp_enable, NULL, 1);
+}
+EXPORT_SYMBOL_FOR_MODULES(snp_prepare_for_snp_init, "ccp");
+
 /*
  * Do the necessary preparations which are verified by the firmware as
  * described in the SNP_INIT_EX firmware command description in the SNP
@@ -516,8 +540,6 @@ static bool __init setup_rmptable(void)
  */
 int __init snp_rmptable_init(void)
 {
-	u64 val;
-
 	if (WARN_ON_ONCE(!cc_platform_has(CC_ATTR_HOST_SEV_SNP)))
 		return -ENOSYS;
 
@@ -527,22 +549,8 @@ int __init snp_rmptable_init(void)
 	if (!setup_rmptable())
 		return -ENOSYS;
 
-	/*
-	 * Check if SEV-SNP is already enabled, this can happen in case of
-	 * kexec boot.
-	 */
-	rdmsrq(MSR_AMD64_SYSCFG, val);
-	if (val & MSR_AMD64_SYSCFG_SNP_EN)
-		goto skip_enable;
-
-	snp_clear_rmp();
-
-	/* MtrrFixDramModEn must be enabled on all the CPUs prior to enabling SNP. */
-	on_each_cpu(mfd_enable, NULL, 1);
-
-	on_each_cpu(snp_enable, NULL, 1);
+	snp_prepare_for_snp_init();
 
-skip_enable:
 	/*
 	 * Setting crash_kexec_post_notifiers to 'true' to ensure that SNP panic
 	 * notifier is invoked to do SNP IOMMU shutdown before kdump.
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 06/11] x86/snp, crypto: move SNP init to ccp driver
  2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
                   ` (4 preceding siblings ...)
  2026-03-02 19:13 ` [PATCH 05/11] x86/snp: create snp_prepare_for_snp_init() Tycho Andersen
@ 2026-03-02 19:13 ` Tycho Andersen
  2026-03-02 20:25   ` Tom Lendacky
  2026-03-02 19:13 ` [PATCH 07/11] x86/snp, crypto: move HSAVE_PA setup to arch/ Tycho Andersen
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

Use the new snp_prepare_for_snp_init() to initialize SNP from the ccp
driver instead of at boot time. This means that SNP is not enabled unless
it is really going to be used (i.e. kvm_amd loads the ccp driver
automatically).

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 arch/x86/virt/svm/sev.c      | 2 --
 drivers/crypto/ccp/sev-dev.c | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 8f50538baf7b..aa784542b32d 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -549,8 +549,6 @@ int __init snp_rmptable_init(void)
 	if (!setup_rmptable())
 		return -ENOSYS;
 
-	snp_prepare_for_snp_init();
-
 	/*
 	 * Setting crash_kexec_post_notifiers to 'true' to ensure that SNP panic
 	 * notifier is invoked to do SNP IOMMU shutdown before kdump.
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 096f993974d1..5b1a24b11e3e 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -1375,6 +1375,8 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
 		return -EOPNOTSUPP;
 	}
 
+	snp_prepare_for_snp_init();
+
 	/* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
 	on_each_cpu(snp_set_hsave_pa, NULL, 1);
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 07/11] x86/snp, crypto: move HSAVE_PA setup to arch/
  2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
                   ` (5 preceding siblings ...)
  2026-03-02 19:13 ` [PATCH 06/11] x86/snp, crypto: move SNP init to ccp driver Tycho Andersen
@ 2026-03-02 19:13 ` Tycho Andersen
  2026-03-02 20:27   ` Tom Lendacky
  2026-03-02 19:13 ` [PATCH 08/11] x86/snp: allow disabling MFDM Tycho Andersen
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

Now that there is snp_prepare_for_snp_init() that indicates when the CCP
driver wants to prepare the architecture for SNP_INIT(_EX), move this
architecture-specific bit of code to a more sensible place.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 arch/x86/virt/svm/sev.c      | 8 ++++++++
 drivers/crypto/ccp/sev-dev.c | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index aa784542b32d..53bc0c7f2c50 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -509,6 +509,11 @@ static bool __init setup_rmptable(void)
 	return true;
 }
 
+static void snp_set_hsave_pa(void *arg)
+{
+	wrmsrq(MSR_VM_HSAVE_PA, 0);
+}
+
 void snp_prepare_for_snp_init(void)
 {
 	u64 val;
@@ -530,6 +535,9 @@ void snp_prepare_for_snp_init(void)
 	on_each_cpu(mfd_enable, NULL, 1);
 
 	on_each_cpu(snp_enable, NULL, 1);
+
+	/* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
+	on_each_cpu(snp_set_hsave_pa, NULL, 1);
 }
 EXPORT_SYMBOL_FOR_MODULES(snp_prepare_for_snp_init, "ccp");
 
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 5b1a24b11e3e..ef45977b09b6 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -1076,11 +1076,6 @@ static inline int __sev_do_init_locked(int *psp_ret)
 		return __sev_init_locked(psp_ret);
 }
 
-static void snp_set_hsave_pa(void *arg)
-{
-	wrmsrq(MSR_VM_HSAVE_PA, 0);
-}
-
 /* Hypervisor Fixed pages API interface */
 static void snp_hv_fixed_pages_state_update(struct sev_device *sev,
 					    enum snp_hv_fixed_pages_state page_state)
@@ -1377,9 +1372,6 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
 
 	snp_prepare_for_snp_init();
 
-	/* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
-	on_each_cpu(snp_set_hsave_pa, NULL, 1);
-
 	/*
 	 * Starting in SNP firmware v1.52, the SNP_INIT_EX command takes a list
 	 * of system physical address ranges to convert into HV-fixed page
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 08/11] x86/snp: allow disabling MFDM
  2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
                   ` (6 preceding siblings ...)
  2026-03-02 19:13 ` [PATCH 07/11] x86/snp, crypto: move HSAVE_PA setup to arch/ Tycho Andersen
@ 2026-03-02 19:13 ` Tycho Andersen
  2026-03-02 20:29   ` Tom Lendacky
  2026-03-02 19:13 ` [PATCH 09/11] x86/snp: create snp_x86_shutdown() Tycho Andersen
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

The SNP x86 shutdown path needs to disable MFDM, since as the comment for
k8_check_syscfg_dram_mod_en(), the "BIOS" is supposed clear it, or the
kernel in the case of module unload and shutdown followed by kexec.

Change this helper to allow for disabling it.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 arch/x86/virt/svm/sev.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 53bc0c7f2c50..cf984b8f4493 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -132,7 +132,7 @@ static unsigned long snp_nr_leaked_pages;
 #undef pr_fmt
 #define pr_fmt(fmt)	"SEV-SNP: " fmt
 
-static void mfd_enable(void *arg)
+static void mfd_reconfigure(void *arg)
 {
 	u64 val;
 
@@ -141,7 +141,10 @@ static void mfd_enable(void *arg)
 
 	rdmsrq(MSR_AMD64_SYSCFG, val);
 
-	val |= MSR_AMD64_SYSCFG_MFDM;
+	if (arg)
+		val |= MSR_AMD64_SYSCFG_MFDM;
+	else
+		val &= ~MSR_AMD64_SYSCFG_MFDM;
 
 	wrmsrq(MSR_AMD64_SYSCFG, val);
 }
@@ -532,7 +535,7 @@ void snp_prepare_for_snp_init(void)
 	 * MtrrFixDramModEn is not shared between threads on a core,
 	 * therefore it must be set on all CPUs prior to enabling SNP.
 	 */
-	on_each_cpu(mfd_enable, NULL, 1);
+	on_each_cpu(mfd_reconfigure, (void *)1, 1);
 
 	on_each_cpu(snp_enable, NULL, 1);
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 09/11] x86/snp: create snp_x86_shutdown()
  2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
                   ` (7 preceding siblings ...)
  2026-03-02 19:13 ` [PATCH 08/11] x86/snp: allow disabling MFDM Tycho Andersen
@ 2026-03-02 19:13 ` Tycho Andersen
  2026-03-02 20:35   ` Tom Lendacky
  2026-03-02 19:13 ` [PATCH 10/11] crypto: ccp - implement SNP x86 shutdown Tycho Andersen
  2026-03-02 19:13 ` [PATCH 11/11] crypto: ccp - Update HV_FIXED page states to allow freeing of memory Tycho Andersen
  10 siblings, 1 reply; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

After SNP_SHUTDOWN, two architecture-level things should be done:

1. clear the RMP table
2. disable MFDM to prevent the FW_WARN in k8_check_syscfg_dram_mod_en() in
   the event of a kexec

Create and export to the CCP driver a function that does them.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 arch/x86/include/asm/sev.h | 2 ++
 arch/x86/virt/svm/sev.c    | 7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
index 0bcd89d4fe90..36d2b1ea19c0 100644
--- a/arch/x86/include/asm/sev.h
+++ b/arch/x86/include/asm/sev.h
@@ -662,6 +662,7 @@ static inline void snp_leak_pages(u64 pfn, unsigned int pages)
 	__snp_leak_pages(pfn, pages, true);
 }
 void snp_prepare_for_snp_init(void);
+void snp_x86_shutdown(void);
 #else
 static inline bool snp_probe_rmptable_info(void) { return false; }
 static inline int snp_rmptable_init(void) { return -ENOSYS; }
@@ -679,6 +680,7 @@ static inline void snp_leak_pages(u64 pfn, unsigned int npages) {}
 static inline void kdump_sev_callback(void) { }
 static inline void snp_fixup_e820_tables(void) {}
 static inline void snp_prepare_for_snp_init(void) {}
+static inline void snp_x86_shutdown(void) {}
 #endif
 
 #endif
diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index cf984b8f4493..0524fc77b44d 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -544,6 +544,13 @@ void snp_prepare_for_snp_init(void)
 }
 EXPORT_SYMBOL_FOR_MODULES(snp_prepare_for_snp_init, "ccp");
 
+void snp_x86_shutdown(void)
+{
+	snp_clear_rmp();
+	on_each_cpu(mfd_reconfigure, 0, 1);
+}
+EXPORT_SYMBOL_FOR_MODULES(snp_x86_shutdown, "ccp");
+
 /*
  * Do the necessary preparations which are verified by the firmware as
  * described in the SNP_INIT_EX firmware command description in the SNP
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 10/11] crypto: ccp - implement SNP x86 shutdown
  2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
                   ` (8 preceding siblings ...)
  2026-03-02 19:13 ` [PATCH 09/11] x86/snp: create snp_x86_shutdown() Tycho Andersen
@ 2026-03-02 19:13 ` Tycho Andersen
  2026-03-02 20:47   ` Tom Lendacky
  2026-03-02 19:13 ` [PATCH 11/11] crypto: ccp - Update HV_FIXED page states to allow freeing of memory Tycho Andersen
  10 siblings, 1 reply; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

The SEV firmware has support to disable SNP during an SNP_SHUTDOWN_EX
command. Verify that this support is available and set the flag so that SNP
is disabled when it is not being used. In cases where SNP is disabled, skip
the call to amd_iommu_snp_disable(), as all of the IOMMU pages have already
been made shared.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 drivers/crypto/ccp/sev-dev.c | 44 ++++++++++++++++++++++--------------
 include/linux/psp-sev.h      |  4 +++-
 2 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index ef45977b09b6..665fe0615b06 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -2028,6 +2028,7 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
 	struct psp_device *psp = psp_master;
 	struct sev_device *sev;
 	struct sev_data_snp_shutdown_ex data;
+	u64 syscfg;
 	int ret;
 
 	if (!psp || !psp->sev_data)
@@ -2041,6 +2042,8 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
 	memset(&data, 0, sizeof(data));
 	data.len = sizeof(data);
 	data.iommu_snp_shutdown = 1;
+	if (sev->snp_feat_info_0.ecx & SNP_X86_SHUTDOWN_SUPPORTED)
+		data.x86_snp_shutdown = 1;
 
 	/*
 	 * If invoked during panic handling, local interrupts are disabled
@@ -2074,23 +2077,30 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
 		return ret;
 	}
 
-	/*
-	 * SNP_SHUTDOWN_EX with IOMMU_SNP_SHUTDOWN set to 1 disables SNP
-	 * enforcement by the IOMMU and also transitions all pages
-	 * associated with the IOMMU to the Reclaim state.
-	 * Firmware was transitioning the IOMMU pages to Hypervisor state
-	 * before version 1.53. But, accounting for the number of assigned
-	 * 4kB pages in a 2M page was done incorrectly by not transitioning
-	 * to the Reclaim state. This resulted in RMP #PF when later accessing
-	 * the 2M page containing those pages during kexec boot. Hence, the
-	 * firmware now transitions these pages to Reclaim state and hypervisor
-	 * needs to transition these pages to shared state. SNP Firmware
-	 * version 1.53 and above are needed for kexec boot.
-	 */
-	ret = amd_iommu_snp_disable();
-	if (ret) {
-		dev_err(sev->dev, "SNP IOMMU shutdown failed\n");
-		return ret;
+	rdmsrq(MSR_AMD64_SYSCFG, syscfg);
+	if (data.x86_snp_shutdown &&
+	    !WARN_ON_ONCE(syscfg & MSR_AMD64_SYSCFG_SNP_EN)) {
+		if (!panic)
+			snp_x86_shutdown();
+	} else {
+		/*
+		 * SNP_SHUTDOWN_EX with IOMMU_SNP_SHUTDOWN set to 1 disables SNP
+		 * enforcement by the IOMMU and also transitions all pages
+		 * associated with the IOMMU to the Reclaim state.
+		 * Firmware was transitioning the IOMMU pages to Hypervisor state
+		 * before version 1.53. But, accounting for the number of assigned
+		 * 4kB pages in a 2M page was done incorrectly by not transitioning
+		 * to the Reclaim state. This resulted in RMP #PF when later accessing
+		 * the 2M page containing those pages during kexec boot. Hence, the
+		 * firmware now transitions these pages to Reclaim state and hypervisor
+		 * needs to transition these pages to shared state. SNP Firmware
+		 * version 1.53 and above are needed for kexec boot.
+		 */
+		ret = amd_iommu_snp_disable();
+		if (ret) {
+			dev_err(sev->dev, "SNP IOMMU shutdown failed\n");
+			return ret;
+		}
 	}
 
 	snp_leak_hv_fixed_pages();
diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
index 69ffa4b4d1fa..2adb990189c1 100644
--- a/include/linux/psp-sev.h
+++ b/include/linux/psp-sev.h
@@ -834,7 +834,8 @@ struct sev_data_range_list {
 struct sev_data_snp_shutdown_ex {
 	u32 len;
 	u32 iommu_snp_shutdown:1;
-	u32 rsvd1:31;
+	u32 x86_snp_shutdown:1;
+	u32 rsvd1:30;
 } __packed;
 
 /**
@@ -891,6 +892,7 @@ struct snp_feature_info {
 } __packed;
 
 /* Feature bits in ECX */
+#define SNP_X86_SHUTDOWN_SUPPORTED		BIT(1)
 #define SNP_RAPL_DISABLE_SUPPORTED		BIT(2)
 #define SNP_CIPHER_TEXT_HIDING_SUPPORTED	BIT(3)
 #define SNP_AES_256_XTS_POLICY_SUPPORTED	BIT(4)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 11/11] crypto: ccp - Update HV_FIXED page states to allow freeing of memory
  2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
                   ` (9 preceding siblings ...)
  2026-03-02 19:13 ` [PATCH 10/11] crypto: ccp - implement SNP x86 shutdown Tycho Andersen
@ 2026-03-02 19:13 ` Tycho Andersen
  10 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 19:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: Tom Lendacky <thomas.lendacky@amd.com>

After SNP is disabled, any pages allocated as HV_FIXED can now be freed.
Update the page state of these pages and the snp_leak_hv_fixed_pages()
function to free pages on SNP_SHUTDOWN.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 drivers/crypto/ccp/sev-dev.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 665fe0615b06..930fe98993d7 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -1221,7 +1221,7 @@ static void snp_add_hv_fixed_pages(struct sev_device *sev, struct sev_data_range
 
 static void snp_leak_hv_fixed_pages(void)
 {
-	struct snp_hv_fixed_pages_entry *entry;
+	struct snp_hv_fixed_pages_entry *entry, *nentry;
 
 	/* List is protected by sev_cmd_mutex */
 	lockdep_assert_held(&sev_cmd_mutex);
@@ -1229,10 +1229,16 @@ static void snp_leak_hv_fixed_pages(void)
 	if (list_empty(&snp_hv_fixed_pages))
 		return;
 
-	list_for_each_entry(entry, &snp_hv_fixed_pages, list)
-		if (entry->page_state == HV_FIXED)
+	list_for_each_entry_safe(entry, nentry, &snp_hv_fixed_pages, list) {
+		if (entry->free && entry->page_state != HV_FIXED)
+			__free_pages(entry->page, entry->order);
+		else
 			__snp_leak_pages(page_to_pfn(entry->page),
 					 1 << entry->order, false);
+
+		list_del(&entry->list);
+		kfree(entry);
+	}
 }
 
 bool sev_is_snp_ciphertext_hiding_supported(void)
@@ -2082,6 +2088,7 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
 	    !WARN_ON_ONCE(syscfg & MSR_AMD64_SYSCFG_SNP_EN)) {
 		if (!panic)
 			snp_x86_shutdown();
+		snp_hv_fixed_pages_state_update(sev, ALLOCATED);
 	} else {
 		/*
 		 * SNP_SHUTDOWN_EX with IOMMU_SNP_SHUTDOWN set to 1 disables SNP
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 01/11] x86/snp: drop support for SNP hotplug
  2026-03-02 19:13 ` [PATCH 01/11] x86/snp: drop support for SNP hotplug Tycho Andersen
@ 2026-03-02 19:56   ` Tom Lendacky
  2026-03-05 12:57   ` Borislav Petkov
  2026-03-06 15:38   ` Borislav Petkov
  2 siblings, 0 replies; 36+ messages in thread
From: Tom Lendacky @ 2026-03-02 19:56 UTC (permalink / raw)
  To: Tycho Andersen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Ashish Kalra, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

On 3/2/26 13:13, Tycho Andersen wrote:
> [Some people who received this message don't often get email from tycho@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
> 
> During an SNP_INIT(_EX), the SEV firmware checks that all CPUs have SNPEn
> set, and fails if they do not. As such, it does not make sense to have
> offline CPUs: the firmware will fail initialization because of the offlined
> ones that the kernel did not initialize.
> 
> Futher, there is a bug: SNP_INIT(_EX) require MFDM to be set in addition to
> SNPEn which the previous hotplug code did not do. Since
> k8_check_syscfg_dram_mod_en() enforces this be cleared, hotplug wouldn't
> work.
> 
> Drop the hotplug code. Collapse the __{mfd,snp}__enable() wrappers into
> their non-__ versions, since the cpu number argument is no longer needed.
> 
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  arch/x86/virt/svm/sev.c | 24 ++++--------------------
>  1 file changed, 4 insertions(+), 20 deletions(-)
> 
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index a4f3a364fb65..1446011c6337 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -130,33 +130,26 @@ static unsigned long snp_nr_leaked_pages;
>  #undef pr_fmt
>  #define pr_fmt(fmt)    "SEV-SNP: " fmt
> 
> -static int __mfd_enable(unsigned int cpu)
> +static __init void mfd_enable(void *arg)
>  {
>         u64 val;
> 
>         if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
> -               return 0;
> +               return;
> 
>         rdmsrq(MSR_AMD64_SYSCFG, val);
> 
>         val |= MSR_AMD64_SYSCFG_MFDM;
> 
>         wrmsrq(MSR_AMD64_SYSCFG, val);
> -
> -       return 0;
>  }
> 
> -static __init void mfd_enable(void *arg)
> -{
> -       __mfd_enable(smp_processor_id());
> -}
> -
> -static int __snp_enable(unsigned int cpu)
> +static __init void snp_enable(void *arg)
>  {
>         u64 val;
> 
>         if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
> -               return 0;
> +               return;
> 
>         rdmsrq(MSR_AMD64_SYSCFG, val);
> 
> @@ -164,13 +157,6 @@ static int __snp_enable(unsigned int cpu)
>         val |= MSR_AMD64_SYSCFG_SNP_VMPL_EN;
> 
>         wrmsrq(MSR_AMD64_SYSCFG, val);
> -
> -       return 0;
> -}
> -
> -static __init void snp_enable(void *arg)
> -{
> -       __snp_enable(smp_processor_id());
>  }
> 
>  static void __init __snp_fixup_e820_tables(u64 pa)
> @@ -553,8 +539,6 @@ int __init snp_rmptable_init(void)
>         on_each_cpu(snp_enable, NULL, 1);
> 
>  skip_enable:
> -       cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/rmptable_init:online", __snp_enable, NULL);
> -
>         /*
>          * Setting crash_kexec_post_notifiers to 'true' to ensure that SNP panic
>          * notifier is invoked to do SNP IOMMU shutdown before kdump.
> --
> 2.53.0
> 


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 04/11] x86/snp: drop WBINVD before setting SNPEn
  2026-03-02 19:13 ` [PATCH 04/11] x86/snp: drop WBINVD before setting SNPEn Tycho Andersen
@ 2026-03-02 20:00   ` Tom Lendacky
  0 siblings, 0 replies; 36+ messages in thread
From: Tom Lendacky @ 2026-03-02 20:00 UTC (permalink / raw)
  To: Tycho Andersen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Ashish Kalra, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

On 3/2/26 13:13, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
> 
> WBINVD is required before SNP_INIT(_EX), but not before setting SNPEn,
> since the ccp driver already does its own WBINVD before SNP_INIT (and this
> one would be too early for that anyway...).
> 
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  arch/x86/virt/svm/sev.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index e7fbbf1cdf8e..258e67ba7415 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -537,9 +537,6 @@ int __init snp_rmptable_init(void)
>  
>  	snp_clear_rmp();
>  
> -	/* Flush the caches to ensure that data is written before SNP is enabled. */
> -	wbinvd_on_all_cpus();
> -
>  	/* MtrrFixDramModEn must be enabled on all the CPUs prior to enabling SNP. */
>  	on_each_cpu(mfd_enable, NULL, 1);
>  


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 05/11] x86/snp: create snp_prepare_for_snp_init()
  2026-03-02 19:13 ` [PATCH 05/11] x86/snp: create snp_prepare_for_snp_init() Tycho Andersen
@ 2026-03-02 20:03   ` Tom Lendacky
  0 siblings, 0 replies; 36+ messages in thread
From: Tom Lendacky @ 2026-03-02 20:03 UTC (permalink / raw)
  To: Tycho Andersen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Ashish Kalra, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Alexey Kardashevskiy,
	Nikunj A Dadhania, Peter Zijlstra (Intel), Kim Phillips,
	Sean Christopherson
  Cc: linux-kernel, linux-crypto

On 3/2/26 13:13, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
> 
> In preparation for delayed SNP initialization, create a function
> snp_prepare_for_snp_init() that does the necessary architecture setup.
> Export this function for the ccp module to allow it to do the setup as
> necessary.
> 
> Also move {mfd,snp}_enable out of the __init section, since these will be
> called later.
> 
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  arch/x86/include/asm/sev.h |  2 ++
>  arch/x86/virt/svm/sev.c    | 46 ++++++++++++++++++++++----------------
>  2 files changed, 29 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
> index 0e6c0940100f..0bcd89d4fe90 100644
> --- a/arch/x86/include/asm/sev.h
> +++ b/arch/x86/include/asm/sev.h
> @@ -661,6 +661,7 @@ static inline void snp_leak_pages(u64 pfn, unsigned int pages)
>  {
>  	__snp_leak_pages(pfn, pages, true);
>  }
> +void snp_prepare_for_snp_init(void);
>  #else
>  static inline bool snp_probe_rmptable_info(void) { return false; }
>  static inline int snp_rmptable_init(void) { return -ENOSYS; }
> @@ -677,6 +678,7 @@ static inline void __snp_leak_pages(u64 pfn, unsigned int npages, bool dump_rmp)
>  static inline void snp_leak_pages(u64 pfn, unsigned int npages) {}
>  static inline void kdump_sev_callback(void) { }
>  static inline void snp_fixup_e820_tables(void) {}
> +static inline void snp_prepare_for_snp_init(void) {}
>  #endif
>  
>  #endif
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index 258e67ba7415..8f50538baf7b 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -132,7 +132,7 @@ static unsigned long snp_nr_leaked_pages;
>  #undef pr_fmt
>  #define pr_fmt(fmt)	"SEV-SNP: " fmt
>  
> -static __init void mfd_enable(void *arg)
> +static void mfd_enable(void *arg)
>  {
>  	u64 val;
>  
> @@ -146,7 +146,7 @@ static __init void mfd_enable(void *arg)
>  	wrmsrq(MSR_AMD64_SYSCFG, val);
>  }
>  
> -static __init void snp_enable(void *arg)
> +static void snp_enable(void *arg)
>  {
>  	u64 val;
>  
> @@ -509,6 +509,30 @@ static bool __init setup_rmptable(void)
>  	return true;
>  }
>  
> +void snp_prepare_for_snp_init(void)
> +{
> +	u64 val;
> +
> +	/*
> +	 * Check if SEV-SNP is already enabled, this can happen in case of
> +	 * kexec boot.
> +	 */
> +	rdmsrq(MSR_AMD64_SYSCFG, val);
> +	if (val & MSR_AMD64_SYSCFG_SNP_EN)
> +		return;
> +
> +	snp_clear_rmp();
> +
> +	/*
> +	 * MtrrFixDramModEn is not shared between threads on a core,
> +	 * therefore it must be set on all CPUs prior to enabling SNP.
> +	 */
> +	on_each_cpu(mfd_enable, NULL, 1);
> +
> +	on_each_cpu(snp_enable, NULL, 1);
> +}
> +EXPORT_SYMBOL_FOR_MODULES(snp_prepare_for_snp_init, "ccp");
> +
>  /*
>   * Do the necessary preparations which are verified by the firmware as
>   * described in the SNP_INIT_EX firmware command description in the SNP
> @@ -516,8 +540,6 @@ static bool __init setup_rmptable(void)
>   */
>  int __init snp_rmptable_init(void)
>  {
> -	u64 val;
> -
>  	if (WARN_ON_ONCE(!cc_platform_has(CC_ATTR_HOST_SEV_SNP)))
>  		return -ENOSYS;
>  
> @@ -527,22 +549,8 @@ int __init snp_rmptable_init(void)
>  	if (!setup_rmptable())
>  		return -ENOSYS;
>  
> -	/*
> -	 * Check if SEV-SNP is already enabled, this can happen in case of
> -	 * kexec boot.
> -	 */
> -	rdmsrq(MSR_AMD64_SYSCFG, val);
> -	if (val & MSR_AMD64_SYSCFG_SNP_EN)
> -		goto skip_enable;
> -
> -	snp_clear_rmp();
> -
> -	/* MtrrFixDramModEn must be enabled on all the CPUs prior to enabling SNP. */
> -	on_each_cpu(mfd_enable, NULL, 1);
> -
> -	on_each_cpu(snp_enable, NULL, 1);
> +	snp_prepare_for_snp_init();
>  
> -skip_enable:
>  	/*
>  	 * Setting crash_kexec_post_notifiers to 'true' to ensure that SNP panic
>  	 * notifier is invoked to do SNP IOMMU shutdown before kdump.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 06/11] x86/snp, crypto: move SNP init to ccp driver
  2026-03-02 19:13 ` [PATCH 06/11] x86/snp, crypto: move SNP init to ccp driver Tycho Andersen
@ 2026-03-02 20:25   ` Tom Lendacky
  0 siblings, 0 replies; 36+ messages in thread
From: Tom Lendacky @ 2026-03-02 20:25 UTC (permalink / raw)
  To: Tycho Andersen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Ashish Kalra, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Alexey Kardashevskiy,
	Nikunj A Dadhania, Peter Zijlstra (Intel), Kim Phillips,
	Sean Christopherson
  Cc: linux-kernel, linux-crypto

On 3/2/26 13:13, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
> 
> Use the new snp_prepare_for_snp_init() to initialize SNP from the ccp
> driver instead of at boot time. This means that SNP is not enabled unless
> it is really going to be used (i.e. kvm_amd loads the ccp driver
> automatically).
> 
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  arch/x86/virt/svm/sev.c      | 2 --
>  drivers/crypto/ccp/sev-dev.c | 2 ++
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index 8f50538baf7b..aa784542b32d 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -549,8 +549,6 @@ int __init snp_rmptable_init(void)
>  	if (!setup_rmptable())
>  		return -ENOSYS;
>  
> -	snp_prepare_for_snp_init();
> -
>  	/*
>  	 * Setting crash_kexec_post_notifiers to 'true' to ensure that SNP panic
>  	 * notifier is invoked to do SNP IOMMU shutdown before kdump.
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 096f993974d1..5b1a24b11e3e 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -1375,6 +1375,8 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
>  		return -EOPNOTSUPP;
>  	}
>  
> +	snp_prepare_for_snp_init();
> +
>  	/* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
>  	on_each_cpu(snp_set_hsave_pa, NULL, 1);
>  


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 07/11] x86/snp, crypto: move HSAVE_PA setup to arch/
  2026-03-02 19:13 ` [PATCH 07/11] x86/snp, crypto: move HSAVE_PA setup to arch/ Tycho Andersen
@ 2026-03-02 20:27   ` Tom Lendacky
  0 siblings, 0 replies; 36+ messages in thread
From: Tom Lendacky @ 2026-03-02 20:27 UTC (permalink / raw)
  To: Tycho Andersen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Ashish Kalra, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Alexey Kardashevskiy,
	Nikunj A Dadhania, Peter Zijlstra (Intel), Kim Phillips,
	Sean Christopherson
  Cc: linux-kernel, linux-crypto

On 3/2/26 13:13, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
> 
> Now that there is snp_prepare_for_snp_init() that indicates when the CCP
> driver wants to prepare the architecture for SNP_INIT(_EX), move this
> architecture-specific bit of code to a more sensible place.
> 
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  arch/x86/virt/svm/sev.c      | 8 ++++++++
>  drivers/crypto/ccp/sev-dev.c | 8 --------
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index aa784542b32d..53bc0c7f2c50 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -509,6 +509,11 @@ static bool __init setup_rmptable(void)
>  	return true;
>  }
>  
> +static void snp_set_hsave_pa(void *arg)
> +{
> +	wrmsrq(MSR_VM_HSAVE_PA, 0);
> +}
> +
>  void snp_prepare_for_snp_init(void)
>  {
>  	u64 val;
> @@ -530,6 +535,9 @@ void snp_prepare_for_snp_init(void)
>  	on_each_cpu(mfd_enable, NULL, 1);
>  
>  	on_each_cpu(snp_enable, NULL, 1);
> +
> +	/* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
> +	on_each_cpu(snp_set_hsave_pa, NULL, 1);
>  }
>  EXPORT_SYMBOL_FOR_MODULES(snp_prepare_for_snp_init, "ccp");
>  
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index 5b1a24b11e3e..ef45977b09b6 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -1076,11 +1076,6 @@ static inline int __sev_do_init_locked(int *psp_ret)
>  		return __sev_init_locked(psp_ret);
>  }
>  
> -static void snp_set_hsave_pa(void *arg)
> -{
> -	wrmsrq(MSR_VM_HSAVE_PA, 0);
> -}
> -
>  /* Hypervisor Fixed pages API interface */
>  static void snp_hv_fixed_pages_state_update(struct sev_device *sev,
>  					    enum snp_hv_fixed_pages_state page_state)
> @@ -1377,9 +1372,6 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
>  
>  	snp_prepare_for_snp_init();
>  
> -	/* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
> -	on_each_cpu(snp_set_hsave_pa, NULL, 1);
> -
>  	/*
>  	 * Starting in SNP firmware v1.52, the SNP_INIT_EX command takes a list
>  	 * of system physical address ranges to convert into HV-fixed page


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 08/11] x86/snp: allow disabling MFDM
  2026-03-02 19:13 ` [PATCH 08/11] x86/snp: allow disabling MFDM Tycho Andersen
@ 2026-03-02 20:29   ` Tom Lendacky
  0 siblings, 0 replies; 36+ messages in thread
From: Tom Lendacky @ 2026-03-02 20:29 UTC (permalink / raw)
  To: Tycho Andersen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Ashish Kalra, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

On 3/2/26 13:13, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
> 
> The SNP x86 shutdown path needs to disable MFDM, since as the comment for
> k8_check_syscfg_dram_mod_en(), the "BIOS" is supposed clear it, or the
> kernel in the case of module unload and shutdown followed by kexec.
> 
> Change this helper to allow for disabling it.
> 
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>

This could be squashed with the next patch, but either way:

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  arch/x86/virt/svm/sev.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index 53bc0c7f2c50..cf984b8f4493 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -132,7 +132,7 @@ static unsigned long snp_nr_leaked_pages;
>  #undef pr_fmt
>  #define pr_fmt(fmt)	"SEV-SNP: " fmt
>  
> -static void mfd_enable(void *arg)
> +static void mfd_reconfigure(void *arg)
>  {
>  	u64 val;
>  
> @@ -141,7 +141,10 @@ static void mfd_enable(void *arg)
>  
>  	rdmsrq(MSR_AMD64_SYSCFG, val);
>  
> -	val |= MSR_AMD64_SYSCFG_MFDM;
> +	if (arg)
> +		val |= MSR_AMD64_SYSCFG_MFDM;
> +	else
> +		val &= ~MSR_AMD64_SYSCFG_MFDM;
>  
>  	wrmsrq(MSR_AMD64_SYSCFG, val);
>  }
> @@ -532,7 +535,7 @@ void snp_prepare_for_snp_init(void)
>  	 * MtrrFixDramModEn is not shared between threads on a core,
>  	 * therefore it must be set on all CPUs prior to enabling SNP.
>  	 */
> -	on_each_cpu(mfd_enable, NULL, 1);
> +	on_each_cpu(mfd_reconfigure, (void *)1, 1);
>  
>  	on_each_cpu(snp_enable, NULL, 1);
>  


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 09/11] x86/snp: create snp_x86_shutdown()
  2026-03-02 19:13 ` [PATCH 09/11] x86/snp: create snp_x86_shutdown() Tycho Andersen
@ 2026-03-02 20:35   ` Tom Lendacky
  2026-03-02 21:20     ` Tycho Andersen
  0 siblings, 1 reply; 36+ messages in thread
From: Tom Lendacky @ 2026-03-02 20:35 UTC (permalink / raw)
  To: Tycho Andersen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Ashish Kalra, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Alexey Kardashevskiy,
	Nikunj A Dadhania, Peter Zijlstra (Intel), Kim Phillips,
	Sean Christopherson
  Cc: linux-kernel, linux-crypto

On 3/2/26 13:13, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
> 
> After SNP_SHUTDOWN, two architecture-level things should be done:
> 
> 1. clear the RMP table
> 2. disable MFDM to prevent the FW_WARN in k8_check_syscfg_dram_mod_en() in
>    the event of a kexec
> 
> Create and export to the CCP driver a function that does them.
> 
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
> ---
>  arch/x86/include/asm/sev.h | 2 ++
>  arch/x86/virt/svm/sev.c    | 7 +++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
> index 0bcd89d4fe90..36d2b1ea19c0 100644
> --- a/arch/x86/include/asm/sev.h
> +++ b/arch/x86/include/asm/sev.h
> @@ -662,6 +662,7 @@ static inline void snp_leak_pages(u64 pfn, unsigned int pages)
>  	__snp_leak_pages(pfn, pages, true);
>  }
>  void snp_prepare_for_snp_init(void);
> +void snp_x86_shutdown(void);
>  #else
>  static inline bool snp_probe_rmptable_info(void) { return false; }
>  static inline int snp_rmptable_init(void) { return -ENOSYS; }
> @@ -679,6 +680,7 @@ static inline void snp_leak_pages(u64 pfn, unsigned int npages) {}
>  static inline void kdump_sev_callback(void) { }
>  static inline void snp_fixup_e820_tables(void) {}
>  static inline void snp_prepare_for_snp_init(void) {}
> +static inline void snp_x86_shutdown(void) {}
>  #endif
>  
>  #endif
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index cf984b8f4493..0524fc77b44d 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -544,6 +544,13 @@ void snp_prepare_for_snp_init(void)
>  }
>  EXPORT_SYMBOL_FOR_MODULES(snp_prepare_for_snp_init, "ccp");
>  
> +void snp_x86_shutdown(void)
> +{

Would it make sense to check for SNP being enabled before calling the
functions below? I realize each of the functions in question will do
that, but it could save a bunch of IPI's with the on_each_cpu() if SNP
is still enabled. Not a big deal either way, so:

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

Thanks,
Tom

> +	snp_clear_rmp();
> +	on_each_cpu(mfd_reconfigure, 0, 1);
> +}
> +EXPORT_SYMBOL_FOR_MODULES(snp_x86_shutdown, "ccp");
> +
>  /*
>   * Do the necessary preparations which are verified by the firmware as
>   * described in the SNP_INIT_EX firmware command description in the SNP


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 10/11] crypto: ccp - implement SNP x86 shutdown
  2026-03-02 19:13 ` [PATCH 10/11] crypto: ccp - implement SNP x86 shutdown Tycho Andersen
@ 2026-03-02 20:47   ` Tom Lendacky
  0 siblings, 0 replies; 36+ messages in thread
From: Tom Lendacky @ 2026-03-02 20:47 UTC (permalink / raw)
  To: Tycho Andersen, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Ashish Kalra, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Alexey Kardashevskiy,
	Nikunj A Dadhania, Peter Zijlstra (Intel), Kim Phillips,
	Sean Christopherson
  Cc: linux-kernel, linux-crypto

On 3/2/26 13:13, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
> 
> The SEV firmware has support to disable SNP during an SNP_SHUTDOWN_EX
> command. Verify that this support is available and set the flag so that SNP
> is disabled when it is not being used. In cases where SNP is disabled, skip
> the call to amd_iommu_snp_disable(), as all of the IOMMU pages have already
> been made shared.
> 
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  drivers/crypto/ccp/sev-dev.c | 44 ++++++++++++++++++++++--------------
>  include/linux/psp-sev.h      |  4 +++-
>  2 files changed, 30 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
> index ef45977b09b6..665fe0615b06 100644
> --- a/drivers/crypto/ccp/sev-dev.c
> +++ b/drivers/crypto/ccp/sev-dev.c
> @@ -2028,6 +2028,7 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
>  	struct psp_device *psp = psp_master;
>  	struct sev_device *sev;
>  	struct sev_data_snp_shutdown_ex data;
> +	u64 syscfg;
>  	int ret;
>  
>  	if (!psp || !psp->sev_data)
> @@ -2041,6 +2042,8 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
>  	memset(&data, 0, sizeof(data));
>  	data.len = sizeof(data);
>  	data.iommu_snp_shutdown = 1;
> +	if (sev->snp_feat_info_0.ecx & SNP_X86_SHUTDOWN_SUPPORTED)
> +		data.x86_snp_shutdown = 1;
>  
>  	/*
>  	 * If invoked during panic handling, local interrupts are disabled
> @@ -2074,23 +2077,30 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
>  		return ret;
>  	}
>  
> -	/*
> -	 * SNP_SHUTDOWN_EX with IOMMU_SNP_SHUTDOWN set to 1 disables SNP
> -	 * enforcement by the IOMMU and also transitions all pages
> -	 * associated with the IOMMU to the Reclaim state.
> -	 * Firmware was transitioning the IOMMU pages to Hypervisor state
> -	 * before version 1.53. But, accounting for the number of assigned
> -	 * 4kB pages in a 2M page was done incorrectly by not transitioning
> -	 * to the Reclaim state. This resulted in RMP #PF when later accessing
> -	 * the 2M page containing those pages during kexec boot. Hence, the
> -	 * firmware now transitions these pages to Reclaim state and hypervisor
> -	 * needs to transition these pages to shared state. SNP Firmware
> -	 * version 1.53 and above are needed for kexec boot.
> -	 */
> -	ret = amd_iommu_snp_disable();
> -	if (ret) {
> -		dev_err(sev->dev, "SNP IOMMU shutdown failed\n");
> -		return ret;
> +	rdmsrq(MSR_AMD64_SYSCFG, syscfg);
> +	if (data.x86_snp_shutdown &&
> +	    !WARN_ON_ONCE(syscfg & MSR_AMD64_SYSCFG_SNP_EN)) {
> +		if (!panic)
> +			snp_x86_shutdown();
> +	} else {
> +		/*
> +		 * SNP_SHUTDOWN_EX with IOMMU_SNP_SHUTDOWN set to 1 disables SNP
> +		 * enforcement by the IOMMU and also transitions all pages
> +		 * associated with the IOMMU to the Reclaim state.
> +		 * Firmware was transitioning the IOMMU pages to Hypervisor state
> +		 * before version 1.53. But, accounting for the number of assigned
> +		 * 4kB pages in a 2M page was done incorrectly by not transitioning
> +		 * to the Reclaim state. This resulted in RMP #PF when later accessing
> +		 * the 2M page containing those pages during kexec boot. Hence, the
> +		 * firmware now transitions these pages to Reclaim state and hypervisor
> +		 * needs to transition these pages to shared state. SNP Firmware
> +		 * version 1.53 and above are needed for kexec boot.
> +		 */
> +		ret = amd_iommu_snp_disable();
> +		if (ret) {
> +			dev_err(sev->dev, "SNP IOMMU shutdown failed\n");
> +			return ret;
> +		}
>  	}
>  
>  	snp_leak_hv_fixed_pages();
> diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
> index 69ffa4b4d1fa..2adb990189c1 100644
> --- a/include/linux/psp-sev.h
> +++ b/include/linux/psp-sev.h
> @@ -834,7 +834,8 @@ struct sev_data_range_list {
>  struct sev_data_snp_shutdown_ex {
>  	u32 len;
>  	u32 iommu_snp_shutdown:1;
> -	u32 rsvd1:31;
> +	u32 x86_snp_shutdown:1;
> +	u32 rsvd1:30;
>  } __packed;
>  
>  /**
> @@ -891,6 +892,7 @@ struct snp_feature_info {
>  } __packed;
>  
>  /* Feature bits in ECX */
> +#define SNP_X86_SHUTDOWN_SUPPORTED		BIT(1)
>  #define SNP_RAPL_DISABLE_SUPPORTED		BIT(2)
>  #define SNP_CIPHER_TEXT_HIDING_SUPPORTED	BIT(3)
>  #define SNP_AES_256_XTS_POLICY_SUPPORTED	BIT(4)


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 09/11] x86/snp: create snp_x86_shutdown()
  2026-03-02 20:35   ` Tom Lendacky
@ 2026-03-02 21:20     ` Tycho Andersen
  0 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-02 21:20 UTC (permalink / raw)
  To: Tom Lendacky
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, John Allen, Herbert Xu,
	David S. Miller, Ard Biesheuvel, Alexey Kardashevskiy,
	Nikunj A Dadhania, Peter Zijlstra (Intel), Kim Phillips,
	Sean Christopherson, linux-kernel, linux-crypto

Hi Tom,

On Mon, Mar 02, 2026 at 02:35:38PM -0600, Tom Lendacky wrote:
> > +void snp_x86_shutdown(void)
> > +{
> 
> Would it make sense to check for SNP being enabled before calling the
> functions below? I realize each of the functions in question will do
> that, but it could save a bunch of IPI's with the on_each_cpu() if SNP
> is still enabled. Not a big deal either way, so:

It is guarded at the call site by:

        if (data.x86_snp_shutdown &&
            !WARN_ON_ONCE(syscfg & MSR_AMD64_SYSCFG_SNP_EN)) {
                if (!panic)
                        snp_x86_shutdown();

but we could push that into here to protect any future callers.

If we require a v2 I will make the fix.

> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

Thanks for this and the others!

Tycho

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 01/11] x86/snp: drop support for SNP hotplug
  2026-03-02 19:13 ` [PATCH 01/11] x86/snp: drop support for SNP hotplug Tycho Andersen
  2026-03-02 19:56   ` Tom Lendacky
@ 2026-03-05 12:57   ` Borislav Petkov
  2026-03-06 15:38   ` Borislav Petkov
  2 siblings, 0 replies; 36+ messages in thread
From: Borislav Petkov @ 2026-03-05 12:57 UTC (permalink / raw)
  To: Tycho Andersen
  Cc: Thomas Gleixner, Ingo Molnar, Dave Hansen, x86, H. Peter Anvin,
	Ashish Kalra, Tom Lendacky, John Allen, Herbert Xu,
	David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson,
	linux-kernel, linux-crypto

On Mon, Mar 02, 2026 at 12:13:24PM -0700, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
> 
> During an SNP_INIT(_EX), the SEV firmware checks that all CPUs have SNPEn

Please write those in a human-readable form - not as code in text. Commit
messages are still predominantly read by humans.

:)

> set, and fails if they do not. As such, it does not make sense to have
> offline CPUs: the firmware will fail initialization because of the offlined
> ones that the kernel did not initialize.
> 
> Futher, there is a bug: SNP_INIT(_EX) require MFDM to be set in addition to
> SNPEn which the previous hotplug code did not do. Since
> k8_check_syscfg_dram_mod_en() enforces this be cleared, hotplug wouldn't
> work.
> 
> Drop the hotplug code. Collapse the __{mfd,snp}__enable() wrappers into
> their non-__ versions, since the cpu number argument is no longer needed.

Please, do not talk about *what* the patch is doing in the commit message
- that should be obvious from the diff itself. Rather, concentrate on the
*why* it needs to be done and why your patch exists.

> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
> ---
>  arch/x86/virt/svm/sev.c | 24 ++++--------------------
>  1 file changed, 4 insertions(+), 20 deletions(-)
> 
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index a4f3a364fb65..1446011c6337 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -130,33 +130,26 @@ static unsigned long snp_nr_leaked_pages;
>  #undef pr_fmt
>  #define pr_fmt(fmt)	"SEV-SNP: " fmt
>  
> -static int __mfd_enable(unsigned int cpu)
> +static __init void mfd_enable(void *arg)
>  {
>  	u64 val;
>  
>  	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
> -		return 0;
> +		return;
>  
>  	rdmsrq(MSR_AMD64_SYSCFG, val);
>  
>  	val |= MSR_AMD64_SYSCFG_MFDM;
>  
>  	wrmsrq(MSR_AMD64_SYSCFG, val);
> -
> -	return 0;
>  }

While at it:

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 1446011c6337..f404c609582c 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -132,16 +132,10 @@ static unsigned long snp_nr_leaked_pages;
 
 static __init void mfd_enable(void *arg)
 {
-	u64 val;
-
 	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
 		return;
 
-	rdmsrq(MSR_AMD64_SYSCFG, val);
-
-	val |= MSR_AMD64_SYSCFG_MFDM;
-
-	wrmsrq(MSR_AMD64_SYSCFG, val);
+	msr_set_bit(MSR_AMD64_SYSCFG, MSR_AMD64_SYSCFG_MFDM_BIT);
 }
 
 static __init void snp_enable(void *arg)

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 01/11] x86/snp: drop support for SNP hotplug
  2026-03-02 19:13 ` [PATCH 01/11] x86/snp: drop support for SNP hotplug Tycho Andersen
  2026-03-02 19:56   ` Tom Lendacky
  2026-03-05 12:57   ` Borislav Petkov
@ 2026-03-06 15:38   ` Borislav Petkov
  2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
  2 siblings, 1 reply; 36+ messages in thread
From: Borislav Petkov @ 2026-03-06 15:38 UTC (permalink / raw)
  To: Tycho Andersen
  Cc: Thomas Gleixner, Ingo Molnar, Dave Hansen, x86, H. Peter Anvin,
	Ashish Kalra, Tom Lendacky, John Allen, Herbert Xu,
	David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson,
	linux-kernel, linux-crypto

On Mon, Mar 02, 2026 at 12:13:24PM -0700, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@kernel.org>
> 
> During an SNP_INIT(_EX), the SEV firmware checks that all CPUs have SNPEn
> set, and fails if they do not. As such, it does not make sense to have
> offline CPUs: the firmware will fail initialization because of the offlined
> ones that the kernel did not initialize.
> 
> Futher, there is a bug: SNP_INIT(_EX) require MFDM to be set in addition to
> SNPEn which the previous hotplug code did not do. Since
> k8_check_syscfg_dram_mod_en() enforces this be cleared, hotplug wouldn't
> work.
> 
> Drop the hotplug code. Collapse the __{mfd,snp}__enable() wrappers into
> their non-__ versions, since the cpu number argument is no longer needed.
> 
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
> ---
>  arch/x86/virt/svm/sev.c | 24 ++++--------------------
>  1 file changed, 4 insertions(+), 20 deletions(-)

Btw, this one conflicts with Ashish's

https://lore.kernel.org/r/85aec55af41957678d214e9629eb6249b064fa87.1772486459.git.ashish.kalra@amd.com

Considering how yours is removing code and is almost ready, I'd suggest you
send a new version of it now-ish, as a reply to this thread and after
incorporating all feedback, so that I can apply it first and then Ashish can
base his stuff ontop.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 02/11] x86/snp: Keep the RMP table bookkeeping area mapped
  2026-03-02 19:13 ` [PATCH 02/11] x86/snp: Keep the RMP table bookkeeping area mapped Tycho Andersen
@ 2026-03-06 15:55   ` Borislav Petkov
  0 siblings, 0 replies; 36+ messages in thread
From: Borislav Petkov @ 2026-03-06 15:55 UTC (permalink / raw)
  To: Tycho Andersen
  Cc: Thomas Gleixner, Ingo Molnar, Dave Hansen, x86, H. Peter Anvin,
	Ashish Kalra, Tom Lendacky, John Allen, Herbert Xu,
	David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson,
	linux-kernel, linux-crypto

On Mon, Mar 02, 2026 at 12:13:25PM -0700, Tycho Andersen wrote:
> From: Tom Lendacky <thomas.lendacky@amd.com>
> 
> In prep for delayed SNP initialization and disablement on shutdown, the
     ^^^^

Yeah, write it out, you can do it... :-P

And yes, this sounds like Tom to me. :-P

> RMP will need to be cleared each time SNP is disabled. Maintain the

s/the //

> the mapping to the RMP bookkeeping area to avoid mapping and unmapping it
> each time and any possible errors that may arise from that.
> 
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
> ---
>  arch/x86/virt/svm/sev.c | 40 +++++++++++++++++-----------------------
>  1 file changed, 17 insertions(+), 23 deletions(-)

Otherwise LGTM.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH v2 00/10] Move SNP initialization to the CCP driver
  2026-03-06 15:38   ` Borislav Petkov
@ 2026-03-09 18:00     ` Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 01/10] x86/snp: drop support for SNP hotplug Tycho Andersen
                         ` (9 more replies)
  0 siblings, 10 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-09 18:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

Here's v2 of the series. Changes are:

* squash MFDM helper into snp_x86_shutdown()
* move MFDM helper to msr_set/clear_bit()
* move SNP bit test during shutdown from ccp into snp_x86_shutdown()
* reorder so that the two code deletion patches come first
* commit message rewrites, carry Tom's reivews as appropriate

Tom Lendacky (3):
  x86/snp: Keep the RMP table bookkeeping area mapped
  x86/snp: Create a function to clear/zero the RMP
  crypto: ccp - Update HV_FIXED page states to allow freeing of memory

Tycho Andersen (AMD) (7):
  x86/snp: drop support for SNP hotplug
  x86/snp: drop WBINVD before setting SNPEn
  x86/snp: create snp_prepare_for_snp_init()
  x86/snp, crypto: move SNP init to ccp driver
  x86/snp, crypto: move HSAVE_PA setup to arch/
  x86/snp: create snp_x86_shutdown()
  crypto: ccp - implement SNP x86 shutdown

 arch/x86/include/asm/sev.h   |   4 +
 arch/x86/virt/svm/sev.c      | 161 +++++++++++++++++++----------------
 drivers/crypto/ccp/sev-dev.c |  62 ++++++++------
 include/linux/psp-sev.h      |   4 +-
 4 files changed, 129 insertions(+), 102 deletions(-)


base-commit: 59f9bfe4641c408c08824a9b52e9f7839bde57d8
-- 
2.53.0


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH v2 01/10] x86/snp: drop support for SNP hotplug
  2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
@ 2026-03-09 18:00       ` Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 02/10] x86/snp: drop WBINVD before setting SNPEn Tycho Andersen
                         ` (8 subsequent siblings)
  9 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-09 18:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

During an SNP_INIT(_EX), the SEV firmware checks that all CPUs have the SNP
syscfg bit set, and fails if they do not. As such, it does not make
sense to have offline CPUs: the firmware will fail initialization because
of the offlined ones that the kernel did not initialize.

Futher, there is a bug: during SNP_INIT(_EX) the firmware requires the MFDM
syscfg bit to be set in addition to having SNP enabled, which the previous
hotplug code did not do. Since k8_check_syscfg_dram_mod_en() enforces this
be cleared, hotplug wouldn't work.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 arch/x86/virt/svm/sev.c | 32 +++++---------------------------
 1 file changed, 5 insertions(+), 27 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index a4f3a364fb65..f404c609582c 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -130,33 +130,20 @@ static unsigned long snp_nr_leaked_pages;
 #undef pr_fmt
 #define pr_fmt(fmt)	"SEV-SNP: " fmt
 
-static int __mfd_enable(unsigned int cpu)
+static __init void mfd_enable(void *arg)
 {
-	u64 val;
-
 	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
-		return 0;
-
-	rdmsrq(MSR_AMD64_SYSCFG, val);
-
-	val |= MSR_AMD64_SYSCFG_MFDM;
-
-	wrmsrq(MSR_AMD64_SYSCFG, val);
+		return;
 
-	return 0;
+	msr_set_bit(MSR_AMD64_SYSCFG, MSR_AMD64_SYSCFG_MFDM_BIT);
 }
 
-static __init void mfd_enable(void *arg)
-{
-	__mfd_enable(smp_processor_id());
-}
-
-static int __snp_enable(unsigned int cpu)
+static __init void snp_enable(void *arg)
 {
 	u64 val;
 
 	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
-		return 0;
+		return;
 
 	rdmsrq(MSR_AMD64_SYSCFG, val);
 
@@ -164,13 +151,6 @@ static int __snp_enable(unsigned int cpu)
 	val |= MSR_AMD64_SYSCFG_SNP_VMPL_EN;
 
 	wrmsrq(MSR_AMD64_SYSCFG, val);
-
-	return 0;
-}
-
-static __init void snp_enable(void *arg)
-{
-	__snp_enable(smp_processor_id());
 }
 
 static void __init __snp_fixup_e820_tables(u64 pa)
@@ -553,8 +533,6 @@ int __init snp_rmptable_init(void)
 	on_each_cpu(snp_enable, NULL, 1);
 
 skip_enable:
-	cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/rmptable_init:online", __snp_enable, NULL);
-
 	/*
 	 * Setting crash_kexec_post_notifiers to 'true' to ensure that SNP panic
 	 * notifier is invoked to do SNP IOMMU shutdown before kdump.
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 02/10] x86/snp: drop WBINVD before setting SNPEn
  2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 01/10] x86/snp: drop support for SNP hotplug Tycho Andersen
@ 2026-03-09 18:00       ` Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 03/10] x86/snp: Keep the RMP table bookkeeping area mapped Tycho Andersen
                         ` (7 subsequent siblings)
  9 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-09 18:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

WBINVD is required before SNP_INIT(_EX), but not before setting SNPEn,
since the ccp driver already does its own WBINVD before SNP_INIT (and this
one would be too early for that anyway...).

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 arch/x86/virt/svm/sev.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index f404c609582c..5e07f103c271 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -524,9 +524,6 @@ int __init snp_rmptable_init(void)
 		memset(desc->rmp_entry, 0, desc->size);
 	}
 
-	/* Flush the caches to ensure that data is written before SNP is enabled. */
-	wbinvd_on_all_cpus();
-
 	/* MtrrFixDramModEn must be enabled on all the CPUs prior to enabling SNP. */
 	on_each_cpu(mfd_enable, NULL, 1);
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 03/10] x86/snp: Keep the RMP table bookkeeping area mapped
  2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 01/10] x86/snp: drop support for SNP hotplug Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 02/10] x86/snp: drop WBINVD before setting SNPEn Tycho Andersen
@ 2026-03-09 18:00       ` Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 04/10] x86/snp: Create a function to clear/zero the RMP Tycho Andersen
                         ` (6 subsequent siblings)
  9 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-09 18:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: Tom Lendacky <thomas.lendacky@amd.com>

In preparation for delayed SNP initialization and disablement on shutdown,
the RMP will need to be cleared each time SNP is disabled. Maintain the
mapping to the RMP bookkeeping area to avoid mapping and unmapping it each
time and any possible errors that may arise from that.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 arch/x86/virt/svm/sev.c | 40 +++++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 5e07f103c271..e35fac0a8a3d 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -117,6 +117,8 @@ static u64 rmp_segment_mask;
 
 static u64 rmp_cfg;
 
+static void *rmp_bookkeeping __ro_after_init;
+
 /* Mask to apply to a PFN to get the first PFN of a 2MB page */
 #define PFN_PMD_MASK	GENMASK_ULL(63, PMD_SHIFT - PAGE_SHIFT)
 
@@ -240,23 +242,6 @@ void __init snp_fixup_e820_tables(void)
 	}
 }
 
-static bool __init clear_rmptable_bookkeeping(void)
-{
-	void *bk;
-
-	bk = memremap(probed_rmp_base, RMPTABLE_CPU_BOOKKEEPING_SZ, MEMREMAP_WB);
-	if (!bk) {
-		pr_err("Failed to map RMP bookkeeping area\n");
-		return false;
-	}
-
-	memset(bk, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
-
-	memunmap(bk);
-
-	return true;
-}
-
 static bool __init alloc_rmp_segment_desc(u64 segment_pa, u64 segment_size, u64 pa)
 {
 	u64 rst_index, rmp_segment_size_max;
@@ -474,10 +459,22 @@ static bool __init setup_segmented_rmptable(void)
 static bool __init setup_rmptable(void)
 {
 	if (rmp_cfg & MSR_AMD64_SEG_RMP_ENABLED) {
-		return setup_segmented_rmptable();
+		if (!setup_segmented_rmptable())
+			return false;
 	} else {
-		return setup_contiguous_rmptable();
+		if (!setup_contiguous_rmptable())
+			return false;
 	}
+
+	rmp_bookkeeping = memremap(probed_rmp_base, RMPTABLE_CPU_BOOKKEEPING_SZ, MEMREMAP_WB);
+	if (!rmp_bookkeeping) {
+		pr_err("Failed to map RMP bookkeeping area\n");
+		free_rmp_segment_table();
+
+		return false;
+	}
+
+	return true;
 }
 
 /*
@@ -508,10 +505,7 @@ int __init snp_rmptable_init(void)
 		goto skip_enable;
 
 	/* Zero out the RMP bookkeeping area */
-	if (!clear_rmptable_bookkeeping()) {
-		free_rmp_segment_table();
-		return -ENOSYS;
-	}
+	memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
 
 	/* Zero out the RMP entries */
 	for (i = 0; i < rst_max_index; i++) {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 04/10] x86/snp: Create a function to clear/zero the RMP
  2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
                         ` (2 preceding siblings ...)
  2026-03-09 18:00       ` [PATCH v2 03/10] x86/snp: Keep the RMP table bookkeeping area mapped Tycho Andersen
@ 2026-03-09 18:00       ` Tycho Andersen
  2026-03-13 16:17         ` Borislav Petkov
  2026-03-09 18:00       ` [PATCH v2 05/10] x86/snp: create snp_prepare_for_snp_init() Tycho Andersen
                         ` (5 subsequent siblings)
  9 siblings, 1 reply; 36+ messages in thread
From: Tycho Andersen @ 2026-03-09 18:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: Tom Lendacky <thomas.lendacky@amd.com>

In prep for delayed SNP initialization and disablement on shutdown, create
a function, snp_clear_rmp(), that clears the RMP bookkeeping area and the
RMP entries.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 arch/x86/virt/svm/sev.c | 41 +++++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index e35fac0a8a3d..f41b92e40014 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -242,6 +242,32 @@ void __init snp_fixup_e820_tables(void)
 	}
 }
 
+static void snp_clear_rmp(void)
+{
+	unsigned int i;
+	u64 val;
+
+	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
+		return;
+
+	/* Clearing the RMP while SNP is enabled will cause an exception */
+	rdmsrq(MSR_AMD64_SYSCFG, val);
+	if (WARN_ON_ONCE(val & MSR_AMD64_SYSCFG_SNP_EN))
+		return;
+
+	memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
+
+	for (i = 0; i < rst_max_index; i++) {
+		struct rmp_segment_desc *desc;
+
+		desc = rmp_segment_table[i];
+		if (!desc)
+			continue;
+
+		memset(desc->rmp_entry, 0, desc->size);
+	}
+}
+
 static bool __init alloc_rmp_segment_desc(u64 segment_pa, u64 segment_size, u64 pa)
 {
 	u64 rst_index, rmp_segment_size_max;
@@ -484,7 +510,6 @@ static bool __init setup_rmptable(void)
  */
 int __init snp_rmptable_init(void)
 {
-	unsigned int i;
 	u64 val;
 
 	if (WARN_ON_ONCE(!cc_platform_has(CC_ATTR_HOST_SEV_SNP)))
@@ -504,19 +529,7 @@ int __init snp_rmptable_init(void)
 	if (val & MSR_AMD64_SYSCFG_SNP_EN)
 		goto skip_enable;
 
-	/* Zero out the RMP bookkeeping area */
-	memset(rmp_bookkeeping, 0, RMPTABLE_CPU_BOOKKEEPING_SZ);
-
-	/* Zero out the RMP entries */
-	for (i = 0; i < rst_max_index; i++) {
-		struct rmp_segment_desc *desc;
-
-		desc = rmp_segment_table[i];
-		if (!desc)
-			continue;
-
-		memset(desc->rmp_entry, 0, desc->size);
-	}
+	snp_clear_rmp();
 
 	/* MtrrFixDramModEn must be enabled on all the CPUs prior to enabling SNP. */
 	on_each_cpu(mfd_enable, NULL, 1);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 05/10] x86/snp: create snp_prepare_for_snp_init()
  2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
                         ` (3 preceding siblings ...)
  2026-03-09 18:00       ` [PATCH v2 04/10] x86/snp: Create a function to clear/zero the RMP Tycho Andersen
@ 2026-03-09 18:00       ` Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 06/10] x86/snp, crypto: move SNP init to ccp driver Tycho Andersen
                         ` (4 subsequent siblings)
  9 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-09 18:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

In preparation for delayed SNP initialization, create a function
snp_prepare_for_snp_init() that does the necessary architecture setup.
Export this function for the ccp module to allow it to do the setup as
necessary.

Also move {mfd,snp}_enable out of the __init section, since these will be
called later.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 arch/x86/include/asm/sev.h |  2 ++
 arch/x86/virt/svm/sev.c    | 46 ++++++++++++++++++++++----------------
 2 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
index 0e6c0940100f..0bcd89d4fe90 100644
--- a/arch/x86/include/asm/sev.h
+++ b/arch/x86/include/asm/sev.h
@@ -661,6 +661,7 @@ static inline void snp_leak_pages(u64 pfn, unsigned int pages)
 {
 	__snp_leak_pages(pfn, pages, true);
 }
+void snp_prepare_for_snp_init(void);
 #else
 static inline bool snp_probe_rmptable_info(void) { return false; }
 static inline int snp_rmptable_init(void) { return -ENOSYS; }
@@ -677,6 +678,7 @@ static inline void __snp_leak_pages(u64 pfn, unsigned int npages, bool dump_rmp)
 static inline void snp_leak_pages(u64 pfn, unsigned int npages) {}
 static inline void kdump_sev_callback(void) { }
 static inline void snp_fixup_e820_tables(void) {}
+static inline void snp_prepare_for_snp_init(void) {}
 #endif
 
 #endif
diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index f41b92e40014..9d2cddbeaf21 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -132,7 +132,7 @@ static unsigned long snp_nr_leaked_pages;
 #undef pr_fmt
 #define pr_fmt(fmt)	"SEV-SNP: " fmt
 
-static __init void mfd_enable(void *arg)
+static void mfd_enable(void *arg)
 {
 	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
 		return;
@@ -140,7 +140,7 @@ static __init void mfd_enable(void *arg)
 	msr_set_bit(MSR_AMD64_SYSCFG, MSR_AMD64_SYSCFG_MFDM_BIT);
 }
 
-static __init void snp_enable(void *arg)
+static void snp_enable(void *arg)
 {
 	u64 val;
 
@@ -503,6 +503,30 @@ static bool __init setup_rmptable(void)
 	return true;
 }
 
+void snp_prepare_for_snp_init(void)
+{
+	u64 val;
+
+	/*
+	 * Check if SEV-SNP is already enabled, this can happen in case of
+	 * kexec boot.
+	 */
+	rdmsrq(MSR_AMD64_SYSCFG, val);
+	if (val & MSR_AMD64_SYSCFG_SNP_EN)
+		return;
+
+	snp_clear_rmp();
+
+	/*
+	 * MtrrFixDramModEn is not shared between threads on a core,
+	 * therefore it must be set on all CPUs prior to enabling SNP.
+	 */
+	on_each_cpu(mfd_enable, NULL, 1);
+
+	on_each_cpu(snp_enable, NULL, 1);
+}
+EXPORT_SYMBOL_FOR_MODULES(snp_prepare_for_snp_init, "ccp");
+
 /*
  * Do the necessary preparations which are verified by the firmware as
  * described in the SNP_INIT_EX firmware command description in the SNP
@@ -510,8 +534,6 @@ static bool __init setup_rmptable(void)
  */
 int __init snp_rmptable_init(void)
 {
-	u64 val;
-
 	if (WARN_ON_ONCE(!cc_platform_has(CC_ATTR_HOST_SEV_SNP)))
 		return -ENOSYS;
 
@@ -521,22 +543,8 @@ int __init snp_rmptable_init(void)
 	if (!setup_rmptable())
 		return -ENOSYS;
 
-	/*
-	 * Check if SEV-SNP is already enabled, this can happen in case of
-	 * kexec boot.
-	 */
-	rdmsrq(MSR_AMD64_SYSCFG, val);
-	if (val & MSR_AMD64_SYSCFG_SNP_EN)
-		goto skip_enable;
-
-	snp_clear_rmp();
-
-	/* MtrrFixDramModEn must be enabled on all the CPUs prior to enabling SNP. */
-	on_each_cpu(mfd_enable, NULL, 1);
-
-	on_each_cpu(snp_enable, NULL, 1);
+	snp_prepare_for_snp_init();
 
-skip_enable:
 	/*
 	 * Setting crash_kexec_post_notifiers to 'true' to ensure that SNP panic
 	 * notifier is invoked to do SNP IOMMU shutdown before kdump.
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 06/10] x86/snp, crypto: move SNP init to ccp driver
  2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
                         ` (4 preceding siblings ...)
  2026-03-09 18:00       ` [PATCH v2 05/10] x86/snp: create snp_prepare_for_snp_init() Tycho Andersen
@ 2026-03-09 18:00       ` Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 07/10] x86/snp, crypto: move HSAVE_PA setup to arch/ Tycho Andersen
                         ` (3 subsequent siblings)
  9 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-09 18:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

Use the new snp_prepare_for_snp_init() to initialize SNP from the ccp
driver instead of at boot time. This means that SNP is not enabled unless
it is really going to be used (i.e. kvm_amd loads the ccp driver
automatically).

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 arch/x86/virt/svm/sev.c      | 2 --
 drivers/crypto/ccp/sev-dev.c | 2 ++
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 9d2cddbeaf21..28d240484453 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -543,8 +543,6 @@ int __init snp_rmptable_init(void)
 	if (!setup_rmptable())
 		return -ENOSYS;
 
-	snp_prepare_for_snp_init();
-
 	/*
 	 * Setting crash_kexec_post_notifiers to 'true' to ensure that SNP panic
 	 * notifier is invoked to do SNP IOMMU shutdown before kdump.
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 8b2dfc11289b..07c4736a1f0a 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -1373,6 +1373,8 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
 		return -EOPNOTSUPP;
 	}
 
+	snp_prepare_for_snp_init();
+
 	/* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
 	on_each_cpu(snp_set_hsave_pa, NULL, 1);
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 07/10] x86/snp, crypto: move HSAVE_PA setup to arch/
  2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
                         ` (5 preceding siblings ...)
  2026-03-09 18:00       ` [PATCH v2 06/10] x86/snp, crypto: move SNP init to ccp driver Tycho Andersen
@ 2026-03-09 18:00       ` Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 08/10] x86/snp: create snp_x86_shutdown() Tycho Andersen
                         ` (2 subsequent siblings)
  9 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-09 18:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

Now that there is snp_prepare_for_snp_init() that indicates when the CCP
driver wants to prepare the architecture for SNP_INIT(_EX), move this
architecture-specific bit of code to a more sensible place.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 arch/x86/virt/svm/sev.c      | 8 ++++++++
 drivers/crypto/ccp/sev-dev.c | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index 28d240484453..cc10d059140d 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -503,6 +503,11 @@ static bool __init setup_rmptable(void)
 	return true;
 }
 
+static void snp_set_hsave_pa(void *arg)
+{
+	wrmsrq(MSR_VM_HSAVE_PA, 0);
+}
+
 void snp_prepare_for_snp_init(void)
 {
 	u64 val;
@@ -524,6 +529,9 @@ void snp_prepare_for_snp_init(void)
 	on_each_cpu(mfd_enable, NULL, 1);
 
 	on_each_cpu(snp_enable, NULL, 1);
+
+	/* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
+	on_each_cpu(snp_set_hsave_pa, NULL, 1);
 }
 EXPORT_SYMBOL_FOR_MODULES(snp_prepare_for_snp_init, "ccp");
 
diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 07c4736a1f0a..b10104f243b9 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -1076,11 +1076,6 @@ static inline int __sev_do_init_locked(int *psp_ret)
 		return __sev_init_locked(psp_ret);
 }
 
-static void snp_set_hsave_pa(void *arg)
-{
-	wrmsrq(MSR_VM_HSAVE_PA, 0);
-}
-
 /* Hypervisor Fixed pages API interface */
 static void snp_hv_fixed_pages_state_update(struct sev_device *sev,
 					    enum snp_hv_fixed_pages_state page_state)
@@ -1375,9 +1370,6 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
 
 	snp_prepare_for_snp_init();
 
-	/* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */
-	on_each_cpu(snp_set_hsave_pa, NULL, 1);
-
 	/*
 	 * Starting in SNP firmware v1.52, the SNP_INIT_EX command takes a list
 	 * of system physical address ranges to convert into HV-fixed page
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 08/10] x86/snp: create snp_x86_shutdown()
  2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
                         ` (6 preceding siblings ...)
  2026-03-09 18:00       ` [PATCH v2 07/10] x86/snp, crypto: move HSAVE_PA setup to arch/ Tycho Andersen
@ 2026-03-09 18:00       ` Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 09/10] crypto: ccp - implement SNP x86 shutdown Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 10/10] crypto: ccp - Update HV_FIXED page states to allow freeing of memory Tycho Andersen
  9 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-09 18:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

After SNP_SHUTDOWN, two architecture-level things should be done:

1. clear the RMP table
2. disable MFDM to prevent the FW_WARN in k8_check_syscfg_dram_mod_en() in
   the event of a kexec

Create and export to the CCP driver a function that does them.

Also change the MFDM helper to allow for disabling the bit, since the SNP
x86 shutdown path needs to disable MFDM. The comment for
k8_check_syscfg_dram_mod_en() notes, the "BIOS" is supposed clear it, or
the kernel in the case of module unload and shutdown followed by kexec.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 arch/x86/include/asm/sev.h |  2 ++
 arch/x86/virt/svm/sev.c    | 23 ++++++++++++++++++++---
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
index 0bcd89d4fe90..36d2b1ea19c0 100644
--- a/arch/x86/include/asm/sev.h
+++ b/arch/x86/include/asm/sev.h
@@ -662,6 +662,7 @@ static inline void snp_leak_pages(u64 pfn, unsigned int pages)
 	__snp_leak_pages(pfn, pages, true);
 }
 void snp_prepare_for_snp_init(void);
+void snp_x86_shutdown(void);
 #else
 static inline bool snp_probe_rmptable_info(void) { return false; }
 static inline int snp_rmptable_init(void) { return -ENOSYS; }
@@ -679,6 +680,7 @@ static inline void snp_leak_pages(u64 pfn, unsigned int npages) {}
 static inline void kdump_sev_callback(void) { }
 static inline void snp_fixup_e820_tables(void) {}
 static inline void snp_prepare_for_snp_init(void) {}
+static inline void snp_x86_shutdown(void) {}
 #endif
 
 #endif
diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index cc10d059140d..321f3c004fbc 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -132,12 +132,15 @@ static unsigned long snp_nr_leaked_pages;
 #undef pr_fmt
 #define pr_fmt(fmt)	"SEV-SNP: " fmt
 
-static void mfd_enable(void *arg)
+static void mfd_reconfigure(void *arg)
 {
 	if (!cc_platform_has(CC_ATTR_HOST_SEV_SNP))
 		return;
 
-	msr_set_bit(MSR_AMD64_SYSCFG, MSR_AMD64_SYSCFG_MFDM_BIT);
+	if (arg)
+		msr_set_bit(MSR_AMD64_SYSCFG, MSR_AMD64_SYSCFG_MFDM_BIT);
+	else
+		msr_clear_bit(MSR_AMD64_SYSCFG, MSR_AMD64_SYSCFG_MFDM_BIT);
 }
 
 static void snp_enable(void *arg)
@@ -526,7 +529,7 @@ void snp_prepare_for_snp_init(void)
 	 * MtrrFixDramModEn is not shared between threads on a core,
 	 * therefore it must be set on all CPUs prior to enabling SNP.
 	 */
-	on_each_cpu(mfd_enable, NULL, 1);
+	on_each_cpu(mfd_reconfigure, (void *)1, 1);
 
 	on_each_cpu(snp_enable, NULL, 1);
 
@@ -535,6 +538,20 @@ void snp_prepare_for_snp_init(void)
 }
 EXPORT_SYMBOL_FOR_MODULES(snp_prepare_for_snp_init, "ccp");
 
+void snp_x86_shutdown(void)
+{
+	u64 syscfg;
+
+	rdmsrq(MSR_AMD64_SYSCFG, syscfg);
+
+	if (syscfg & MSR_AMD64_SYSCFG_SNP_EN)
+		return;
+
+	snp_clear_rmp();
+	on_each_cpu(mfd_reconfigure, 0, 1);
+}
+EXPORT_SYMBOL_FOR_MODULES(snp_x86_shutdown, "ccp");
+
 /*
  * Do the necessary preparations which are verified by the firmware as
  * described in the SNP_INIT_EX firmware command description in the SNP
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 09/10] crypto: ccp - implement SNP x86 shutdown
  2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
                         ` (7 preceding siblings ...)
  2026-03-09 18:00       ` [PATCH v2 08/10] x86/snp: create snp_x86_shutdown() Tycho Andersen
@ 2026-03-09 18:00       ` Tycho Andersen
  2026-03-09 18:00       ` [PATCH v2 10/10] crypto: ccp - Update HV_FIXED page states to allow freeing of memory Tycho Andersen
  9 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-09 18:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: "Tycho Andersen (AMD)" <tycho@kernel.org>

The SEV firmware has support to disable SNP during an SNP_SHUTDOWN_EX
command. Verify that this support is available and set the flag so that SNP
is disabled when it is not being used. In cases where SNP is disabled, skip
the call to amd_iommu_snp_disable(), as all of the IOMMU pages have already
been made shared. Also skip the panic case, since snp_x86_shutdown() does
IPIs.

Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/crypto/ccp/sev-dev.c | 41 +++++++++++++++++++++---------------
 include/linux/psp-sev.h      |  4 +++-
 2 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index b10104f243b9..be6f3720e929 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -2039,6 +2039,8 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
 	memset(&data, 0, sizeof(data));
 	data.len = sizeof(data);
 	data.iommu_snp_shutdown = 1;
+	if (sev->snp_feat_info_0.ecx & SNP_X86_SHUTDOWN_SUPPORTED)
+		data.x86_snp_shutdown = 1;
 
 	/*
 	 * If invoked during panic handling, local interrupts are disabled
@@ -2072,23 +2074,28 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
 		return ret;
 	}
 
-	/*
-	 * SNP_SHUTDOWN_EX with IOMMU_SNP_SHUTDOWN set to 1 disables SNP
-	 * enforcement by the IOMMU and also transitions all pages
-	 * associated with the IOMMU to the Reclaim state.
-	 * Firmware was transitioning the IOMMU pages to Hypervisor state
-	 * before version 1.53. But, accounting for the number of assigned
-	 * 4kB pages in a 2M page was done incorrectly by not transitioning
-	 * to the Reclaim state. This resulted in RMP #PF when later accessing
-	 * the 2M page containing those pages during kexec boot. Hence, the
-	 * firmware now transitions these pages to Reclaim state and hypervisor
-	 * needs to transition these pages to shared state. SNP Firmware
-	 * version 1.53 and above are needed for kexec boot.
-	 */
-	ret = amd_iommu_snp_disable();
-	if (ret) {
-		dev_err(sev->dev, "SNP IOMMU shutdown failed\n");
-		return ret;
+	if (data.x86_snp_shutdown) {
+		if (!panic)
+			snp_x86_shutdown();
+	} else {
+		/*
+		 * SNP_SHUTDOWN_EX with IOMMU_SNP_SHUTDOWN set to 1 disables SNP
+		 * enforcement by the IOMMU and also transitions all pages
+		 * associated with the IOMMU to the Reclaim state.
+		 * Firmware was transitioning the IOMMU pages to Hypervisor state
+		 * before version 1.53. But, accounting for the number of assigned
+		 * 4kB pages in a 2M page was done incorrectly by not transitioning
+		 * to the Reclaim state. This resulted in RMP #PF when later accessing
+		 * the 2M page containing those pages during kexec boot. Hence, the
+		 * firmware now transitions these pages to Reclaim state and hypervisor
+		 * needs to transition these pages to shared state. SNP Firmware
+		 * version 1.53 and above are needed for kexec boot.
+		 */
+		ret = amd_iommu_snp_disable();
+		if (ret) {
+			dev_err(sev->dev, "SNP IOMMU shutdown failed\n");
+			return ret;
+		}
 	}
 
 	snp_leak_hv_fixed_pages();
diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
index 69ffa4b4d1fa..2adb990189c1 100644
--- a/include/linux/psp-sev.h
+++ b/include/linux/psp-sev.h
@@ -834,7 +834,8 @@ struct sev_data_range_list {
 struct sev_data_snp_shutdown_ex {
 	u32 len;
 	u32 iommu_snp_shutdown:1;
-	u32 rsvd1:31;
+	u32 x86_snp_shutdown:1;
+	u32 rsvd1:30;
 } __packed;
 
 /**
@@ -891,6 +892,7 @@ struct snp_feature_info {
 } __packed;
 
 /* Feature bits in ECX */
+#define SNP_X86_SHUTDOWN_SUPPORTED		BIT(1)
 #define SNP_RAPL_DISABLE_SUPPORTED		BIT(2)
 #define SNP_CIPHER_TEXT_HIDING_SUPPORTED	BIT(3)
 #define SNP_AES_256_XTS_POLICY_SUPPORTED	BIT(4)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH v2 10/10] crypto: ccp - Update HV_FIXED page states to allow freeing of memory
  2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
                         ` (8 preceding siblings ...)
  2026-03-09 18:00       ` [PATCH v2 09/10] crypto: ccp - implement SNP x86 shutdown Tycho Andersen
@ 2026-03-09 18:00       ` Tycho Andersen
  9 siblings, 0 replies; 36+ messages in thread
From: Tycho Andersen @ 2026-03-09 18:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Ashish Kalra, Tom Lendacky, John Allen,
	Herbert Xu, David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson
  Cc: linux-kernel, linux-crypto

From: Tom Lendacky <thomas.lendacky@amd.com>

After SNP is disabled, any pages allocated as HV_FIXED can now be freed.
Update the page state of these pages and the snp_leak_hv_fixed_pages()
function to free pages on SNP_SHUTDOWN.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
 drivers/crypto/ccp/sev-dev.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index be6f3720e929..eac1181c2f6a 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -1219,7 +1219,7 @@ static void snp_add_hv_fixed_pages(struct sev_device *sev, struct sev_data_range
 
 static void snp_leak_hv_fixed_pages(void)
 {
-	struct snp_hv_fixed_pages_entry *entry;
+	struct snp_hv_fixed_pages_entry *entry, *nentry;
 
 	/* List is protected by sev_cmd_mutex */
 	lockdep_assert_held(&sev_cmd_mutex);
@@ -1227,10 +1227,16 @@ static void snp_leak_hv_fixed_pages(void)
 	if (list_empty(&snp_hv_fixed_pages))
 		return;
 
-	list_for_each_entry(entry, &snp_hv_fixed_pages, list)
-		if (entry->page_state == HV_FIXED)
+	list_for_each_entry_safe(entry, nentry, &snp_hv_fixed_pages, list) {
+		if (entry->free && entry->page_state != HV_FIXED)
+			__free_pages(entry->page, entry->order);
+		else
 			__snp_leak_pages(page_to_pfn(entry->page),
 					 1 << entry->order, false);
+
+		list_del(&entry->list);
+		kfree(entry);
+	}
 }
 
 bool sev_is_snp_ciphertext_hiding_supported(void)
@@ -2077,6 +2083,7 @@ static int __sev_snp_shutdown_locked(int *error, bool panic)
 	if (data.x86_snp_shutdown) {
 		if (!panic)
 			snp_x86_shutdown();
+		snp_hv_fixed_pages_state_update(sev, ALLOCATED);
 	} else {
 		/*
 		 * SNP_SHUTDOWN_EX with IOMMU_SNP_SHUTDOWN set to 1 disables SNP
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH v2 04/10] x86/snp: Create a function to clear/zero the RMP
  2026-03-09 18:00       ` [PATCH v2 04/10] x86/snp: Create a function to clear/zero the RMP Tycho Andersen
@ 2026-03-13 16:17         ` Borislav Petkov
  0 siblings, 0 replies; 36+ messages in thread
From: Borislav Petkov @ 2026-03-13 16:17 UTC (permalink / raw)
  To: Tycho Andersen
  Cc: Thomas Gleixner, Ingo Molnar, Dave Hansen, x86, H. Peter Anvin,
	Ashish Kalra, Tom Lendacky, John Allen, Herbert Xu,
	David S. Miller, Ard Biesheuvel, Neeraj Upadhyay,
	Kishon Vijay Abraham I, Alexey Kardashevskiy, Nikunj A Dadhania,
	Peter Zijlstra (Intel), Kim Phillips, Sean Christopherson,
	linux-kernel, linux-crypto

On Mon, Mar 09, 2026 at 12:00:46PM -0600, Tycho Andersen wrote:
> From: Tom Lendacky <thomas.lendacky@amd.com>
> 
> In prep for delayed SNP initialization and disablement on shutdown, create
> a function, snp_clear_rmp(), that clears the RMP bookkeeping area and the
> RMP entries.
> 
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
> ---
>  arch/x86/virt/svm/sev.c | 41 +++++++++++++++++++++++++++--------------
>  1 file changed, 27 insertions(+), 14 deletions(-)
> 
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index e35fac0a8a3d..f41b92e40014 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -242,6 +242,32 @@ void __init snp_fixup_e820_tables(void)
>  	}
>  }
>  
> +static void snp_clear_rmp(void)

No need for "snp_" prefix on static functions.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2026-03-13 16:18 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-02 19:13 [PATCH 00/11] Move SEV-SNP initialization to ccp driver Tycho Andersen
2026-03-02 19:13 ` [PATCH 01/11] x86/snp: drop support for SNP hotplug Tycho Andersen
2026-03-02 19:56   ` Tom Lendacky
2026-03-05 12:57   ` Borislav Petkov
2026-03-06 15:38   ` Borislav Petkov
2026-03-09 18:00     ` [PATCH v2 00/10] Move SNP initialization to the CCP driver Tycho Andersen
2026-03-09 18:00       ` [PATCH v2 01/10] x86/snp: drop support for SNP hotplug Tycho Andersen
2026-03-09 18:00       ` [PATCH v2 02/10] x86/snp: drop WBINVD before setting SNPEn Tycho Andersen
2026-03-09 18:00       ` [PATCH v2 03/10] x86/snp: Keep the RMP table bookkeeping area mapped Tycho Andersen
2026-03-09 18:00       ` [PATCH v2 04/10] x86/snp: Create a function to clear/zero the RMP Tycho Andersen
2026-03-13 16:17         ` Borislav Petkov
2026-03-09 18:00       ` [PATCH v2 05/10] x86/snp: create snp_prepare_for_snp_init() Tycho Andersen
2026-03-09 18:00       ` [PATCH v2 06/10] x86/snp, crypto: move SNP init to ccp driver Tycho Andersen
2026-03-09 18:00       ` [PATCH v2 07/10] x86/snp, crypto: move HSAVE_PA setup to arch/ Tycho Andersen
2026-03-09 18:00       ` [PATCH v2 08/10] x86/snp: create snp_x86_shutdown() Tycho Andersen
2026-03-09 18:00       ` [PATCH v2 09/10] crypto: ccp - implement SNP x86 shutdown Tycho Andersen
2026-03-09 18:00       ` [PATCH v2 10/10] crypto: ccp - Update HV_FIXED page states to allow freeing of memory Tycho Andersen
2026-03-02 19:13 ` [PATCH 02/11] x86/snp: Keep the RMP table bookkeeping area mapped Tycho Andersen
2026-03-06 15:55   ` Borislav Petkov
2026-03-02 19:13 ` [PATCH 03/11] x86/snp: Create a function to clear/zero the RMP Tycho Andersen
2026-03-02 19:13 ` [PATCH 04/11] x86/snp: drop WBINVD before setting SNPEn Tycho Andersen
2026-03-02 20:00   ` Tom Lendacky
2026-03-02 19:13 ` [PATCH 05/11] x86/snp: create snp_prepare_for_snp_init() Tycho Andersen
2026-03-02 20:03   ` Tom Lendacky
2026-03-02 19:13 ` [PATCH 06/11] x86/snp, crypto: move SNP init to ccp driver Tycho Andersen
2026-03-02 20:25   ` Tom Lendacky
2026-03-02 19:13 ` [PATCH 07/11] x86/snp, crypto: move HSAVE_PA setup to arch/ Tycho Andersen
2026-03-02 20:27   ` Tom Lendacky
2026-03-02 19:13 ` [PATCH 08/11] x86/snp: allow disabling MFDM Tycho Andersen
2026-03-02 20:29   ` Tom Lendacky
2026-03-02 19:13 ` [PATCH 09/11] x86/snp: create snp_x86_shutdown() Tycho Andersen
2026-03-02 20:35   ` Tom Lendacky
2026-03-02 21:20     ` Tycho Andersen
2026-03-02 19:13 ` [PATCH 10/11] crypto: ccp - implement SNP x86 shutdown Tycho Andersen
2026-03-02 20:47   ` Tom Lendacky
2026-03-02 19:13 ` [PATCH 11/11] crypto: ccp - Update HV_FIXED page states to allow freeing of memory Tycho Andersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox