Re: [PATCH v2 4/4] LoongArch: Add uprobes support

From: Youling Tang
Date: Sun Apr 16 2023 - 22:04:32 EST


Hi, Tiezhu

On 04/14/2023 05:33 PM, Tiezhu Yang wrote:

/* snip */

diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c
index de8ebe2..cfc2e0c 100644
--- a/arch/loongarch/kernel/traps.c
+++ b/arch/loongarch/kernel/traps.c
@@ -45,6 +45,7 @@
#include <asm/tlb.h>
#include <asm/types.h>
#include <asm/unwind.h>
+#include <asm/uprobes.h>

#include "access-helper.h"

@@ -440,7 +441,6 @@ asmlinkage void noinstr do_bp(struct pt_regs *regs)
if (regs->csr_prmd & CSR_PRMD_PIE)
local_irq_enable();

- current->thread.trap_nr = read_csr_excode();
if (__get_inst(&opcode, (u32 *)era, user))
goto out_sigsegv;

@@ -462,18 +462,17 @@ asmlinkage void noinstr do_bp(struct pt_regs *regs)
else
break;
case BRK_UPROBE_BP:
- if (notify_die(DIE_UPROBE, "Uprobe", regs, bcode,
- current->thread.trap_nr, SIGTRAP) == NOTIFY_STOP)
+ if (uprobe_breakpoint_handler(regs))
goto out;
else
break;
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))

After the above modification, we should remove the DIE_UPROBE and
DIE_UPROBE_XOL definitions in arch/loongarch/include/asm/kdebug.h.

At the same time DIE_BREAK, DIE_SSTEPBP and DIE_PAGE_FAULT also need to
be removed after 6d4cc40fb5f581 ("LoongArch: Add kprobes support").

Thanks,
Youling
goto out;
else
break;
default:
+ current->thread.trap_nr = read_csr_excode();
if (notify_die(DIE_TRAP, "Break", regs, bcode,
current->thread.trap_nr, SIGTRAP) == NOTIFY_STOP)
goto out;