tests: arch: arm_thread_swap: 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 <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2021-08-25 03:17:46 +09:00 committed by Anas Nashif
commit 06b1501694

View file

@ -30,6 +30,16 @@
#define EXC_RETURN_FTYPE (0x00000010UL) #define EXC_RETURN_FTYPE (0x00000010UL)
#endif #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 void z_move_thread_to_end_of_prio_q(struct k_thread *thread); extern void z_move_thread_to_end_of_prio_q(struct k_thread *thread);
static struct k_thread alt_thread; static struct k_thread alt_thread;
@ -278,7 +288,7 @@ static void alt_thread_entry(void)
/* Verify that the _current_ (alt) thread is initialized with FPSCR cleared. */ /* Verify that the _current_ (alt) thread is initialized with FPSCR cleared. */
zassert_true(__get_FPSCR() == 0, zassert_true((__get_FPSCR() & FPSCR_MASK) == 0,
"(Alt thread) FPSCR is not cleared at initialization: 0x%x\n", __get_FPSCR()); "(Alt thread) FPSCR is not cleared at initialization: 0x%x\n", __get_FPSCR());
zassert_true((p_ztest_thread->arch.mode_exc_return & EXC_RETURN_FTYPE) == 0, zassert_true((p_ztest_thread->arch.mode_exc_return & EXC_RETURN_FTYPE) == 0,
@ -461,7 +471,7 @@ void test_arm_thread_swap(void)
"CONTROL.FPCA is not cleared at initialization: 0x%x\n", "CONTROL.FPCA is not cleared at initialization: 0x%x\n",
__get_CONTROL()); __get_CONTROL());
/* Verify that the main test thread is initialized with FPSCR cleared. */ /* Verify that the main test thread is initialized with FPSCR cleared. */
zassert_true(__get_FPSCR() == 0, zassert_true((__get_FPSCR() & FPSCR_MASK) == 0,
"FPSCR is not cleared at initialization: 0x%x\n", __get_FPSCR()); "FPSCR is not cleared at initialization: 0x%x\n", __get_FPSCR());
/* Clear the thread's floating-point callee-saved registers' container. /* Clear the thread's floating-point callee-saved registers' container.