question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MIPS] RFE instruction not present.

See original GitHub issue

The MIPS instruction set contains an instruction called “RFE”, for “Return From Exception”. Its encoding is well specified, with no parameters: http://people.cs.pitt.edu/~don/coe1502/current/Unit4a/Unit4a.html

This document translates “RFE” to the opcode 0x42000010

The point of the RFE instruction is to restore cop0 status flags atomically while returning to the user space. Its pseudo-code implementation can be seen as the following:

    COP0.Status = (COP0.Status & 0xfffffff0) | ((COP0.Status & 0x3c) >> 2);

The explanation of this behavior is simple: when triggering an exception, the MIPS CPU does the following atomically, in order to save usermode flags:

    COP0.Status = (COP0.Status & ~0x3f) | (CP0.Status & 0xf) << 2);

When disassembling a MIPS exception handler from a MIPS kernel with ghidra, it will currently fail to disassemble that instruction properly, nor recognize it as even an executable instruction:

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
emteerecommented, Jan 25, 2021

Has been fixed and should be in patch and master soon. Thanks for fixing.

1reaction
nicolasnoblecommented, Apr 13, 2020

the _ is interesting, guessing its just because you might have already had the jr disassembled (which failed to do all the logic involved with delay since the delay slot instruction was broken) so when you disassembled the rfe, it had no clue it should be in the delay slot

Oh, that’s correct. I cleared the whole function and re-disassembled it, and now the underscore shows up.

submitted a PR for this fix

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exceptions in MIPS
At the return from the exception handler (by executing a rfe instruction), the previous state becomes the cur- rent state and the old...
Read more >
System/161 MIPS Processor
The RFE instruction is not a jump; it occurs in the delay slot of a jump. It shifts the six bottom bits of...
Read more >
MIPS IV Instruction Set
Information on MIPS products is available electronically: (a) Through the World Wide Web. ... the non-privileged instructions that execute in user mode.
Read more >
System/161 MIPS Processor - Washington
The RFE instruction is not a jump; it occurs in the delay slot of a jump. It shifts the six bottom bits of...
Read more >
Exception and Interrupt handling in the MIPS architecture
Undefined instruction occurs when an unknown instruction is fetched. This exception is caused by an instruction in the IR that has an unknown...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found