2008-11-06 02:30:53

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH 1/4] x86: signal_32: do save_i387_xstate() at get_sigframe()

From: Hiroshi Shimamoto <[email protected]>

move calling save_i387_xstate() into get_sigframe() from setup_sigcontext()
like 64bit.

Signed-off-by: Hiroshi Shimamoto <[email protected]>
---
arch/x86/kernel/signal_32.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index a0efc1b..6a05c74 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -303,11 +303,7 @@ setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
err |= __put_user(regs->sp, &sc->sp_at_signal);
err |= __put_user(regs->ss, (unsigned int __user *)&sc->ss);

- tmp = save_i387_xstate(fpstate);
- if (tmp < 0)
- err = 1;
- else
- err |= __put_user(tmp ? fpstate : NULL, &sc->fpstate);
+ err |= __put_user(fpstate, &sc->fpstate);

/* non-iBCS2 extensions.. */
err |= __put_user(mask, &sc->oldmask);
@@ -350,6 +346,8 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
if (used_math()) {
sp = sp - sig_xstate_size;
*fpstate = (struct _fpstate *) sp;
+ if (save_i387_xstate(*fpstate) < 0)
+ return (void __user *)-1L;
}

sp -= frame_size;
--
1.5.6


2008-11-06 02:35:49

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH 2/4] x86: ia32_signal: do save_i387_xstate_ia32 at get_sigframe()

From: Hiroshi Shimamoto <[email protected]>

move calling save_i387_xstate_ia32() into get_sigframe() from
setup_sigcontext().

Signed-off-by: Hiroshi Shimamoto <[email protected]>
---
arch/x86/ia32/ia32_signal.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index e82ebd6..bafc0b4 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -367,12 +367,7 @@ static int ia32_setup_sigcontext(struct sigcontext_ia32 __user *sc,
err |= __put_user(regs->flags, &sc->flags);
err |= __put_user(regs->sp, &sc->sp_at_signal);

- tmp = save_i387_xstate_ia32(fpstate);
- if (tmp < 0)
- err = -EFAULT;
- else
- err |= __put_user(ptr_to_compat(tmp ? fpstate : NULL),
- &sc->fpstate);
+ err |= __put_user(ptr_to_compat(fpstate), &sc->fpstate);

/* non-iBCS2 extensions.. */
err |= __put_user(mask, &sc->oldmask);
@@ -408,6 +403,8 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
if (used_math()) {
sp = sp - sig_xstate_ia32_size;
*fpstate = (struct _fpstate_ia32 *) sp;
+ if (save_i387_xstate_ia32(*fpstate) < 0)
+ return (void __user *) -1L;
}

sp -= frame_size;
--
1.5.6

2008-11-06 02:37:38

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH 4/4] x86: signal_64: make setup_sigcontext() similar

From: Hiroshi Shimamoto <[email protected]>

remove passing task struct.

Signed-off-by: Hiroshi Shimamoto <[email protected]>
---
arch/x86/kernel/signal_64.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c
index 97d26fa..3868c2a 100644
--- a/arch/x86/kernel/signal_64.c
+++ b/arch/x86/kernel/signal_64.c
@@ -160,8 +160,7 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)

static inline int
setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
- struct pt_regs *regs,
- unsigned long mask, struct task_struct *me)
+ struct pt_regs *regs, unsigned long mask)
{
int err = 0;

@@ -185,13 +184,13 @@ setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
err |= __put_user(regs->r13, &sc->r13);
err |= __put_user(regs->r14, &sc->r14);
err |= __put_user(regs->r15, &sc->r15);
- err |= __put_user(me->thread.trap_no, &sc->trapno);
- err |= __put_user(me->thread.error_code, &sc->err);
+ err |= __put_user(current->thread.trap_no, &sc->trapno);
+ err |= __put_user(current->thread.error_code, &sc->err);
err |= __put_user(regs->ip, &sc->ip);
err |= __put_user(regs->flags, &sc->flags);
err |= __put_user(fpstate, &sc->fpstate);
err |= __put_user(mask, &sc->oldmask);
- err |= __put_user(me->thread.cr2, &sc->cr2);
+ err |= __put_user(current->thread.cr2, &sc->cr2);

return err;
}
@@ -251,8 +250,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
err |= __put_user(sas_ss_flags(regs->sp),
&frame->uc.uc_stack.ss_flags);
err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
- err |= setup_sigcontext(&frame->uc.uc_mcontext, fp,
- regs, set->sig[0], me);
+ err |= setup_sigcontext(&frame->uc.uc_mcontext, fp, regs, set->sig[0]);
err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));

/* Set up to return from userspace. If provided, use a stub
--
1.5.6

2008-11-06 02:38:54

by Hiroshi Shimamoto

[permalink] [raw]
Subject: [PATCH 3/4] x86: signal_64: setup fpstate in setup_sigcontext()

From: Hiroshi Shimamoto <[email protected]>

set fpstate field of signal context at setup_sigcontext().

Signed-off-by: Hiroshi Shimamoto <[email protected]>
---
arch/x86/kernel/signal_64.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c
index cfbb60a..97d26fa 100644
--- a/arch/x86/kernel/signal_64.c
+++ b/arch/x86/kernel/signal_64.c
@@ -159,8 +159,9 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
*/

static inline int
-setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
- unsigned long mask, struct task_struct *me)
+setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
+ struct pt_regs *regs,
+ unsigned long mask, struct task_struct *me)
{
int err = 0;

@@ -188,6 +189,7 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
err |= __put_user(me->thread.error_code, &sc->err);
err |= __put_user(regs->ip, &sc->ip);
err |= __put_user(regs->flags, &sc->flags);
+ err |= __put_user(fpstate, &sc->fpstate);
err |= __put_user(mask, &sc->oldmask);
err |= __put_user(me->thread.cr2, &sc->cr2);

@@ -249,8 +251,8 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
err |= __put_user(sas_ss_flags(regs->sp),
&frame->uc.uc_stack.ss_flags);
err |= __put_user(me->sas_ss_size, &frame->uc.uc_stack.ss_size);
- err |= setup_sigcontext(&frame->uc.uc_mcontext, regs, set->sig[0], me);
- err |= __put_user(fp, &frame->uc.uc_mcontext.fpstate);
+ err |= setup_sigcontext(&frame->uc.uc_mcontext, fp,
+ regs, set->sig[0], me);
err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));

/* Set up to return from userspace. If provided, use a stub
--
1.5.6

2008-11-06 07:03:32

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 1/4] x86: signal_32: do save_i387_xstate() at get_sigframe()


i've applied your patches to tip/x86/signal:

8735b7d: x86: signal_64: make setup_sigcontext() similar
ee7d523: x86: signal_64: setup fpstate in setup_sigcontext()
99ea1b9: x86: ia32_signal: do save_i387_xstate_ia32 at get_sigframe()
4b33669: x86: signal_32: do save_i387_xstate() at get_sigframe()

thanks!

Ingo