Skip to contentSkip to conversation

x86, kprobes: Hide skip_singlestep forward declaration properly

PATCH In review Borislav Petkov 4 participants 10 messages Sep 19, 2012 – Sep 24, 2012 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, kprobes: Hide skip_singlestep forward declaration properly

From: Borislav Petkov <[email protected]>

I get

arch/x86/kernel/kprobes.c:544:23: warning: ‘skip_singlestep’ declared ‘static’ but never defined [-Wunused-function]

on tip/auto-latest.

Hide the forward declaration in the KPROBES_CAN_USE_FTRACE as it is done in its callsites.

Cc Masami Hiramatsu <[email protected]>
Cc Steven Rostedt <[email protected]>
---
 arch/x86/kernel/kprobes.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/kprobes.c +3 -0
index b7c2a85d1926..ac4188368fdf 100644
@@ -541,8 +541,11 @@ reenter_kprobe(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb
 	return 1;
 }
 
+#ifdef KPROBES_CAN_USE_FTRACE
 static void __kprobes skip_singlestep(struct kprobe *p, struct pt_regs *regs,
 				      struct kprobe_ctlblk *kcb);
+#endif
+
 /*
  * Interrupts are disabled on entry as trap3 is an interrupt gate and they
  * remain disabled throughout this function.
Signature · 1 line
1.7.11.rc1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

I get

arch/x86/kernel/kprobes.c:544:23: warning: ‘skip_singlestep’ declared ‘static’ but never defined [-Wunused-function]

on tip/auto-latest.

Hide the forward declaration in the KPROBES_CAN_USE_FTRACE as it is done in its callsites.

Thank you for reporting and fixing :)

Ingo, please pull this.

Thank you,

Quoted 25 lines
Cc Masami Hiramatsu <[email protected]>
Cc Steven Rostedt <[email protected]>
---
 arch/x86/kernel/kprobes.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/kprobes.c +3 -0
index b7c2a85d1926..ac4188368fdf 100644
@@ -541,8 +541,11 @@ reenter_kprobe(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb
 	return 1;
 }
 
+#ifdef KPROBES_CAN_USE_FTRACE
 static void __kprobes skip_singlestep(struct kprobe *p, struct pt_regs *regs,
 				      struct kprobe_ctlblk *kcb);
+#endif
+
 /*
  * Interrupts are disabled on entry as trap3 is an interrupt gate and they
  * remain disabled throughout this function.
Signature · 4 lines
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]
#2 lore raw
Quoted 5 lines · Masami Hiramatsu
Quoted 4 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

I get

Quoted 8 lines
Quoted 6 lines

arch/x86/kernel/kprobes.c:544:23: warning: ‘skip_singlestep’ declared ‘static’ but never defined [-Wunused-function]

on tip/auto-latest.

Hide the forward declaration in the KPROBES_CAN_USE_FTRACE as it is done in its callsites.

Thank you for reporting and fixing :)

Why is a forward declation needed, why isn't the function in the proper spot in the file to begin with?

Thanks,

Ingo

#3 lore raw
Quoted 12 lines · Ingo Molnar
Quoted 9 lines · Masami Hiramatsu
Quoted 8 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

I get

arch/x86/kernel/kprobes.c:544:23: warning: ‘skip_singlestep’ declared ‘static’ but never defined [-Wunused-function]

on tip/auto-latest.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Hide the forward declaration in the KPROBES_CAN_USE_FTRACE as it is done in its callsites.

Thank you for reporting and fixing :)

Why is a forward declation needed, why isn't the function in the proper spot in the file to begin with?

There is no reason, ftrace-related things can also be moved on top. Borislav, could you move it?

Thanks,

Signature · 4 lines
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]
#4 lore raw
Quoted 16 lines · Masami Hiramatsu
Quoted 15 lines · Ingo Molnar
Quoted 12 lines · Masami Hiramatsu
Quoted 10 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

I get

arch/x86/kernel/kprobes.c:544:23: warning: ‘skip_singlestep’ declared ‘static’ but never defined [-Wunused-function]

on tip/auto-latest.

Hide the forward declaration in the KPROBES_CAN_USE_FTRACE as it is done in its callsites.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Thank you for reporting and fixing :)

Why is a forward declation needed, why isn't the function in the proper spot in the file to begin with?

There is no reason, ftrace-related things can also be moved on top. Borislav, could you move it?

Could be moved into a separate file as well - we could have arch/x86/kprobes/, with core.c, opt.c, ftrace.c and common.h in it - possibly more in the future.

Thanks,

Ingo

#5 lore raw
Quoted 3 lines · Ingo Molnar

Could be moved into a separate file as well - we could have arch/x86/kprobes/, with core.c, opt.c, ftrace.c and common.h in it - possibly more in the future.

So, I'm guessing I should move only the function now and let Masami do the proper splitup later, correct?

Signature · 8 lines
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551
#6 lore raw
Quoted 8 lines · Borislav Petkov
Quoted 3 lines · Ingo Molnar

Could be moved into a separate file as well - we could have arch/x86/kprobes/, with core.c, opt.c, ftrace.c and common.h in it - possibly more in the future.

So, I'm guessing I should move only the function now and let Masami do the proper splitup later, correct?

Yeah, I guess.

Thanks,

Ingo

#7 lore raw

PATCH 1/1 x86, kprobes: Move skip_singlestep up

From: Borislav Petkov <[email protected]>

I get

arch/x86/kernel/kprobes.c:544:23: warning: ‘skip_singlestep’ declared ‘static’ but never defined [-Wunused-function]

on tip/auto-latest.

Put the skip_singlestep function declaration up, in KPROBES_CAN_USE_FTRACE and drop the superfluous forward declaration.

Cc Masami Hiramatsu <[email protected]>
Cc Steven Rostedt <[email protected]>
---
 arch/x86/kernel/kprobes.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
arch/x86/kernel/kprobes.c +16 -16
index b7c2a85d1926..57916c0d3cf6 100644
@@ -541,8 +541,23 @@ reenter_kprobe(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb
 	return 1;
 }
 
+#ifdef KPROBES_CAN_USE_FTRACE
 static void __kprobes skip_singlestep(struct kprobe *p, struct pt_regs *regs,
-				      struct kprobe_ctlblk *kcb);
+				      struct kprobe_ctlblk *kcb)
+{
+	/*
+	 * Emulate singlestep (and also recover regs->ip)
+	 * as if there is a 5byte nop
+	 */
+	regs->ip = (unsigned long)p->addr + MCOUNT_INSN_SIZE;
+	if (unlikely(p->post_handler)) {
+		kcb->kprobe_status = KPROBE_HIT_SSDONE;
+		p->post_handler(p, regs, 0);
+	}
+	__this_cpu_write(current_kprobe, NULL);
+}
+#endif
+
 /*
  * Interrupts are disabled on entry as trap3 is an interrupt gate and they
  * remain disabled throughout this function.
@@ -1061,21 +1076,6 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
 }
 
 #ifdef KPROBES_CAN_USE_FTRACE
-static void __kprobes skip_singlestep(struct kprobe *p, struct pt_regs *regs,
-				      struct kprobe_ctlblk *kcb)
-{
-	/*
-	 * Emulate singlestep (and also recover regs->ip)
-	 * as if there is a 5byte nop
-	 */
-	regs->ip = (unsigned long)p->addr + MCOUNT_INSN_SIZE;
-	if (unlikely(p->post_handler)) {
-		kcb->kprobe_status = KPROBE_HIT_SSDONE;
-		p->post_handler(p, regs, 0);
-	}
-	__this_cpu_write(current_kprobe, NULL);
-}
-
 /* Ftrace callback handler for kprobes */
 void __kprobes kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
 				     struct ftrace_ops *ops, struct pt_regs *regs)
