lkml.org 
[lkml]   [2014]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/5] x86, fpu: don't drop_fpu() in __restore_xstate_sig() if use_eager_fpu()
I'm afraid you all already hate me, but let me continue to spam your
mailboxes.

On 08/25, Oleg Nesterov wrote:
>
> I'll try to play with copy_from_user_in_atomic(), if nothing else just
> to complete the discussion and see how the code can look in this case.

OK, to complete the discussion, the code looks simple unless I missed
something,

if (ia32_fxstate) {
/*
* For 32-bit frames with fxstate, copy the user state to the
* thread's fpu state, reconstruct fxstate from the fsave
* header. Sanitize the copied state etc.
*/
struct xsave_struct *xsave = &tsk->thread.fpu.state->xsave;
struct user_i387_ia32_struct env;
bool done;

if (__copy_from_user(&env, buf, sizeof(env))
return -1;

for (done = false; !done; ) {
if (fatal_signal_pending(current) ||
fault_in_pages_readable(buf_fx, state_size))
return -1;

preempt_disable();
pagefault_disable(); /* not really needed */
done = !__copy_from_user_inatomic(xsave, buf_fx, state_size);
pagefault_enable();
if (likely(done)) {
sanitize_restored_xstate(tsk, &env, xstate_bv, fx_only);
if (__thread_has_fpu(tsk))
math_state_restore();
} else {
fpu_finit(&tsk->thread.fpu);
}
preempt_enable();
}

return 0;
}

and in some sense it is even simpler because we do not care about
use_eager_fpu() or set/clear_used_math().

Does it look better than switch_fpu_xstate() hack?


However, this code can race with kernel_fpu_begin() if use_eager_fpu().
I _think_ that kernel_fpu_begin/end and irq_fpu_usable() need cleanups
too and in any case. Will try to do, but I am not sure.

And to spam you even more, I'll send you a couple of other, more simple
cleanups.

Oleg.



\
 
 \ /
  Last update: 2014-08-27 20:01    [W:0.060 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site