From: Kris Van Hees Date: Tue, 21 May 2013 06:48:39 +0000 (-0400) Subject: dtrace: update syscall tracing in view of Linux 3.8 changes X-Git-Tag: v4.1.12-92~313^2~81 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=dbe57287d25670b971ff14395326908dbb804344;p=users%2Fjedix%2Flinux-maple.git dtrace: update syscall tracing in view of Linux 3.8 changes The handling of various stub-based syscalls in Linux 3.8 changed to no longer use the saved registers directly. This change is now also reflected in the DTrace overrides for those system calls. Also reset the compilatio debug settings to all-off (they should only be turned on in local compilations - never in the repo.) Signed-off-by: Kris Van Hees --- diff --git a/kernel/dtrace/dtrace_os.c b/kernel/dtrace/dtrace_os.c index c8279e31229d..a7adcfd5e0a0 100644 --- a/kernel/dtrace/dtrace_os.c +++ b/kernel/dtrace/dtrace_os.c @@ -625,9 +625,6 @@ asmlinkage long dtrace_stub_fork(uintptr_t, uintptr_t, asmlinkage long dtrace_stub_vfork(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); -asmlinkage long dtrace_stub_sigaltstack(uintptr_t, uintptr_t, - uintptr_t, uintptr_t, - uintptr_t, uintptr_t); asmlinkage long dtrace_stub_iopl(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); @@ -647,7 +644,6 @@ static systrace_info_t systrace_info = [SCE_CLONE] dtrace_stub_clone, [SCE_FORK] dtrace_stub_fork, [SCE_VFORK] dtrace_stub_vfork, - [SCE_SIGALTSTACK] dtrace_stub_sigaltstack, [SCE_IOPL] dtrace_stub_iopl, [SCE_EXECVE] dtrace_stub_execve, [SCE_RT_SIGRETURN] dtrace_stub_rt_sigreturn, @@ -706,28 +702,25 @@ systrace_info_t *dtrace_syscalls_init() { EXPORT_SYMBOL(dtrace_syscalls_init); long dtrace_clone(unsigned long clone_flags, unsigned long newsp, - void __user *parent_tid, void __user *child_tid, - struct pt_regs *regs) + int __user *parent_tidptr, int __user *child_tidptr, + int tls_val) { long rc = 0; dtrace_id_t id; dtrace_syscalls_t *sc; - if (!newsp) - newsp = regs->sp; - sc = &systrace_info.sysent[__NR_clone]; if ((id = sc->stsy_entry) != DTRACE_IDNONE) (*systrace_probe)(id, clone_flags, newsp, - (uintptr_t)parent_tid, (uintptr_t)child_tid, - (uintptr_t)regs, 0); + (uintptr_t)parent_tidptr, + (uintptr_t)child_tidptr, tls_val, 0); /* * FIXME: Add stop functionality for DTrace. */ - rc = do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid); + rc = do_fork(clone_flags, newsp, 0, parent_tidptr, child_tidptr); if ((id = sc->stsy_return) != DTRACE_IDNONE) (*systrace_probe)(id, (uintptr_t)rc, (uintptr_t)rc, @@ -736,7 +729,7 @@ long dtrace_clone(unsigned long clone_flags, unsigned long newsp, return rc; } -long dtrace_fork(struct pt_regs *regs) +long dtrace_fork(void) { long rc = 0; dtrace_id_t id; @@ -745,13 +738,13 @@ long dtrace_fork(struct pt_regs *regs) sc = &systrace_info.sysent[__NR_fork]; if ((id = sc->stsy_entry) != DTRACE_IDNONE) - (*systrace_probe)(id, (uintptr_t)regs, 0, 0, 0, 0, 0); + (*systrace_probe)(id, 0, 0, 0, 0, 0, 0); /* * FIXME: Add stop functionality for DTrace. */ - rc = do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL); + rc = do_fork(SIGCHLD, 0, 0, NULL, NULL); if ((id = sc->stsy_return) != DTRACE_IDNONE) (*systrace_probe)(id, (uintptr_t)rc, (uintptr_t)rc, @@ -760,7 +753,7 @@ long dtrace_fork(struct pt_regs *regs) return rc; } -long dtrace_vfork(struct pt_regs *regs) +long dtrace_vfork(void) { long rc = 0; dtrace_id_t id; @@ -769,14 +762,13 @@ long dtrace_vfork(struct pt_regs *regs) sc = &systrace_info.sysent[__NR_vfork]; if ((id = sc->stsy_entry) != DTRACE_IDNONE) - (*systrace_probe)(id, (uintptr_t)regs, 0, 0, 0, 0, 0); + (*systrace_probe)(id, 0, 0, 0, 0, 0, 0); /* * FIXME: Add stop functionality for DTrace. */ - rc = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->sp, regs, 0, - NULL, NULL); + rc = do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, 0, NULL, NULL); if ((id = sc->stsy_return) != DTRACE_IDNONE) (*systrace_probe)(id, (uintptr_t)rc, (uintptr_t)rc, @@ -793,13 +785,12 @@ long dtrace_execve(const char __user *name, dtrace_id_t id; dtrace_syscalls_t *sc; struct filename *path; - struct pt_regs *regs = current_pt_regs(); sc = &systrace_info.sysent[__NR_execve]; if ((id = sc->stsy_entry) != DTRACE_IDNONE) (*systrace_probe)(id, (uintptr_t)name, (uintptr_t)argv, - (uintptr_t)envp, (uintptr_t)regs, 0, 0); + (uintptr_t)envp, 0, 0, 0); /* * FIXME: Add stop functionality for DTrace. @@ -809,7 +800,7 @@ long dtrace_execve(const char __user *name, rc = PTR_ERR(path); if (IS_ERR(path)) goto out; - rc = do_execve(path->name, argv, envp, regs); + rc = do_execve(path->name, argv, envp); putname(path); out: @@ -820,32 +811,6 @@ out: return rc; } -long dtrace_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, - struct pt_regs *regs) -{ - long rc = 0; - dtrace_id_t id; - dtrace_syscalls_t *sc; - - sc = &systrace_info.sysent[__NR_sigaltstack]; - - if ((id = sc->stsy_entry) != DTRACE_IDNONE) - (*systrace_probe)(id, (uintptr_t)uss, (uintptr_t)uoss, - (uintptr_t)regs, 0, 0, 0); - - /* - * FIXME: Add stop functionality for DTrace. - */ - - rc = do_sigaltstack(uss, uoss, regs->sp); - - if ((id = sc->stsy_return) != DTRACE_IDNONE) - (*systrace_probe)(id, (uintptr_t)rc, (uintptr_t)rc, - (uintptr_t)((uint64_t)rc >> 32), 0, 0, 0); - - return rc; -} - long dtrace_iopl(unsigned int level, struct pt_regs *regs) { long rc = 0; @@ -1024,9 +989,6 @@ static int handler(struct uprobe_consumer *self, struct pt_regs *regs) return 0; } -static struct uprobe_consumer usdt_hndlr = { handler, }; -static int done = 0; - int dtrace_tracepoint_enable(pid_t pid, uintptr_t addr, fasttrap_machtp_t *mtp) { diff --git a/kernel/dtrace/dtrace_stubs_x86_64.S b/kernel/dtrace/dtrace_stubs_x86_64.S index 39620b2ef1e2..4efccdf5054b 100644 --- a/kernel/dtrace/dtrace_stubs_x86_64.S +++ b/kernel/dtrace/dtrace_stubs_x86_64.S @@ -158,10 +158,25 @@ ENTRY(\label) END(\label) .endm - PTREGSCALL dtrace_stub_clone, dtrace_clone, %r8 - PTREGSCALL dtrace_stub_fork, dtrace_fork, %rdi - PTREGSCALL dtrace_stub_vfork, dtrace_vfork, %rdi - PTREGSCALL dtrace_stub_sigaltstack, dtrace_sigaltstack, %rdx + .macro FORK_LIKE func +ENTRY(dtrace_stub_\func) + CFI_STARTPROC + popq %r11 /* save return address */ + PARTIAL_FRAME 0 + SAVE_REST + pushq %r11 /* put it back on stack */ + FIXUP_TOP_OF_STACK %r11, 8 + DEFAULT_FRAME 0 8 /* offset 8: return address */ + call dtrace_\func + RESTORE_TOP_OF_STACK %r11, 8 + ret $REST_SKIP /* pop extended registers */ + CFI_ENDPROC +END(dtrace_stub_\func) + .endm + + FORK_LIKE clone + FORK_LIKE fork + FORK_LIKE vfork PTREGSCALL dtrace_stub_iopl, dtrace_iopl, %rsi ENTRY(dtrace_stub_execve)