kernel: sched: Disable FPU context when thread ends
When `CONFIG_FPU_SHARING` is enabled each `k_thread` struct has a saved floating point context (`saved_fp_context`). During a context switch, the current FPU owner's (`_current_cpu->arch.fpu_owner`) registers are saved to its `saved_fp_context`, and the destination threads FPU registers are loaded from its `saved_fp_context`. When a thread ends, it does not release ownership of the FPU (`_current_cpu->arch.fpu_owner`). This is problematic if the `k_thread` struct was allocated on the stack. The next context switch will save the FPU registers into `k_thread -> saved_fp_context` which may now be out of scope. This will likely (but not always) result in a crash. Adding `arch_float_disable(thread);` when a thread ends disables preservation of floating point context information, fixing this issue Signed-off-by:Grant Ramsay <gramsay@enphaseenergy.com> (cherry picked from commit 45701e69)
Loading
Please sign in to comment