Skip to contentSkip to conversation

arm64: set VMAP_STACK by default

PATCH Applied Breno Leitao 4 participants 15 messages Jul 7, 2025 – Jul 8, 2025

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/8 arm64: Enable VMAP_STACK support

In reply to Breno Leitao

Enable virtually mapped kernel stacks for ARM64. This provides better stack overflow detection and improved security by mapping kernel stacks in vmalloc space rather than using direct mapping.

VMAP_STACK helps catch stack overflows early by placing guard pages around kernel stacks, and also provides better isolation between kernel stacks and other kernel data structures.

All dependencies are satisfied for arm64: HAVE_ARCH_VMAP_STACK is already selected above, and KASAN_VMALLOC is selected when KASAN is enabled, meeting the KASAN dependency requirements.

---
 arch/arm64/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/Kconfig +1 -0
index 393d71124f5d..179b302f43c2 100644
@@ -280,6 +280,7 @@ config ARM64
 	select HAVE_SOFTIRQ_ON_OWN_STACK
 	select USER_STACKTRACE_SUPPORT
 	select VDSO_GETRANDOM
+	select VMAP_STACK
 	help
 	  ARM 64-bit (AArch64) Linux support.
 
Signature · 1 line
2.47.1
#5 lore raw

PATCH 2/8 arm64: efi: Remove CONFIG_VMAP_STACK check

In reply to Breno Leitao

Remove the CONFIG_VMAP_STACK check in arm64_efi_rt_init() since VMAP_STACK is now always enabled on arm64.

The arch_alloc_vmap_stack() call will fail to build if VMAP_STACK is not set, providing sufficient protection without the explicit runtime check.

---
 arch/arm64/kernel/efi.c | 5 -----
 1 file changed, 5 deletions(-)
arch/arm64/kernel/efi.c +0 -5
index 62230d6dd919..6c371b158b99 100644
@@ -215,11 +215,6 @@ static int __init arm64_efi_rt_init(void)
 	if (!efi_enabled(EFI_RUNTIME_SERVICES))
 		return 0;
 
-	if (!IS_ENABLED(CONFIG_VMAP_STACK)) {
-		clear_bit(EFI_RUNTIME_SERVICES, &efi.flags);
-		return -ENOMEM;
-	}
-
 	p = arch_alloc_vmap_stack(THREAD_SIZE, NUMA_NO_NODE);
 	if (!p) {
 		pr_warn("Failed to allocate EFI runtime stack\n");
Signature · 1 line
2.47.1
#6 lore raw

PATCH 3/8 arm64: Remove CONFIG_VMAP_STACK conditionals from THREAD_SHIFT and THREAD_ALIGN

In reply to Breno Leitao

Now that VMAP_STACK is always enabled on arm64, remove the CONFIG_VMAP_STACK conditional logic from the definitions of THREAD_SHIFT and THREAD_ALIGN in arch/arm64/include/asm/memory.h. This simplifies the code by unconditionally setting THREAD_ALIGN to (2 * THREAD_SIZE) and adjusting the THREAD_SHIFT definition to only depend on MIN_THREAD_SHIFT and PAGE_SHIFT.

This change reflects the updated arm64 stack model, where all kernel threads use virtually mapped stacks with guard pages, and ensures alignment and stack sizing are consistently handled.

---
 arch/arm64/include/asm/memory.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
arch/arm64/include/asm/memory.h +1 -5
index 717829df294e..5213248e081b 100644
@@ -118,7 +118,7 @@
  * VMAP'd stacks are allocated at page granularity, so we must ensure that such
  * stacks are a multiple of page size.
  */
-#if defined(CONFIG_VMAP_STACK) && (MIN_THREAD_SHIFT < PAGE_SHIFT)
+#if (MIN_THREAD_SHIFT < PAGE_SHIFT)
 #define THREAD_SHIFT		PAGE_SHIFT
 #else
 #define THREAD_SHIFT		MIN_THREAD_SHIFT
@@ -135,11 +135,7 @@
  * checking sp & (1 << THREAD_SHIFT), which we can do cheaply in the entry
  * assembly.
  */
-#ifdef CONFIG_VMAP_STACK
 #define THREAD_ALIGN		(2 * THREAD_SIZE)
-#else
-#define THREAD_ALIGN		THREAD_SIZE
-#endif
 
 #define IRQ_STACK_SIZE		THREAD_SIZE
 
Signature · 1 line
2.47.1
#7 lore raw

PATCH 4/8 arm64: remove CONFIG_VMAP_STACK conditionals from irq stack setup

In reply to Breno Leitao

With VMAP_STACK always enabled on arm64, drop the CONFIG_VMAP_STACK checks and legacy irq stack allocation from arch/arm64/kernel/irq.c. The code now unconditionally uses the VMAP_STACK path for irq stack initialization, simplifying the logic.

---
 arch/arm64/kernel/irq.c | 13 -------------
 1 file changed, 13 deletions(-)
arch/arm64/kernel/irq.c +0 -13
index 85087e2df564..c0065a1d77cf 100644
@@ -51,7 +51,6 @@ static void init_irq_scs(void)
 			scs_alloc(early_cpu_to_node(cpu));
 }
 
