Kernel KVM virtualization development
 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 v16 2/5] x86/sev: Disable CPU hotplug while SNP is active
Date: Wed, 16 Sep 2026 22:36:30 +0000	[thread overview]
Message-ID: <20260916223630.C5E1C1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <cd6962a88d691a020c2bf40fe77a6a3f3852fdfc.1789594774.git.ashish.kalra@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] x86/sev: CPU hotplug disablement bypassed on early kexec errors
--

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

x86/sev: Disable CPU hotplug while SNP is active

This commit disables CPU hotplug when SNP is enabled to prevent SNP guest
memory from being broken by CPUs coming online without the SnpEn bit set.
It ties CPU hotplug to the SNP-enable bit, disabling it in snp_prepare()
and re-enabling it in snp_shutdown() when SNP is disabled. It also
explicitly disables CPU hotplug during kexec if SNP is already enabled.

> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index cff285d8ad8e3..558f7924a3f85 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c

[ ... ]

> @@ -577,6 +582,8 @@ EXPORT_SYMBOL_FOR_MODULES(snp_shutdown, "ccp");
>   */
>  int __init snp_rmptable_init(void)
>  {
> +	u64 val;
> +
>  	if (WARN_ON_ONCE(!cc_platform_has(CC_ATTR_HOST_SEV_SNP)))
>  		return -ENOSYS;
>  
> @@ -586,6 +593,15 @@ int __init snp_rmptable_init(void)
>  	if (!setup_rmptable())
>  		return -ENOSYS;
>  
> +	/*
> +	 * On a kexec boot SNP may already be enabled (legacy firmware leaves
> +	 * SnpEn set across shutdown), in which case snp_prepare() bails without
> +	 * disabling CPU hotplug, so disable it here.
> +	 */
> +	rdmsrq(MSR_AMD64_SYSCFG, val);
> +	if (val & MSR_AMD64_SYSCFG_SNP_EN)
> +		cpu_hotplug_disable();

[Severity: High]
If a kexec kernel boots into a system where the previous kernel left
MSR_AMD64_SYSCFG_SNP_EN active, and an early initialization step fails
(such as passing amd_iommu=off on the kernel command line resulting in
!amd_iommu_snp_en, or setup_rmptable() failing), snp_rmptable_init() will
return -ENOSYS before checking the physical MSR hardware state and
disabling CPU hotplug.

Because hotplug remains enabled and the CCP driver skips initialization on
failure (bypassing snp_prepare()), could a subsequently hotplugged CPU come
online without the SNP_EN bit set?

If this results in a mixed hardware state, does it violate firmware
constraints and cause fatal RMP faults when the new CPU accesses memory?

Should the hardware state be checked and hotplug disabled unconditionally
before the software configuration checks?

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

  reply	other threads:[~2026-09-16 22:36 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 [this message]
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
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=20260916223630.C5E1C1F000FF@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