Re: [PATCH 01/11] x86/snp: drop support for SNP hotplug
From: Borislav Petkov
Date: Thu Mar 05 2026 - 08:01:40 EST
On Mon, Mar 02, 2026 at 12:13:24PM -0700, Tycho Andersen wrote:
> From: "Tycho Andersen (AMD)" <tycho@xxxxxxxxxx>
>
> 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@xxxxxxxxxx>
> ---
> 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