-#ifdef CONFIG_VMAP_STACK
 static void __init init_irq_stacks(void)
 {
 	int cpu;
@@ -62,18 +61,6 @@ static void __init init_irq_stacks(void)
 		per_cpu(irq_stack_ptr, cpu) = p;
 	}
 }
-#else
-/* irq stack only needs to be 16 byte aligned - not IRQ_STACK_SIZE aligned. */
-DEFINE_PER_CPU_ALIGNED(unsigned long [IRQ_STACK_SIZE/sizeof(long)], irq_stack);
-
-static void init_irq_stacks(void)
-{
-	int cpu;
-
-	for_each_possible_cpu(cpu)
-		per_cpu(irq_stack_ptr, cpu) = per_cpu(irq_stack, cpu);
-}
-#endif
 
 #ifndef CONFIG_PREEMPT_RT
 static void ____do_softirq(struct pt_regs *regs)
Signature · 1 line
2.47.1
#8 lore raw

PATCH 5/8 arm64: remove CONFIG_VMAP_STACK conditionals from traps overflow stack

In reply to Breno Leitao

With VMAP_STACK now always enabled on arm64, remove the CONFIG_VMAP_STACK checks from overflow stack definitions and related code in arch/arm64/kernel/traps.c. The overflow_stack and panic_bad_stack() logic are now unconditionally included, simplifying the source and matching the mandatory stack model.

---
 arch/arm64/kernel/traps.c | 3 ---
 1 file changed, 3 deletions(-)
arch/arm64/kernel/traps.c +0 -3
index 9bfa5c944379..6acbcffca650 100644
@@ -894,8 +894,6 @@ void bad_el0_sync(struct pt_regs *regs, int reason, unsigned long esr)
 			      "Bad EL0 synchronous exception");
 }
 
-#ifdef CONFIG_VMAP_STACK
-
 DEFINE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack)
 	__aligned(16);
 
@@ -927,7 +925,6 @@ void __noreturn panic_bad_stack(struct pt_regs *regs, unsigned long esr, unsigne
 	nmi_panic(NULL, "kernel stack overflow");
 	cpu_park_loop();
 }
