What is the purpose of MipsEmulateBranch function?

Warner Losh imp at bsdimp.com
Thu Apr 26 15:51:34 UTC 2018


On Thu, Apr 26, 2018 at 4:01 AM, Jan Mazur <dingorth at gmail.com> wrote:

> Hi
>
> I'm wondering why FreeBSD has to simulate branches when the faulting
> instruction is in the branch delay slot.
> I'm curious about MipsEmulateBranch function, which is defined in
> http://bxr.su/FreeBSD/sys/mips/mips/trap.c#MipsEmulateBranch
>
> Why can't you just restart execution from the branch instruction?
>

You can't restart a branch in the delay slot, so you have to emulate the
branch. It's used in various places to adjust the return PC of the trap
frame data when an instruction in the delay slot causes a fault.

Warner


More information about the freebsd-mips mailing list