1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #18697 from kaspar030/cortexm_clear_fpu_state_on_thread_exit

cpu/cortexm: clear FPU state in `cpu_switch_context_exit()`
This commit is contained in:
Marian Buschsieweke 2022-10-06 19:05:38 +02:00 committed by GitHub
commit 90c92797bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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();