Skip to content

Commit 10f6d99

Browse files
Maciej W. Rozyckiralfbaechle
authored andcommitted
MIPS: traps.c: Don't emulate RDHWR in the CpU #0 exception handler
In the regular MIPS instruction set RDHWR is encoded with the SPECIAL3 (011111) major opcode. Therefore it cannot trigger the CpU (Coprocessor Unusable) exception, and certainly not for coprocessor 0, as the opcode does not overlap with any of the older ISA reservations, i.e. LWC0 (110000), SWC0 (111000), LDC0 (110100) or SDC0 (111100). The closest match might be SDC3 (111111), possibly causing a CpU #3 exception, however our code does not handle it anyway. A quick check with a MIPS I and a MIPS III processor: CPU0 revision is: 00000220 (R3000) CPU0 revision is: 00000440 (R4400SC) indeed indicates that the RI (Reserved Instruction) exception is triggered. It's only LL and SC that require emulation in the CpU #0 exception handler as they reuse the LWC0 and SWC0 opcodes respectively. In the microMIPS instruction set RDHWR is mandatory and triggering the RI exception is required on unimplemented or disabled register accesses. Therefore emulating the microMIPS instruction in the CpU #0 exception handler is not required either. Signed-off-by: Maciej W. Rozycki <macro@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/12280/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 87bee0e commit 10f6d99

1 file changed

Lines changed: 1 addition & 15 deletions

File tree

arch/mips/kernel/traps.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,26 +1369,12 @@ asmlinkage void do_cpu(struct pt_regs *regs)
13691369
if (unlikely(compute_return_epc(regs) < 0))
13701370
break;
13711371

1372-
if (get_isa16_mode(regs->cp0_epc)) {
1373-
unsigned short mmop[2] = { 0 };
1374-
1375-
if (unlikely(get_user(mmop[0], epc) < 0))
1376-
status = SIGSEGV;
1377-
if (unlikely(get_user(mmop[1], epc) < 0))
1378-
status = SIGSEGV;
1379-
opcode = (mmop[0] << 16) | mmop[1];
1380-
1381-
if (status < 0)
1382-
status = simulate_rdhwr_mm(regs, opcode);
1383-
} else {
1372+
if (!get_isa16_mode(regs->cp0_epc)) {
13841373
if (unlikely(get_user(opcode, epc) < 0))
13851374
status = SIGSEGV;
13861375

13871376
if (!cpu_has_llsc && status < 0)
13881377
status = simulate_llsc(regs, opcode);
1389-
1390-
if (status < 0)
1391-
status = simulate_rdhwr_normal(regs, opcode);
13921378
}
13931379

13941380
if (status < 0)

0 commit comments

Comments
 (0)