Skip to content

Commit 2a713f0

Browse files
t-8chjmberg-intel
authored andcommitted
um/ptrace: Implement HAVE_SYSCALL_TRACEPOINTS
Implement syscall tracepoints through the generic tracing infrastructure. Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Nam Cao <[email protected]> Link: https://patch.msgid.link/20250703-uml-have_syscall_tracepoints-v1-2-23c1d3808578@linutronix.de Signed-off-by: Johannes Berg <[email protected]>
1 parent 32a1566 commit 2a713f0

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

arch/um/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ config UML
3535
select HAVE_RUST
3636
select ARCH_HAS_UBSAN
3737
select HAVE_ARCH_TRACEHOOK
38+
select HAVE_SYSCALL_TRACEPOINTS
3839
select THREAD_INFO_IN_TASK
3940

4041
config MMU

arch/um/include/asm/thread_info.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ struct thread_info {
4343
#define TIF_NOTIFY_RESUME 8
4444
#define TIF_SECCOMP 9 /* secure computing */
4545
#define TIF_SINGLESTEP 10 /* single stepping userspace */
46+
#define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
47+
4648

4749
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
4850
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)

arch/um/kernel/ptrace.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#include <linux/uaccess.h>
1010
#include <asm/ptrace-abi.h>
1111

12+
#define CREATE_TRACE_POINTS
13+
#include <trace/events/syscalls.h>
14+
1215
void user_enable_single_step(struct task_struct *child)
1316
{
1417
set_tsk_thread_flag(child, TIF_SINGLESTEP);
@@ -126,6 +129,9 @@ int syscall_trace_enter(struct pt_regs *regs)
126129
UPT_SYSCALL_ARG3(&regs->regs),
127130
UPT_SYSCALL_ARG4(&regs->regs));
128131

132+
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
133+
trace_sys_enter(regs, UPT_SYSCALL_NR(&regs->regs));
134+
129135
if (!test_thread_flag(TIF_SYSCALL_TRACE))
130136
return 0;
131137

@@ -142,6 +148,9 @@ void syscall_trace_leave(struct pt_regs *regs)
142148
if (test_thread_flag(TIF_SINGLESTEP))
143149
send_sigtrap(&regs->regs, 0);
144150

151+
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
152+
trace_sys_exit(regs, PT_REGS_SYSCALL_RET(regs));
153+
145154
if (!test_thread_flag(TIF_SYSCALL_TRACE))
146155
return;
147156

0 commit comments

Comments
 (0)