Date: Thu, 26 Apr 2018 08:56:49 -0700 From: John Baldwin <jhb@freebsd.org> To: freebsd-mips@freebsd.org Cc: Jan Mazur <dingorth@gmail.com> Subject: Re: What is the purpose of MipsEmulateBranch function? Message-ID: <101684495.RDgfxnoLgE@ralph.baldwin.cx> In-Reply-To: <CADGEm4doaap9T-pJ8HBAT_=ZVgNhuo=Lqu3Vunc6E8%2BRJTPu8A@mail.gmail.com> References: <CADGEm4doaap9T-pJ8HBAT_=ZVgNhuo=Lqu3Vunc6E8%2BRJTPu8A@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday, April 26, 2018 12:01:11 PM Jan Mazur 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? For single-stepping via PT_STEP you need to place the next breakpoint instruction at the target of the branch, so you don't emulate the branch, but you need to know what it will do so you know where to place the breakpoint. For cpu_fetch_syscall_args, we don't want to return to the existing instruction and retrigger the system call unless the system call fails with ERESTART, so we need to manually advance PC to the next instruction. The handler for 'trap' instructions similarly needs to advance PC past the instruction rather than restarting it and staying in an infinite loop. The code to handle unaligned stores wants to simulate the load or store and advance PC rather than retrying the instruction. -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?101684495.RDgfxnoLgE>