Skip to content

Commit b98ec9e

Browse files
stephanosiocarlescufi
authored andcommitted
x86: Initialise FPU regs during thread creation for eager FPU sharing
When "eager FPU sharing" mode is enabled, FPU registers must be initialised at the time of thread creation because the floating-point context is always active and no further FPU initialisation is performed later. Note that, in case of the "lazy FPU sharing" mode, floating-point context is inactive by default and the FPU is initialised when the first floating-point instruction is executed. Refer to the issue #44902 for more details. Signed-off-by: Stephanos Ioannidis <[email protected]> (cherry picked from commit f9a3f02)
1 parent 8f2d164 commit b98ec9e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

arch/x86/core/ia32/thread.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,18 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
114114
thread->arch.excNestCount = 0;
115115
#endif /* CONFIG_LAZY_FPU_SHARING */
116116
thread->arch.flags = 0;
117+
118+
/*
119+
* When "eager FPU sharing" mode is enabled, FPU registers must be
120+
* initialised at the time of thread creation because the floating-point
121+
* context is always active and no further FPU initialisation is performed
122+
* later.
123+
*/
124+
#if defined(CONFIG_EAGER_FPU_SHARING)
125+
thread->arch.preempFloatReg.floatRegsUnion.fpRegs.fcw = 0x037f;
126+
thread->arch.preempFloatReg.floatRegsUnion.fpRegs.ftw = 0xffff;
127+
#if defined(CONFIG_X86_SSE)
128+
thread->arch.preempFloatReg.floatRegsUnion.fpRegsEx.mxcsr = 0x1f80;
129+
#endif /* CONFIG_X86_SSE */
130+
#endif /* CONFIG_EAGER_FPU_SHARING */
117131
}

0 commit comments

Comments
 (0)