aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2017-10-03 13:25:46 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2017-10-04 12:37:33 -0400
commitb02faed15d86f846b0f23f47b92e0782baa873ed (patch)
tree7dbbaa5b79d23c74241be5acfc4666a2456ca0cf
parent37f6b42e9c2966b08c7df5cfddc0d73c39cead4a (diff)
arm64: Use larger stacks when KASAN is selected
AddressSanitizer instrumentation can significantly bloat the stack, and with GCC 7 this can result in stack overflows at boot time in some configurations. We can avoid this by doubling our stack size when KASAN is in use, as is already done on x86 (and has been since KASAN was introduced). Regardless of other patches to decrease KASAN's stack utilization, kernels built with KASAN will always require more stack space than those built without, and we should take this into account. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r--arch/arm64/include/asm/memory.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 3585a5e26151..f7c4d2146aed 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -95,16 +95,19 @@
95#define KERNEL_END _end 95#define KERNEL_END _end
96 96
97/* 97/*
98 * The size of the KASAN shadow region. This should be 1/8th of the 98 * KASAN requires 1/8th of the kernel virtual address space for the shadow
99 * size of the entire kernel virtual address space. 99 * region. KASAN can bloat the stack significantly, so double the (minimum)
100 * stack size when KASAN is in use.
100 */ 101 */
101#ifdef CONFIG_KASAN 102#ifdef CONFIG_KASAN
102#define KASAN_SHADOW_SIZE (UL(1) << (VA_BITS - 3)) 103#define KASAN_SHADOW_SIZE (UL(1) << (VA_BITS - 3))
104#define KASAN_THREAD_SHIFT 1
103#else 105#else
104#define KASAN_SHADOW_SIZE (0) 106#define KASAN_SHADOW_SIZE (0)
107#define KASAN_THREAD_SHIFT 0
105#endif 108#endif
106 109
107#define MIN_THREAD_SHIFT 14 110#define MIN_THREAD_SHIFT (14 + KASAN_THREAD_SHIFT)
108 111
109/* 112/*
110 * VMAP'd stacks are allocated at page granularity, so we must ensure that such 113 * VMAP'd stacks are allocated at page granularity, so we must ensure that such