From: Oleg Nesterov <oleg@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Fenghua Yu <fenghua.yu@intel.com>,
Suresh Siddha <sbsiddha@gmail.com>,
Bean Anderson <bean@azulsystems.com>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
the arch/x86 maintainers <x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/5] x86, fpu: don't drop_fpu() in __restore_xstate_sig() if use_eager_fpu()
Date: Mon, 25 Aug 2014 19:09:20 +0200 [thread overview]
Message-ID: <20140825170920.GA8338@redhat.com> (raw)
In-Reply-To: <CA+55aFwNUF+CLWKkDBe56xOtK_JTj9zHWip+_Ep41GJniN+sPw@mail.gmail.com>
On 08/25, Linus Torvalds wrote:
>
> On Mon, Aug 25, 2014 at 7:41 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > I think this should be safe, because this thread and/or swapper/0 can
> > do nothing with with fpu->state, and they should not use fpu.
>
> .. but if that's the case, then what was wrong with the old code
Confused... Just in case, I think that you mean current code, and ignoring
the lack of preempt_disable() around math_state_restore() it is correct.
I'd like to change it only because this code is the main source of the
nasty special case, used_math() and/or __thread_has_fpu(current) can be
false even if use_eager_fpu().
> that
> just copied the state over the unused space from the user space
> buffer?
But it is not unused? Although I probably misunderstood you from the
very beginning.
OK, what I meant that without switch_fpu_xstate(init_task.fpu.state)
or another hack we can't avoid drop_fpu() which leads to this special
case.
Currently __copy_from_user(&xstate->xsave) copies the new registers
right into this thread's fpu->state. If this thread is preempted before
math_state_restore(), the context switch (__save_init_fpu) will overwrite
the same buffer, the result of __copy_from_user() can be simply lost
(entirely or not).
With this patch we can safely do __copy_from_user(xstate), this buffer
is not used until the 2nd switch_fpu_xstate().
> You can't have it both ways. Either the old code was fine (because it
> doesn't use the buffer while it is in flux), or the new code is broken
> (because it uses the shared buffer). Your choice.No?
It uses the shared buffer, yes. But in this case (I think! please correct
me!), when this thread uses the swapper's fpu->state, schedule() ->
fpu_xsave() into this shared buffer should be fine because it should write
the same content?
Oleg.
next prev parent reply other threads:[~2014-08-25 17:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-22 17:11 [PATCH 0/1] x86, fpu: shift drop_init_fpu() from save_xstate_sig() to handle_signal() Oleg Nesterov
2014-08-22 17:12 ` [PATCH 1/1] " Oleg Nesterov
2014-08-24 19:47 ` [PATCH 0/5] x86, fpu: make use_eager_fpu() more eager Oleg Nesterov
2014-08-24 19:47 ` [PATCH 1/5] x86, fpu: change sanitize_restored_xstate() and convert_to_fxsr() to accept thread_xstate Oleg Nesterov
2014-08-24 19:47 ` [PATCH 2/5] x86, fpu: don't drop_fpu() in __restore_xstate_sig() if use_eager_fpu() Oleg Nesterov
2014-08-24 20:05 ` Linus Torvalds
2014-08-25 14:26 ` Oleg Nesterov
2014-08-25 14:41 ` Oleg Nesterov
2014-08-25 16:27 ` Linus Torvalds
2014-08-25 17:09 ` Oleg Nesterov [this message]
2014-08-25 17:26 ` Linus Torvalds
2014-08-25 17:39 ` Oleg Nesterov
2014-08-27 17:02 ` Oleg Nesterov
2014-08-24 19:47 ` [PATCH 3/5] x86, fpu: don't drop_fpu() in exit_thread() " Oleg Nesterov
2014-08-24 19:47 ` [PATCH 4/5] x86, fpu: shift init_fpu() from eager_fpu_init() to eager_fpu_init_bp() Oleg Nesterov
2014-08-24 19:47 ` [PATCH 5/5] x86, fpu: sanitize the usage of use_eager_fpu() in switch_fpu_prepare() Oleg Nesterov
2014-08-25 18:08 ` [PATCH] x86, fpu: __restore_xstate_sig()->math_state_restore() needs preempt_disable() Oleg Nesterov
2014-09-02 5:01 ` Suresh Siddha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140825170920.GA8338@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bean@azulsystems.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=sbsiddha@gmail.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox