Skip to content

Commit 2bcb3fb

Browse files
paulburtonralfbaechle
authored andcommitted
MIPS: Dumb MSA FP exception handler
This patch adds a simple handler for MSA FP exceptions which delivers a SIGFPE to the running task. In the future it should probably be extended to re-execute the instruction with the MSACSR.NX bit set in order to generate results for any elements which did not cause an exception before delivering the SIGFPE signal. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/6432/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 1db1af8 commit 2bcb3fb

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎arch/mips/kernel/genex.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ NESTED(nmi_handler, PT_SIZE, sp)
475475
BUILD_HANDLER cpu cpu sti silent /* #11 */
476476
BUILD_HANDLER ov ov sti silent /* #12 */
477477
BUILD_HANDLER tr tr sti silent /* #13 */
478+
BUILD_HANDLER msa_fpe msa_fpe sti silent /* #14 */
478479
BUILD_HANDLER fpe fpe fpe silent /* #15 */
479480
BUILD_HANDLER ftlb ftlb none silent /* #16 */
480481
BUILD_HANDLER msa msa sti silent /* #21 */

‎arch/mips/kernel/traps.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ extern asmlinkage void handle_ri_rdhwr(void);
7878
extern asmlinkage void handle_cpu(void);
7979
extern asmlinkage void handle_ov(void);
8080
extern asmlinkage void handle_tr(void);
81+
extern asmlinkage void handle_msa_fpe(void);
8182
extern asmlinkage void handle_fpe(void);
8283
extern asmlinkage void handle_ftlb(void);
8384
extern asmlinkage void handle_msa(void);
@@ -1250,6 +1251,16 @@ asmlinkage void do_cpu(struct pt_regs *regs)
12501251
exception_exit(prev_state);
12511252
}
12521253

1254+
asmlinkage void do_msa_fpe(struct pt_regs *regs)
1255+
{
1256+
enum ctx_state prev_state;
1257+
1258+
prev_state = exception_enter();
1259+
die_if_kernel("do_msa_fpe invoked from kernel context!", regs);
1260+
force_sig(SIGFPE, current);
1261+
exception_exit(prev_state);
1262+
}
1263+
12531264
asmlinkage void do_msa(struct pt_regs *regs)
12541265
{
12551266
enum ctx_state prev_state;
@@ -2106,6 +2117,7 @@ void __init trap_init(void)
21062117
set_except_vector(11, handle_cpu);
21072118
set_except_vector(12, handle_ov);
21082119
set_except_vector(13, handle_tr);
2120+
set_except_vector(14, handle_msa_fpe);
21092121

21102122
if (current_cpu_type() == CPU_R6000 ||
21112123
current_cpu_type() == CPU_R6000A) {

0 commit comments

Comments
 (0)