From: Zack Rusin <zack.rusin@broadcom.com>
To: Kiryl Shutsemau <kas@kernel.org>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, Dennis Zhou <dennis@kernel.org>,
Tejun Heo <tj@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Ajay Kaher <ajay.kaher@broadcom.com>,
Alexey Makhalov <alexey.makhalov@broadcom.com>,
Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
virtualization@lists.linux.dev,
bcm-kernel-feedback-list@broadcom.com,
linux-kernel@vger.kernel.org, Christoph Lameter <cl@gentwo.org>,
Andrew Morton <akpm@linux-foundation.org>,
Bo Gan <bo.gan@broadcom.com>,
linux-mm@kvack.org, linux-arch@vger.kernel.org,
linux-coco@lists.linux.dev, kvm@vger.kernel.org,
Jonathan Corbet <corbet@lwn.net>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Long Li <longli@microsoft.com>, Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
linux-doc@vger.kernel.org, linux-hyperv@vger.kernel.org,
Nathan Chancellor <nathan@kernel.org>,
Kees Cook <kees@kernel.org>, Ashish Kalra <ashish.kalra@amd.com>
Subject: [PATCH v2 3/6] x86/percpu: Require embedded allocation in encrypted guests
Date: Tue, 29 Sep 2026 00:02:52 -0400 [thread overview]
Message-ID: <20260929040256.543767-4-zack.rusin@broadcom.com> (raw)
In-Reply-To: <20260929040256.543767-1-zack.rusin@broadcom.com>
Early sharing needs direct-mapped per-CPU storage. In TDX, a private
direct-map alias of a shared page can terminate the guest, including
through load_unaligned_zeropad(). Require embed rather than adding early
vmalloc conversion and alias synchronization.
Warn when overriding percpu_alloc=page and let embed failures reach the
existing panic. Restrict this policy to encrypted guests, leaving host
SME allocation unchanged.
Suggested-by: Kiryl Shutsemau <kas@kernel.org>
Link: https://lore.kernel.org/r/aqvxQoIoYhJTZpAC@thinkstation
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
---
Documentation/admin-guide/kernel-parameters.txt | 3 +++
arch/x86/kernel/setup_percpu.c | 12 ++++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 33cd30996e47..8ba881af3520 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5347,6 +5347,9 @@ Kernel parameters
See comments in mm/percpu.c for details on each
allocator. This parameter is primarily for debugging
and performance comparison.
+ On x86 encrypted guests, only "embed" is supported;
+ "page" is ignored with a warning. An embed allocation
+ failure is fatal instead of falling back to "page".
pirq= [SMP,APIC] Manual mp-table setup
See Documentation/arch/x86/i386/IO-APIC.rst.
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index bfa48e7a32a2..c83c61e0b20a 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -8,6 +8,7 @@
#include <linux/percpu.h>
#include <linux/kexec.h>
#include <linux/crash_dump.h>
+#include <linux/cc_platform.h>
#include <linux/smp.h>
#include <linux/topology.h>
#include <linux/pfn.h>
@@ -112,6 +113,7 @@ void __init setup_per_cpu_areas(void)
{
unsigned int cpu;
unsigned long delta;
+ bool encrypted = cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT);
int rc;
pr_info("NR_CPUS:%d nr_cpumask_bits:%d nr_cpu_ids:%u nr_node_ids:%u\n",
@@ -127,6 +129,12 @@ void __init setup_per_cpu_areas(void)
if (pcpu_chosen_fc == PCPU_FC_AUTO && pcpu_need_numa())
pcpu_chosen_fc = PCPU_FC_PAGE;
#endif
+ if (encrypted) {
+ if (pcpu_chosen_fc == PCPU_FC_PAGE)
+ pr_warn("Ignoring percpu_alloc=page in an encrypted guest\n");
+ pcpu_chosen_fc = PCPU_FC_EMBED;
+ }
+
rc = -EINVAL;
if (pcpu_chosen_fc != PCPU_FC_PAGE) {
const size_t dyn_size = PERCPU_MODULE_RESERVE +
@@ -149,11 +157,11 @@ void __init setup_per_cpu_areas(void)
dyn_size, atom_size,
pcpu_cpu_distance,
pcpu_cpu_to_node);
- if (rc < 0)
+ if (rc < 0 && !encrypted)
pr_warn("%s allocator failed (%d), falling back to page size\n",
pcpu_fc_names[pcpu_chosen_fc], rc);
}
- if (rc < 0)
+ if (rc < 0 && !encrypted)
rc = pcpu_page_first_chunk(PERCPU_FIRST_CHUNK_RESERVE,
pcpu_cpu_to_node);
if (rc < 0)
--
2.53.0
next prev parent reply other threads:[~2026-09-29 4:03 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 4:02 [PATCH v2 0/6] x86/percpu: Share decrypted storage before guest setup Zack Rusin
2026-09-29 4:02 ` [PATCH v2 1/6] percpu: Page-align decrypted data in UP kernels Zack Rusin
2026-09-29 4:09 ` sashiko-bot
2026-09-29 4:02 ` [PATCH v2 2/6] percpu: Bound decrypted storage for all x86 encrypted guests Zack Rusin
2026-09-29 4:12 ` sashiko-bot
2026-09-29 7:54 ` Peter Zijlstra
2026-09-29 17:12 ` Zack Rusin
2026-09-29 17:12 ` Zack Rusin
2026-09-29 17:12 ` Zack Rusin
2026-09-29 17:12 ` Zack Rusin
2026-09-29 17:12 ` Zack Rusin
2026-09-30 8:54 ` Peter Zijlstra
2026-09-29 4:02 ` Zack Rusin [this message]
2026-09-29 4:07 ` [PATCH v2 3/6] x86/percpu: Require embedded allocation in " sashiko-bot
2026-09-29 4:02 ` [PATCH v2 4/6] x86/mm: Provide common early memory decryption Zack Rusin
2026-09-29 4:14 ` sashiko-bot
2026-09-29 4:02 ` [PATCH v2 5/6] x86/tdx: Support early sharing of kernel data Zack Rusin
2026-09-29 4:14 ` sashiko-bot
2026-09-29 4:02 ` [PATCH v2 6/6] x86/percpu: Share decrypted storage before guest CPU setup Zack Rusin
2026-09-29 4:14 ` sashiko-bot
2026-09-29 5:39 ` [PATCH v2 0/6] x86/percpu: Share decrypted storage before guest setup Borislav Petkov
2026-09-29 17:25 ` Zack Rusin
2026-09-29 17:25 ` Zack Rusin
2026-09-29 17:25 ` Zack Rusin
2026-10-01 23:59 ` Borislav Petkov
2026-10-02 6:06 ` Zack Rusin
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=20260929040256.543767-4-zack.rusin@broadcom.com \
--to=zack.rusin@broadcom.com \
--cc=ajay.kaher@broadcom.com \
--cc=akpm@linux-foundation.org \
--cc=alexey.makhalov@broadcom.com \
--cc=arnd@arndb.de \
--cc=ashish.kalra@amd.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bo.gan@broadcom.com \
--cc=bp@alien8.de \
--cc=cl@gentwo.org \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=dennis@kernel.org \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kas@kernel.org \
--cc=kees@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=longli@microsoft.com \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=tglx@kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=tj@kernel.org \
--cc=virtualization@lists.linux.dev \
--cc=vkuznets@redhat.com \
--cc=wei.liu@kernel.org \
--cc=x86@kernel.org \
/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.