[lkml]   [2015]   [Mar]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH RFC 2/2] x86/fpu: change xsave_user() and xrestore_user() to use __user_insn()
On Sun, Mar 15, 2015 at 05:50:36PM +0100, Oleg Nesterov wrote:
> Change xsave_user() and xrestore_user() to avoid the (imho) horrible
> and should-die xstate_fault helper, they both can use __user_insn().
> This also removes the "memory" clobber but I think it was never needed.
> xrestore_user() doesn't change the memory, it only changes the FPU regs.
> xsave_user() does write to "*buf" but this memory is "__user", we must
> never access it directly.

So I'm really not sure about all the callers, but it seems that this
instruction can be used to restore more than just the FPU state and I've no
idea how much can change underneath gcc when we do so. It "feels" safe
when saving the CPU state, not sure for the restoring case.

> This patch adds '"=m" (*buf)' in both cases, but this is only because
> currently __user_insn() needs the non-empty "output" arg.

See if my suggestion on your front e-mail works for you.

> Note: I think we can change all other xstate_fault users too, including
> alternative_input's.

I'd agree but I think we'll need new safe versions of alternative_input_*()
macros as opposed to just using check_insn(alternative_input_2(...),...).

 \ /
  Last update: 2015-03-17 00:01    [W:0.863 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site