diff options
author | Michael Neuling <mikey@neuling.org> | 2008-07-02 14:06:37 +1000 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-07-03 16:58:11 +1000 |
commit | 6a274c08f2f4dfac7167bbd849621f3a2b55d424 (patch) | |
tree | 1bad45a11c1e436ffbcb84107783da0e423925f9 /arch/powerpc/kernel/signal_64.c | |
parent | 2d1b2027626d5151fff8ef7c06ca8e7876a1a510 (diff) | |
download | op-kernel-dev-6a274c08f2f4dfac7167bbd849621f3a2b55d424.zip op-kernel-dev-6a274c08f2f4dfac7167bbd849621f3a2b55d424.tar.gz |
powerpc: Clean up copy_to/from_user for vsx and fpr
This merges and cleans up some of the ugly copy/to from user code
which is required for the new fpr and vsx layout in the thread_struct.
Also fixes some hard coded buffer sizes and removes a redundant
fpr_flush_to_thread.
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/signal_64.c')
-rw-r--r-- | arch/powerpc/kernel/signal_64.c | 43 |
1 files changed, 11 insertions, 32 deletions
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c index 8214e57..93ebfb6 100644 --- a/arch/powerpc/kernel/signal_64.c +++ b/arch/powerpc/kernel/signal_64.c @@ -89,10 +89,6 @@ static long setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, #endif unsigned long msr = regs->msr; long err = 0; -#ifdef CONFIG_VSX - double buf[FP_REGS_SIZE]; - int i; -#endif flush_fp_to_thread(current); @@ -117,12 +113,9 @@ static long setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, err |= __put_user(0, &sc->v_regs); #endif /* CONFIG_ALTIVEC */ flush_fp_to_thread(current); + /* copy fpr regs and fpscr */ + err |= copy_fpr_to_user(&sc->fp_regs, current); #ifdef CONFIG_VSX - /* Copy FP to local buffer then write that out */ - for (i = 0; i < 32 ; i++) - buf[i] = current->thread.TS_FPR(i); - memcpy(&buf[i], ¤t->thread.fpscr, sizeof(double)); - err |= __copy_to_user(&sc->fp_regs, buf, FP_REGS_SIZE); /* * Copy VSX low doubleword to local buffer for formatting, * then out to userspace. Update v_regs to point after the @@ -131,17 +124,12 @@ static long setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, if (current->thread.used_vsr) { flush_vsx_to_thread(current); v_regs += ELF_NVRREG; - for (i = 0; i < 32 ; i++) - buf[i] = current->thread.fpr[i][TS_VSRLOWOFFSET]; - err |= __copy_to_user(v_regs, buf, 32 * sizeof(double)); + err |= copy_vsx_to_user(v_regs, current); /* set MSR_VSX in the MSR value in the frame to * indicate that sc->vs_reg) contains valid data. */ msr |= MSR_VSX; } -#else /* CONFIG_VSX */ - /* copy fpr regs and fpscr */ - err |= __copy_to_user(&sc->fp_regs, ¤t->thread.fpr, FP_REGS_SIZE); #endif /* CONFIG_VSX */ err |= __put_user(&sc->gp_regs, &sc->regs); WARN_ON(!FULL_REGS(regs)); @@ -165,13 +153,12 @@ static long restore_sigcontext(struct pt_regs *regs, sigset_t *set, int sig, #ifdef CONFIG_ALTIVEC elf_vrreg_t __user *v_regs; #endif -#ifdef CONFIG_VSX - double buf[FP_REGS_SIZE]; - int i; -#endif unsigned long err = 0; unsigned long save_r13 = 0; unsigned long msr; +#ifdef CONFIG_VSX + int i; +#endif /* If this is not a signal return, we preserve the TLS in r13 */ if (!sig) @@ -234,15 +221,9 @@ static long restore_sigcontext(struct pt_regs *regs, sigset_t *set, int sig, else current->thread.vrsave = 0; #endif /* CONFIG_ALTIVEC */ -#ifdef CONFIG_VSX /* restore floating point */ - err |= __copy_from_user(buf, &sc->fp_regs, FP_REGS_SIZE); - if (err) - return err; - for (i = 0; i < 32 ; i++) - current->thread.TS_FPR(i) = buf[i]; - memcpy(¤t->thread.fpscr, &buf[i], sizeof(double)); - + err |= copy_fpr_from_user(current, &sc->fp_regs); +#ifdef CONFIG_VSX /* * Get additional VSX data. Update v_regs to point after the * VMX data. Copy VSX low doubleword from userspace to local @@ -250,14 +231,12 @@ static long restore_sigcontext(struct pt_regs *regs, sigset_t *set, int sig, */ v_regs += ELF_NVRREG; if ((msr & MSR_VSX) != 0) - err |= __copy_from_user(buf, v_regs, 32 * sizeof(double)); + err |= copy_vsx_from_user(current, v_regs); else - memset(buf, 0, 32 * sizeof(double)); + for (i = 0; i < 32 ; i++) + current->thread.fpr[i][TS_VSRLOWOFFSET] = 0; - for (i = 0; i < 32 ; i++) - current->thread.fpr[i][TS_VSRLOWOFFSET] = buf[i]; #else - err |= __copy_from_user(¤t->thread.fpr, &sc->fp_regs, FP_REGS_SIZE); #endif return err; } |