From a6c5a7e0b68ea9b9eed98997b85fe49434eeb1c8 Mon Sep 17 00:00:00 2001 From: Daniel Krueger Date: Tue, 17 Mar 2015 14:02:59 +0000 Subject: arm: Align ARM exception frame to 8 bytes The stack pointer must be aligned on 8 byte boundary on ARM, so the size of the exception frame must be a multiple of 8 bytes. Otherwise we might/will get an alignment fault, when executing code in the data abort handler for example. Close #2318. Signed-off-by: Daniel Krueger --- cpukit/score/cpu/arm/cpu.c | 5 +++++ cpukit/score/cpu/arm/rtems/score/cpu.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cpukit/score/cpu/arm/cpu.c b/cpukit/score/cpu/arm/cpu.c index 9942c4a40e..944ca630c7 100644 --- a/cpukit/score/cpu/arm/cpu.c +++ b/cpukit/score/cpu/arm/cpu.c @@ -63,6 +63,11 @@ RTEMS_STATIC_ASSERT( ARM_EXCEPTION_FRAME_SIZE ); +RTEMS_STATIC_ASSERT( + sizeof( CPU_Exception_frame ) % CPU_STACK_ALIGNMENT == 0, + CPU_Exception_frame_alignment +); + RTEMS_STATIC_ASSERT( offsetof( CPU_Exception_frame, register_sp ) == ARM_EXCEPTION_FRAME_REGISTER_SP_OFFSET, diff --git a/cpukit/score/cpu/arm/rtems/score/cpu.h b/cpukit/score/cpu/arm/rtems/score/cpu.h index ca8a09fbf9..6aced79b3b 100644 --- a/cpukit/score/cpu/arm/rtems/score/cpu.h +++ b/cpukit/score/cpu/arm/rtems/score/cpu.h @@ -222,7 +222,7 @@ #endif #endif -#define ARM_EXCEPTION_FRAME_SIZE 76 +#define ARM_EXCEPTION_FRAME_SIZE 80 #define ARM_EXCEPTION_FRAME_REGISTER_SP_OFFSET 52 @@ -687,6 +687,7 @@ typedef struct { uint32_t vector; #endif const ARM_VFP_context *vfp_context; + uint32_t reserved_for_stack_alignment; } CPU_Exception_frame; typedef CPU_Exception_frame CPU_Interrupt_frame; -- cgit v1.2.3