Skip to content

Commit

Permalink
x86, xsave: clear the user buffer before doing fxsave/xsave
Browse files Browse the repository at this point in the history
fxsave/xsave instructions will not touch all the bytes in the
fxsave/xsave frame. Clear the user buffer before doing fxsave/xsave
directly to user buffer during the sigcontext setup.

This is essentially needed in the context of xsave(for example,
some of the fields in the xsave header are not touched by the xsave
and defined as must be zero).

This will also present uniform and clean context to the user (from
which user can safely do fxrstor/xrstor).

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Suresh Siddha authored and Ingo Molnar committed Aug 14, 2008
1 parent ee2b92a commit ed40595
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions arch/x86/kernel/xsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ int save_i387_xstate(void __user *buf)
return 0;
clear_used_math(); /* trigger finit */
if (task_thread_info(tsk)->status & TS_USEDFPU) {
/*
* Start with clearing the user buffer. This will present a
* clean context for the bytes not touched by the fxsave/xsave.
*/
__clear_user(buf, sig_xstate_size);

if (task_thread_info(tsk)->status & TS_XSAVE)
err = xsave_user(buf);
else
Expand Down

0 comments on commit ed40595

Please sign in to comment.