mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Kalra, Ashish" <ashish.kalra@amd.com>
To: Borislav Petkov <bp@alien8.de>, sashiko-reviews@lists.linux.dev
Cc: kvm@vger.kernel.org, tglx@kernel.org, mingo@redhat.com,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	seanjc@google.com, peterz@infradead.org, thomas.lendacky@amd.com,
	herbert@gondor.apana.org.au, davem@davemloft.net,
	ardb@kernel.org, pbonzini@redhat.com, aik@amd.com,
	Michael.Roth@amd.com, KPrateek.Nayak@amd.com,
	Tycho.Andersen@amd.com, Nathan.Fontenot@amd.com,
	ackerleytng@google.com, jackyli@google.com, pgonda@google.com,
	rientjes@google.com, jacobhxu@google.com, xin@zytor.com,
	pawan.kumar.gupta@linux.intel.com, babu.moger@amd.com,
	dyoung@redhat.com, nikunj@amd.com, darwi@linutronix.de,
	linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	linux-coco@lists.linux.dev
Subject: Re: [PATCH v16 2/5] x86/sev: Disable CPU hotplug while SNP is active
Date: Thu, 17 Sep 2026 11:31:07 -0500	[thread overview]
Message-ID: <dacf788f-7921-4a76-92d3-2218ff23c44f@amd.com> (raw)
In-Reply-To: <20260917021937.GEaqtOOfbceTzNy0um@fat_crate.local>

Hello Boris,

On 9/16/2026 9:19 PM, Borislav Petkov wrote:
> On Wed, Sep 16, 2026 at 10:36:30PM +0000, sashiko-bot@kernel.org wrote:
>> 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
> 
> amd_iommu=off means no SNP.
> 
>> on the kernel command line resulting in !amd_iommu_snp_en, or
>> setup_rmptable() failing),
> 
> The same happens in that case:
> 
>         if (snp_rmptable_init()) {
>                 pr_warn("SNP: RMP initialization failed, SNP cannot be supported.\n");
>                 goto disable_snp;
> 		     ^^^^^^^^^^^
> 
> Does Sashiko not see that or somehow it ate a lot of credits so it cannot use
> enough now to "swap in" the whole context... if that is the AI that is going
> to destroy the world, then I'm not too worried. :)
> 
> Or is my AI failing me right now?
> 
> :-P
> 
> Leaving in the rest.

Right, agreed — 

As you have pointed out, on any snp_rmptable_init() failure — setup_rmptable() failing,
!amd_iommu_snp_en (amd_iommu=off), etc. — the caller does goto disable_snp and SNP is
disabled entirely. 

Thanks,
Ashish

> 
>> 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?
> 
> Yes, but the above disabled all our intention of running SNP in the first
> place...
>  
>> 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-17 16:31 UTC|newest]

Thread overview: 9+ 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
     [not found]   ` <20260916223630.C5E1C1F000FF@smtp.kernel.org>
2026-09-17  2:19     ` Borislav Petkov
2026-09-17 16:31       ` Kalra, Ashish [this message]
2026-09-16 22:14 ` [PATCH v16 3/5] x86/sev: Initialize RMPOPT configuration MSRs Ashish Kalra
2026-09-16 22:15 ` [PATCH v16 4/5] x86/sev: Perform RMP optimizations asynchronously Ashish Kalra
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=dacf788f-7921-4a76-92d3-2218ff23c44f@amd.com \
    --to=ashish.kalra@amd.com \
    --cc=KPrateek.Nayak@amd.com \
    --cc=Michael.Roth@amd.com \
    --cc=Nathan.Fontenot@amd.com \
    --cc=Tycho.Andersen@amd.com \
    --cc=ackerleytng@google.com \
    --cc=aik@amd.com \
    --cc=ardb@kernel.org \
    --cc=babu.moger@amd.com \
    --cc=bp@alien8.de \
    --cc=darwi@linutronix.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=dyoung@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=jackyli@google.com \
    --cc=jacobhxu@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nikunj@amd.com \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pgonda@google.com \
    --cc=rientjes@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=seanjc@google.com \
    --cc=tglx@kernel.org \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    --cc=xin@zytor.com \
    /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

all inboxes | Powered by JetHome®