From nobody Sat Jun 13 07:50:59 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99F493DA5B1; Fri, 8 May 2026 18:42:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778265756; cv=none; b=IsRAvqa/fbB7bMLoexnEBemNfrsk1ddR+QE+GhtrVwOT4OEojsn6sSO3rsTeb2onH9lWIpxuSrEMZgsWg4hymq3zLwGvLV8EAMM2wtFvy/0AY62xOBhfR5TeA6slFrNGt0cTaXCt124kOK6Xk1zycNbK6xJoYpdlnh8jA04XN9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778265756; c=relaxed/simple; bh=qx2vvOZ+XS1Pe1n4ZygzsWTm7bkBlaw7CnMRNpga3O0=; h=Date:From:To:Subject:Cc:MIME-Version:Message-ID:Content-Type; b=pvBnH1ThAag7bZUAtvoDNHB4p4Vptcj2JRzGb1BLam0sFAjlDbi5a0RD/5DOIb2Xx4Tnjx7fY/oi/qF4VLZGJNbxjRbKUoV9zOccdKdeEoh+vwVEuMLtRKjcQGBcGTpeeuUb4IkTmsxse5GE6ILDTYPZJDM8zRpJUO1VNC8+k7o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Xoiec+UO; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ugFC+ZAv; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Xoiec+UO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ugFC+ZAv" Date: Fri, 08 May 2026 18:42:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1778265753; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X/AYDlCTwBl5reWcr0+YHElAUmasuMIlnnMOtjuRv1Q=; b=Xoiec+UOf4sDfWtVJ0UY3HYoNuuJ/qZ2tXbknM/TkXE8Uh8ZsSnvSHM8NJh2a8Jm6JjjjK bNlr2WmIPd1mDdV5JwPjkWFVcPJEYwJlQHOIE0ACEKqB4W4htCw47hQ1AOQcNaHlIudond cNLz3EOdLqhvHS9ENEW+Y4SNJmKQrrUMDe8lueVlbFouIMR+Qi6+PEbPbGmo/LZ2mQ+tSD 8wICxzxo1BMY0KLRshnyRWjrsWA2Xs+WjXAqywS6UoAfkE7wP2y4O8EZEQwEGIVhvaHShx 7TIXSoW7jD9W3TjhKgd26OH9ADuCR6XPsOngd726eOR4E0ON5rTS1DLVWvOcGg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1778265753; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=X/AYDlCTwBl5reWcr0+YHElAUmasuMIlnnMOtjuRv1Q=; b=ugFC+ZAvr6+TAR0QR0tsmrPvWyjJf+4iMKBQzL/WEs69XMAuyGMY7wvrNhCVOWKTR3P1yZ isphOfozH51nbhCw== From: "tip-bot2 for Tycho Andersen (AMD)" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/sev] x86/sev: Do not initialize SNP if missing CPUs Cc: "Borislav Petkov (AMD)" , "Tycho Andersen (AMD)" , Nikunj A Dadhania , Tom Lendacky , x86@kernel.org, linux-kernel@vger.kernel.org Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177826575195.864.3575958854068038528.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/sev branch of tip: Commit-ID: 39f1de2fffb3dc1751153e4c3d9138ccd958e8b1 Gitweb: https://git.kernel.org/tip/39f1de2fffb3dc1751153e4c3d9138ccd= 958e8b1 Author: Tycho Andersen (AMD) AuthorDate: Wed, 29 Apr 2026 09:56:35 -06:00 Committer: Borislav Petkov (AMD) CommitterDate: Fri, 08 May 2026 20:28:49 +02:00 x86/sev: Do not initialize SNP if missing CPUs The SEV firmware checks that the SNP enable bit is set on each CPU during S= NP initialization, and will fail if not. If there are some CPUs offline, they will not run the setup functions, so SNP initialization will always fail. Skip the IPIs in this case and return an error so that the CCP driver can skip the SNP_INIT that will fail. Also print the CPU masks in order to leave breadcrumbs so people can figure out what happened. [ bp: Massage commit message. ] Suggested-by: Borislav Petkov (AMD) Signed-off-by: Tycho Andersen (AMD) Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Nikunj A Dadhania Reviewed-by: Tom Lendacky Link: https://20260429155636.540040-1-tycho@kernel.org --- arch/x86/include/asm/sev.h | 4 ++-- arch/x86/virt/svm/sev.c | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h index 09e605c..594cfa1 100644 --- a/arch/x86/include/asm/sev.h +++ b/arch/x86/include/asm/sev.h @@ -661,7 +661,7 @@ static inline void snp_leak_pages(u64 pfn, unsigned int= pages) { __snp_leak_pages(pfn, pages, true); } -void snp_prepare(void); +int snp_prepare(void); void snp_shutdown(void); #else static inline bool snp_probe_rmptable_info(void) { return false; } @@ -679,7 +679,7 @@ static inline void __snp_leak_pages(u64 pfn, unsigned i= nt npages, bool dump_rmp) static inline void snp_leak_pages(u64 pfn, unsigned int npages) {} static inline void kdump_sev_callback(void) { } static inline void snp_fixup_e820_tables(void) {} -static inline void snp_prepare(void) {} +static inline int snp_prepare(void) { return -ENODEV; } static inline void snp_shutdown(void) {} #endif =20 diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c index 41f76f1..8bcdce9 100644 --- a/arch/x86/virt/svm/sev.c +++ b/arch/x86/virt/svm/sev.c @@ -511,8 +511,9 @@ static void clear_hsave_pa(void *arg) wrmsrq(MSR_VM_HSAVE_PA, 0); } =20 -void snp_prepare(void) +int snp_prepare(void) { + int ret; u64 val; =20 /* @@ -521,12 +522,20 @@ void snp_prepare(void) */ rdmsrq(MSR_AMD64_SYSCFG, val); if (val & MSR_AMD64_SYSCFG_SNP_EN) - return; + return 0; =20 clear_rmp(); =20 cpus_read_lock(); =20 + if (!cpumask_equal(cpu_online_mask, cpu_present_mask)) { + ret =3D -EOPNOTSUPP; + pr_warn("SNP init failed: not all CPUs online. (%*pbl online <-> %*pbl p= resent masks).\n", + cpumask_pr_args(cpu_online_mask), + cpumask_pr_args(cpu_present_mask)); + goto unlock; + } + /* * MtrrFixDramModEn is not shared between threads on a core, * therefore it must be set on all CPUs prior to enabling SNP. @@ -537,7 +546,12 @@ void snp_prepare(void) /* SNP_INIT requires MSR_VM_HSAVE_PA to be cleared on all CPUs. */ on_each_cpu(clear_hsave_pa, NULL, 1); =20 + ret =3D 0; + +unlock: cpus_read_unlock(); + + return ret; } EXPORT_SYMBOL_FOR_MODULES(snp_prepare, "ccp"); =20