All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ashish Kalra" <Ashish.Kalra@amd.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v10 4/6] x86/sev: Add support to perform RMP optimizations asynchronously
Date: Tue, 30 Jun 2026 18:28:07 +0000	[thread overview]
Message-ID: <20260630182808.6860E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <ada64cdc976b98a70687b3a347bca0c25c89eb09.1782841284.git.ashish.kalra@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Re-initializing SNP after a partial shutdown bypasses the RMPOPT optimization pass, leaving the new RMP table unoptimized.
--

commit 2d85f8f029da9849b60d0154807adccc997f6502
Author: Ashish Kalra <ashish.kalra@amd.com>

x86/sev: Add support to perform RMP optimizations asynchronously

This patch introduces support for the RMPOPT instruction to minimize performance
overhead by skipping RMP checks on 1GB memory ranges known not to contain
SEV-SNP guest memory. It adds a dedicated workqueue to perform these
optimizations asynchronously.

> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index 04a58ac4339cb..40b06e959ee87 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c

[ ... ]

> @@ -625,14 +743,42 @@ void snp_setup_rmpopt(void)
>  	if (!cpu_feature_enabled(X86_FEATURE_RMPOPT) || !rmpopt_capable)
>  		return;
>  
> +	guard(mutex)(&rmpopt_wq_mutex);
> +
> +	/*
> +	 * Guard against re-initialization.  When SNP_SHUTDOWN_EX is issued
> +	 * with x86_snp_shutdown=0, snp_shutdown() is not called and
> +	 * rmpopt_cleanup() is skipped, but snp_initialized is still cleared.
> +	 * A subsequent __sev_snp_init_locked() would call snp_setup_rmpopt()
> +	 * again, leaking the existing workqueue, delayed work, and cpumask
> +	 * state.
> +	 */
> +	if (rmpopt_wq)
> +		return;

[Severity: Medium]
Will this early return prevent the initial RMPOPT optimization pass if SNP is
re-initialized after a partial shutdown?

If a partial shutdown occurs where rmpopt_cleanup() is skipped, rmpopt_wq
remains allocated. When snp_setup_rmpopt() is called again during
re-initialization, returning early here skips the queue_delayed_work()
call at the end of the function.

Does this mean the system will run without RMP optimizations on the newly
initialized RMP table, incurring RMP check overhead until a later event
triggers a rescan?

[ ... ]

> +	/* Limit memory scanning to 2TB of RAM */
> +	if ((rmpopt_pa_end - rmpopt_pa_start) > SZ_2T) {
> +		pr_info("RMPOPT coverage limited to 2TB; memory above 0x%llx not optimized\n",
> +			rmpopt_pa_start + SZ_2T);
> +		rmpopt_pa_end = rmpopt_pa_start + SZ_2T;
> +	}
> +
> +	/*
> +	 * Once all per-CPU RMPOPT tables have been configured, enable RMPOPT
> +	 * optimizations on all physical memory.
> +	 */
> +	queue_delayed_work(rmpopt_wq, &rmpopt_delayed_work, 0);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1782841284.git.ashish.kalra@amd.com?part=4

  reply	other threads:[~2026-06-30 18:28 UTC|newest]

Thread overview: 14+ 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-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-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 [this message]
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

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=20260630182808.6860E1F00A3A@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.