diff options
author | Paul Burton <paul.burton@imgtec.com> | 2015-07-27 21:58:20 +0200 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2015-09-03 12:07:56 +0200 |
commit | 0d071fa3772b85fe5d81032fbc011c623570d2fc (patch) | |
tree | 0d477af57f1e9d81aa2437dc5fc0b25032a8fd8f /arch/mips/kernel/signal.c | |
parent | MIPS: Remove unused {get,put}_sigset functions (diff) | |
download | linux-0d071fa3772b85fe5d81032fbc011c623570d2fc.tar.xz linux-0d071fa3772b85fe5d81032fbc011c623570d2fc.zip |
MIPS: Indicate FP mode in sigcontext sc_used_math
The sc_used_math field of struct sigcontext & its variants has
traditionally been used as a boolean value indicating only whether or
not floating point context is saved within the sigcontext. With various
supported FP modes & the ability to switch between them this information
will no longer be enough to decode the meaning of the data stored in the
sc_fpregs fields of struct sigcontext.
To make that possible 3 bits are defined within sc_used_math:
- Bit 0 (USED_FP) represents whether FP was used, essentially
providing the boolean flag which sc_used_math as a whole provided
previously.
- Bit 1 (USED_FR1) provides the value of the Status.FR bit at the time
the FP context was saved.
- Bit 2 (USED_HYBRID_FPRS) indicates whether the FP context was saved
under the hybrid FPR scheme. Essentially, when set the odd singles
are located in bits 63:32 of the preceding even indexed sc_fpregs
element.
Any userland that tests whether the sc_used_math field is zero or
non-zero will continue to function as expected. Having said that, I
could not find any userland which uses the sc_used_math field at all.
[ralf@linux-mips.org: Fixed rejects.]
Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Matthew Fortune <matthew.fortune@imgtec.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linux-kernel@vger.kernel.org
Cc: Richard Weinberger <richard@nod.at>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Maciej W. Rozycki <macro@codesourcery.com>
Patchwork: https://patchwork.linux-mips.org/patch/10794/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/signal.c')
-rw-r--r-- | arch/mips/kernel/signal.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c index 08f521567d64..9cb75e9519c5 100644 --- a/arch/mips/kernel/signal.c +++ b/arch/mips/kernel/signal.c @@ -133,9 +133,16 @@ int protected_save_fp_context(void __user *sc) unsigned int used; int err; - used = !!used_math(); + used = used_math() ? USED_FP : 0; + if (used) { + if (!test_thread_flag(TIF_32BIT_FPREGS)) + used |= USED_FR1; + if (test_thread_flag(TIF_HYBRID_FPREGS)) + used |= USED_HYBRID_FPRS; + } + err = __put_user(used, used_math); - if (err || !used) + if (err || !(used & USED_FP)) return err; /* @@ -177,13 +184,13 @@ int protected_restore_fp_context(void __user *sc) int err, sig, tmp __maybe_unused; err = __get_user(used, used_math); - conditional_used_math(used); + conditional_used_math(used & USED_FP); /* * The signal handler may have used FPU; give it up if the program * doesn't want it following sigreturn. */ - if (err || !used) { + if (err || !(used & USED_FP)) { lose_fpu(0); return err; } |