From: "Kalra, Ashish" <ashish.kalra@amd.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v10 3/6] x86/sev: Disable CPU hotplug while SNP is active
Date: Mon, 6 Jul 2026 15:11:25 -0500 [thread overview]
Message-ID: <151e544a-63dc-414f-8418-e6912d196a9e@amd.com> (raw)
In-Reply-To: <20260630183231.393071F000E9@smtp.kernel.org>
On 6/30/2026 1:32 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Critical] System suspend (PM transitions) bypasses `cpu_hotplug_disable()`, stripping `SnpEn` from secondary CPUs on resume.
> --
>
> commit 29b8362e9ad72efa8892f6bb3124dbbcc29ee822
> Author: Ashish Kalra <ashish.kalra@amd.com>
>
> x86/sev: Disable CPU hotplug while SNP is active
>
> This commit disables CPU hotplug in snp_prepare() before SNP is enabled and
> re-enables it in snp_shutdown(). This aims to prevent CPUs from coming online
> without the SnpEn bit set while SNP is active, as the firmware cannot track
> OS CPU hotplug events.
>
>> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
>> index dab6e1c290bca..04a58ac4339cb 100644
>> --- a/arch/x86/virt/svm/sev.c
>> +++ b/arch/x86/virt/svm/sev.c
>> @@ -535,6 +535,15 @@ int snp_prepare(void)
>>
>> clear_rmp();
>>
>> + /*
>> + * Disable CPU hotplug before enabling SNP, so no CPU can come online
>> + * without SnpEn while SNP is enabled; it is re-enabled in snp_shutdown()
>> + * once SNP is disabled. Must be before cpus_read_lock():
>> + * cpu_hotplug_disable() takes cpu_add_remove_lock, which nests above
>> + * cpu_hotplug_lock.
>> + */
>> + cpu_hotplug_disable();
>
> [Severity: Critical]
> Does this actually prevent all CPUs from coming online without SnpEn?
>
> Looking at system suspend (PM transitions), freeze_secondary_cpus() calls
> _cpu_down() directly, which bypasses the cpu_hotplug_disabled check. Upon
> resume, thaw_secondary_cpus() brings them back online via _cpu_up().
>
> Since snp_enable() is called via a one-off on_each_cpu() in snp_prepare()
> rather than being registered as a CPU hotplug callback, wouldn't secondary
> CPUs resume with the SnpEn MSR bit cleared?
>
> This could allow a suspend/resume cycle to create an asymmetrical state where
> hardware RMP checks are bypassed.
>
> [ ... ]
>
You're right about the mechanism — cpu_hotplug_disable() doesn't cover the suspend freeze/thaw path, and snp_enable() has no resume hook. But an SNP
host doesn't support suspend/resume: SNP is set up once at boot (SnpEn on all CPUs followed by SNP_INIT), and that state can't be rebuilt on resume
without a full re-init. So this can't arise in practice, and it's pre-existing base-SNP behavior, not something this patch introduces.
Thanks,
Ashish
next prev parent reply other threads:[~2026-07-06 20:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 18:08 [PATCH v10 0/6] Add RMPOPT support Ashish Kalra
2026-06-30 18:09 ` [PATCH v10 1/6] x86/cpufeatures: Add X86_FEATURE_RMPOPT feature flag Ashish Kalra
2026-06-30 18:10 ` [PATCH v10 2/6] x86/sev: Initialize RMPOPT configuration MSRs Ashish Kalra
2026-06-30 18:11 ` [PATCH v10 3/6] x86/sev: Disable CPU hotplug while SNP is active Ashish Kalra
2026-06-30 18:32 ` sashiko-bot
2026-07-06 20:11 ` Kalra, Ashish [this message]
2026-07-01 9:40 ` Jethro Beekman
2026-07-01 16:39 ` K Prateek Nayak
2026-07-01 21:08 ` Kalra, Ashish
2026-07-01 21:25 ` Kalra, Ashish
2026-07-06 12:02 ` Jethro Beekman
2026-06-30 18:11 ` [PATCH v10 4/6] x86/sev: Add support to perform RMP optimizations asynchronously Ashish Kalra
2026-06-30 18:28 ` sashiko-bot
2026-07-06 18:59 ` Kalra, Ashish
2026-06-30 18:11 ` [PATCH v10 5/6] x86/sev: Add interface to re-enable RMP optimizations Ashish Kalra
2026-06-30 18:12 ` [PATCH v10 6/6] KVM: SEV: Perform RMP optimizations on SNP guest shutdown Ashish Kalra
2026-06-30 18:24 ` sashiko-bot
2026-07-06 19:25 ` Kalra, Ashish
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=151e544a-63dc-414f-8418-e6912d196a9e@amd.com \
--to=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