From: "Kalra, Ashish" <ashish.kalra@amd.com>
To: sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v13 3/5] x86/sev: Initialize RMPOPT configuration MSRs
Date: Wed, 2 Sep 2026 16:56:50 -0500 [thread overview]
Message-ID: <b1dec7be-d63d-4bd1-886d-c10b2af9290a@amd.com> (raw)
In-Reply-To: <20260902214500.6B06D1F00A3F@smtp.kernel.org>
On 9/2/2026 4:44 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] CPU hotplug lock is leaked if SEV-SNP initialization fails.
> --
>
> commit 16bd9580b377dc645541bd4f478c471c109e65ae
> Author: Ashish Kalra <ashish.kalra@amd.com>
>
> x86/sev: Initialize RMPOPT configuration MSRs
>
> This commit introduces the RMPOPT configuration MSRs and adds support to
> set up and enable RMPOPT once SNP is initialized. The RMPOPT table base
> is initialized to enable RMP optimization for up to 2 TB of system RAM.
>
>> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
>> index f833cb7e4da36..287a8345854ba 100644
>> --- a/drivers/crypto/ccp/sev-dev.c
>> +++ b/drivers/crypto/ccp/sev-dev.c
>> @@ -1663,6 +1663,8 @@ static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
>>
>> sev_es_tmr_size = SNP_TMR_SIZE;
>>
>> + snp_setup_rmpopt();
>> +
>
> [Severity: High]
> This is a pre-existing issue, but does __sev_snp_init_locked() permanently
> leak the CPU hotplug lock if SEV-SNP initialization fails?
>
> If snp_prepare() succeeds, it disables CPU hotplug. However, if an error
> occurs later in the function (for example, if walk_iomem_res_desc() fails),
> the function returns the error code without re-enabling CPU hotplug:
>
> drivers/crypto/ccp/sev-dev.c:__sev_snp_init_locked() {
> ...
> rc = snp_prepare();
> if (rc)
> return rc;
> ...
> rc = walk_iomem_res_desc(IORES_DESC_NONE, IORESOURCE_MEM, 0, ~0,
> snp_range_list, snp_filter_reserved_mem_regions);
> if (rc) {
> dev_err(sev->dev,
> "SEV: SNP_INIT_EX walk_iomem_res_desc failed rc = %d\n", rc);
> return rc;
> }
> ...
> }
>
> This leaves cpu_hotplug_disabled strictly greater than zero, which would
> permanently prevent CPUs from being onlined or offlined. Does this function
> need an error handling path that calls cpu_hotplug_enable() before returning
> on these failure paths?
>
Thanks — but this is intentional, not a leak. CPU hotplug is tied to
SnpEn, not to the success of __sev_snp_init_locked().
snp_prepare() disables hotplug and then sets SnpEn on all CPUs via
on_each_cpu(snp_enable, ...) before it returns 0. So by the time
walk_iomem_res_desc() (and the other post-snp_prepare() steps) run,
SnpEn is already set on every online CPU and the machine is in SNP mode.
While SnpEn is set, a CPU must not come online without it — that is
exactly what disabling hotplug guards against. Re-enabling hotplug on
the walk_iomem_res_desc() failure path, with SnpEn still set, would
reopen that unsafe window, so hotplug is deliberately left disabled
there. It is re-enabled only once SnpEn is actually cleared, on the
x86_snp_shutdown path: snp_shutdown() verifies SnpEn is clear and then
calls cpu_hotplug_enable().
The one snp_prepare() failure that occurs before SnpEn is set — the
"not all CPUs online" check — does re-enable hotplug itself. There is no
failure path between cpu_hotplug_disable() and snp_enable() that can
return with hotplug disabled and SnpEn clear (the intervening steps are
void). So hotplug tracks SnpEn on every path.
Thanks,
Ashish
>> return 0;
>> }
>
next prev parent reply other threads:[~2026-09-02 21:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 21:27 [PATCH v13 0/5] Add RMPOPT support Ashish Kalra
2026-09-02 21:27 ` [PATCH v13 1/5] x86/cpufeatures: Add X86_FEATURE_RMPOPT feature flag Ashish Kalra
2026-09-02 21:28 ` [PATCH v13 2/5] x86/sev: Disable CPU hotplug while SNP is active Ashish Kalra
2026-09-02 21:51 ` sashiko-bot
2026-09-02 22:12 ` Kalra, Ashish
2026-09-02 21:28 ` [PATCH v13 3/5] x86/sev: Initialize RMPOPT configuration MSRs Ashish Kalra
2026-09-02 21:44 ` sashiko-bot
2026-09-02 21:56 ` Kalra, Ashish [this message]
2026-09-02 21:28 ` [PATCH v13 4/5] x86/sev: Add support to perform RMP optimizations asynchronously Ashish Kalra
2026-09-02 21:36 ` Dave Hansen
2026-09-02 21:57 ` sashiko-bot
2026-09-02 22:36 ` Kalra, Ashish
2026-09-05 1:29 ` Borislav Petkov
2026-09-02 21:29 ` [PATCH v13 5/5] x86/sev: Re-enable RMP optimizations on SNP guest shutdown Ashish Kalra
2026-09-02 21:37 ` Dave Hansen
2026-09-02 22:01 ` sashiko-bot
2026-09-02 22:45 ` 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=b1dec7be-d63d-4bd1-886d-c10b2af9290a@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