From: sashiko-bot@kernel.org
To: "Ashish Kalra" <Ashish.Kalra@amd.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v11 4/6] x86/sev: Add support to perform RMP optimizations asynchronously
Date: Mon, 27 Jul 2026 19:22:56 +0000 [thread overview]
Message-ID: <20260727192256.7EAD31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <7f582569acea933c3045be604a81975e29b5ee2b.1784844080.git.ashish.kalra@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Inline assembly for __rmpopt fails to specify EAX/RAX as a clobbered or output register, risking an infinite loop.
- [High] Missing CPU yield in long-running RMP optimization loops leads to soft lockups on non-preemptible kernels.
--
--- Patch [4]: [PATCH v11 4/6] x86/sev: Add support to perform RMP optimizations asynchronously ---
commit 9b1e0ac7d870b3ba02472132010185afc997e02d
Author: Ashish Kalra <ashish.kalra@amd.com>
x86/sev: Add support to perform RMP optimizations asynchronously
This commit adds support for performing RMP optimizations asynchronously using
a dedicated workqueue. It introduces a new RMPOPT instruction to skip RMP checks
for 1GB regions not containing SEV-SNP guest memory. Optimizations are enabled
for up to 2TB of system RAM starting at RMP initialization time.
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index 8bfd802848361..04b19e64f8329 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
[ ... ]
> +static inline bool __rmpopt(u64 pa_start, u64 op_type)
> +{
> + bool optimized;
> +
> + asm volatile(".byte 0xf2, 0x0f, 0x01, 0xfc"
> + : "=@ccc" (optimized)
> + : "a" (pa_start), "c" (op_type)
> + : "memory", "cc");
[Severity: High]
Does this inline assembly need to specify EAX/RAX as a clobbered or output
register?
If the RMPOPT instruction modifies RAX (as AMD SEV-SNP instructions like
RMPUPDATE typically return an execution status code in EAX/RAX), the current
specification of RAX as input-only ("a" (pa_start)) could allow the compiler
to optimize the loop counter into RAX and silently overwrite it.
This could lead to an infinite loop during rmpopt_work_handler() execution.
> +
> + return optimized;
> +}
[ ... ]
> +static void rmpopt_work_handler(struct work_struct *work)
> +{
[ ... ]
> + migrate_disable();
> + this_cpu = smp_processor_id();
> +
> + cpumask_andnot(follower_mask, rmpopt_cpumask,
> + topology_sibling_cpumask(this_cpu));
> +
> + for (pa = rmpopt_pa_start; pa < rmpopt_pa_end; pa += SZ_1G)
> + rmpopt(pa);
[Severity: High]
Does this loop need a cond_resched() to yield the CPU?
This loops up to 2048 times doing an expensive hardware scan inside a
migrate_disable() block. On kernels with CONFIG_PREEMPT_NONE or
PREEMPT_VOLUNTARY, preemption is not implicit.
Without explicitly yielding the CPU, this could cause severe scheduling latency
spikes or trigger a soft lockup watchdog panic.
> +
> + migrate_enable();
> +
> + /*
> + * Followers: run RMPOPT on the remaining cores. cpus_read_lock() is
> + * intentionally not held here: CPU hotplug is disabled for the entire
> + * time SNP is active (see snp_prepare()), and this work only runs while
> + * SNP is active, so the follower set stays valid across the whole scan.
> + */
> + for (pa = rmpopt_pa_start; pa < rmpopt_pa_end; pa += SZ_1G)
> + on_each_cpu_mask(follower_mask, rmpopt_smp, (void *)pa, true);
[Severity: High]
Could this secondary follower loop also need a cond_resched() to prevent
CPU monopolization?
This loop iterates up to 2048 times broadcasting IPIs via on_each_cpu_mask().
Similar to the first loop, without a yield, this could lead to soft lockups on
non-preemptible kernels.
> +
> + free_cpumask_var(follower_mask);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1784844080.git.ashish.kalra@amd.com?part=4
next prev parent reply other threads:[~2026-07-27 19:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 19:00 [PATCH v11 0/6] Add RMPOPT support Ashish Kalra
2026-07-27 19:03 ` [PATCH v11 1/6] x86/cpufeatures: Add X86_FEATURE_RMPOPT feature flag Ashish Kalra
2026-07-27 19:01 ` Ashish Kalra
2026-07-27 19:04 ` [PATCH v11 2/6] x86/sev: Disable CPU hotplug while SNP is active Ashish Kalra
2026-07-27 19:37 ` sashiko-bot
2026-07-27 20:44 ` Kalra, Ashish
2026-07-29 2:15 ` Borislav Petkov
2026-07-29 17:51 ` Kalra, Ashish
2026-07-31 19:35 ` Tom Lendacky
2026-07-31 20:27 ` Kalra, Ashish
2026-07-27 19:04 ` [PATCH v11 3/6] x86/sev: Initialize RMPOPT configuration MSRs Ashish Kalra
2026-07-27 19:22 ` sashiko-bot
2026-07-27 21:02 ` Kalra, Ashish
2026-07-30 2:07 ` Borislav Petkov
2026-07-30 2:55 ` K Prateek Nayak
2026-07-30 3:39 ` Borislav Petkov
2026-07-30 19:52 ` Kalra, Ashish
2026-07-30 20:00 ` Kalra, Ashish
2026-07-31 0:12 ` Borislav Petkov
2026-07-31 19:43 ` Tom Lendacky
2026-07-27 19:05 ` [PATCH v11 4/6] x86/sev: Add support to perform RMP optimizations asynchronously Ashish Kalra
2026-07-27 19:22 ` sashiko-bot [this message]
2026-07-27 20:49 ` Kalra, Ashish
2026-07-31 5:44 ` Borislav Petkov
2026-07-31 12:37 ` Kalra, Ashish
2026-07-31 20:14 ` Tom Lendacky
2026-07-27 19:05 ` [PATCH v11 5/6] x86/sev: Add interface to re-enable RMP optimizations Ashish Kalra
2026-07-27 19:06 ` [PATCH v11 6/6] KVM: SEV: Perform RMP optimizations on SNP guest shutdown Ashish Kalra
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=20260727192256.7EAD31F000E9@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