[RFC][PATCH 10/24] x86/cea: Refactor stack mapping macros
From: Dave Hansen
Date: Wed Oct 21 2026 - 15:53:53 EST
Continuing the trend, the stack mapping macros can currently
only work with the "_stack" structure member. Make them more
flexible by taking a partial structure member name.
Also make the mapping permission explicit. This will allow
shadow stack permission mappings in the near future.
This does make following the macro maze a bit harder. But,
in the end, it's quite readable to have code that looks like
this:
cea_map_stack(MCE, stack, PAGE_KERNEL);
vs.
cea_map_stack(MCE, shadow_stack, PAGE_KERNEL_SHSTK);
---
b/arch/x86/mm/cpu_entry_area.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff -puN arch/x86/mm/cpu_entry_area.c~cea-estacks-shadows-refactor-0 arch/x86/mm/cpu_entry_area.c
--- a/arch/x86/mm/cpu_entry_area.c~cea-estacks-shadows-refactor-0 2026-10-21 12:36:37.273879808 -0700
+++ b/arch/x86/mm/cpu_entry_area.c 2026-10-21 12:36:37.275879812 -0700
@@ -130,10 +130,10 @@ static void __init percpu_setup_debug_st
#ifdef CONFIG_X86_64
-#define cea_map_stack(name) do { \
- npages = sizeof(estacks->name## _stack) / PAGE_SIZE; \
- cea_map_percpu_pages(cea->estacks.name## _stack, \
- estacks->name## _stack, npages, PAGE_KERNEL); \
+#define cea_map_stack(name, member, perm) do { \
+ npages = sizeof(estacks->name## _ ##member) / PAGE_SIZE; \
+ cea_map_percpu_pages(cea->estacks.name## _ ##member, \
+ estacks->name## _ ##member, npages, perm); \
} while (0)
static void __init percpu_setup_exception_stacks(unsigned int cpu)
@@ -151,15 +151,15 @@ static void __init percpu_setup_exceptio
* by guard pages so each stack must be mapped separately. DB2 is
* not mapped; it just exists to catch triple nesting of #DB.
*/
- cea_map_stack(DF);
- cea_map_stack(NMI);
- cea_map_stack(DB);
- cea_map_stack(MCE);
+ cea_map_stack(DF, stack, PAGE_KERNEL);
+ cea_map_stack(NMI, stack, PAGE_KERNEL);
+ cea_map_stack(DB, stack, PAGE_KERNEL);
+ cea_map_stack(MCE, stack, PAGE_KERNEL);
if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT)) {
if (cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT)) {
- cea_map_stack(VC);
- cea_map_stack(VC2);
+ cea_map_stack(VC, stack, PAGE_KERNEL);
+ cea_map_stack(VC2, stack, PAGE_KERNEL);
}
}
}
_