[RFC][PATCH 09/24] x86/cea: Refactor "CEA" macros to deal with multiple stacks

From: Dave Hansen

Date: Wed Oct 21 2026 - 15:54:06 EST



There are a series of CPU Entry Area (CEA) helper macros to make
it easier to deal with the CEA structure geometry. Right now,
many of them can deal only with the regular stack.

Prepare for shadow stacks by refactoring the macros to take a
(partial) structure member name. For now, that is just "stack".

This is a pure refactoring. No behavioral changes intended.

Nits: CEA_ESTACK_PAGES gets a whitespace change to make it
consistent with the new width of the four related macros above
it. There's also some slight rewrapping of the macros in a place
or two to make them more readable.

---

b/arch/x86/include/asm/cpu_entry_area.h | 23 ++++++++++++-----------
b/arch/x86/kernel/dumpstack_64.c | 9 +++++----
2 files changed, 17 insertions(+), 15 deletions(-)

diff -puN arch/x86/include/asm/cpu_entry_area.h~cea-estacks-shadows arch/x86/include/asm/cpu_entry_area.h
--- a/arch/x86/include/asm/cpu_entry_area.h~cea-estacks-shadows 2026-10-21 12:36:36.741878790 -0700
+++ b/arch/x86/include/asm/cpu_entry_area.h 2026-10-21 12:36:36.746878799 -0700
@@ -55,19 +55,20 @@ enum exception_stack_ordering {
N_EXCEPTION_STACKS
};

-#define CEA_ESTACK_SIZE(st) \
- sizeof(((struct cea_exception_stacks *)0)->st## _stack)
+#define CEA_ESTACK_SIZE(st, member) \
+ sizeof(((struct cea_exception_stacks *)0)->st## _ ##member)

-#define CEA_ESTACK_BOT(ceastp, st) \
- ((unsigned long)&(ceastp)->st## _stack)
+#define CEA_ESTACK_BOT(ceastp, st, member) \
+ ((unsigned long)&(ceastp)->st## _ ##member)

-#define CEA_ESTACK_TOP(ceastp, st) \
- (CEA_ESTACK_BOT(ceastp, st) + CEA_ESTACK_SIZE(st))
+#define CEA_ESTACK_TOP(ceastp, st, member) \
+ (CEA_ESTACK_BOT(ceastp, st, member) + \
+ CEA_ESTACK_SIZE(st, member))

-#define CEA_ESTACK_OFFS(st) \
- offsetof(struct cea_exception_stacks, st## _stack)
+#define CEA_ESTACK_OFFS(st, member) \
+ offsetof(struct cea_exception_stacks, st## _ ##member)

-#define CEA_ESTACK_PAGES \
+#define CEA_ESTACK_PAGES \
(sizeof(struct cea_exception_stacks) / PAGE_SIZE)

#endif
@@ -145,9 +146,9 @@ static __always_inline struct entry_stac
}

#define __this_cpu_ist_top_va(name) \
- CEA_ESTACK_TOP(__this_cpu_read(cea_exception_stacks), name)
+ CEA_ESTACK_TOP(__this_cpu_read(cea_exception_stacks), name, stack)

#define __this_cpu_ist_bottom_va(name) \
- CEA_ESTACK_BOT(__this_cpu_read(cea_exception_stacks), name)
+ CEA_ESTACK_BOT(__this_cpu_read(cea_exception_stacks), name, stack)

#endif
diff -puN arch/x86/kernel/dumpstack_64.c~cea-estacks-shadows arch/x86/kernel/dumpstack_64.c
--- a/arch/x86/kernel/dumpstack_64.c~cea-estacks-shadows 2026-10-21 12:36:36.743878793 -0700
+++ b/arch/x86/kernel/dumpstack_64.c 2026-10-21 12:36:36.746878799 -0700
@@ -69,10 +69,11 @@ struct estack_pages {
};

#define EPAGERANGE(st) \
- [PFN_DOWN(CEA_ESTACK_OFFS(st)) ... \
- PFN_DOWN(CEA_ESTACK_OFFS(st) + CEA_ESTACK_SIZE(st) - 1)] = { \
- .offs = CEA_ESTACK_OFFS(st), \
- .size = CEA_ESTACK_SIZE(st), \
+ [PFN_DOWN(CEA_ESTACK_OFFS(st, stack)) ... \
+ PFN_DOWN(CEA_ESTACK_OFFS(st, stack) + \
+ CEA_ESTACK_SIZE(st, stack) - 1)] = { \
+ .offs = CEA_ESTACK_OFFS(st, stack), \
+ .size = CEA_ESTACK_SIZE(st, stack), \
.type = STACK_TYPE_EXCEPTION + ESTACK_ ##st, }

/*
_