summaryrefslogtreecommitdiff
path: root/sys/arch/arm/include/frame.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/arm/include/frame.h')
-rw-r--r--sys/arch/arm/include/frame.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/arch/arm/include/frame.h b/sys/arch/arm/include/frame.h
index 31b2936a865..e2031486c28 100644
--- a/sys/arch/arm/include/frame.h
+++ b/sys/arch/arm/include/frame.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: frame.h,v 1.7 2016/01/31 00:14:50 jsg Exp $ */
+/* $OpenBSD: frame.h,v 1.8 2016/04/24 01:31:02 patrick Exp $ */
/* $NetBSD: frame.h,v 1.9 2003/12/01 08:48:33 scw Exp $ */
/*
@@ -75,6 +75,7 @@ typedef struct trapframe {
register_t tf_svc_sp;
register_t tf_svc_lr;
register_t tf_pc;
+ register_t tf_pad;
} trapframe_t;
/* Register numbers */
@@ -137,6 +138,7 @@ typedef struct irqframe {
unsigned int if_svc_sp;
unsigned int if_svc_lr;
unsigned int if_pc;
+ unsigned int if_pad;
} irqframe_t;
#define clockframe irqframe
@@ -146,6 +148,7 @@ typedef struct irqframe {
*/
struct switchframe {
+ u_int sf_pad;
u_int sf_r4;
u_int sf_r5;
u_int sf_r6;
@@ -203,6 +206,7 @@ struct frame {
*/
#define PUSHFRAME \
+ sub sp, sp, #4; /* Align the stack */ \
str lr, [sp, #-4]!; /* Push the return address */ \
sub sp, sp, #(4*17); /* Adjust the stack pointer */ \
stmia sp, {r0-r14}^; /* Push the user mode registers */ \
@@ -221,7 +225,8 @@ struct frame {
ldmia sp, {r0-r14}^; /* Restore registers (usr mode) */ \
mov r0, r0; /* NOP for previous instruction */ \
add sp, sp, #(4*17); /* Adjust the stack pointer */ \
- ldr lr, [sp], #0x0004 /* Pull the return address */
+ ldr lr, [sp], #0x0004; /* Pull the return address */ \
+ add sp, sp, #4 /* Align the stack */
/*
* PUSHFRAMEINSVC - macro to push a trap frame on the stack in SVC32 mode
@@ -241,6 +246,8 @@ struct frame {
orr r2, r2, #(PSR_SVC32_MODE); \
msr cpsr_c, r2; /* Punch into SVC mode */ \
mov r2, sp; /* Save SVC sp */ \
+ bic sp, sp, #7; /* Align sp to an 8-byte address */ \
+ sub sp, sp, #4; /* Pad trapframe to keep alignment */ \
str r0, [sp, #-4]!; /* Push return address */ \
str lr, [sp, #-4]!; /* Push SVC lr */ \
str r2, [sp, #-4]!; /* Push SVC sp */ \