From: Suresh Siddha <suresh.b.siddha@intel.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Eric Sesterhenn <snakebyte@gmx.de>, Ingo Molnar <mingo@elte.hu>,
Frederik Deweerdt <deweerdt@free.fr>,
linux-kernel@vger.kernel.org, suresh.b.siddha@intel.com,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: Oops with strace_test
Date: Wed, 7 May 2008 12:09:52 -0700 [thread overview]
Message-ID: <20080507190952.GA11931@linux-os.sc.intel.com> (raw)
In-Reply-To: <alpine.LFD.1.10.0805071924550.3318@apollo.tec.linutronix.de>
On Wed, May 07, 2008 at 07:26:20PM +0200, Thomas Gleixner wrote:
>
> Ok, we decoded the problem in meantime. Suresh will send a patch soon.
Appended patch should fix it. Eric, can you please check if it fixes the issue?
I have to fix the math-emu aswell. But I will send a different patch for it.
thanks,
suresh
---
[patch] fix fpu restore during sig return
If the task never used fpu, initialize the fpu before restoring the FP state
from the signal handler context. This will allocate the fpu state,
if the task never needed it before.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
---
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index db6839b..45e19ee 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -450,7 +450,6 @@ static inline int restore_i387_fsave(struct _fpstate_ia32 __user *buf)
{
struct task_struct *tsk = current;
- clear_fpu(tsk);
return __copy_from_user(&tsk->thread.xstate->fsave, buf,
sizeof(struct i387_fsave_struct));
}
@@ -461,7 +460,6 @@ static int restore_i387_fxsave(struct _fpstate_ia32 __user *buf)
struct user_i387_ia32_struct env;
int err;
- clear_fpu(tsk);
err = __copy_from_user(&tsk->thread.xstate->fxsave, &buf->_fxsr_env[0],
sizeof(struct i387_fxsave_struct));
/* mxcsr reserved bits must be masked to zero for security reasons */
@@ -478,6 +476,16 @@ int restore_i387_ia32(struct _fpstate_ia32 __user *buf)
int err;
if (HAVE_HWFP) {
+ struct task_struct *tsk = current;
+
+ clear_fpu(tsk);
+
+ if (!used_math()) {
+ err = init_fpu(tsk);
+ if (err)
+ return err;
+ }
+
if (cpu_has_fxsr)
err = restore_i387_fxsave(buf);
else
diff --git a/include/asm-x86/i387.h b/include/asm-x86/i387.h
index da2adb4..6b722d3 100644
--- a/include/asm-x86/i387.h
+++ b/include/asm-x86/i387.h
@@ -175,7 +175,15 @@ static inline int save_i387(struct _fpstate __user *buf)
*/
static inline int restore_i387(struct _fpstate __user *buf)
{
- set_used_math();
+ struct task_struct *tsk = current;
+ int err;
+
+ if (!used_math()) {
+ err = init_fpu(tsk);
+ if (err)
+ return err;
+ }
+
if (!(task_thread_info(current)->status & TS_USEDFPU)) {
clts();
task_thread_info(current)->status |= TS_USEDFPU;
next prev parent reply other threads:[~2008-05-07 19:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-30 12:12 Oops with strace_test Eric Sesterhenn
2008-04-30 16:19 ` Andi Kleen
2008-05-05 10:00 ` Eric Sesterhenn
2008-05-05 18:00 ` Frederik Deweerdt
2008-05-06 12:10 ` Ingo Molnar
2008-05-06 15:07 ` Eric Sesterhenn
2008-05-07 10:36 ` Eric Sesterhenn
2008-05-07 13:36 ` Thomas Gleixner
2008-05-07 17:20 ` Eric Sesterhenn
2008-05-07 17:26 ` Thomas Gleixner
2008-05-07 19:09 ` Suresh Siddha [this message]
2008-05-07 21:46 ` Eric Sesterhenn
2008-05-08 15:02 ` Thomas Gleixner
2008-05-08 18:29 ` Eric Sesterhenn
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=20080507190952.GA11931@linux-os.sc.intel.com \
--to=suresh.b.siddha@intel.com \
--cc=deweerdt@free.fr \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=snakebyte@gmx.de \
--cc=tglx@linutronix.de \
/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