From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Alexander van Heukelum <heukelum@mailshack.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: [RFC -tip] x86: introduce X86_ assembly names macros to catch unbalanced declaration
Date: Sun, 23 Nov 2008 19:14:55 +0300 [thread overview]
Message-ID: <20081123161455.GE27396@localhost> (raw)
It's usefull to catch unbalanced or messed declarations of ENTRY and
KPROBES. These macros would help a bit (at least I hope so).
For example the following code would compile without problems
X86_ENTRY(mcount)
retq
X86_END(mcount)
But if you forget and mess the following form
X86_ENTRY(mcount)
retq
END(mcount)
X86_ENTRY(ftrace_caller)
The assembler will issue the following message:
Error: X86_ENTRY/KPROBE unbalanced or missed
Actually the checking is performed at every X86_ macro
so maybe it's good idea to put __x86_check_entry_kprobe
at the end of .S file to be sure you didn't miss anything.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
Anyway -- it's just a RFC -- so I hope there will not be much
screams of hate :-)
arch/x86/include/asm/linkage.h | 58 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 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,63 @@
#define __ALIGN_STR ".align 16,0x90"
#endif
+/*
+ * to check X86_ENTRY/X86_END and
+ * X86_KPROBE_ENTRY/X86_KPROBE_END
+ * unbalanced/messed appearance
+ */
+#define __x86_set_entry .set _X86_ENTRY_IN, 0
+#define __x86_unset_entry .set _X86_ENTRY_IN, 1
+#define __x86_set_kprobe .set _X86_KPROBE_IN, 0
+#define __x86_unset_kprobe .set _X86_KPROBE_IN, 1
+
+#define __x86_macro_err .error "X86_ENTRY/KPROBE unbalanced or missed"
+
+#define __x86_check_entry \
+ .ifdef _X86_ENTRY_IN; \
+ .ifeq _X86_ENTRY_IN; \
+ __x86_macro_err; \
+ .abort; \
+ .endif; \
+ .endif
+
+#define __x86_check_kprobe \
+ .ifdef _X86_KPROBE_IN; \
+ .ifeq _X86_KPROBE_IN; \
+ __x86_macro_err; \
+ .abort; \
+ .endif; \
+ .endif
+
+#define __x86_check_entry_kprobe \
+ __x86_check_entry; \
+ __x86_check_kprobe
+
+#define X86_ENTRY(name) \
+ __x86_check_entry_kprobe; \
+ __x86_set_entry; \
+ .globl name; \
+ __ALIGN; \
+ name:
+
+#define X86_KPROBE_ENTRY(name) \
+ __x86_check_entry_kprobe; \
+ __x86_set_kprobe; \
+ .pushsection .kprobes.text, "ax"; \
+ .globl name; \
+ __ALIGN; \
+ name:
+
+#define X86_KPROBE_END(name) \
+ __x86_unset_kprobe; \
+ __x86_check_entry_kprobe; \
+ .size name, .-name; \
+ .popsection
+
+#define X86_END(name) \
+ __x86_unset_entry; \
+ __x86_check_entry_kprobe; \
+ .size name, .-name
+
#endif /* _ASM_X86_LINKAGE_H */
next reply other threads:[~2008-11-23 16:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-23 16:14 Cyrill Gorcunov [this message]
2008-11-23 16:22 ` [RFC -tip] x86: introduce X86_ assembly names macros to catch unbalanced declaration Ingo Molnar
2008-11-23 16:27 ` Cyrill Gorcunov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081123161455.GE27396@localhost \
--to=gorcunov@gmail.com \
--cc=heukelum@mailshack.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.