mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander van Heukelum <heukelum@fastmail.fm>
To: linux-arch@vger.kernel.org,
	Alexander van Heukelum <heukelum@mailshack.com>,
	Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Sam Ravnborg <sam@ravnborg.org>,
	Cyrill Gorcunov <gorcunov@gmail.com>,
	Alexander van Heukelum <heukelum@fastmail.fm>
Subject: [PATCH last/many] x86: checking framework for correct use of ENTRY/PROC
Date: Wed, 17 Dec 2008 10:17:55 +0100	[thread overview]
Message-ID: <1229505475-10219-3-git-send-email-heukelum@fastmail.fm> (raw)
In-Reply-To: <1229505475-10219-2-git-send-email-heukelum@fastmail.fm>

[ DO NOT APPLY (yet...) At this point this patch will
just cause the build to abort due to annotation errors
found. ]

Introduce a checking framework to check correct pairing
of ENTRY/END and PROC/ENDPROC. It also checks that the
annotations are not nested. I have used the ideas and
most of the implementation from Cyrill Gorcunov who
introduced the framework to check for mismatching
KPROBE_ENTRY annotations, which was however soon made
obsolete by the removal of KPROBE_ENTRY/KPROBE_END.

Checks performed:
 o  END must terminate an ENTRY annotation
 o  ENDPROC must terminate a PROC annotation
 o  ENTRY or PROC cannot be nested inside
	another ENTRY or PROC section.

Finally the macro ENTRY_PROC_FINAL is introduced to
enable checking correct closing of PROC and ENTRY
sections at the end of assembly files.

Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
---
 arch/x86/include/asm/linkage.h |   96 ++++++++++++++++++++++++----------------
 1 files changed, 58 insertions(+), 38 deletions(-)

diff --git a/arch/x86/include/asm/linkage.h b/arch/x86/include/asm/linkage.h
index 5d98d0b..299cdf2 100644
--- a/arch/x86/include/asm/linkage.h
+++ b/arch/x86/include/asm/linkage.h
@@ -58,64 +58,84 @@
 #endif
 
 /*
- * to check ENTRY_X86/END_X86 and
- * KPROBE_ENTRY_X86/KPROBE_END_X86
+ * to check ENTRY/END and PROC/ENDPROC
  * 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;			\
+#ifdef __ASSEMBLER__
+#define __set_entry		.set ENTRY_IN, 0
+#define __unset_entry		.set ENTRY_IN, 1
+#define __set_proc		.set PROC_IN, 0
+#define __unset_proc		.set PROC_IN, 1
+
+#define __macro_err \
+	.error "ENTRY/PROC unbalanced,missed,mixed"; \
+	.abort
+
+#define __check_entry		\
+	.ifdef ENTRY_IN;	\
+	.ifeq ENTRY_IN;		\
+	__macro_err;		\
 	.endif;			\
 	.endif
 
-#define __check_kprobe_x86	\
-	.ifdef KPROBE_X86_IN;	\
-	.ifeq KPROBE_X86_IN;	\
-	__macro_err_x86;	\
-	.abort;			\
+#define __check_in_entry	\
+	.ifndef ENTRY_IN;	\
+	__macro_err;		\
+	.else;			\
+	.ifeq !ENTRY_IN;	\
+	__macro_err;		\
 	.endif;			\
 	.endif
 
-#define __check_entry_kprobe_x86	\
-	__check_entry_x86;		\
-	__check_kprobe_x86
+#define __check_proc		\
+	.ifdef PROC_IN;		\
+	.ifeq PROC_IN;		\
+	__macro_err;		\
+	.endif;			\
+	.endif
 
-#define ENTRY_KPROBE_FINAL_X86 __check_entry_kprobe_x86
+#define __check_in_proc		\
+	.ifndef PROC_IN;	\
+	__macro_err;		\
+	.else;			\
+	.ifeq !PROC_IN;		\
+	__macro_err;		\
+	.endif;			\
+	.endif
 
-#define ENTRY_X86(name)			\
-	__check_entry_kprobe_x86;	\
-	__set_entry_x86;		\
+#define __check_entry_proc	\
+	__check_entry;		\
+	__check_proc
+
+#define ENTRY_PROC_FINAL __check_entry_proc
+
+#define ENTRY(name)			\
+	__check_entry_proc;		\
+	__set_entry;			\
 	.globl name;			\
 	__ALIGN;			\
 	name:
 
-#define END_X86(name)			\
-	__unset_entry_x86;		\
-	__check_entry_kprobe_x86;	\
+#define END(name)			\
+	__check_in_entry;		\
+	__unset_entry;			\
+	__check_entry_proc;		\
 	.size name, .-name
 
-#define KPROBE_ENTRY_X86(name)		\
-	__check_entry_kprobe_x86;	\
-	__set_kprobe_x86;		\
-	.pushsection .kprobes.text, "ax"; \
+#define PROC(name)			\
+	__check_entry_proc;		\
+	__set_proc;			\
 	.globl name;			\
 	__ALIGN;			\
 	name:
 
-#define KPROBE_END_X86(name)		\
-	__unset_kprobe_x86;		\
-	__check_entry_kprobe_x86;	\
-	.size name, .-name;		\
-	.popsection
+#define ENDPROC(name)			\
+	__check_in_proc;		\
+	__unset_proc;			\
+	__check_entry_proc;		\
+	.type name, @function;		\
+	.size name, .-name
+#endif /* __ASSEMBLER__ */
 
 #endif /* _ASM_X86_LINKAGE_H */
 
-- 
1.5.4.3


  reply	other threads:[~2008-12-17  9:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-17  9:17 PROC macro to annotate functions in assembly files Alexander van Heukelum
2008-12-17  9:17 ` [PATCH 1/many] " Alexander van Heukelum
2008-12-17  9:17   ` Alexander van Heukelum [this message]
2008-12-17 11:51     ` [PATCH last/many] x86: checking framework for correct use of ENTRY/PROC Cyrill Gorcunov
2008-12-17 12:04       ` Alexander van Heukelum
2008-12-17 14:43         ` Cyrill Gorcunov
2008-12-17 17:26   ` [PATCH 1/many] PROC macro to annotate functions in assembly files Sam Ravnborg
2008-12-17 17:38     ` Cyrill Gorcunov
2008-12-17 18:00       ` Sam Ravnborg
2008-12-17 18:33         ` Cyrill Gorcunov
2008-12-18  9:51         ` Alexander van Heukelum
2008-12-18 10:07           ` Russell King
2008-12-18 11:30             ` Alexander van Heukelum
2008-12-18 10:20           ` Jan Beulich
2008-12-18 12:03           ` Cyrill Gorcunov
2008-12-18 12:40             ` Alexander van Heukelum
2008-12-18 16:05               ` Cyrill Gorcunov
2008-12-18  9:23     ` Alexander van Heukelum
2008-12-18 12:52     ` Ingo Molnar
2008-12-17 10:53 ` David Howells
2008-12-17 11:12   ` Alexander van Heukelum
2008-12-18 11:44     ` Russell King
2008-12-18 12:35       ` Alexander van Heukelum
2008-12-18 15:53         ` Russell King

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=1229505475-10219-3-git-send-email-heukelum@fastmail.fm \
    --to=heukelum@fastmail.fm \
    --cc=akpm@linux-foundation.org \
    --cc=gorcunov@gmail.com \
    --cc=heukelum@mailshack.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sam@ravnborg.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®