From: sashiko-bot@kernel.org
To: "Ashish Kalra" <Ashish.Kalra@amd.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v15 2/5] x86/sev: Disable CPU hotplug while SNP is active
Date: Wed, 16 Sep 2026 20:11:45 +0000 [thread overview]
Message-ID: <20260916201145.9B1BD1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <cd6962a88d691a020c2bf40fe77a6a3f3852fdfc.1789586444.git.ashish.kalra@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] x86/sev: PM suspend bypasses cpu_hotplug_disable() leading to missing SnpEn
- [Medium] x86/sev: early return skips cpu_hotplug_disable() when SnpEn is already set
--
commit b1980431b3abd35a5fe5e83fed1107ef1f0ec745
Author: Ashish Kalra <ashish.kalra@amd.com>
x86/sev: Disable CPU hotplug while SNP is active
This patch ties CPU hotplug to the SNP-enable bit to prevent CPUs from
coming online without SNP enabled and initialized. It replaces the
cpus_read_lock() previously taken in snp_prepare() with
cpu_hotplug_disable() and reenables it in snp_shutdown(). Additionally,
it disables CPU hotplug in snp_rmptable_init() for kexec boots where
SNP is already active.
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index cff285d8ad8e3..558f7924a3f85 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
[ ... ]
> @@ -526,14 +525,18 @@ int snp_prepare(void)
>
> clear_rmp();
>
> - cpus_read_lock();
> + /*
> + * No CPU may come online without SnpEn while SNP is active; disable
> + * hotplug here and re-enable it in snp_shutdown().
> + */
> + cpu_hotplug_disable();
>
> if (!cpumask_equal(cpu_online_mask, cpu_present_mask)) {
[Severity: High]
Does this fully prevent secondary CPUs from coming online without SnpEn set
during power management suspend and resume?
Looking at the PM suspend path, freeze_secondary_cpus() calls _cpu_down(),
and thaw_secondary_cpus() calls _cpu_up().
Both of these internal functions bypass the cpu_hotplug_disabled counter
that is incremented by cpu_hotplug_disable().
Could a PM suspend/resume cycle successfully offline and online secondary
CPUs, causing them to resume without SnpEn set and bypassing hardware RMP
checks?
[ ... ]
> @@ -577,6 +582,8 @@ EXPORT_SYMBOL_FOR_MODULES(snp_shutdown, "ccp");
> */
> int __init snp_rmptable_init(void)
> {
> + u64 val;
> +
> if (WARN_ON_ONCE(!cc_platform_has(CC_ATTR_HOST_SEV_SNP)))
> return -ENOSYS;
>
> @@ -586,6 +593,15 @@ int __init snp_rmptable_init(void)
> if (!setup_rmptable())
> return -ENOSYS;
>
> + /*
> + * On a kexec boot SNP may already be enabled (legacy firmware leaves
> + * SnpEn set across shutdown), in which case snp_prepare() bails without
> + * disabling CPU hotplug, so disable it here.
> + */
> + rdmsrq(MSR_AMD64_SYSCFG, val);
> + if (val & MSR_AMD64_SYSCFG_SNP_EN)
> + cpu_hotplug_disable();
[Severity: Medium]
Could this leave CPU hotplug enabled if an early initialization step fails
during a kexec boot where legacy firmware leaves SnpEn set?
If setup_rmptable() fails and returns false, the function returns -ENOSYS
early.
Because the check for MSR_AMD64_SYSCFG_SNP_EN and the call to
cpu_hotplug_disable() happen after these early returns, CPU hotplug would
remain enabled.
Newly onlined CPUs might lack SnpEn as a result, creating a mixed hardware
state. Should the hotplug disablement happen before these early returns?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1789586444.git.ashish.kalra@amd.com?part=2
next prev parent reply other threads:[~2026-09-16 20:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 19:52 [PATCH v15 0/5] Add RMPOPT support Ashish Kalra
2026-09-16 19:52 ` [PATCH v15 1/5] x86/cpufeatures: Add X86_FEATURE_RMPOPT feature flag Ashish Kalra
2026-09-16 19:52 ` [PATCH v15 2/5] x86/sev: Disable CPU hotplug while SNP is active Ashish Kalra
2026-09-16 20:11 ` sashiko-bot [this message]
2026-09-16 19:53 ` [PATCH v15 3/5] x86/sev: Initialize RMPOPT configuration MSRs Ashish Kalra
2026-09-16 20:06 ` sashiko-bot
2026-09-16 19:53 ` [PATCH v15 4/5] x86/sev: Perform RMP optimizations asynchronously Ashish Kalra
2026-09-16 20:09 ` sashiko-bot
2026-09-16 19:53 ` [PATCH v15 5/5] x86/sev: Re-enable RMP optimizations on SNP guest shutdown Ashish Kalra
2026-09-16 20:06 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260916201145.9B1BD1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Ashish.Kalra@amd.com \
--cc=kvm@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox