From: Rik van Riel <riel@xxxxxxxxxxx> If the FPU state is not loaded in registers at fork time, memcpy the fpstate from the parent task to the child task. Signed-off-by: Rik van Riel <riel@xxxxxxxxxxx> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> --- arch/x86/kernel/fpu/core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index 2ea85b32421a0..8564086c217fc 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -210,11 +210,14 @@ int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu) * ( The function 'fails' in the FNSAVE case, which destroys * register contents so we have to copy them back. ) */ - if (!copy_fpregs_to_fpstate(dst_fpu)) { + __fpregs_changes_begin(); + if (test_thread_flag(TIF_LOAD_FPU)) { + memcpy(&src_fpu->state, &dst_fpu->state, fpu_kernel_xstate_size); + } else if (!copy_fpregs_to_fpstate(dst_fpu)) { memcpy(&src_fpu->state, &dst_fpu->state, fpu_kernel_xstate_size); copy_kernel_to_fpregs(&src_fpu->state); } - + __fpregs_changes_end(); trace_x86_fpu_copy_src(src_fpu); trace_x86_fpu_copy_dst(dst_fpu); -- 2.19.0