-#endif
 
 void __noreturn arm64_serror_panic(struct pt_regs *regs, unsigned long esr)
 {
Signature · 1 line
2.47.1
#0 lore raw

cover arm64: set VMAP_STACK by default

Hi all,

This patchset select VMAP_STACK on arm64 by default, and cleans up the code by removing all associated CONFIG_VMAP_STACK conditionals.

This is a suggestion from Will Deacon from another discussion[1].

With VMAP_STACK now always enabled on arm64, the code can be significantly simplified, reducing complexity and potential for misconfiguration.

Overview of Changes

* Remove all #ifdef CONFIG_VMAP_STACK and related runtime checks throughout the architecture codebase.
* Replace runtime checks with build-time assertions where appropriate.

---
Breno Leitao (8):
arm64: Enable VMAP_STACK support
arm64: efi: Remove CONFIG_VMAP_STACK check
arm64: Remove CONFIG_VMAP_STACK conditionals from THREAD_SHIFT and THREAD_ALIGN
arm64: remove CONFIG_VMAP_STACK conditionals from irq stack setup
arm64: remove CONFIG_VMAP_STACK conditionals from traps overflow stack
arm64: remove CONFIG_VMAP_STACK checks from stacktrace overflow logic
arm64: remove CONFIG_VMAP_STACK checks from SDEI stack handling
arm64: remove CONFIG_VMAP_STACK checks from entry code

 arch/arm64/Kconfig                  |  1 +
 arch/arm64/include/asm/memory.h     |  6 +-----
 arch/arm64/include/asm/stacktrace.h |  6 +-----
 arch/arm64/kernel/efi.c             |  5 -----
 arch/arm64/kernel/entry-common.c    |  2 --
 arch/arm64/kernel/entry.S           |  6 ------
 arch/arm64/kernel/irq.c             | 13 -------------
 arch/arm64/kernel/sdei.c            |  8 ++------
 arch/arm64/kernel/stacktrace.c      |  4 +---
 arch/arm64/kernel/traps.c           |  3 ---
 10 files changed, 6 insertions(+), 48 deletions(-)

---
base-commit: 9dd1757493416310a5e71146a08bc228869f8dae
change-id: 20250707-arm64_vmap-fa70ba3c9cfb

Best regards,

Signature · 1 line
Breno Leitao <[email protected]>
#9 lore raw

PATCH 6/8 arm64: remove CONFIG_VMAP_STACK checks from stacktrace overflow logic

With VMAP_STACK now always enabled on arm64, remove all CONFIG_VMAP_STACK conditionals from overflow stack handling in stacktrace code.

This change unconditionally defines the per-CPU overflow_stack and stackinfo_get_overflow() helper in arch/arm64/include/asm/stacktrace.h, and always includes the overflow stack in the stack_info array in arch/arm64/kernel/stacktrace.c. Also, drop redundant CONFIG_VMAP_STACK checks from SDEI stack declarations.

---
 arch/arm64/include/asm/stacktrace.h | 6 +-----
 arch/arm64/kernel/stacktrace.c      | 4 +---
 2 files changed, 2 insertions(+), 8 deletions(-)
arch/arm64/include/asm/stacktrace.h +1 -5
index 66ec8caa6ac0..6d3280932bf5 100644
@@ -59,7 +59,6 @@ static inline bool on_task_stack(const struct task_struct *tsk,
 
 #define on_thread_stack()	(on_task_stack(current, current_stack_pointer, 1))
 
-#ifdef CONFIG_VMAP_STACK
 DECLARE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack);
 
 static inline struct stack_info stackinfo_get_overflow(void)
@@ -72,11 +71,8 @@ static inline struct stack_info stackinfo_get_overflow(void)
 		.high = high,
 	};
 }
-#else
-#define stackinfo_get_overflow()	stackinfo_get_unknown()
-#endif
 
-#if defined(CONFIG_ARM_SDE_INTERFACE) && defined(CONFIG_VMAP_STACK)
+#if defined(CONFIG_ARM_SDE_INTERFACE)
 DECLARE_PER_CPU(unsigned long *, sdei_stack_normal_ptr);
 DECLARE_PER_CPU(unsigned long *, sdei_stack_critical_ptr);
 