Signature · 1 line
1.7.11.rc1
#8 lore raw

[tip:perf/core] kprobes/x86: Move skip_singlestep up

Commit-ID:  50a011f6409e888d5f41343024d24885281f048c
Gitweb:     http://git.kernel.org/tip/50a011f6409e888d5f41343024d24885281f048c
Author:     Borislav Petkov <[email protected]>
AuthorDate: Thu, 20 Sep 2012 14:43:54 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 20 Sep 2012 14:48:16 +0200

kprobes/x86: Move skip_singlestep up

I get this warning:

arch/x86/kernel/kprobes.c:544:23: warning: ‘skip_singlestep’ declared ‘static’ but never defined

on tip/auto-latest.

Put the skip_singlestep function declaration up, in KPROBES_CAN_USE_FTRACE and drop the superfluous forward declaration.

---
 arch/x86/kernel/kprobes.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)
arch/x86/kernel/kprobes.c +16 -16
index b7c2a85..57916c0 100644
@@ -541,8 +541,23 @@ reenter_kprobe(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb
 	return 1;
 }
 
+#ifdef KPROBES_CAN_USE_FTRACE
 static void __kprobes skip_singlestep(struct kprobe *p, struct pt_regs *regs,
-				      struct kprobe_ctlblk *kcb);
+				      struct kprobe_ctlblk *kcb)
+{
+	/*
+	 * Emulate singlestep (and also recover regs->ip)
+	 * as if there is a 5byte nop
+	 */
+	regs->ip = (unsigned long)p->addr + MCOUNT_INSN_SIZE;
+	if (unlikely(p->post_handler)) {
+		kcb->kprobe_status = KPROBE_HIT_SSDONE;
+		p->post_handler(p, regs, 0);
+	}
+	__this_cpu_write(current_kprobe, NULL);
+}
+#endif
+
 /*
  * Interrupts are disabled on entry as trap3 is an interrupt gate and they
  * remain disabled throughout this function.
@@ -1061,21 +1076,6 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
 }
 
 #ifdef KPROBES_CAN_USE_FTRACE
-static void __kprobes skip_singlestep(struct kprobe *p, struct pt_regs *regs,
-				      struct kprobe_ctlblk *kcb)
-{
-	/*
-	 * Emulate singlestep (and also recover regs->ip)
-	 * as if there is a 5byte nop
-	 */
-	regs->ip = (unsigned long)p->addr + MCOUNT_INSN_SIZE;
-	if (unlikely(p->post_handler)) {
-		kcb->kprobe_status = KPROBE_HIT_SSDONE;
-		p->post_handler(p, regs, 0);
-	}
-	__this_cpu_write(current_kprobe, NULL);
-}
-
 /* Ftrace callback handler for kprobes */
 void __kprobes kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
 				     struct ftrace_ops *ops, struct pt_regs *regs)
#9 lore raw
In reply to Ingo Molnar
Quoted 24 lines · Ingo Molnar
Quoted 21 lines · Masami Hiramatsu
Quoted 19 lines · Ingo Molnar
Quoted 5 lines · Masami Hiramatsu
Quoted 4 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

I get

Quoted 8 lines
Quoted 6 lines

arch/x86/kernel/kprobes.c:544:23: warning: ‘skip_singlestep’ declared ‘static’ but never defined [-Wunused-function]

on tip/auto-latest.

Hide the forward declaration in the KPROBES_CAN_USE_FTRACE as it is done in its callsites.

Thank you for reporting and fixing :)

Why is a forward declation needed, why isn't the function in the proper spot in the file to begin with?

Quoted 6 lines
Quoted 2 lines

There is no reason, ftrace-related things can also be moved on top. Borislav, could you move it?

Could be moved into a separate file as well - we could have arch/x86/kprobes/, with core.c, opt.c, ftrace.c and common.h in it - possibly more in the future.

OK, I'll break it into those pieces :)

Thank you,

Signature · 4 lines
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]