[RFC][PATCH 13/24] x86/task: Grow thread_union for shadow stacks
From: Dave Hansen
Date: Wed Oct 21 2026 - 15:54:06 EST
Define the size of an x86 shadow stack: one page. This will inflate the
virtual size and physical backing of thread_union, wasting one page
per task on non-shadow-stack configurations.
This waste can be cleaned up with the "double vmap()" approach discussed
earlier. For now, please ignore the gluttonous use of DRAM.
---
b/arch/x86/include/asm/page_64_types.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff -puN arch/x86/include/asm/page_64_types.h~x86-define-shadow-stack-size arch/x86/include/asm/page_64_types.h
--- a/arch/x86/include/asm/page_64_types.h~x86-define-shadow-stack-size 2026-10-21 12:36:38.870882865 -0700
+++ b/arch/x86/include/asm/page_64_types.h 2026-10-21 12:36:38.872882869 -0700
@@ -15,6 +15,15 @@
#define THREAD_SIZE_ORDER (2 + KASAN_STACK_ORDER)
#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
+/*
+ * Grow 'thread_union' to make space for the shadow stack
+ * page. For now, this wastes a page of space per task on
+ * systems that do not support shadow stacks.
+ */
+#ifdef CONFIG_X86_KERN_SHADOW_STACK
+#define TASK_SHADOW_STACK_SIZE PAGE_SIZE
+#endif
+
#define EXCEPTION_STACK_ORDER (1 + KASAN_STACK_ORDER)
#define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
_