Debian Codegraph @

tapset/linux/sysc_move_pages.stp

raw
1 # move_pages ____________________________________________________
2 # long sys_move_pages(pid_t pid, unsigned long nr_pages,
3 # const void __user * __user *pages,
4 # const int __user *nodes,
5 # int __user *status,
6 # int flags)
7 #
8 # long compat_sys_move_pages(pid_t pid, unsigned long nr_pages,
9 # compat_uptr_t __user *pages32,
10 # const int __user *nodes,
11 # int __user *status,
12 # int flags)
13 #
14
15 @define _SYSCALL_MOVE_PAGES_NAME
16 %(
17 name = "move_pages"
18 %)
19
20 @define _SYSCALL_MOVE_PAGES_ARGSTR
21 %(
22 argstr = sprintf("%d, %u, %p, %p, %p, %s", pid, nr_pages, pages,
23 nodes, status, flags_str)
24 %)
25
26 @define _SYSCALL_MOVE_PAGES_REGARGS
27 %(
28 pid = int_arg(1)
29 nr_pages = ulong_arg(2)
30 pages = pointer_arg(3)
31 nodes = pointer_arg(4)
32 status = pointer_arg(5)
33 flags = int_arg(6)
34 flags_str = _mempolicy_flags_str(flags)
35 %)
36
37 @define _SYSCALL_MOVE_PAGES_REGARGS_STORE
38 %(
39 if (@probewrite(pid))
40 set_int_arg(1, pid)
41
42 if (@probewrite(nr_pages))
43 set_ulong_arg(2, nr_pages)
44
45 if (@probewrite(pages))
46 set_pointer_arg(3, pages)
47
48 if (@probewrite(nodes))
49 set_pointer_arg(4, nodes)
50
51 if (@probewrite(status))
52 set_pointer_arg(5, status)
53
54 if (@probewrite(flags))
55 set_int_arg(6, flags)
56 %)
57
58 probe syscall.move_pages = dw_syscall.move_pages !, nd_syscall.move_pages ? {}
59 probe syscall.move_pages.return = dw_syscall.move_pages.return !, nd_syscall.move_pages.return ? {}
60
61 # dw_move_pages _____________________________________________________
62
63 probe dw_syscall.move_pages = __syscall.move_pages ?,
64 kernel.function("compat_sys_move_pages").call ?
65 {
66 @_SYSCALL_MOVE_PAGES_NAME
67 pages = @choose_defined($pages32, $pages)
68 pid = __int32($pid)
69 nodes = $nodes
70 status = $status
71 flags = __int32($flags)
72 flags_str = _mempolicy_flags_str(flags)
73 nr_pages = @__compat_ulong($nr_pages)
74 @_SYSCALL_MOVE_PAGES_ARGSTR
75 }
76 probe __syscall.move_pages = kernel.function("sys_move_pages").call
77 {
78 @__syscall_gate(@const("__NR_move_pages"))
79 }
80 probe dw_syscall.move_pages.return = __syscall.move_pages.return ?,
81 kernel.function("compat_sys_move_pages").return ?
82 {
83 @_SYSCALL_MOVE_PAGES_NAME
84 @SYSC_RETVALSTR($return)
85 }
86 probe __syscall.move_pages.return = kernel.function("sys_move_pages").return
87 {
88 @__syscall_gate(@const("__NR_move_pages"))
89 }
90
91 # nd_move_pages _____________________________________________________
92
93 probe nd_syscall.move_pages = nd1_syscall.move_pages!, nd2_syscall.move_pages!, tp_syscall.move_pages
94 { }
95
96 probe nd1_syscall.move_pages = __nd1_syscall.move_pages ?,
97 kprobe.function("compat_sys_move_pages") ?
98 {
99 @_SYSCALL_MOVE_PAGES_NAME
100 asmlinkage()
101 @_SYSCALL_MOVE_PAGES_REGARGS
102 @_SYSCALL_MOVE_PAGES_ARGSTR
103 }
104 probe __nd1_syscall.move_pages = kprobe.function("sys_move_pages")
105 {
106 @__syscall_gate(@const("__NR_move_pages"))
107 }
108
109 /* kernel 4.17+ */
110 probe nd2_syscall.move_pages =
111 kprobe.function(@arch_syscall_prefix "sys_move_pages") ?,
112 kprobe.function(@arch_syscall_prefix "compat_sys_move_pages") ?
113 {
114 __set_syscall_pt_regs(pointer_arg(1))
115 @_SYSCALL_MOVE_PAGES_NAME
116 @_SYSCALL_MOVE_PAGES_REGARGS
117 @_SYSCALL_MOVE_PAGES_ARGSTR
118 },
119 {
120 %( @_IS_SREG_KERNEL %? @_SYSCALL_MOVE_PAGES_REGARGS_STORE %)
121 }
122
123 /* kernel 3.5+, but undesirable because it affects all syscalls */
124 probe tp_syscall.move_pages = kernel.trace("sys_enter")
125 {
126 __set_syscall_pt_regs($regs)
127 @__syscall_compat_gate(@const("__NR_move_pages"), @const("__NR_compat_move_pages"))
128 @_SYSCALL_MOVE_PAGES_NAME
129 @_SYSCALL_MOVE_PAGES_REGARGS
130 @_SYSCALL_MOVE_PAGES_ARGSTR
131 },
132 {
133 %( @_IS_SREG_KERNEL %? @_SYSCALL_MOVE_PAGES_REGARGS_STORE %)
134 }
135
136 probe nd_syscall.move_pages.return = nd1_syscall.move_pages.return!, nd2_syscall.move_pages.return!, tp_syscall.move_pages.return
137 { }
138
139 probe nd1_syscall.move_pages.return = __nd1_syscall.move_pages.return ?,
140 kprobe.function("compat_sys_move_pages").return ?
141 {
142 @_SYSCALL_MOVE_PAGES_NAME
143 @SYSC_RETVALSTR(returnval())
144 }
145 probe __nd1_syscall.move_pages.return = kprobe.function("sys_move_pages").return
146 {
147 @__syscall_gate(@const("__NR_move_pages"))
148 }
149
150 /* kernel 4.17+ */
151 probe nd2_syscall.move_pages.return =
152 kprobe.function(@arch_syscall_prefix "sys_move_pages").return ?,
153 kprobe.function(@arch_syscall_prefix "compat_sys_move_pages").return ?
154 {
155 @_SYSCALL_MOVE_PAGES_NAME
156 @SYSC_RETVALSTR(returnval())
157 }
158
159 /* kernel 3.5+, but undesirable because it affects all syscalls */
160 probe tp_syscall.move_pages.return = kernel.trace("sys_exit")
161 {
162 __set_syscall_pt_regs($regs)
163 @__syscall_compat_gate(@const("__NR_move_pages"), @const("__NR_compat_move_pages"))
164 @_SYSCALL_MOVE_PAGES_NAME
165 @SYSC_RETVALSTR($ret)
166 }