arch/arm64/kernel/stacktrace.c +1 -3
index 1d9d51d7627f..e823320fe031 100644
@@ -332,10 +332,8 @@ kunwind_stack_walk(kunwind_consume_fn consume_state,
 	struct stack_info stacks[] = {
 		stackinfo_get_task(task),
 		STACKINFO_CPU(irq),
-#if defined(CONFIG_VMAP_STACK)
 		STACKINFO_CPU(overflow),
-#endif
-#if defined(CONFIG_VMAP_STACK) && defined(CONFIG_ARM_SDE_INTERFACE)
+#if defined(CONFIG_ARM_SDE_INTERFACE)
 		STACKINFO_SDEI(normal),
 		STACKINFO_SDEI(critical),
 #endif
Signature · 1 line
2.47.1
#11 lore raw

PATCH 8/8 arm64: remove CONFIG_VMAP_STACK checks from entry code

In reply to Breno Leitao

With VMAP_STACK now always enabled on arm64, remove all CONFIG_VMAP_STACK conditionals from entry handling in arch/arm64/kernel/entry-common.c and arch/arm64/kernel/entry.S.

This change unconditionally includes the bad stack handling and overflow detection logic, simplifying the code and reflecting the mandatory use of VMAP_STACK for all arm64 kernel builds.

---
 arch/arm64/kernel/entry-common.c | 2 --
 arch/arm64/kernel/entry.S        | 6 ------
 2 files changed, 8 deletions(-)
arch/arm64/kernel/entry-common.c +0 -2
index 7c1970b341b8..99a341ee7131 100644
@@ -977,7 +977,6 @@ UNHANDLED(el0t, 32, fiq)
 UNHANDLED(el0t, 32, error)
 #endif /* CONFIG_COMPAT */
 
-#ifdef CONFIG_VMAP_STACK
 asmlinkage void noinstr __noreturn handle_bad_stack(struct pt_regs *regs)
 {
 	unsigned long esr = read_sysreg(esr_el1);
@@ -986,7 +985,6 @@ asmlinkage void noinstr __noreturn handle_bad_stack(struct pt_regs *regs)
 	arm64_enter_nmi(regs);
 	panic_bad_stack(regs, esr, far);
 }
-#endif /* CONFIG_VMAP_STACK */
 
 #ifdef CONFIG_ARM_SDE_INTERFACE
 asmlinkage noinstr unsigned long
arch/arm64/kernel/entry.S +0 -6
index 5ae2a34b50bd..ea74cb7aac5b 100644
@@ -55,7 +55,6 @@
 	.endif
 
 	sub	sp, sp, #PT_REGS_SIZE
-#ifdef CONFIG_VMAP_STACK
 	/*
 	 * Test whether the SP has overflowed, without corrupting a GPR.
 	 * Task and IRQ stacks are aligned so that SP & (1 << THREAD_SHIFT)
@@ -97,7 +96,6 @@
 	/* We were already on the overflow stack. Restore sp/x0 and carry on. */
 	sub	sp, sp, x0
 	mrs	x0, tpidrro_el0
-#endif
 	b	el\el\ht\()_\regsize\()_\label
 .org .Lventry_start\@ + 128	// Did we overflow the ventry slot?
 	.endm
@@ -540,7 +538,6 @@ SYM_CODE_START(vectors)
 	kernel_ventry	0, t, 32, error		// Error 32-bit EL0
 SYM_CODE_END(vectors)
 
-#ifdef CONFIG_VMAP_STACK
 SYM_CODE_START_LOCAL(__bad_stack)
 	/*
 	 * We detected an overflow in kernel_ventry, which switched to the
@@ -568,7 +565,6 @@ SYM_CODE_START_LOCAL(__bad_stack)
 	bl	handle_bad_stack
 	ASM_BUG()
 SYM_CODE_END(__bad_stack)
-#endif /* CONFIG_VMAP_STACK */
 
 
 	.macro entry_handler el:req, ht:req, regsize:req, label:req
@@ -1003,7 +999,6 @@ SYM_CODE_START(__sdei_asm_handler)
 1:	adr_this_cpu dst=x5, sym=sdei_active_critical_event, tmp=x6
 2:	str	x19, [x5]
 
-#ifdef CONFIG_VMAP_STACK
 	/*
 	 * entry.S may have been using sp as a scratch register, find whether
 	 * this is a normal or critical event and switch to the appropriate
@@ -1016,7 +1011,6 @@ SYM_CODE_START(__sdei_asm_handler)
 2:	mov	x6, #SDEI_STACK_SIZE
 	add	x5, x5, x6
 	mov	sp, x5
-#endif
 
 #ifdef CONFIG_SHADOW_CALL_STACK
 	/* Use a separate shadow call stack for normal and critical events */
Signature · 1 line
2.47.1
#10 lore raw

PATCH 7/8 arm64: remove CONFIG_VMAP_STACK checks from SDEI stack handling

In reply to Breno Leitao

With VMAP_STACK now always enabled on arm64, remove all CONFIG_VMAP_STACK conditionals from SDEI stack allocation and initialization in arch/arm64/kernel/sdei.c.

This change unconditionally defines the SDEI stack pointers and replaces runtime checks with BUILD_BUG_ON() assertions, ensuring that the code is only built when VMAP_STACK is enabled. This simplifies the logic and reflects the mandatory use of VMAP_STACK for all arm64 kernel builds.

---
 arch/arm64/kernel/sdei.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
arch/arm64/kernel/sdei.c +2 -6
index 255d12f881c2..6f24a0251e18 100644
@@ -34,10 +34,8 @@ unsigned long sdei_exit_mode;
 DECLARE_PER_CPU(unsigned long *, sdei_stack_normal_ptr);
 DECLARE_PER_CPU(unsigned long *, sdei_stack_critical_ptr);
 
-#ifdef CONFIG_VMAP_STACK
 DEFINE_PER_CPU(unsigned long *, sdei_stack_normal_ptr);
 DEFINE_PER_CPU(unsigned long *, sdei_stack_critical_ptr);
-#endif
 
 DECLARE_PER_CPU(unsigned long *, sdei_shadow_call_stack_normal_ptr);
 DECLARE_PER_CPU(unsigned long *, sdei_shadow_call_stack_critical_ptr);
@@ -65,8 +63,7 @@ static void free_sdei_stacks(void)
 {
 	int cpu;
 
-	if (!IS_ENABLED(CONFIG_VMAP_STACK))
-		return;
+	BUILD_BUG_ON(!IS_ENABLED(CONFIG_VMAP_STACK));
 
 	for_each_possible_cpu(cpu) {
 		_free_sdei_stack(&sdei_stack_normal_ptr, cpu);
@@ -91,8 +88,7 @@ static int init_sdei_stacks(void)
 	int cpu;
 	int err = 0;
 
-	if (!IS_ENABLED(CONFIG_VMAP_STACK))
-		return 0;
+	BUILD_BUG_ON(!IS_ENABLED(CONFIG_VMAP_STACK));
 
 	for_each_possible_cpu(cpu) {
 		err = _init_sdei_stack(&sdei_stack_normal_ptr, cpu);
Signature · 1 line
2.47.1
reviewer
#2 lore raw

Re: [PATCH 1/8] arm64: Enable VMAP_STACK support

In reply to Breno Leitao

Hi Breno,

Quoted 11 lines · Breno Leitao

Enable virtually mapped kernel stacks for ARM64. This provides better stack overflow detection and improved security by mapping kernel stacks in vmalloc space rather than using direct mapping.

VMAP_STACK helps catch stack overflows early by placing guard pages around kernel stacks, and also provides better isolation between kernel stacks and other kernel data structures.

All dependencies are satisfied for arm64: HAVE_ARCH_VMAP_STACK is already selected above, and KASAN_VMALLOC is selected when KASAN is enabled, meeting the KASAN dependency requirements.

I reckon it might be better to say something like:

| arm64: Mandate VMAP_STACK
|
| On arm64, VMAP_STACK has been enabled by default for a while now, and
| the only reason to disable it was a historical lack of support for
| KASAN_VMALLOC. Today there's no good reason to disable VMAP_STACK.
|
| Mandate VMAP_STACK, which will allow code to be simplified in
| subsequent patches.

... to make it clear that we're not changing the default, and we are removing the ability to deselect VMAP_STACK.

Either way, the patch itself looks good to me.

Mark.

Quoted 23 lines
---
 arch/arm64/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/Kconfig +1 -0
index 393d71124f5d..179b302f43c2 100644
@@ -280,6 +280,7 @@ config ARM64
 	select HAVE_SOFTIRQ_ON_OWN_STACK
 	select USER_STACKTRACE_SUPPORT
 	select VDSO_GETRANDOM
+	select VMAP_STACK
 	help
 	  ARM 64-bit (AArch64) Linux support.
 
Signature · 2 lines
-- 
2.47.1
reviewer Acked-by on the v1 series
#12 lore raw
In reply to Breno Leitao
Quoted 13 lines · Breno Leitao

Hi all,

This patchset select VMAP_STACK on arm64 by default, and cleans up the code by removing all associated CONFIG_VMAP_STACK conditionals.

This is a suggestion from Will Deacon from another discussion[1].

With VMAP_STACK now always enabled on arm64, the code can be significantly simplified, reducing complexity and potential for misconfiguration.

Overview of Changes

Quoted 8 lines

* Remove all #ifdef CONFIG_VMAP_STACK and related runtime checks throughout the architecture codebase.
* Replace runtime checks with build-time assertions where appropriate.

Nice!

Aside from a minor comment on the first patch, this all looks good to me. For the series:

Mark.

Quoted 30 lines

---
Breno Leitao (8):
arm64: Enable VMAP_STACK support
arm64: efi: Remove CONFIG_VMAP_STACK check
arm64: Remove CONFIG_VMAP_STACK conditionals from THREAD_SHIFT and THREAD_ALIGN
arm64: remove CONFIG_VMAP_STACK conditionals from irq stack setup
arm64: remove CONFIG_VMAP_STACK conditionals from traps overflow stack
arm64: remove CONFIG_VMAP_STACK checks from stacktrace overflow logic
arm64: remove CONFIG_VMAP_STACK checks from SDEI stack handling
arm64: remove CONFIG_VMAP_STACK checks from entry code

 arch/arm64/Kconfig                  |  1 +
 arch/arm64/include/asm/memory.h     |  6 +-----
 arch/arm64/include/asm/stacktrace.h |  6 +-----
 arch/arm64/kernel/efi.c             |  5 -----
 arch/arm64/kernel/entry-common.c    |  2 --
 arch/arm64/kernel/entry.S           |  6 ------
 arch/arm64/kernel/irq.c             | 13 -------------
 arch/arm64/kernel/sdei.c            |  8 ++------
 arch/arm64/kernel/stacktrace.c      |  4 +---
 arch/arm64/kernel/traps.c           |  3 ---
 10 files changed, 6 insertions(+), 48 deletions(-)

---
base-commit: 9dd1757493416310a5e71146a08bc228869f8dae
change-id: 20250707-arm64_vmap-fa70ba3c9cfb

Best regards,

Signature · 1 line
Breno Leitao <[email protected]>
maintainer Acked-by on the v1 series
#13 lore raw
In reply to Breno Leitao
Quoted 22 lines · Breno Leitao

Hi all,

This patchset select VMAP_STACK on arm64 by default, and cleans up the code by removing all associated CONFIG_VMAP_STACK conditionals.

This is a suggestion from Will Deacon from another discussion[1].

With VMAP_STACK now always enabled on arm64, the code can be significantly simplified, reducing complexity and potential for misconfiguration.

Overview of Changes

* Remove all #ifdef CONFIG_VMAP_STACK and related runtime checks throughout the architecture codebase.
* Replace runtime checks with build-time assertions where appropriate.

Quoted 11 lines

---
Breno Leitao (8):
arm64: Enable VMAP_STACK support
arm64: efi: Remove CONFIG_VMAP_STACK check
arm64: Remove CONFIG_VMAP_STACK conditionals from THREAD_SHIFT and THREAD_ALIGN
arm64: remove CONFIG_VMAP_STACK conditionals from irq stack setup
arm64: remove CONFIG_VMAP_STACK conditionals from traps overflow stack
arm64: remove CONFIG_VMAP_STACK checks from stacktrace overflow logic
arm64: remove CONFIG_VMAP_STACK checks from SDEI stack handling
arm64: remove CONFIG_VMAP_STACK checks from entry code

For the series,

#3 lore raw

Re: [PATCH 1/8] arm64: Enable VMAP_STACK support

In reply to Mark Rutland

Hello Mark,

Quoted 24 lines · Mark Rutland
Quoted 11 lines · Breno Leitao

Enable virtually mapped kernel stacks for ARM64. This provides better stack overflow detection and improved security by mapping kernel stacks in vmalloc space rather than using direct mapping.

VMAP_STACK helps catch stack overflows early by placing guard pages around kernel stacks, and also provides better isolation between kernel stacks and other kernel data structures.

All dependencies are satisfied for arm64: HAVE_ARCH_VMAP_STACK is already selected above, and KASAN_VMALLOC is selected when KASAN is enabled, meeting the KASAN dependency requirements.

I reckon it might be better to say something like:

| arm64: Mandate VMAP_STACK
|
| On arm64, VMAP_STACK has been enabled by default for a while now, and
| the only reason to disable it was a historical lack of support for
| KASAN_VMALLOC. Today there's no good reason to disable VMAP_STACK.
|
| Mandate VMAP_STACK, which will allow code to be simplified in
| subsequent patches.
Quoted 4 lines

... to make it clear that we're not changing the default, and we are removing the ability to deselect VMAP_STACK.

Either way, the patch itself looks good to me.

Thanks for the suggestion. I will update and respin.

Thanks for the review,
--breno

maintainer
#4 lore raw

Re: [PATCH 1/8] arm64: Enable VMAP_STACK support

Hey Breno,

Thanks for doing this.

Quoted 25 lines · Breno Leitao
Quoted 24 lines · Mark Rutland
Quoted 11 lines · Breno Leitao

Enable virtually mapped kernel stacks for ARM64. This provides better stack overflow detection and improved security by mapping kernel stacks in vmalloc space rather than using direct mapping.

VMAP_STACK helps catch stack overflows early by placing guard pages around kernel stacks, and also provides better isolation between kernel stacks and other kernel data structures.

All dependencies are satisfied for arm64: HAVE_ARCH_VMAP_STACK is already selected above, and KASAN_VMALLOC is selected when KASAN is enabled, meeting the KASAN dependency requirements.

I reckon it might be better to say something like:

| arm64: Mandate VMAP_STACK
|
| On arm64, VMAP_STACK has been enabled by default for a while now, and
| the only reason to disable it was a historical lack of support for
| KASAN_VMALLOC. Today there's no good reason to disable VMAP_STACK.
|
| Mandate VMAP_STACK, which will allow code to be simplified in
| subsequent patches.
Quoted 6 lines
Quoted 4 lines

... to make it clear that we're not changing the default, and we are removing the ability to deselect VMAP_STACK.

Either way, the patch itself looks good to me.

Thanks for the suggestion. I will update and respin.

No need to respin just for that; I can fold the above when I apply.

Cheers,

Will

maintainer Applied
#14 lore raw
In reply to Breno Leitao
Quoted 10 lines · Breno Leitao

This patchset select VMAP_STACK on arm64 by default, and cleans up the code by removing all associated CONFIG_VMAP_STACK conditionals.

This is a suggestion from Will Deacon from another discussion[1].

With VMAP_STACK now always enabled on arm64, the code can be significantly simplified, reducing complexity and potential for misconfiguration.

[...]

Applied to arm64 (for-next/vmap-stack), thanks!

[1/8] arm64: Enable VMAP_STACK support

      https://git.kernel.org/arm64/c/ef6861b8e6dd
[2/8] arm64: efi: Remove CONFIG_VMAP_STACK check
      https://git.kernel.org/arm64/c/63829521a8e8
[3/8] arm64: Remove CONFIG_VMAP_STACK conditionals from THREAD_SHIFT and THREAD_ALIGN
      https://git.kernel.org/arm64/c/0909c719c17b
[4/8] arm64: remove CONFIG_VMAP_STACK conditionals from irq stack setup
      https://git.kernel.org/arm64/c/c4a5699d5cef
[5/8] arm64: remove CONFIG_VMAP_STACK conditionals from traps overflow stack
      https://git.kernel.org/arm64/c/e5692bba1e66
[6/8] arm64: remove CONFIG_VMAP_STACK checks from stacktrace overflow logic
      https://git.kernel.org/arm64/c/907cb5cd8efd
[7/8] arm64: remove CONFIG_VMAP_STACK checks from SDEI stack handling
      https://git.kernel.org/arm64/c/3e72b9e9f01a
[8/8] arm64: remove CONFIG_VMAP_STACK checks from entry code
      https://git.kernel.org/arm64/c/9d1869f0f537

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev