Skip to content
Commit 45701e69 authored by Grant Ramsay's avatar Grant Ramsay Committed by Carles Cufí
Browse files

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: default avatarGrant Ramsay <gramsay@enphaseenergy.com>
parent 993cb302
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment