Re: [PATCH v3 4/6] LoongArch: Add uprobes support

From: Tiezhu Yang
Date: Sun Apr 23 2023 - 21:20:40 EST




On 04/23/2023 09:12 PM, Huacai Chen wrote:
Hi, Tiezhu,

On Wed, Apr 19, 2023 at 5:57 PM Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> wrote:

Uprobes is the user-space counterpart to kprobes, this commit
adds uprobes support for LoongArch.

...

+#define MAX_UINSN_BYTES 8
+#define UPROBE_XOL_SLOT_BYTES MAX_UINSN_BYTES
In old versions we define UPROBE_XOL_SLOT_BYTES to 128, why we use 8 now?

I assume "the old version" maybe comes from mips, I am not quite sure the backgrounds. For LoongArch, there are 2 xol slots to save 2 instructions, each of them is 32 bit, 2*32bit=8bytes, so UPROBE_XOL_SLOT_BYTES can be 8.

+
+#define UPROBE_XOLBP_INSN larch_insn_gen_break(BRK_UPROBE_XOLBP)
+#define UPROBE_SWBP_INSN larch_insn_gen_break(BRK_UPROBE_BP)
+#define UPROBE_SWBP_INSN_SIZE LOONGARCH_INSN_SIZE

...

case BRK_UPROBE_XOLBP:
- if (notify_die(DIE_UPROBE_XOL, "Uprobe_XOL", regs, bcode,
- current->thread.trap_nr, SIGTRAP) == NOTIFY_STOP)
+ if (uprobe_singlestep_handler(regs))
As I know, XOL means "execute out of line", is it an alias of "single step"?

I think so, the instruction filled in xol slots is to single step, arm64, riscv, csky also uses "single step" for the related code, powerpc, s390 uses "DIE_SSTEP".

Thanks,
Tiezhu