mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
[MIPS] Check FCSR for pending interrupts, alternative version
Commit 6d6671066a
is incomplete and misses
non-r4k CPUs. This patch reverts the commit and fixes in other way.
o Do FCSR checking in caller of restore_fp_context.
o Send SIGFPE if the signal handler set any FPU exception bits.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
parent
f1dbf8e718
commit
c6a2f46793
5 changed files with 75 additions and 23 deletions
|
@ -124,6 +124,37 @@ int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
|
|||
return err;
|
||||
}
|
||||
|
||||
int fpcsr_pending(unsigned int __user *fpcsr)
|
||||
{
|
||||
int err, sig = 0;
|
||||
unsigned int csr, enabled;
|
||||
|
||||
err = __get_user(csr, fpcsr);
|
||||
enabled = FPU_CSR_UNI_X | ((csr & FPU_CSR_ALL_E) << 5);
|
||||
/*
|
||||
* If the signal handler set some FPU exceptions, clear it and
|
||||
* send SIGFPE.
|
||||
*/
|
||||
if (csr & enabled) {
|
||||
csr &= ~enabled;
|
||||
err |= __put_user(csr, fpcsr);
|
||||
sig = SIGFPE;
|
||||
}
|
||||
return err ?: sig;
|
||||
}
|
||||
|
||||
static int
|
||||
check_and_restore_fp_context(struct sigcontext __user *sc)
|
||||
{
|
||||
int err, sig;
|
||||
|
||||
err = sig = fpcsr_pending(&sc->sc_fpc_csr);
|
||||
if (err > 0)
|
||||
err = 0;
|
||||
err |= restore_fp_context(sc);
|
||||
return err ?: sig;
|
||||
}
|
||||
|
||||
int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
|
||||
{
|
||||
unsigned int used_math;
|
||||
|
@ -162,7 +193,8 @@ int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
|
|||
if (used_math()) {
|
||||
/* restore fpu context if we have used it before */
|
||||
own_fpu();
|
||||
err |= restore_fp_context(sc);
|
||||
if (!err)
|
||||
err = check_and_restore_fp_context(sc);
|
||||
} else {
|
||||
/* signal handler may have used FPU. Give it up. */
|
||||
lose_fpu();
|
||||
|
@ -332,6 +364,7 @@ asmlinkage void sys_sigreturn(nabi_no_regargs struct pt_regs regs)
|
|||
{
|
||||
struct sigframe __user *frame;
|
||||
sigset_t blocked;
|
||||
int sig;
|
||||
|
||||
frame = (struct sigframe __user *) regs.regs[29];
|
||||
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
|
||||
|
@ -345,8 +378,11 @@ asmlinkage void sys_sigreturn(nabi_no_regargs struct pt_regs regs)
|
|||
recalc_sigpending();
|
||||
spin_unlock_irq(¤t->sighand->siglock);
|
||||
|
||||
if (restore_sigcontext(®s, &frame->sf_sc))
|
||||
sig = restore_sigcontext(®s, &frame->sf_sc);
|
||||
if (sig < 0)
|
||||
goto badframe;
|
||||
else if (sig)
|
||||
force_sig(sig, current);
|
||||
|
||||
/*
|
||||
* Don't let your children do this ...
|
||||
|
@ -368,6 +404,7 @@ asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
|
|||
struct rt_sigframe __user *frame;
|
||||
sigset_t set;
|
||||
stack_t st;
|
||||
int sig;
|
||||
|
||||
frame = (struct rt_sigframe __user *) regs.regs[29];
|
||||
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
|
||||
|
@ -381,8 +418,11 @@ asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
|
|||
recalc_sigpending();
|
||||
spin_unlock_irq(¤t->sighand->siglock);
|
||||
|
||||
if (restore_sigcontext(®s, &frame->rs_uc.uc_mcontext))
|
||||
sig = restore_sigcontext(®s, &frame->rs_uc.uc_mcontext);
|
||||
if (sig < 0)
|
||||
goto badframe;
|
||||
else if (sig)
|
||||
force_sig(sig, current);
|
||||
|
||||
if (__copy_from_user(&st, &frame->rs_uc.uc_stack, sizeof(st)))
|
||||
goto badframe;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue