From 518bfa39e349477fffd687cb3fda3deb7ccd47fa Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Thu, 13 Jun 2019 13:41:16 +0200 Subject: [PATCH] arch: arm: introduce macro to describe the privilege stack alignment We introduce a new define to describe the alignment for a privilege stack buffer. This macro definition is used by the privilege stack generation script, to determine the required alignment of threads' privilege stacks when building with support for user mode. We cannot use Z_THREAD_MIN_STACK_ALIGN in this case, because the privilege stacks do not need to respect the minimum MPU region alignment requirement, unless, of course, this is enforced via the MPU Stack Guard feature. Signed-off-by: Ioannis Glaropoulos --- include/arch/arm/arch.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/arch/arm/arch.h b/include/arch/arm/arch.h index 84045a76d2d..0f199a9a291 100644 --- a/include/arch/arm/arch.h +++ b/include/arch/arm/arch.h @@ -155,6 +155,21 @@ extern "C" { */ #define STACK_ALIGN MAX(Z_THREAD_MIN_STACK_ALIGN, Z_MPU_GUARD_ALIGN) +/** + * @brief Define alignment of a privilege stack buffer + * + * This is used to determine the required alignment of threads' + * privilege stacks when building with support for user mode. + * + * @note + * The privilege stacks do not need to respect the minimum MPU + * region alignment requirement (unless this is enforced via + * the MPU Stack Guard feature). + */ +#if defined(CONFIG_USERSPACE) +#define Z_PRIVILEGE_STACK_ALIGN MAX(STACK_ALIGN_SIZE, Z_MPU_GUARD_ALIGN) +#endif + /** * @brief Calculate power of two ceiling for a buffer size input *