* [RFC -tip] x86: introduce ENTRY(KPROBE_ENTRY)_X86 assembly helpers to catch unbalanced declaration v3
@ 2008-11-23 17:21 Cyrill Gorcunov
2008-11-23 17:30 ` Cyrill Gorcunov
0 siblings, 1 reply; 4+ messages in thread
From: Cyrill Gorcunov @ 2008-11-23 17:21 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Alexander van Heukelum, H. Peter Anvin, Thomas Gleixner
Impact: improvements
It's usefull to catch unbalanced or messed or mixed declarations of ENTRY and
KPROBES. These macros would help a bit.
For example the following code would compile without problems
ENTRY_X86(mcount)
retq
END_X86(mcount)
But if you forget and mess the following form
ENTRY_X86(mcount)
retq
END(mcount)
ENTRY_X86(ftrace_caller)
The assembler will issue the following message:
Error: ENTRY_X86/KPROBE_X86 unbalanced,missed,mixed
Actually the checking is performed at every _X86 macro
so maybe it's good idea to put ENTRY_KPROBE_FINAL_X86
at the end of .S file to be sure you didn't miss anything.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
arch/x86/include/asm/linkage.h | 60 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
Index: linux-2.6.git/arch/x86/include/asm/linkage.h
===================================================================
--- linux-2.6.git.orig/arch/x86/include/asm/linkage.h
+++ linux-2.6.git/arch/x86/include/asm/linkage.h
@@ -57,5 +57,65 @@
#define __ALIGN_STR ".align 16,0x90"
#endif
+/*
+ * to check ENTRY_X86/END_X86 and
+ * KPROBE_ENTRY_X86/KPROBE_END_X86
+ * unbalanced-missed-mixed appearance
+ */
+#define __set_entry_x86 .set ENTRY_X86_IN, 0
+#define __unset_entry_x86 .set ENTRY_X86_IN, 1
+#define __set_kprobe_x86 .set KPROBE_X86_IN, 0
+#define __unset_kprobe_x86 .set KPROBE_X86_IN, 1
+
+#define __macro_err_x86 .error "ENTRY_X86/KPROBE_X86 unbalanced,missed,mixed"
+
+#define __check_entry_x86 \
+ .ifdef ENTRY_X86_IN; \
+ .ifeq ENTRY_X86_IN; \
+ __macro_err_x86; \
+ .abort; \
+ .endif; \
+ .endif
+
+#define __check_kprobe_x86 \
+ .ifdef KPROBE_X86_IN; \
+ .ifeq KPROBE_X86_IN; \
+ __macro_err_x86; \
+ .abort; \
+ .endif; \
+ .endif
+
+#define __check_entry_kprobe_x86 \
+ __check_entry_x86; \
+ __check_kprobe_x86
+
+#define ENTRY_KPROBE_FINAL_X86 __check_entry_kprobe_x86
+
+#define ENTRY_X86(name) \
+ __check_entry_kprobe_x86; \
+ __set_entry_x86; \
+ .globl name; \
+ __ALIGN; \
+ name:
+
+#define END_X86(name) \
+ __unset_entry_x86; \
+ __check_entry_kprobe_x86; \
+ .size name, .-name
+
+#define KPROBE_ENTRY_X86(name) \
+ __check_entry_kprobe_x86; \
+ __set_kprobe_x86; \
+ .pushsection .kprobes.text, "ax"; \
+ .globl name; \
+ __ALIGN; \
+ name:
+
+#define KPROBE_END_X86(name) \
+ __unset_kprobe_x86; \
+ __check_entry_kprobe_x86; \
+ .size name, .-name; \
+ .popsection
+
#endif /* _ASM_X86_LINKAGE_H */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC -tip] x86: introduce ENTRY(KPROBE_ENTRY)_X86 assembly helpers to catch unbalanced declaration v3
2008-11-23 17:21 [RFC -tip] x86: introduce ENTRY(KPROBE_ENTRY)_X86 assembly helpers to catch unbalanced declaration v3 Cyrill Gorcunov
@ 2008-11-23 17:30 ` Cyrill Gorcunov
2008-11-23 18:57 ` Ingo Molnar
0 siblings, 1 reply; 4+ messages in thread
From: Cyrill Gorcunov @ 2008-11-23 17:30 UTC (permalink / raw)
To: Ingo Molnar, Alexander van Heukelum, H. Peter Anvin,
Thomas Gleixner; +Cc: LKML
[Cyrill Gorcunov - Sun, Nov 23, 2008 at 08:21:39PM +0300]
| Impact: improvements
|
| It's usefull to catch unbalanced or messed or mixed declarations of ENTRY and
| KPROBES. These macros would help a bit.
|
...
Forgot to CC LKML, so I bounce the message to LKML and add
this reply with LKML CC'ed. Sorry.
- Cyrill -
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC -tip] x86: introduce ENTRY(KPROBE_ENTRY)_X86 assembly helpers to catch unbalanced declaration v3
2008-11-23 17:30 ` Cyrill Gorcunov
@ 2008-11-23 18:57 ` Ingo Molnar
2008-11-23 18:59 ` Cyrill Gorcunov
0 siblings, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2008-11-23 18:57 UTC (permalink / raw)
To: Cyrill Gorcunov
Cc: Alexander van Heukelum, H. Peter Anvin, Thomas Gleixner, LKML
* Cyrill Gorcunov <gorcunov@gmail.com> wrote:
> | Impact: improvements
> |
> | It's usefull to catch unbalanced or messed or mixed declarations of ENTRY and
> | KPROBES. These macros would help a bit.
applied to tip/x86/irq, thanks Cyrill.
Now lets try a patch that makes use of it in the entry*.S files, and
see the fallout?
Ingo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC -tip] x86: introduce ENTRY(KPROBE_ENTRY)_X86 assembly helpers to catch unbalanced declaration v3
2008-11-23 18:57 ` Ingo Molnar
@ 2008-11-23 18:59 ` Cyrill Gorcunov
0 siblings, 0 replies; 4+ messages in thread
From: Cyrill Gorcunov @ 2008-11-23 18:59 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Alexander van Heukelum, H. Peter Anvin, Thomas Gleixner, LKML
[Ingo Molnar - Sun, Nov 23, 2008 at 07:57:26PM +0100]
|
| * Cyrill Gorcunov <gorcunov@gmail.com> wrote:
|
| > | Impact: improvements
| > |
| > | It's usefull to catch unbalanced or messed or mixed declarations of ENTRY and
| > | KPROBES. These macros would help a bit.
|
| applied to tip/x86/irq, thanks Cyrill.
|
| Now lets try a patch that makes use of it in the entry*.S files, and
| see the fallout?
|
| Ingo
|
OK, let me fetch your branch first :)
- Cyrill -
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-11-23 18:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-23 17:21 [RFC -tip] x86: introduce ENTRY(KPROBE_ENTRY)_X86 assembly helpers to catch unbalanced declaration v3 Cyrill Gorcunov
2008-11-23 17:30 ` Cyrill Gorcunov
2008-11-23 18:57 ` Ingo Molnar
2008-11-23 18:59 ` Cyrill Gorcunov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox