aboutsummaryrefslogtreecommitdiff
path: root/asm
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-11-17 18:22:04 +1100
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-11-17 18:22:04 +1100
commit71664fd8d2d2550a56cc6a9c2b81797bfe90d613 (patch)
tree6f55e009ff6a8b00f9f1c7a905ad4075225dec93 /asm
parent31d20fc02c8ee7c12d84bc28ce732bbc362ce369 (diff)
downloadskiboot-71664fd8d2d2550a56cc6a9c2b81797bfe90d613.zip
skiboot-71664fd8d2d2550a56cc6a9c2b81797bfe90d613.tar.gz
skiboot-71664fd8d2d2550a56cc6a9c2b81797bfe90d613.tar.bz2
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 <benh@kernel.crashing.org>
Diffstat (limited to 'asm')
-rw-r--r--asm/asm-offsets.c4
-rw-r--r--asm/head.S8
-rw-r--r--asm/misc.S9
3 files changed, 20 insertions, 1 deletions
diff --git a/asm/asm-offsets.c b/asm/asm-offsets.c
index e33c181..4fb2344 100644
--- a/asm/asm-offsets.c
+++ b/asm/asm-offsets.c
@@ -36,6 +36,10 @@ int main(void)
OFFSET(CPUTHREAD_SAVE_R1, cpu_thread, save_r1);
OFFSET(CPUTHREAD_STATE, cpu_thread, state);
OFFSET(CPUTHREAD_CUR_TOKEN, cpu_thread, current_token);
+ DEFINE(CPUTHREAD_GAP, sizeof(struct cpu_thread) + STACK_SAFETY_GAP);
+ OFFSET(CPUTHREAD_STACK_BOT_MARK, cpu_thread, stack_bot_mark);
+ OFFSET(CPUTHREAD_STACK_BOT_PC, cpu_thread, stack_bot_pc);
+ OFFSET(CPUTHREAD_STACK_BOT_TOK, cpu_thread, stack_bot_tok);
OFFSET(STACK_TYPE, stack_frame, type);
OFFSET(STACK_LOCALS, stack_frame, locals);
diff --git a/asm/head.S b/asm/head.S
index a56f2bb..75eb170 100644
--- a/asm/head.S
+++ b/asm/head.S
@@ -308,8 +308,14 @@ boot_entry:
addi %r3,%r3,8
bdnz 1b
- /* Jump to C */
+ /* Get our per-cpu pointer into r13 */
GET_CPU()
+
+ /* Initialize stack bottom mark to 0, it will be updated in C code */
+ li %r0,0
+ std %r0,CPUTHREAD_STACK_BOT_MARK(%r13)
+
+ /* Jump to C */
mr %r3,%r27
mr %r4,%r25
bl main_cpu_entry
diff --git a/asm/misc.S b/asm/misc.S
index ccb30d1..00c7f78 100644
--- a/asm/misc.S
+++ b/asm/misc.S
@@ -17,6 +17,7 @@
#include <asm-utils.h>
#include <asm-offsets.h>
#include <processor.h>
+#include <stack.h>
.section ".text","ax"
.balign 0x10
@@ -41,3 +42,11 @@ trigger_attn:
isync
attn
blr
+
+#ifdef STACK_CHECK_ENABLED
+.global _mcount
+_mcount:
+ mr %r3,%r1
+ mflr %r4
+ b __mcount_stack_check
+#endif