Skip to content

Commit 8f4d818

Browse files
oleg-nesterovIngo Molnar
authored andcommitted
x86/fpu: Introduce restore_init_xstate()
Extract the "use_eager_fpu()" code from drop_init_fpu() into a new, simple helper restore_init_xstate(). The next patch adds another user. - It is not clear why we do not check use_fxsr() like fpu_restore_checking() does. eager_fpu_init_bp() calls setup_init_fpu_buf() too, and we have the "eagerfpu=on" kernel option. - Ignoring the fact that init_xstate_buf is "struct xsave_struct *", not "union thread_xstate *", it is not clear why we can not simply use fpu_restore_checking() and avoid the code duplication. - It is not clear why we can't call setup_init_fpu_buf() unconditionally to always create init_xstate_buf(). Then do_device_not_available() path (at least) could use restore_init_xstate() too. It doesn't need to init fpu->state, its content doesn't matter until unlazy_fpu()/__switch_to()/etc which overwrites this memory anyway. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Pekka Riikonen <priikone@iki.fi> Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com> Cc: Rik van Riel <riel@redhat.com> Cc: Suresh Siddha <sbsiddha@gmail.com> Link: http://lkml.kernel.org/r/20150311173429.GD5032@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent fb14b4e commit 8f4d818

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

arch/x86/include/asm/fpu-internal.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,20 @@ static inline void drop_fpu(struct task_struct *tsk)
401401
preempt_enable();
402402
}
403403

404+
static inline void restore_init_xstate(void)
405+
{
406+
if (use_xsave())
407+
xrstor_state(init_xstate_buf, -1);
408+
else
409+
fxrstor_checking(&init_xstate_buf->i387);
410+
}
411+
404412
static inline void drop_init_fpu(struct task_struct *tsk)
405413
{
406414
if (!use_eager_fpu())
407415
drop_fpu(tsk);
408-
else {
409-
if (use_xsave())
410-
xrstor_state(init_xstate_buf, -1);
411-
else
412-
fxrstor_checking(&init_xstate_buf->i387);
413-
}
416+
else
417+
restore_init_xstate();
414418
}
415419

416420
/*

0 commit comments

Comments
 (0)