1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/cortexm: clear FPU state in cpu_switch_context_exit()

This commit is contained in:
Kaspar Schleiser 2022-10-05 22:17:26 +02:00
parent 6257e328c0
commit 5cc43e5d5e

View File

@ -282,6 +282,16 @@ void *thread_isr_stack_start(void)
void NORETURN cpu_switch_context_exit(void)
{
#ifdef MODULE_CORTEXM_FPU
/* An exiting thread won't need it's FPU state anymore, so clear it here.
* This is important, as `sched_task_exit` clears `sched_active_thread`,
* which in turn causes `isr_pendsv` to skip all FPU storing/restoring.
* That might lead to this thread's FPU lazy stacking / FPCAR to stay active.
*/
__set_FPSCR(0);
__set_CONTROL(__get_CONTROL() & (~(CONTROL_FPCA_Msk)));
#endif
/* enable IRQs to make sure the PENDSV interrupt is reachable */
irq_enable();