linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] um/ptrace: Implement HAVE_SYSCALL_TRACEPOINTS
@ 2025-07-03 12:38 Thomas Weißschuh
  2025-07-03 12:38 ` [PATCH 1/2] um/x86: Add system call table to header file Thomas Weißschuh
  2025-07-03 12:38 ` [PATCH 2/2] um/ptrace: Implement HAVE_SYSCALL_TRACEPOINTS Thomas Weißschuh
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Weißschuh @ 2025-07-03 12:38 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Steven Rostedt,
	Masami Hiramatsu, Mathieu Desnoyers
  Cc: linux-um, linux-kernel, linux-trace-kernel, Nam Cao,
	Thomas Weißschuh

Implement syscall tracepoints through the generic tracing infrastructure.

We want to use this to run realtime validation monitors [0] inside UML,
to test applications for PREEMPT_RT compliance.

[0] https://lore.kernel.org/lkml/cover.1749547399.git.namcao@linutronix.de/

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Thomas Weißschuh (2):
      um/x86: Add system call table to header file
      um/ptrace: Implement HAVE_SYSCALL_TRACEPOINTS

 arch/um/Kconfig                   | 1 +
 arch/um/include/asm/thread_info.h | 2 ++
 arch/um/kernel/ptrace.c           | 9 +++++++++
 arch/x86/um/asm/syscall.h         | 2 ++
 4 files changed, 14 insertions(+)
---
base-commit: 19272b37aa4f83ca52bdf9c16d5d81bdd1354494
change-id: 20250702-uml-have_syscall_tracepoints-9f4d182fc308

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh@linutronix.de>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] um/x86: Add system call table to header file
  2025-07-03 12:38 [PATCH 0/2] um/ptrace: Implement HAVE_SYSCALL_TRACEPOINTS Thomas Weißschuh
@ 2025-07-03 12:38 ` Thomas Weißschuh
  2025-07-03 12:38 ` [PATCH 2/2] um/ptrace: Implement HAVE_SYSCALL_TRACEPOINTS Thomas Weißschuh
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Weißschuh @ 2025-07-03 12:38 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Steven Rostedt,
	Masami Hiramatsu, Mathieu Desnoyers
  Cc: linux-um, linux-kernel, linux-trace-kernel, Nam Cao,
	Thomas Weißschuh

The generic system call tracing infrastructure requires access to the
system call table. The symbol is already visible to the linker but is
lacking a public declaration.

Add a public declaration.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Nam Cao <namcao@linutronix.de>
---
 arch/x86/um/asm/syscall.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/um/asm/syscall.h b/arch/x86/um/asm/syscall.h
index 56a2f0913e3c0307958eb47815a7634447cb1390..d6208d0fad51a95f3d56879c1bceb50c3ec0f6b2 100644
--- a/arch/x86/um/asm/syscall.h
+++ b/arch/x86/um/asm/syscall.h
@@ -9,6 +9,8 @@ typedef asmlinkage long (*sys_call_ptr_t)(unsigned long, unsigned long,
 					  unsigned long, unsigned long,
 					  unsigned long, unsigned long);
 
+extern const sys_call_ptr_t sys_call_table[];
+
 static inline int syscall_get_arch(struct task_struct *task)
 {
 #ifdef CONFIG_X86_32

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] um/ptrace: Implement HAVE_SYSCALL_TRACEPOINTS
  2025-07-03 12:38 [PATCH 0/2] um/ptrace: Implement HAVE_SYSCALL_TRACEPOINTS Thomas Weißschuh
  2025-07-03 12:38 ` [PATCH 1/2] um/x86: Add system call table to header file Thomas Weißschuh
@ 2025-07-03 12:38 ` Thomas Weißschuh
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Weißschuh @ 2025-07-03 12:38 UTC (permalink / raw)
  To: Richard Weinberger, Anton Ivanov, Johannes Berg, Steven Rostedt,
	Masami Hiramatsu, Mathieu Desnoyers
  Cc: linux-um, linux-kernel, linux-trace-kernel, Nam Cao,
	Thomas Weißschuh

Implement syscall tracepoints through the generic tracing infrastructure.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Nam Cao <namcao@linutronix.de>
---
 arch/um/Kconfig                   | 1 +
 arch/um/include/asm/thread_info.h | 2 ++
 arch/um/kernel/ptrace.c           | 9 +++++++++
 3 files changed, 12 insertions(+)

diff --git a/arch/um/Kconfig b/arch/um/Kconfig
index f08e8a7fac93d9f98384de02710542fd75d23553..c2d2d2d99bbe3f5a5dc4afaa69e02a520e326c2d 100644
--- a/arch/um/Kconfig
+++ b/arch/um/Kconfig
@@ -35,6 +35,7 @@ config UML
 	select HAVE_RUST
 	select ARCH_HAS_UBSAN
 	select HAVE_ARCH_TRACEHOOK
+	select HAVE_SYSCALL_TRACEPOINTS
 	select THREAD_INFO_IN_TASK
 
 config MMU
diff --git a/arch/um/include/asm/thread_info.h b/arch/um/include/asm/thread_info.h
index f9ad06fcc991a2b10e2aa6059880b993e3d60a2d..b8c021f97bd17515e4f9082206addfce05b9321e 100644
--- a/arch/um/include/asm/thread_info.h
+++ b/arch/um/include/asm/thread_info.h
@@ -43,6 +43,8 @@ struct thread_info {
 #define TIF_NOTIFY_RESUME	8
 #define TIF_SECCOMP		9	/* secure computing */
 #define TIF_SINGLESTEP		10	/* single stepping userspace */
+#define TIF_SYSCALL_TRACEPOINT	11	/* syscall tracepoint instrumentation */
+
 
 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 2124624b7817439b8e1c962e8e6eb0e267db6f53..fdbb37b5c3996188d92cf307d31eeaeca1f0acce 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -9,6 +9,9 @@
 #include <linux/uaccess.h>
 #include <asm/ptrace-abi.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 void user_enable_single_step(struct task_struct *child)
 {
 	set_tsk_thread_flag(child, TIF_SINGLESTEP);
@@ -126,6 +129,9 @@ int syscall_trace_enter(struct pt_regs *regs)
 			    UPT_SYSCALL_ARG3(&regs->regs),
 			    UPT_SYSCALL_ARG4(&regs->regs));
 
+	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
+		trace_sys_enter(regs, UPT_SYSCALL_NR(&regs->regs));
+
 	if (!test_thread_flag(TIF_SYSCALL_TRACE))
 		return 0;
 
@@ -142,6 +148,9 @@ void syscall_trace_leave(struct pt_regs *regs)
 	if (test_thread_flag(TIF_SINGLESTEP))
 		send_sigtrap(&regs->regs, 0);
 
+	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
+		trace_sys_exit(regs, PT_REGS_SYSCALL_RET(regs));
+
 	if (!test_thread_flag(TIF_SYSCALL_TRACE))
 		return;
 

-- 
2.50.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-03 12:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-03 12:38 [PATCH 0/2] um/ptrace: Implement HAVE_SYSCALL_TRACEPOINTS Thomas Weißschuh
2025-07-03 12:38 ` [PATCH 1/2] um/x86: Add system call table to header file Thomas Weißschuh
2025-07-03 12:38 ` [PATCH 2/2] um/ptrace: Implement HAVE_SYSCALL_TRACEPOINTS Thomas Weißschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).