]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
csky: Fixup perf probe -x hungup
authorGuo Ren <guoren@linux.alibaba.com>
Tue, 14 Apr 2020 12:14:12 +0000 (20:14 +0800)
committerGuo Ren <guoren@linux.alibaba.com>
Wed, 13 May 2020 09:55:05 +0000 (17:55 +0800)
case:
 # perf probe -x /lib/libc-2.28.9000.so memcpy
 # perf record -e probe_libc:memcpy -aR sleep 1

System hangup and cpu get in trap_c loop, because our hardware
singlestep state could still get interrupt signal. When we get in
uprobe_xol singlestep slot, we should disable irq in pt_regs->psr.

And is_swbp_insn() need a csky arch implementation with a low 16bit
mask.

Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
arch/csky/kernel/probes/uprobes.c
arch/csky/kernel/ptrace.c

index b3a56c260e3e14347ea6fdb3e3e4bd3351346643..1a9e0961b2b5b8a6ade8b583d6cbc299815c82a4 100644 (file)
 
 #define UPROBE_TRAP_NR UINT_MAX
 
+bool is_swbp_insn(uprobe_opcode_t *insn)
+{
+       return (*insn & 0xffff) == UPROBE_SWBP_INSN;
+}
+
 unsigned long uprobe_get_swbp_addr(struct pt_regs *regs)
 {
        return instruction_pointer(regs);
index 21ac2608f2057b630d4cba4c87eae7dde00db9d9..5a82230bddf988409bbb4e0640ebe95cb003b537 100644 (file)
@@ -41,6 +41,9 @@ static void singlestep_disable(struct task_struct *tsk)
 
        regs = task_pt_regs(tsk);
        regs->sr = (regs->sr & TRACE_MODE_MASK) | TRACE_MODE_RUN;
+
+       /* Enable irq */
+       regs->sr |= BIT(6);
 }
 
 static void singlestep_enable(struct task_struct *tsk)
@@ -49,6 +52,9 @@ static void singlestep_enable(struct task_struct *tsk)
 
        regs = task_pt_regs(tsk);
        regs->sr = (regs->sr & TRACE_MODE_MASK) | TRACE_MODE_SI;
+
+       /* Disable irq */
+       regs->sr &= ~BIT(6);
 }
 
 /*