From: sashiko-bot@kernel.org
To: "Ashish Kalra" <Ashish.Kalra@amd.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v16 3/5] x86/sev: Initialize RMPOPT configuration MSRs
Date: Wed, 16 Sep 2026 22:26:44 +0000 [thread overview]
Message-ID: <20260916222644.E513D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <7fdf0f5b1be4b561c884c5200d6606a947cbc09d.1789594774.git.ashish.kalra@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] x86/sev: missing MSR configuration on CPU hotplug cycle due to local check
--
commit f73eea5b303a29d64f9efe740eeba6e570bac844
Author: Ashish Kalra <ashish.kalra@amd.com>
x86/sev: Initialize RMPOPT configuration MSRs
The new RMPOPT instruction helps manage per-CPU RMP optimization
structures inside the CPU. Initialize the per-CPU RMPOPT table base to
the starting physical address to enable RMP optimization for up to 2 TB
of system RAM on all CPUs.
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index 558f7924a3f85..25cb486ff61b6 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
[ ... ]
> @@ -575,6 +577,42 @@ void snp_shutdown(void)
> }
> EXPORT_SYMBOL_FOR_MODULES(snp_shutdown, "ccp");
>
> +static bool rmpopt_capable(void)
> +{
> + return cpu_feature_enabled(X86_FEATURE_RMPOPT) &&
> + cc_platform_has(CC_ATTR_HOST_SEV_SNP);
> +}
> +
> +void snp_enable_rmpopt(void)
> +{
> + u64 base;
> + int cpu;
> +
> + if (!rmpopt_capable())
> + return;
> +
> + rmpopt_pa_start = ALIGN_DOWN(PFN_PHYS(min_low_pfn), SZ_1G);
> +
> + /*
> + * Per-CPU RMPOPT tables cover at most 2 TB. Program each core's
> + * RMPOPT_BASE with the start of RAM to optimize up to 2 TB. The MSR
> + * can only be written after SNP is enabled, so this runs from the ccp
> + * SNP init path (and again on guest teardown) rather than an initcall.
> + *
> + * The loop below programs RMPOPT_BASE on all primary threads. RMPOPT_EN
> + * cannot be cleared while SNP is enabled, and CPU hotplug is disabled
> + * while SNP is active, so once programmed the MSRs stay set on all CPUs
> + * until SNP is disabled. A set RMPOPT_EN on the local CPU therefore
> + * means the programming has already been done, so skip it.
> + */
> + rdmsrq(MSR_AMD64_RMPOPT_BASE, base);
> + if (!(base & MSR_AMD64_RMPOPT_ENABLE))
> + for_each_cpu(cpu, cpu_primary_thread_mask)
> + wrmsrq_on_cpu(cpu, MSR_AMD64_RMPOPT_BASE,
> + rmpopt_pa_start | MSR_AMD64_RMPOPT_ENABLE);
[Severity: High]
Could this local CPU check cause hotplugged CPUs to miss MSR configuration?
If SNP is shut down, CPU hotplug is re-enabled but the MSR remains intact on
existing CPUs. If a CPU is offlined and brought back online, its MSR is reset
to the default.
Later, when SNP is re-enabled, the local CPU executing snp_enable_rmpopt()
might still have its own RMPOPT_ENABLE bit set. Will it erroneously assume
all CPUs are programmed and skip the wrmsrq_on_cpu() loop, leaving the
hotplugged CPU unconfigured?
> +}
> +EXPORT_SYMBOL_FOR_MODULES(snp_enable_rmpopt, "ccp");
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1789594774.git.ashish.kalra@amd.com?part=3
next prev parent reply other threads:[~2026-09-16 22:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 22:13 [PATCH v16 0/5] Add RMPOPT support Ashish Kalra
2026-09-16 22:14 ` [PATCH v16 1/5] x86/cpufeatures: Add X86_FEATURE_RMPOPT feature flag Ashish Kalra
2026-09-16 22:14 ` [PATCH v16 2/5] x86/sev: Disable CPU hotplug while SNP is active Ashish Kalra
2026-09-16 22:36 ` sashiko-bot
2026-09-16 23:31 ` Kalra, Ashish
2026-09-17 2:19 ` Borislav Petkov
2026-09-17 16:31 ` Kalra, Ashish
2026-09-16 22:14 ` [PATCH v16 3/5] x86/sev: Initialize RMPOPT configuration MSRs Ashish Kalra
2026-09-16 22:26 ` sashiko-bot [this message]
2026-09-16 23:11 ` Kalra, Ashish
2026-09-18 18:00 ` Borislav Petkov
2026-09-16 22:15 ` [PATCH v16 4/5] x86/sev: Perform RMP optimizations asynchronously Ashish Kalra
2026-09-16 22:29 ` sashiko-bot
2026-09-16 23:24 ` Kalra, Ashish
2026-09-18 22:23 ` Borislav Petkov
2026-09-18 22:46 ` Kalra, Ashish
2026-09-18 23:39 ` Borislav Petkov
2026-09-16 22:15 ` [PATCH v16 5/5] x86/sev: Re-enable RMP optimizations on SNP guest shutdown Ashish Kalra
2026-09-17 19:47 ` [PATCH v16 0/5] Add RMPOPT support Tom Lendacky
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=20260916222644.E513D1F000FF@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.