[PATCH] arm64: Fix early single-stepping

Masami Hiramatsu mhiramat at kernel.org
Wed Oct 28 08:21:45 EDT 2020


On Wed, 28 Oct 2020 10:48:27 +0100
Jean-Philippe Brucker <jean-philippe at linaro.org> wrote:

> On Wed, Oct 28, 2020 at 06:07:31PM +0900, Masami Hiramatsu wrote:
> > > > Yes, I think so. Same order problem as the OS lock, they need to be reset
> > > > before enable_debug_monitors(). On CPU0 that would be before
> > > > early_initcall and for secondaries the hotplug notifier needs to be
> > > > installed earlier as well. I'll send a v2.
> > > 
> > > Cheers. An alternative (which I think would be better in the long run
> > > anyway) would be to avoid using hardware step in kprobes and instead rely
> > > on a BRK instruction to trap after running the trampoline.
> > 
> > But how we trap the instruction which can change pc? (like br?)
> > Are all those instruction emulated now?
> 
> According to aarch64_insn_is_steppable() anything that changes the PC is
> emulated.

OK, that sounds good. Then we can put the BRK right after the copied instruction.

> I'm also checking whether there is a change of behavior with
> synchronous exceptions taken while single-stepping (page faults).

Thanks! From the kprobe_fault_handler(), it seems the page faults handled
before the single-stepping exception and the fault handler disables single
steping explicitly. So if we use BRK, that code will not be needed.

Thank you,

-- 
Masami Hiramatsu <mhiramat at kernel.org>



More information about the linux-arm-kernel mailing list