Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arch: arm: mpu: Fix BUILD_ASSERT on pointer value #86415

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions include/zephyr/arch/arm/mpu/arm_mpu_v7m.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,23 @@ typedef struct {

#endif /* _ASMLANGUAGE */

#define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \
#define _ARCH_MEM_PARTITION_ALIGN_CHECK_SIZE(start, size) \
BUILD_ASSERT(!(((size) & ((size) - 1))) && \
(size) >= CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE && \
!((uint32_t)(start) & ((size) - 1)), \
(size) >= CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE, \
"The size of the partition must be power of 2 and greater than or equal to " \
"the minimum MPU region size.\n")

/* Some compilers do not handle BUILD_ASSERT on the values of pointers.*/
#if defined(__IAR_SYSTEMS_ICC__)
#define _ARCH_MEM_PARTITION_ALIGN_CHECK_START(start, size)
#else
#define _ARCH_MEM_PARTITION_ALIGN_CHECK_START(start, size) \
BUILD_ASSERT(!((uint32_t)(start) & ((size) - 1)), \
"The size of the partition must be power of 2 and greater than or equal to " \
"the minimum MPU region size.\n" \
"The start address of the partition must align with size.")
#endif

#define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \
_ARCH_MEM_PARTITION_ALIGN_CHECK_SIZE(start, size); \
_ARCH_MEM_PARTITION_ALIGN_CHECK_START(start, size)
Loading