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 v2 2/2] x86/sev: Only announce RMPOPT optimizations when SNP is enabled
Date: Wed, 14 Oct 2026 21:26:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-171925@kernel.org> (raw)
In-Reply-To: <5fbbf065e912fc011ec0f043db90f530b55c4517.1792011434.git.ashish.kalra@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] x86/sev: rmpopt_init checks CPU feature instead of CC_ATTR_HOST_SEV_SNP
--

commit 4dd9ce9c71a0a62c99cac5b242adafc6f676a4ec
Author: Ashish Kalra <ashish.kalra@amd.com>

x86/sev: Only announce RMPOPT optimizations when SNP is enabled

This commit updates rmpopt_init() to check for X86_FEATURE_SEV_SNP in
addition to X86_FEATURE_RMPOPT. The intent is to avoid allocating the RMPOPT
workqueue and printing the enablement message when the host is not an SNP host.

> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index 43e4945e6cdf1..81b9efd55c511 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -639,7 +639,8 @@ static void do_rmpopt_work(struct work_struct *work)
>  
>  static int __init rmpopt_init(void)
>  {
> -	if (!cpu_feature_enabled(X86_FEATURE_RMPOPT))
> +	if (!cpu_feature_enabled(X86_FEATURE_SEV_SNP) ||
> +	    !cpu_feature_enabled(X86_FEATURE_RMPOPT))

[Severity: Medium]
Will this reliably detect if SNP is disabled during IOMMU initialization?

If AMD IOMMU initialization fails to enable SNP (e.g., RMP initialization
fails or IOMMU is missing), it dynamically clears CC_ATTR_HOST_SEV_SNP but
leaves X86_FEATURE_SEV_SNP enabled:

drivers/iommu/amd/init.c:iommu_go_to_state() {
    ...
		cc_platform_clear(CC_ATTR_HOST_SEV_SNP);
    ...
}

Since rmpopt_init() runs as a device_initcall, it executes after IOMMU
initialization (which runs as a rootfs_initcall). By checking the CPU
feature instead of the software CC_ATTR flag, it seems it will erroneously
allocate the rmpopt_wq workqueue and print a misleading
'RMPOPT optimizations enabled' message on a non-SNP host, leaking an unused
workqueue on a cold path.

Should this check use cc_platform_has(CC_ATTR_HOST_SEV_SNP) instead?

>  		return -ENODEV;
>  
>  	rmpopt_wq = alloc_workqueue("rmpopt_wq", WQ_PERCPU, 1);

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

  reply	other threads:[~2026-10-14 21:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 21:14 [PATCH v2 0/2] x86/sev: Fix RMPOPT enablement on non-RMPOPT configs Ashish Kalra
2026-10-14 21:14 ` [PATCH v2 1/2] x86/sev: Clear RMPOPT when segmented RMP is disabled by firmware Ashish Kalra
2026-10-14 21:14 ` [PATCH v2 2/2] x86/sev: Only announce RMPOPT optimizations when SNP is enabled Ashish Kalra
2026-10-14 21:26   ` sashiko-bot [this message]
2026-10-14 22:13     ` 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=sashiko-outbox-171925@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.