]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
MIPS: kernel: Prepare the JR instruction for emulation on MIPS R6
authorMarkos Chandras <markos.chandras@imgtec.com>
Tue, 25 Nov 2014 15:54:14 +0000 (15:54 +0000)
committerMarkos Chandras <markos.chandras@imgtec.com>
Tue, 17 Feb 2015 15:37:31 +0000 (15:37 +0000)
The MIPS R6 JR instruction is an alias to the JALR one, so it may
need emulation for non-R6 userlands.

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
arch/mips/include/asm/branch.h
arch/mips/kernel/branch.c
arch/mips/math-emu/cp1emu.c

index de781cf54bc7a22b4ae81f506ff1a869c6b1cc32..2894ea58454d8902a3c80ff1d4257560f2e57051 100644 (file)
@@ -13,6 +13,9 @@
 #include <asm/ptrace.h>
 #include <asm/inst.h>
 
+static int mipsr2_emulation = 0;
+#define NO_R6EMU       (cpu_has_mips_r6 && !mipsr2_emulation)
+
 extern int __isa_exception_epc(struct pt_regs *regs);
 extern int __compute_return_epc(struct pt_regs *regs);
 extern int __compute_return_epc_for_insn(struct pt_regs *regs,
index 4d7d99d601cc13219e9d8f9631da6002b3d9df9d..5736949896d19f8282833715eb43c07088a2a5b0 100644 (file)
@@ -417,6 +417,8 @@ int __compute_return_epc_for_insn(struct pt_regs *regs,
                        regs->regs[insn.r_format.rd] = epc + 8;
                        /* Fall through */
                case jr_op:
+                       if (NO_R6EMU && insn.r_format.func == jr_op)
+                               goto sigill_r6;
                        regs->cp0_epc = regs->regs[insn.r_format.rs];
                        break;
                }
@@ -477,7 +479,7 @@ int __compute_return_epc_for_insn(struct pt_regs *regs,
 
                case bposge32_op:
                        if (!cpu_has_dsp)
-                               goto sigill;
+                               goto sigill_dsp;
 
                        dspcontrol = rddsp(0x01);
 
@@ -631,10 +633,15 @@ int __compute_return_epc_for_insn(struct pt_regs *regs,
 
        return ret;
 
-sigill:
+sigill_dsp:
        printk("%s: DSP branch but not DSP ASE - sending SIGBUS.\n", current->comm);
        force_sig(SIGBUS, current);
        return -EFAULT;
+sigill_r6:
+       pr_info("%s: R2 branch but r2-to-r6 emulator is not preset - sending SIGILL.\n",
+               current->comm);
+       force_sig(SIGILL, current);
+       return -EFAULT;
 }
 EXPORT_SYMBOL_GPL(__compute_return_epc_for_insn);
 
index 9dfcd7fc1bc3dd712980c93f95ea4b8c1f3049d9..9bf82117b4f2d9b21845a7c4e06c2b45beac0aca 100644 (file)
@@ -448,6 +448,9 @@ static int isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
                                dec_insn.next_pc_inc;
                        /* Fall through */
                case jr_op:
+                       /* For R6, JR already emulated in jalr_op */
+                       if (NO_R6EMU && insn.r_format.opcode == jr_op)
+                               break;
                        *contpc = regs->regs[insn.r_format.rs];
                        return 1;
                }