Date: Sun, 22 Jun 2014 03:17:30 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 191260] New: [patch] dtrace fbt entry function gets the wrong values from arg5 to arg9 on amd64 platform Message-ID: <bug-191260-8@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191260 Bug ID: 191260 Summary: [patch] dtrace fbt entry function gets the wrong values from arg5 to arg9 on amd64 platform Product: Base System Version: 11.0-CURRENT Hardware: Any OS: Any Status: Needs Triage Severity: Affects Some People Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: luke.tw@gmail.com Created attachment 144012 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=144012&action=edit patch for dtrace_getarg() There are two problems in the dtrace_getarg() implementation on amd64 platform. In sys/cddl/dev/dtrace/amd64/dtrace_isa.c, 1. dtrace_getarg() cannot find the dtrace_invop stack frame The return address of function dtrace_invop() may be different than dtrace_invop_callsite, because the later is aligned on 16-byte boundary on amd64 platform. As shown in the following disassembly code, there is 14 bytes nop between them. 00000000000249f0 <dtrace_invop_start>: 249f0: 48 8b bc 24 98 00 00 mov 0x98(%rsp),%rdi 249f7: 00 249f8: 48 ff cf dec %rdi 249fb: 48 8b b4 24 b0 00 00 mov 0xb0(%rsp),%rsi 24a02: 00 24a03: 48 8b 54 24 30 mov 0x30(%rsp),%rdx 24a08: ff 36 pushq (%rsi) 24a0a: 48 89 e6 mov %rsp,%rsi 24a0d: e8 00 00 00 00 callq 24a12 <dtrace_invop_start+0x22> 24a12: 66 66 66 66 66 2e 0f nopw %cs:0x0(%rax,%rax,1) 24a19: 1f 84 00 00 00 00 00 0000000000024a20 <dtrace_invop_callsite>: 24a20: 48 83 c4 08 add $0x8,%rsp 24a24: 83 f8 01 cmp $0x1,%eax 2. struct trapframe should be used to match the struct regs used in illumos. * experiment: I write a simple kernel module with a function traceme to print its ten arguments: void traceme(long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long arg6, long arg7, long arg8, long arg9) { printf("test:%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); } And the calling the function like this: traceme(0,1,2,3,4,5,6,7,8,9); * before patch # dtrace -n 'fbt:example:traceme:entry {printf("%d %d %d %d %d %d %d %d %d %d\n", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);}' dtrace: description 'fbt:example:traceme:entry ' matched 1 probe CPU ID FUNCTION:NAME 0 48648 traceme:entry 0 1 2 3 4 -2118041099 0 1 2 3 * after patch # dtrace -n 'fbt:example:traceme:entry {printf("%d %d %d %d %d %d %d %d %d %d\n", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);}' dtrace: description 'fbt:example:traceme:entry ' matched 1 probe CPU ID FUNCTION:NAME 1 48648 traceme:entry 0 1 2 3 4 5 6 7 8 9 -- You are receiving this mail because: You are the assignee for the bug.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-191260-8>