summaryrefslogtreecommitdiffstats
path: root/kernel/test_kprobes.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@kernel.org>2017-09-19 05:59:00 -0400
committerIngo Molnar <mingo@kernel.org>2017-09-28 03:23:03 -0400
commit3539d09154e11336c31a900a9cd49e386ba6d9b2 (patch)
tree952cd91ef95828a407fc6862c508e3cda8f6c6f3 /kernel/test_kprobes.c
parenta8976fc84b644e3b567ea2bafad3b53b21ed6b6c (diff)
kprobes: Improve smoke test to check preemptibility
Add preemptible check to each handler. Handlers are called with non-preemtible, which is guaranteed by Documentation/kprobes.txt. Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Cc: Alexei Starovoitov <ast@fb.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/150581513991.32348.7956810394499654272.stgit@devbox Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/test_kprobes.c')
-rw-r--r--kernel/test_kprobes.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/kernel/test_kprobes.c b/kernel/test_kprobes.c
index 0dbab6d1acb4..47106a1e645a 100644
--- a/kernel/test_kprobes.c
+++ b/kernel/test_kprobes.c
@@ -34,6 +34,10 @@ static noinline u32 kprobe_target(u32 value)
34 34
35static int kp_pre_handler(struct kprobe *p, struct pt_regs *regs) 35static int kp_pre_handler(struct kprobe *p, struct pt_regs *regs)
36{ 36{
37 if (preemptible()) {
38 handler_errors++;
39 pr_err("pre-handler is preemptible\n");
40 }
37 preh_val = (rand1 / div_factor); 41 preh_val = (rand1 / div_factor);
38 return 0; 42 return 0;
39} 43}
@@ -41,6 +45,10 @@ static int kp_pre_handler(struct kprobe *p, struct pt_regs *regs)
41static void kp_post_handler(struct kprobe *p, struct pt_regs *regs, 45static void kp_post_handler(struct kprobe *p, struct pt_regs *regs,
42 unsigned long flags) 46 unsigned long flags)
43{ 47{
48 if (preemptible()) {
49 handler_errors++;
50 pr_err("post-handler is preemptible\n");
51 }
44 if (preh_val != (rand1 / div_factor)) { 52 if (preh_val != (rand1 / div_factor)) {
45 handler_errors++; 53 handler_errors++;
46 pr_err("incorrect value in post_handler\n"); 54 pr_err("incorrect value in post_handler\n");
@@ -156,6 +164,10 @@ static int test_kprobes(void)
156 164
157static u32 j_kprobe_target(u32 value) 165static u32 j_kprobe_target(u32 value)
158{ 166{
167 if (preemptible()) {
168 handler_errors++;
169 pr_err("jprobe-handler is preemptible\n");
170 }
159 if (value != rand1) { 171 if (value != rand1) {
160 handler_errors++; 172 handler_errors++;
161 pr_err("incorrect value in jprobe handler\n"); 173 pr_err("incorrect value in jprobe handler\n");
@@ -232,6 +244,10 @@ static u32 krph_val;
232 244
233static int entry_handler(struct kretprobe_instance *ri, struct pt_regs *regs) 245static int entry_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
234{ 246{
247 if (preemptible()) {
248 handler_errors++;
249 pr_err("kretprobe entry handler is preemptible\n");
250 }
235 krph_val = (rand1 / div_factor); 251 krph_val = (rand1 / div_factor);
236 return 0; 252 return 0;
237} 253}
@@ -240,6 +256,10 @@ static int return_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
240{ 256{
241 unsigned long ret = regs_return_value(regs); 257 unsigned long ret = regs_return_value(regs);
242 258
259 if (preemptible()) {
260 handler_errors++;
261 pr_err("kretprobe return handler is preemptible\n");
262 }
243 if (ret != (rand1 / div_factor)) { 263 if (ret != (rand1 / div_factor)) {
244 handler_errors++; 264 handler_errors++;
245 pr_err("incorrect value in kretprobe handler\n"); 265 pr_err("incorrect value in kretprobe handler\n");