From ba7fda70ff29b4c18e2baa4ec6d686142ccafe6d Mon Sep 17 00:00:00 2001 From: Stephanos Ioannidis Date: Wed, 25 Aug 2021 03:26:51 +0900 Subject: [PATCH] tests: arch: arm_no_multithreading: Fix FPSCR validation for ARMv8.1-M This commit fixes the FPSCR register initialisation validation test for the ARMv8.1-M architecture. For ARMv8.1-M, the newly added LTPSIZE field in the FPSCR may always read the value of 4 when the M-Profile Vector Extension (MVE) is not implemented or FP context is not active, so we must ignore its value when validating the FPSCR register initialisation. Signed-off-by: Stephanos Ioannidis --- tests/arch/arm/arm_no_multithreading/src/main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/arch/arm/arm_no_multithreading/src/main.c b/tests/arch/arm/arm_no_multithreading/src/main.c index 75964163b79..198d7f8dae0 100644 --- a/tests/arch/arm/arm_no_multithreading/src/main.c +++ b/tests/arch/arm/arm_no_multithreading/src/main.c @@ -13,6 +13,16 @@ #error test can only run on Cortex-M MCUs #endif +#if defined(CONFIG_ARMV8_1_M_MAINLINE) +/* + * For ARMv8.1-M, the FPSCR[18:16] LTPSIZE field may always read 0b010 if MVE + * is not implemented, so mask it when validating the value of the FPSCR. + */ +#define FPSCR_MASK (~FPU_FPDSCR_LTPSIZE_Msk) +#else +#define FPSCR_MASK (0xffffffffU) +#endif + extern K_THREAD_STACK_DEFINE(z_main_stack, CONFIG_MAIN_STACK_SIZE); static volatile int test_flag; @@ -58,7 +68,7 @@ void test_main(void) psp, main_stack_base, main_stack_top); #if defined(CONFIG_FPU) - __ASSERT(__get_FPSCR() == 0, + __ASSERT((__get_FPSCR() & FPSCR_MASK) == 0, "FPSCR not zero (0x%x)", __get_FPSCR()); #endif