Commit 8f6bb793 authored by Guo Ren's avatar Guo Ren
Browse files

csky: Add uprobes support



This patch adds support for uprobes on csky architecture.

Just like kprobe, it support single-step and simulate instructions.

Signed-off-by: default avatarGuo Ren <guoren@linux.alibaba.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
parent 33e53ae1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ config CSKY
config LOCKDEP_SUPPORT
	def_bool y

config ARCH_SUPPORTS_UPROBES
	def_bool y if !CPU_CK610

config CPU_HAS_CACHEV2
	bool

+2 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ static inline struct thread_info *current_thread_info(void)
#define TIF_SYSCALL_TRACE	3	/* syscall trace active */
#define TIF_SYSCALL_TRACEPOINT	4       /* syscall tracepoint instrumentation */
#define TIF_SYSCALL_AUDIT	5	/* syscall auditing */
#define TIF_UPROBE		6	/* uprobe breakpoint or singlestep */
#define TIF_POLLING_NRFLAG	16	/* poll_idle() is TIF_NEED_RESCHED */
#define TIF_MEMDIE		18      /* is terminating due to OOM killer */
#define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
@@ -68,6 +69,7 @@ static inline struct thread_info *current_thread_info(void)
#define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
#define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
#define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
#define _TIF_UPROBE		(1 << TIF_UPROBE)
#define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
#define _TIF_MEMDIE		(1 << TIF_MEMDIE)
#define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
+33 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef __ASM_CSKY_UPROBES_H
#define __ASM_CSKY_UPROBES_H

#include <asm/probes.h>

#define MAX_UINSN_BYTES		4

#define UPROBE_SWBP_INSN	USR_BKPT
#define UPROBE_SWBP_INSN_SIZE	2
#define UPROBE_XOL_SLOT_BYTES	MAX_UINSN_BYTES

typedef u32 uprobe_opcode_t;

struct arch_uprobe_task {
	unsigned long   saved_trap_no;
};

struct arch_uprobe {
	union {
		u8 insn[MAX_UINSN_BYTES];
		u8 ixol[MAX_UINSN_BYTES];
	};
	struct arch_probe_insn api;
	unsigned long insn_size;
	bool simulate;
};

int uprobe_breakpoint_handler(struct pt_regs *regs);
int uprobe_single_step_handler(struct pt_regs *regs);

#endif /* __ASM_CSKY_UPROBES_H */
+1 −1
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ ret_from_exception:
	andn	r9, r10

	ldw	r12, (r9, TINFO_FLAGS)
	andi	r12, (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED)
	andi	r12, (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | _TIF_UPROBE)
	cmpnei	r12, 0
	bt	exit_work
1:
+1 −0
Original line number Diff line number Diff line
@@ -2,5 +2,6 @@
obj-$(CONFIG_KPROBES)		+= kprobes.o decode-insn.o simulate-insn.o
obj-$(CONFIG_KPROBES)		+= kprobes_trampoline.o
obj-$(CONFIG_KPROBES_ON_FTRACE)	+= ftrace.o
obj-$(CONFIG_UPROBES)		+= uprobes.o decode-insn.o simulate-insn.o

CFLAGS_REMOVE_simulate-insn.o = $(CC_FLAGS_FTRACE)
Loading