arm: mpu: fix: align stack for mpu stack guard

The mimimum mpu size is 32 bytes, but requires mpu base address to be
aligned on 32 bytes to work. Define architecture thread macro when
MPU_STACK_GUARD config to allocate stack with 32 more bytes.

Signed-off-by: Michel Jaouen <michel.jaouen@st.com>
This commit is contained in:
Michel Jaouen 2017-06-27 09:02:47 +02:00 committed by Kumar Gala
commit deeaa40e1e
3 changed files with 91 additions and 3 deletions

View file

@ -24,7 +24,7 @@ void configure_mpu_stack_guard(struct k_thread *thread)
{
arm_core_mpu_disable();
arm_core_mpu_configure(THREAD_STACK_GUARD_REGION,
thread->stack_info.start,
thread->stack_info.start - STACK_ALIGN,
thread->stack_info.size);
arm_core_mpu_enable();
}

View file

@ -64,8 +64,8 @@ void _new_thread(struct k_thread *thread, k_thread_stack_t stack,
char *stackEnd = pStackMem + stackSize;
struct __esf *pInitCtx;
_new_thread_init(thread, pStackMem, stackSize, priority, options);
_new_thread_init(thread, K_THREAD_STACK_BUFFER(pStackMem), stackSize,
priority, options);
/* carve the thread entry struct from the "base" of the stack */