Debian Codegraph @

tapset/linux/sysc_getcpu.stp

raw
1 # getcpu _____________________________________________________
2 # getcpu() was added in kernel 2.6.19 for x86_64 and i386.
3 # Note that the 'tcache' argument is unused since Linux 2.6.24.
4 #
5 # SYSCALL_DEFINE3(getcpu, unsigned __user *, cpup, unsigned __user *, nodep,
6 # struct getcpu_cache __user *, unused)
7
8 @define _SYSCALL_GETCPU_NAME
9 %(
10 name = "getcpu"
11 %)
12
13 @define _SYSCALL_GETCPU_ARGSTR
14 %(
15 argstr = sprintf("%p, %p, %p", cpu_uaddr, node_uaddr, tcache_uaddr)
16 %)
17
18 @define _SYSCALL_GETCPU_REGARGS
19 %(
20 cpu_uaddr = pointer_arg(1)
21 node_uaddr = pointer_arg(2)
22 tcache_uaddr = pointer_arg(3)
23 %)
24
25 @define _SYSCALL_GETCPU_REGARGS_STORE
26 %(
27 if (@probewrite(cpu_uaddr))
28 set_pointer_arg(1, cpu_uaddr)
29
30 if (@probewrite(node_uaddr))
31 set_pointer_arg(2, node_uaddr)
32
33 if (@probewrite(tcache_uaddr))
34 set_pointer_arg(3, tcache_uaddr)
35 %)
36
37 probe syscall.getcpu = dw_syscall.getcpu !, nd_syscall.getcpu ? {}
38 probe syscall.getcpu.return = dw_syscall.getcpu.return !, nd_syscall.getcpu.return ? {}
39
40 # dw_getcpu _____________________________________________________
41
42 probe dw_syscall.getcpu = kernel.function("sys_getcpu").call ?
43 {
44 @_SYSCALL_GETCPU_NAME
45 cpu_uaddr = $cpup
46 node_uaddr = $nodep
47 tcache_uaddr = @choose_defined($unused, $cache)
48 @_SYSCALL_GETCPU_ARGSTR
49 }
50 probe dw_syscall.getcpu.return = kernel.function("sys_getcpu").return ?
51 {
52 @_SYSCALL_GETCPU_NAME
53 @SYSC_RETVALSTR($return)
54 }
55
56 # nd_getcpu _____________________________________________________
57
58 probe nd_syscall.getcpu = nd1_syscall.getcpu!, nd2_syscall.getcpu!, tp_syscall.getcpu
59 { }
60
61 probe nd1_syscall.getcpu = kprobe.function("sys_getcpu") ?
62 {
63 @_SYSCALL_GETCPU_NAME
64 asmlinkage()
65 @_SYSCALL_GETCPU_REGARGS
66 @_SYSCALL_GETCPU_ARGSTR
67 }
68
69 /* kernel 4.17+ */
70 probe nd2_syscall.getcpu = kprobe.function(@arch_syscall_prefix "sys_getcpu") ?
71 {
72 __set_syscall_pt_regs(pointer_arg(1))
73 @_SYSCALL_GETCPU_NAME
74 @_SYSCALL_GETCPU_REGARGS
75 @_SYSCALL_GETCPU_ARGSTR
76 },
77 {
78 @_SYSCALL_GETCPU_REGARGS_STORE
79 }
80
81 /* kernel 3.5+, but undesirable because it affects all syscalls */
82 probe tp_syscall.getcpu = kernel.trace("sys_enter")
83 {
84 __set_syscall_pt_regs($regs)
85 @__syscall_compat_gate(@const("__NR_getcpu"), @const("__NR_compat_getcpu"))
86 @_SYSCALL_GETCPU_NAME
87 @_SYSCALL_GETCPU_REGARGS
88 @_SYSCALL_GETCPU_ARGSTR
89 },
90 {
91 @_SYSCALL_GETCPU_REGARGS_STORE
92 }
93
94 probe nd_syscall.getcpu.return = nd1_syscall.getcpu.return!, nd2_syscall.getcpu.return!, tp_syscall.getcpu.return
95 { }
96
97 probe nd1_syscall.getcpu.return = kprobe.function("sys_getcpu").return ?
98 {
99 @_SYSCALL_GETCPU_NAME
100 @SYSC_RETVALSTR(returnval())
101 }
102
103 /* kernel 4.17+ */
104 probe nd2_syscall.getcpu.return = kprobe.function(@arch_syscall_prefix "sys_getcpu").return ?
105 {
106 @_SYSCALL_GETCPU_NAME
107 @SYSC_RETVALSTR(returnval())
108 }
109
110 /* kernel 3.5+, but undesirable because it affects all syscalls */
111 probe tp_syscall.getcpu.return = kernel.trace("sys_exit")
112 {
113 __set_syscall_pt_regs($regs)
114 @__syscall_compat_gate(@const("__NR_getcpu"), @const("__NR_compat_getcpu"))
115 @_SYSCALL_GETCPU_NAME
116 @SYSC_RETVALSTR($ret)
117 }