From 71664fd8d2d2550a56cc6a9c2b81797bfe90d613 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Mon, 17 Nov 2014 18:22:04 +1100 Subject: Stack checking extensions This patch adds: - Normal builds are done with -fstack-protector (we want to investigate using -fstack-protector-strong on gcc4.9 but for now we just use that - Build with STACK_CHECK=1 will use -fstack-protector-all and -pg and will check the stack in mcount Signed-off-by: Benjamin Herrenschmidt --- include/stack.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/stack.h') diff --git a/include/stack.h b/include/stack.h index 6eedc01d..57771b4d 100644 --- a/include/stack.h +++ b/include/stack.h @@ -17,6 +17,8 @@ #ifndef __STACKFRAME_H #define __STACKFRAME_H +#include + #define STACK_ENTRY_OPAL_API 0 /* OPAL call */ #define STACK_ENTRY_MCHECK 0x0200 /* Machine check */ #define STACK_ENTRY_HMI 0x0e60 /* Hypervisor maintainance */ @@ -39,6 +41,16 @@ /* Offset to get to machine check CPU stacks */ #define CPU_MC_STACKS_OFFSET (CPU_STACKS_BASE + STACK_SIZE - STACK_TOP_GAP) +/* Gap below the stack. If our stack checker sees the stack below that + * gap, it will flag a stack overflow + */ +#define STACK_SAFETY_GAP 512 + +/* Warning threshold, if stack goes below that on mcount, print a + * warning + */ +#define STACK_WARNING_GAP 1024 + #ifndef __ASSEMBLY__ #include -- cgit v1.2.1