From: Ingo Molnar <mingo@elte.hu>
To: "Daniel Glöckner" <dg@emlix.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"Suresh Siddha" <suresh.b.siddha@intel.com>,
"Pallipadi, Venkatesh" <venkatesh.pallipadi@intel.com>,
"Arjan van de Ven" <arjan@infradead.org>
Cc: x86@kernel.org, Bill Metzenthen <billm@suburbia.net>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86, math-emu: fix init_fpu for task != current
Date: Mon, 2 Mar 2009 20:52:30 +0100 [thread overview]
Message-ID: <20090302195230.GA12252@elte.hu> (raw)
In-Reply-To: <E1Le9vp-00020J-AA@mailer.emlix.com>
* Daniel Glöckner <dg@emlix.com> wrote:
> init_fpu calls finit to initialize a task's xstate, while finit always
> works on the current task. If we use PTRACE_GETFPREGS on another
> process and both processes did not already use floating point, we get
> a null pointer exception in finit.
>
> This patch creates a new function finit_task that takes a task_struct
> parameter. finit becomes a wrapper that simply calls finit_task with
> current. On the plus side this avoids many calls to get_current which
> would each resolve to an inline assembler mov instruction.
>
> Signed-off-by: Daniel Glöckner <dg@emlix.com>
> ---
> arch/x86/include/asm/i387.h | 1 +
> arch/x86/kernel/i387.c | 2 +-
> arch/x86/math-emu/fpu_aux.c | 31 ++++++++++++++++++++-----------
> 3 files changed, 22 insertions(+), 12 deletions(-)
>
> diff --git a/arch/x86/include/asm/i387.h b/arch/x86/include/asm/i387.h
> index 48f0004..10f349b 100644
> --- a/arch/x86/include/asm/i387.h
> +++ b/arch/x86/include/asm/i387.h
> @@ -172,6 +172,7 @@ static inline void __save_init_fpu(struct task_struct *tsk)
>
> #else /* CONFIG_X86_32 */
>
> +extern void finit_task(struct task_struct *tsk);
> extern void finit(void);
>
> static inline void tolerant_fwait(void)
> diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
> index b0f61f0..f2f8540 100644
> --- a/arch/x86/kernel/i387.c
> +++ b/arch/x86/kernel/i387.c
> @@ -136,7 +136,7 @@ int init_fpu(struct task_struct *tsk)
> #ifdef CONFIG_X86_32
> if (!HAVE_HWFP) {
> memset(tsk->thread.xstate, 0, xstate_size);
> - finit();
> + finit_task(tsk);
> set_stopped_child_used_math(tsk);
> return 0;
> }
> diff --git a/arch/x86/math-emu/fpu_aux.c b/arch/x86/math-emu/fpu_aux.c
> index 491e737..aa09870 100644
> --- a/arch/x86/math-emu/fpu_aux.c
> +++ b/arch/x86/math-emu/fpu_aux.c
> @@ -30,20 +30,29 @@ static void fclex(void)
> }
>
> /* Needs to be externally visible */
> -void finit(void)
> +void finit_task(struct task_struct *tsk)
ok, the fix looks good - but we sure want to define this
function in the "# CONFIG_MATH_EMU is not set" case too, agreed?
Ingo
next prev parent reply other threads:[~2009-03-02 19:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-02 15:19 [PATCH] x86, math-emu: fix init_fpu for task != current Daniel Glöckner
2009-03-02 19:52 ` Ingo Molnar [this message]
2009-03-04 16:01 ` Daniel Glöckner
2009-03-04 17:51 ` Ingo Molnar
2009-03-04 18:42 ` [PATCH -v2] " Daniel Glöckner
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=20090302195230.GA12252@elte.hu \
--to=mingo@elte.hu \
--cc=arjan@infradead.org \
--cc=billm@suburbia.net \
--cc=dg@emlix.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=suresh.b.siddha@intel.com \
--cc=venkatesh.pallipadi@intel.com \
--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