Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1743054 > unrolled thread

[PATCH v4 01/27] linkage: new macros for assembler symbols

Started byJiri Slaby <jslaby@suse.cz>
First post2017-10-02 11:20 +0200
Last post2017-10-02 22:50 +0200
Articles 8 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v4 01/27] linkage: new macros for assembler symbols Jiri Slaby <jslaby@suse.cz> - 2017-10-02 11:20 +0200
    [PATCH v4 19/27] x86: assembly, make some functions local Jiri Slaby <jslaby@suse.cz> - 2017-10-02 11:20 +0200
      Re: [PATCH v4 19/27] x86: assembly, make some functions local Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-10-02 14:50 +0200
    [PATCH v4 10/27] x86: head, annotate data appropriatelly Jiri Slaby <jslaby@suse.cz> - 2017-10-02 11:20 +0200
    [PATCH v4 22/27] x86_64: assembly, change all ENTRY+END to SYM_CODE_* Jiri Slaby <jslaby@suse.cz> - 2017-10-02 11:20 +0200
      Re: [PATCH v4 22/27] x86_64: assembly, change all ENTRY+END to  SYM_CODE_* Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2017-10-02 22:50 +0200
    Re: [PATCH v4 23/27] x86_64: assembly, change all ENTRY+ENDPROC to SYM_FUNC_* "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2017-10-02 14:50 +0200
    Re: [PATCH v4 23/27] x86_64: assembly, change all ENTRY+ENDPROC to  SYM_FUNC_* Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2017-10-02 22:50 +0200

#1743054 — [PATCH v4 01/27] linkage: new macros for assembler symbols

FromJiri Slaby <jslaby@suse.cz>
Date2017-10-02 11:20 +0200
Subject[PATCH v4 01/27] linkage: new macros for assembler symbols
Message-ID<uw53j-5uV-3@gated-at.bofh.it>
Introduce new C macros for annotations of functions and data in
assembly. There is a long-standing mess in macros like ENTRY, END,
ENDPROC and similar. They are used in different manners and sometimes
incorrectly.

So introduce macros with clear use to annotate assembly as follows:

a) Support macros for the ones below
   SYM_T_FUNC -- type used by assembler to mark functions
   SYM_T_OBJECT -- type used by assembler to mark data
   SYM_T_NONE -- type used by assembler to mark entries of unknown type

   They are defined as STT_FUNC, STT_OBJECT, and STT_NOTYPE
   respectively. According to the gas manual, this is the most portable
   way. I am not sure about other assemblers, so we can switch this back
   to %function and %object if this turns into a problem. Architectures
   can also override them by something like ", @function" if they need.

   SYM_A_ALIGN, SYM_A_NONE -- align the symbol?
   SYM_V_GLOBAL, SYM_V_WEAK, SYM_V_LOCAL -- visibility of symbols

b) Mostly internal annotations, used by the ones below
   SYM_ENTRY -- use only if you have to (for non-paired symbols)
   SYM_START -- use only if you have to (for paired symbols)
   SYM_END -- use only if you have to (for paired symbols)

c) Annotations for code
   SYM_FUNC_START_LOCAL_ALIAS -- use where there are two local names for
	one function
   SYM_FUNC_START_ALIAS -- use where there are two global names for one
	function
   SYM_FUNC_END_ALIAS -- the end of LOCAL_ALIASed or ALIASed function

   SYM_FUNC_START -- use for global functions
   SYM_FUNC_START_NOALIGN -- use for global functions, w/o alignment
   SYM_FUNC_START_LOCAL -- use for local functions
   SYM_FUNC_START_LOCAL_NOALIGN -- use for local functions, w/o
	alignment
   SYM_FUNC_START_WEAK -- use for weak functions
   SYM_FUNC_START_WEAK_NOALIGN -- use for weak functions, w/o alignment
   SYM_FUNC_END -- the end of SYM_FUNC_START_LOCAL, SYM_FUNC_START,
	SYM_FUNC_START_WEAK, ...

   SYM_FUNC_INNER_LABEL -- only for labels in the middle of functions
   SYM_FUNC_INNER_LABEL_NOALIGN -- only for labels in the middle of
	functions, w/o alignment

   For functions with special (non-C) calling conventions:
   SYM_CODE_START -- use for non-C (special) functions
   SYM_CODE_START_NOALIGN -- use for non-C (special) functions, w/o
	alignment
   SYM_CODE_START_LOCAL -- use for local non-C (special) functions
   SYM_CODE_START_LOCAL_NOALIGN -- use for local non-C (special)
	functions, w/o alignment
   SYM_CODE_END -- the end of SYM_CODE_START_LOCAL or SYM_CODE_START

   SYM_CODE_INNER_LABEL -- only for labels in the middle of code
   SYM_CODE_INNER_LABEL_NOALIGN -- only for labels in the middle of code

d) For data
   SYM_DATA_START -- global data symbol
   SYM_DATA_END -- the end of the SYM_DATA_START symbol
   SYM_DATA_END_LABEL -- the labeled end of SYM_DATA_START symbol
   SYM_DATA_SIMPLE -- start+end wrapper around simple global data
   SYM_DATA_SIMPLE_LOCAL -- start+end wrapper around simple local data

==========

The macros allow to pair starts and ends of functions and mark functions
correctly in the output ELF objects.

All users of the old macros in x86 are converted to use these in further
patches.

[v2]
* use SYM_ prefix and sane names
* add SYM_START and SYM_END and parametrize all the macros

[v3]
* add SYM_DATA_SIMPLE, SYM_DATA_SIMPLE_LOCAL, and SYM_DATA_END_LABEL

[v4]
* add _NOALIGN versions of some macros
* add _CODE_ derivates of _FUNC_ macros

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: hpa@zytor.com
Cc: Ingo Molnar <mingo@kernel.org>
Cc: jpoimboe@redhat.com
Cc: Juergen Gross <jgross@suse.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-pm@vger.kernel.org
Cc: mingo@redhat.com
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: xen-devel@lists.xenproject.org
Cc: x86@kernel.org
---
 arch/x86/include/asm/linkage.h |  10 +-
 include/linux/linkage.h        | 257 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 257 insertions(+), 10 deletions(-)

diff --git a/arch/x86/include/asm/linkage.h b/arch/x86/include/asm/linkage.h
index 0ccb26dda126..1d22926bb313 100644
--- a/arch/x86/include/asm/linkage.h
+++ b/arch/x86/include/asm/linkage.h
@@ -12,9 +12,13 @@
 
 #ifdef __ASSEMBLY__
 
-#define GLOBAL(name)	\
-	.globl name;	\
-	name:
+/*
+ * GLOBAL is DEPRECATED
+ *
+ * use SYM_DATA_START, SYM_FUNC_START, SYM_FUNC_INNER_LABEL, SYM_CODE_START, or
+ * similar
+ */
+#define GLOBAL(name)	SYM_ENTRY(name, SYM_V_GLOBAL, SYM_A_NONE)
 
 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_ALIGNMENT_16)
 #define __ALIGN		.p2align 4, 0x90
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index a6a42dd02466..05b5591b5cf7 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -74,25 +74,51 @@
 
 #ifdef __ASSEMBLY__
 
+/* SYM_T_FUNC -- type used by assembler to mark functions */
+#ifndef SYM_T_FUNC
+#define SYM_T_FUNC				STT_FUNC
+#endif
+
+/* SYM_T_OBJECT -- type used by assembler to mark data */
+#ifndef SYM_T_OBJECT
+#define SYM_T_OBJECT				STT_OBJECT
+#endif
+
+/* SYM_T_NONE -- type used by assembler to mark entries of unknown type */
+#ifndef SYM_T_NONE
+#define SYM_T_NONE				STT_NOTYPE
+#endif
+
+/* SYM_A_* -- align the symbol? */
+#define SYM_A_ALIGN				ALIGN
+#define SYM_A_NONE				/* nothing */
+
+/* SYM_V_* -- visibility of symbols */
+#define SYM_V_GLOBAL(name)			.globl name
+#define SYM_V_WEAK(name)			.weak name
+#define SYM_V_LOCAL(name)			/* nothing */
+
 #ifndef LINKER_SCRIPT
 #define ALIGN __ALIGN
 #define ALIGN_STR __ALIGN_STR
 
+/* === DEPRECATED annotations === */
+
 #ifndef ENTRY
+/* deprecated, use SYM_FUNC_START */
 #define ENTRY(name) \
-	.globl name ASM_NL \
-	ALIGN ASM_NL \
-	name:
+	SYM_FUNC_START(name)
 #endif
 #endif /* LINKER_SCRIPT */
 
 #ifndef WEAK
+/* deprecated, use SYM_FUNC_START_WEAK* */
 #define WEAK(name)	   \
-	.weak name ASM_NL   \
-	name:
+	SYM_FUNC_START_WEAK_NOALIGN(name)
 #endif
 
 #ifndef END
+/* deprecated, use SYM_FUNC_END, SYM_DATA_END, or SYM_END */
 #define END(name) \
 	.size name, .-name
 #endif
@@ -102,11 +128,228 @@
  * static analysis tools such as stack depth analyzer.
  */
 #ifndef ENDPROC
+/* deprecated, use SYM_FUNC_END */
 #define ENDPROC(name) \
-	.type name, @function ASM_NL \
-	END(name)
+	SYM_FUNC_END(name)
 #endif
 
+/* === generic annotations === */
+
+/* SYM_ENTRY -- use only if you have to for non-paired symbols */
+#ifndef SYM_ENTRY
+#define SYM_ENTRY(name, visibility, align...)		\
+	visibility(name) ASM_NL				\
+	align ASM_NL					\
+	name:
+#endif
+
+/* SYM_START -- use only if you have to */
+#ifndef SYM_START
+#define SYM_START(name, visibility, align...)		\
+	SYM_ENTRY(name, visibility, align)
 #endif
 
+/* SYM_END -- use only if you have to */
+#ifndef SYM_END
+#define SYM_END(name, sym_type)				\
+	.type name sym_type ASM_NL			\
+	.size name, .-name
 #endif
+
+/* === code annotations === */
+
+/*
+ * FUNC -- C-like functions (proper stack frame etc.)
+ * CODE -- non-C code (e.g. irq handlers with different, special stack etc.)
+ *
+ * Objtool validates stack for FUNC, but not for CODE.
+ * Objtool generates debug info for both FUNC & CODE, but needs special
+ * annotations for each CODE's start (to describe the actual stack frame).
+ *
+ * ALIAS -- does not generate debug info -- the aliased function will
+ */
+
+/*
+ * SYM_FUNC_START_LOCAL_ALIAS -- use where there are two local names for one
+ * function
+ */
+#ifndef SYM_FUNC_START_LOCAL_ALIAS
+#define SYM_FUNC_START_LOCAL_ALIAS(name)		\
+	SYM_START(name, SYM_V_LOCAL, SYM_A_ALIGN)
+#endif
+
+/*
+ * SYM_FUNC_START_ALIAS -- use where there are two global names for one
+ * function
+ */
+#ifndef SYM_FUNC_START_ALIAS
+#define SYM_FUNC_START_ALIAS(name)			\
+	SYM_START(name, SYM_V_GLOBAL, SYM_A_ALIGN)
+#endif
+
+/* SYM_FUNC_START -- use for global functions */
+#ifndef SYM_FUNC_START
+/*
+ * The same as SYM_FUNC_START_ALIAS, but we will need to distinguish these two
+ * later.
+ */
+#define SYM_FUNC_START(name)				\
+	SYM_START(name, SYM_V_GLOBAL, SYM_A_ALIGN)
+#endif
+
+/* SYM_FUNC_START_NOALIGN -- use for global functions, w/o alignment */
+#ifndef SYM_FUNC_START_NOALIGN
+#define SYM_FUNC_START_NOALIGN(name)			\
+	SYM_START(name, SYM_V_GLOBAL, SYM_A_NONE)
+#endif
+
+/* SYM_FUNC_START_LOCAL -- use for local functions */
+#ifndef SYM_FUNC_START_LOCAL
+/* the same as SYM_FUNC_START_LOCAL_ALIAS, see comment near SYM_FUNC_START */
+#define SYM_FUNC_START_LOCAL(name)			\
+	SYM_START(name, SYM_V_LOCAL, SYM_A_ALIGN)
+#endif
+
+/* SYM_FUNC_START_LOCAL_NOALIGN -- use for local functions, w/o alignment */
+#ifndef SYM_FUNC_START_LOCAL_NOALIGN
+#define SYM_FUNC_START_LOCAL_NOALIGN(name)		\
+	SYM_START(name, SYM_V_LOCAL, SYM_A_NONE)
+#endif
+
+/* SYM_FUNC_START_WEAK -- use for weak functions */
+#ifndef SYM_FUNC_START_WEAK
+#define SYM_FUNC_START_WEAK(name)			\
+	SYM_START(name, SYM_V_WEAK, SYM_A_ALIGN)
+#endif
+
+/* SYM_FUNC_START_WEAK_NOALIGN -- use for weak functions, w/o alignment */
+#ifndef SYM_FUNC_START_WEAK_NOALIGN
+#define SYM_FUNC_START_WEAK_NOALIGN(name)		\
+	SYM_START(name, SYM_V_WEAK, SYM_A_NONE)
+#endif
+
+/* SYM_FUNC_END_ALIAS -- the end of LOCAL_ALIASed or ALIASed function */
+#ifndef SYM_FUNC_END_ALIAS
+#define SYM_FUNC_END_ALIAS(name)			\
+	SYM_END(name, SYM_T_FUNC)
+#endif
+
+/*
+ * SYM_FUNC_END -- the end of SYM_FUNC_START_LOCAL, SYM_FUNC_START,
+ * SYM_FUNC_START_WEAK, ...
+ */
+#ifndef SYM_FUNC_END
+/* the same as SYM_FUNC_END_ALIAS, see comment near SYM_FUNC_START */
+#define SYM_FUNC_END(name)				\
+	SYM_END(name, SYM_T_FUNC)
+#endif
+
+/* SYM_FUNC_INNER_LABEL -- only for labels in the middle of functions */
+#ifndef SYM_FUNC_INNER_LABEL
+#define SYM_FUNC_INNER_LABEL(name, visibility)		\
+	.type name SYM_T_FUNC ASM_NL			\
+	SYM_ENTRY(name, visibility, SYM_A_ALIGN)
+#endif
+
+/* SYM_FUNC_INNER_LABEL_NOALIGN -- only for labels in the middle of functions */
+#ifndef SYM_FUNC_INNER_LABEL_NOALIGN
+#define SYM_FUNC_INNER_LABEL_NOALIGN(name, visibility)	\
+	.type name SYM_T_FUNC ASM_NL			\
+	SYM_ENTRY(name, visibility, SYM_A_NONE)
+#endif
+
+/* SYM_CODE_START -- use for non-C (special) functions */
+#ifndef SYM_CODE_START
+#define SYM_CODE_START(name)				\
+	SYM_START(name, SYM_V_GLOBAL, SYM_A_ALIGN)
+#endif
+
+/* SYM_CODE_START_NOALIGN -- use for non-C (special) functions, w/o alignment */
+#ifndef SYM_CODE_START_NOALIGN
+#define SYM_CODE_START_NOALIGN(name)			\
+	SYM_START(name, SYM_V_GLOBAL, SYM_A_NONE)
+#endif
+
+/* SYM_CODE_START_LOCAL -- use for local non-C (special) functions */
+#ifndef SYM_CODE_START_LOCAL
+#define SYM_CODE_START_LOCAL(name)			\
+	SYM_START(name, SYM_V_LOCAL, SYM_A_ALIGN)
+#endif
+
+/*
+ * SYM_CODE_START_LOCAL_NOALIGN -- use for local non-C (special) functions,
+ * w/o alignment
+ */
+#ifndef SYM_CODE_START_LOCAL_NOALIGN
+#define SYM_CODE_START_LOCAL_NOALIGN(name)		\
+	SYM_START(name, SYM_V_LOCAL, SYM_A_NONE)
+#endif
+
+/* SYM_CODE_END -- the end of SYM_CODE_START_LOCAL, SYM_CODE_START, ... */
+#ifndef SYM_CODE_END
+#define SYM_CODE_END(name)				\
+	SYM_END(name, SYM_T_NONE)
+#endif
+
+/* SYM_CODE_INNER_LABEL -- only for labels in the middle of code */
+#ifndef SYM_CODE_INNER_LABEL
+#define SYM_CODE_INNER_LABEL(name, visibility)		\
+	.type name SYM_T_NONE ASM_NL			\
+	SYM_ENTRY(name, visibility, SYM_A_ALIGN)
+#endif
+
+/* SYM_CODE_INNER_LABEL_NOALIGN -- only for labels in the middle of code */
+#ifndef SYM_CODE_INNER_LABEL_NOALIGN
+#define SYM_CODE_INNER_LABEL_NOALIGN(name, visibility)	\
+	.type name SYM_T_NONE ASM_NL			\
+	SYM_ENTRY(name, visibility, SYM_A_NONE)
+#endif
+
+/* === data annotations === */
+
+/* SYM_DATA_START -- global data symbol */
+#ifndef SYM_DATA_START
+#define SYM_DATA_START(name)				\
+	SYM_START(name, SYM_V_GLOBAL, SYM_A_NONE)
+#endif
+
+/* SYM_DATA_START -- local data symbol */
+#ifndef SYM_DATA_START_LOCAL
+#define SYM_DATA_START_LOCAL(name)			\
+	SYM_START(name, SYM_V_LOCAL, SYM_A_NONE)
+#endif
+
+/* SYM_DATA_END -- the end of SYM_DATA_START symbol */
+#ifndef SYM_DATA_END
+#define SYM_DATA_END(name)				\
+	SYM_END(name, SYM_T_OBJECT)
+#endif
+
+/* SYM_DATA_END_LABEL -- the labeled end of SYM_DATA_START symbol */
+#ifndef SYM_DATA_END_LABEL
+#define SYM_DATA_END_LABEL(name, visibility, label)	\
+	visibility(label) ASM_NL			\
+	.type label SYM_T_OBJECT ASM_NL			\
+	label:						\
+	SYM_END(name, SYM_T_OBJECT)
+#endif
+
+/* SYM_DATA_SIMPLE -- start+end wrapper around simple global data */
+#ifndef SYM_DATA_SIMPLE
+#define SYM_DATA_SIMPLE(name, data)				\
+	SYM_DATA_START(name) ASM_NL				\
+	data ASM_NL						\
+	SYM_DATA_END(name)
+#endif
+
+/* SYM_DATA_SIMPLE_LOCAL -- start+end wrapper around simple local data */
+#ifndef SYM_DATA_SIMPLE_LOCAL
+#define SYM_DATA_SIMPLE_LOCAL(name, data...)			\
+	SYM_DATA_START_LOCAL(name) ASM_NL			\
+	data ASM_NL						\
+	SYM_DATA_END(name)
+#endif
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* _LINUX_LINKAGE_H */
-- 
2.14.2

[toc] | [next] | [standalone]


#1743055 — [PATCH v4 19/27] x86: assembly, make some functions local

FromJiri Slaby <jslaby@suse.cz>
Date2017-10-02 11:20 +0200
Subject[PATCH v4 19/27] x86: assembly, make some functions local
Message-ID<uw53l-5uV-55@gated-at.bofh.it>
In reply to#1743054
There is a couple of assembly functions, which are invoked only locally
in the file they are defined. In C, we mark them "static". In assembly,
annotate them using SYM_{FUNC,CODE}_START_LOCAL (and switch their
ENDPROC to SYM_{FUNC,CODE}_END too). Whether FUNC or CODE depends on
ENDPROC/END for a particular function (C or non-C).

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: x86@kernel.org
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: linux-efi@vger.kernel.org
Cc: xen-devel@lists.xenproject.org
---
 arch/x86/boot/compressed/efi_thunk_64.S |  8 ++++----
 arch/x86/entry/entry_64.S               | 25 +++++++++++++------------
 arch/x86/lib/copy_page_64.S             |  4 ++--
 arch/x86/lib/memcpy_64.S                | 12 ++++++------
 arch/x86/lib/memset_64.S                |  8 ++++----
 arch/x86/platform/efi/efi_thunk_64.S    | 12 ++++++------
 arch/x86/xen/xen-pvh.S                  |  4 ++--
 7 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/arch/x86/boot/compressed/efi_thunk_64.S b/arch/x86/boot/compressed/efi_thunk_64.S
index 86528f120962..c072711d8d62 100644
--- a/arch/x86/boot/compressed/efi_thunk_64.S
+++ b/arch/x86/boot/compressed/efi_thunk_64.S
@@ -98,12 +98,12 @@ ENTRY(efi64_thunk)
 	ret
 ENDPROC(efi64_thunk)
 
-ENTRY(efi_exit32)
+SYM_FUNC_START_LOCAL(efi_exit32)
 	movq	func_rt_ptr(%rip), %rax
 	push	%rax
 	mov	%rdi, %rax
 	ret
-ENDPROC(efi_exit32)
+SYM_FUNC_END(efi_exit32)
 
 	.code32
 /*
@@ -111,7 +111,7 @@ ENDPROC(efi_exit32)
  *
  * The stack should represent the 32-bit calling convention.
  */
-ENTRY(efi_enter32)
+SYM_FUNC_START_LOCAL(efi_enter32)
 	movl	$__KERNEL_DS, %eax
 	movl	%eax, %ds
 	movl	%eax, %es
@@ -171,7 +171,7 @@ ENTRY(efi_enter32)
 	btsl	$X86_CR0_PG_BIT, %eax
 	movl	%eax, %cr0
 	lret
-ENDPROC(efi_enter32)
+SYM_FUNC_END(efi_enter32)
 
 	.data
 	.balign	8
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 509504db0e2a..ff4964dac2dc 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -324,7 +324,7 @@ opportunistic_sysret_failed:
 	jmp	restore_c_regs_and_iret
 END(entry_SYSCALL_64)
 
-ENTRY(stub_ptregs_64)
+SYM_CODE_START_LOCAL(stub_ptregs_64)
 	/*
 	 * Syscalls marked as needing ptregs land here.
 	 * If we are on the fast path, we need to save the extra regs,
@@ -349,7 +349,7 @@ ENTRY(stub_ptregs_64)
 
 1:
 	jmp	*%rax				/* Called from C */
-END(stub_ptregs_64)
+SYM_CODE_END(stub_ptregs_64)
 
 .macro ptregs_stub func
 ENTRY(ptregs_\func)
@@ -976,7 +976,8 @@ idtentry hypervisor_callback xen_do_hypervisor_callback has_error_code=0
  * existing activation in its critical region -- if so, we pop the current
  * activation and restart the handler using the previous one.
  */
-ENTRY(xen_do_hypervisor_callback)		/* do_hypervisor_callback(struct *pt_regs) */
+/* do_hypervisor_callback(struct *pt_regs) */
+SYM_CODE_START_LOCAL(xen_do_hypervisor_callback)
 
 /*
  * Since we don't modify %rdi, evtchn_do_upall(struct *pt_regs) will
@@ -994,7 +995,7 @@ ENTRY(xen_do_hypervisor_callback)		/* do_hypervisor_callback(struct *pt_regs) */
 	call	xen_maybe_preempt_hcall
 #endif
 	jmp	error_exit
-END(xen_do_hypervisor_callback)
+SYM_CODE_END(xen_do_hypervisor_callback)
 
 /*
  * Hypervisor uses this for application faults while it executes.
@@ -1078,7 +1079,7 @@ idtentry machine_check					has_error_code=0	paranoid=1 do_sym=*machine_check_vec
  * Use slow, but surefire "are we in kernel?" check.
  * Return: ebx=0: need swapgs on exit, ebx=1: otherwise
  */
-ENTRY(paranoid_entry)
+SYM_CODE_START_LOCAL(paranoid_entry)
 	UNWIND_HINT_FUNC
 	cld
 	SAVE_C_REGS 8
@@ -1092,7 +1093,7 @@ ENTRY(paranoid_entry)
 	SWAPGS
 	xorl	%ebx, %ebx
 1:	ret
-END(paranoid_entry)
+SYM_CODE_END(paranoid_entry)
 
 /*
  * "Paranoid" exit path from exception stack.  This is invoked
@@ -1106,7 +1107,7 @@ END(paranoid_entry)
  *
  * On entry, ebx is "no swapgs" flag (1: don't need swapgs, 0: need it)
  */
-ENTRY(paranoid_exit)
+SYM_CODE_START_LOCAL(paranoid_exit)
 	UNWIND_HINT_REGS
 	DISABLE_INTERRUPTS(CLBR_ANY)
 	TRACE_IRQS_OFF_DEBUG
@@ -1122,13 +1123,13 @@ paranoid_exit_restore:
 	RESTORE_C_REGS
 	REMOVE_PT_GPREGS_FROM_STACK 8
 	INTERRUPT_RETURN
-END(paranoid_exit)
+SYM_CODE_END(paranoid_exit)
 
 /*
  * Save all registers in pt_regs, and switch gs if needed.
  * Return: EBX=0: came from user mode; EBX=1: otherwise
  */
-ENTRY(error_entry)
+SYM_CODE_START_LOCAL(error_entry)
 	UNWIND_HINT_FUNC
 	cld
 	SAVE_C_REGS 8
@@ -1205,7 +1206,7 @@ ENTRY(error_entry)
 	mov	%rax, %rsp
 	decl	%ebx
 	jmp	.Lerror_entry_from_usermode_after_swapgs
-END(error_entry)
+SYM_CODE_END(error_entry)
 
 
 /*
@@ -1213,14 +1214,14 @@ END(error_entry)
  *   1: already in kernel mode, don't need SWAPGS
  *   0: user gsbase is loaded, we need SWAPGS and standard preparation for return to usermode
  */
-ENTRY(error_exit)
+SYM_CODE_START_LOCAL(error_exit)
 	UNWIND_HINT_REGS
 	DISABLE_INTERRUPTS(CLBR_ANY)
 	TRACE_IRQS_OFF
 	testl	%ebx, %ebx
 	jnz	retint_kernel
 	jmp	retint_user
-END(error_exit)
+SYM_CODE_END(error_exit)
 
 /* Runs on exception stack */
 /* XXX: broken on Xen PV */
diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
index e8508156c99d..e1ee50bc161a 100644
--- a/arch/x86/lib/copy_page_64.S
+++ b/arch/x86/lib/copy_page_64.S
@@ -20,7 +20,7 @@ ENTRY(copy_page)
 ENDPROC(copy_page)
 EXPORT_SYMBOL(copy_page)
 
-ENTRY(copy_page_regs)
+SYM_FUNC_START_LOCAL(copy_page_regs)
 	subq	$2*8,	%rsp
 	movq	%rbx,	(%rsp)
 	movq	%r12,	1*8(%rsp)
@@ -85,4 +85,4 @@ ENTRY(copy_page_regs)
 	movq	1*8(%rsp), %r12
 	addq	$2*8, %rsp
 	ret
-ENDPROC(copy_page_regs)
+SYM_FUNC_END(copy_page_regs)
diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
index 4911b1c61aa8..728703c47d58 100644
--- a/arch/x86/lib/memcpy_64.S
+++ b/arch/x86/lib/memcpy_64.S
@@ -27,7 +27,7 @@
  * rax original destination
  */
 SYM_FUNC_START_ALIAS(__memcpy)
-ENTRY(memcpy)
+SYM_FUNC_START_LOCAL(memcpy)
 	ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \
 		      "jmp memcpy_erms", X86_FEATURE_ERMS
 
@@ -39,7 +39,7 @@ ENTRY(memcpy)
 	movl %edx, %ecx
 	rep movsb
 	ret
-ENDPROC(memcpy)
+SYM_FUNC_END(memcpy)
 SYM_FUNC_END_ALIAS(__memcpy)
 EXPORT_SYMBOL(memcpy)
 EXPORT_SYMBOL(__memcpy)
@@ -48,14 +48,14 @@ EXPORT_SYMBOL(__memcpy)
  * memcpy_erms() - enhanced fast string memcpy. This is faster and
  * simpler than memcpy. Use memcpy_erms when possible.
  */
-ENTRY(memcpy_erms)
+SYM_FUNC_START_LOCAL(memcpy_erms)
 	movq %rdi, %rax
 	movq %rdx, %rcx
 	rep movsb
 	ret
-ENDPROC(memcpy_erms)
+SYM_FUNC_END(memcpy_erms)
 
-ENTRY(memcpy_orig)
+SYM_FUNC_START_LOCAL(memcpy_orig)
 	movq %rdi, %rax
 
 	cmpq $0x20, %rdx
@@ -180,7 +180,7 @@ ENTRY(memcpy_orig)
 
 .Lend:
 	retq
-ENDPROC(memcpy_orig)
+SYM_FUNC_END(memcpy_orig)
 
 #ifndef CONFIG_UML
 /*
diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
index 0d3a1d341e60..c63ae9987612 100644
--- a/arch/x86/lib/memset_64.S
+++ b/arch/x86/lib/memset_64.S
@@ -58,16 +58,16 @@ EXPORT_SYMBOL(__memset)
  *
  * rax   original destination
  */
-ENTRY(memset_erms)
+SYM_FUNC_START_LOCAL(memset_erms)
 	movq %rdi,%r9
 	movb %sil,%al
 	movq %rdx,%rcx
 	rep stosb
 	movq %r9,%rax
 	ret
-ENDPROC(memset_erms)
+SYM_FUNC_END(memset_erms)
 
-ENTRY(memset_orig)
+SYM_FUNC_START_LOCAL(memset_orig)
 	movq %rdi,%r10
 
 	/* expand byte value  */
@@ -138,4 +138,4 @@ ENTRY(memset_orig)
 	subq %r8,%rdx
 	jmp .Lafter_bad_alignment
 .Lfinal:
-ENDPROC(memset_orig)
+SYM_FUNC_END(memset_orig)
diff --git a/arch/x86/platform/efi/efi_thunk_64.S b/arch/x86/platform/efi/efi_thunk_64.S
index ff85d28c50f2..d18697df1fe9 100644
--- a/arch/x86/platform/efi/efi_thunk_64.S
+++ b/arch/x86/platform/efi/efi_thunk_64.S
@@ -66,7 +66,7 @@ ENDPROC(efi64_thunk)
  *
  * This function must be invoked with a 1:1 mapped stack.
  */
-ENTRY(__efi64_thunk)
+SYM_FUNC_START_LOCAL(__efi64_thunk)
 	movl	%ds, %eax
 	push	%rax
 	movl	%es, %eax
@@ -113,14 +113,14 @@ ENTRY(__efi64_thunk)
 	or	%rcx, %rax
 1:
 	ret
-ENDPROC(__efi64_thunk)
+SYM_FUNC_END(__efi64_thunk)
 
-ENTRY(efi_exit32)
+SYM_FUNC_START_LOCAL(efi_exit32)
 	movq	func_rt_ptr(%rip), %rax
 	push	%rax
 	mov	%rdi, %rax
 	ret
-ENDPROC(efi_exit32)
+SYM_FUNC_END(efi_exit32)
 
 	.code32
 /*
@@ -128,7 +128,7 @@ ENDPROC(efi_exit32)
  *
  * The stack should represent the 32-bit calling convention.
  */
-ENTRY(efi_enter32)
+SYM_FUNC_START_LOCAL(efi_enter32)
 	movl	$__KERNEL_DS, %eax
 	movl	%eax, %ds
 	movl	%eax, %es
@@ -144,7 +144,7 @@ ENTRY(efi_enter32)
 	pushl	%eax
 
 	lret
-ENDPROC(efi_enter32)
+SYM_FUNC_END(efi_enter32)
 
 	.data
 	.balign	8
diff --git a/arch/x86/xen/xen-pvh.S b/arch/x86/xen/xen-pvh.S
index 1b78837bad06..ba5aad3b3d6a 100644
--- a/arch/x86/xen/xen-pvh.S
+++ b/arch/x86/xen/xen-pvh.S
@@ -54,7 +54,7 @@
  * charge of setting up it's own stack, GDT and IDT.
  */
 
-ENTRY(pvh_start_xen)
+SYM_CODE_START_LOCAL(pvh_start_xen)
 	cld
 
 	lgdt (_pa(gdt))
@@ -133,7 +133,7 @@ ENTRY(pvh_start_xen)
 
 	ljmp $__BOOT_CS, $_pa(startup_32)
 #endif
-END(pvh_start_xen)
+SYM_CODE_END(pvh_start_xen)
 
 	.section ".init.data","aw"
 	.balign 8
-- 
2.14.2

[toc] | [prev] | [next] | [standalone]


#1743188 — Re: [PATCH v4 19/27] x86: assembly, make some functions local

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2017-10-02 14:50 +0200
SubjectRe: [PATCH v4 19/27] x86: assembly, make some functions local
Message-ID<uw8ky-7kS-5@gated-at.bofh.it>
In reply to#1743055
On 2 October 2017 at 10:12, Jiri Slaby <jslaby@suse.cz> wrote:
> There is a couple of assembly functions, which are invoked only locally
> in the file they are defined. In C, we mark them "static". In assembly,
> annotate them using SYM_{FUNC,CODE}_START_LOCAL (and switch their
> ENDPROC to SYM_{FUNC,CODE}_END too). Whether FUNC or CODE depends on
> ENDPROC/END for a particular function (C or non-C).
>

I wasn't cc'ed on the cover letter, so I am missing the rationale of
replacing ENTRY/ENDPROC with other macros.


> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: x86@kernel.org
> Cc: Matt Fleming <matt@codeblueprint.co.uk>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: linux-efi@vger.kernel.org
> Cc: xen-devel@lists.xenproject.org
> ---
>  arch/x86/boot/compressed/efi_thunk_64.S |  8 ++++----
>  arch/x86/entry/entry_64.S               | 25 +++++++++++++------------
>  arch/x86/lib/copy_page_64.S             |  4 ++--
>  arch/x86/lib/memcpy_64.S                | 12 ++++++------
>  arch/x86/lib/memset_64.S                |  8 ++++----
>  arch/x86/platform/efi/efi_thunk_64.S    | 12 ++++++------
>  arch/x86/xen/xen-pvh.S                  |  4 ++--
>  7 files changed, 37 insertions(+), 36 deletions(-)
>
> diff --git a/arch/x86/boot/compressed/efi_thunk_64.S b/arch/x86/boot/compressed/efi_thunk_64.S
> index 86528f120962..c072711d8d62 100644
> --- a/arch/x86/boot/compressed/efi_thunk_64.S
> +++ b/arch/x86/boot/compressed/efi_thunk_64.S
> @@ -98,12 +98,12 @@ ENTRY(efi64_thunk)
>         ret
>  ENDPROC(efi64_thunk)
>
> -ENTRY(efi_exit32)
> +SYM_FUNC_START_LOCAL(efi_exit32)
>         movq    func_rt_ptr(%rip), %rax
>         push    %rax
>         mov     %rdi, %rax
>         ret
> -ENDPROC(efi_exit32)
> +SYM_FUNC_END(efi_exit32)
>
>         .code32
>  /*
> @@ -111,7 +111,7 @@ ENDPROC(efi_exit32)
>   *
>   * The stack should represent the 32-bit calling convention.
>   */
> -ENTRY(efi_enter32)
> +SYM_FUNC_START_LOCAL(efi_enter32)
>         movl    $__KERNEL_DS, %eax
>         movl    %eax, %ds
>         movl    %eax, %es
> @@ -171,7 +171,7 @@ ENTRY(efi_enter32)
>         btsl    $X86_CR0_PG_BIT, %eax
>         movl    %eax, %cr0
>         lret
> -ENDPROC(efi_enter32)
> +SYM_FUNC_END(efi_enter32)
>
>         .data
>         .balign 8
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index 509504db0e2a..ff4964dac2dc 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -324,7 +324,7 @@ opportunistic_sysret_failed:
>         jmp     restore_c_regs_and_iret
>  END(entry_SYSCALL_64)
>
> -ENTRY(stub_ptregs_64)
> +SYM_CODE_START_LOCAL(stub_ptregs_64)
>         /*
>          * Syscalls marked as needing ptregs land here.
>          * If we are on the fast path, we need to save the extra regs,
> @@ -349,7 +349,7 @@ ENTRY(stub_ptregs_64)
>
>  1:
>         jmp     *%rax                           /* Called from C */
> -END(stub_ptregs_64)
> +SYM_CODE_END(stub_ptregs_64)
>
>  .macro ptregs_stub func
>  ENTRY(ptregs_\func)
> @@ -976,7 +976,8 @@ idtentry hypervisor_callback xen_do_hypervisor_callback has_error_code=0
>   * existing activation in its critical region -- if so, we pop the current
>   * activation and restart the handler using the previous one.
>   */
> -ENTRY(xen_do_hypervisor_callback)              /* do_hypervisor_callback(struct *pt_regs) */
> +/* do_hypervisor_callback(struct *pt_regs) */
> +SYM_CODE_START_LOCAL(xen_do_hypervisor_callback)
>
>  /*
>   * Since we don't modify %rdi, evtchn_do_upall(struct *pt_regs) will
> @@ -994,7 +995,7 @@ ENTRY(xen_do_hypervisor_callback)           /* do_hypervisor_callback(struct *pt_regs) */
>         call    xen_maybe_preempt_hcall
>  #endif
>         jmp     error_exit
> -END(xen_do_hypervisor_callback)
> +SYM_CODE_END(xen_do_hypervisor_callback)
>
>  /*
>   * Hypervisor uses this for application faults while it executes.
> @@ -1078,7 +1079,7 @@ idtentry machine_check                                    has_error_code=0        paranoid=1 do_sym=*machine_check_vec
>   * Use slow, but surefire "are we in kernel?" check.
>   * Return: ebx=0: need swapgs on exit, ebx=1: otherwise
>   */
> -ENTRY(paranoid_entry)
> +SYM_CODE_START_LOCAL(paranoid_entry)
>         UNWIND_HINT_FUNC
>         cld
>         SAVE_C_REGS 8
> @@ -1092,7 +1093,7 @@ ENTRY(paranoid_entry)
>         SWAPGS
>         xorl    %ebx, %ebx
>  1:     ret
> -END(paranoid_entry)
> +SYM_CODE_END(paranoid_entry)
>
>  /*
>   * "Paranoid" exit path from exception stack.  This is invoked
> @@ -1106,7 +1107,7 @@ END(paranoid_entry)
>   *
>   * On entry, ebx is "no swapgs" flag (1: don't need swapgs, 0: need it)
>   */
> -ENTRY(paranoid_exit)
> +SYM_CODE_START_LOCAL(paranoid_exit)
>         UNWIND_HINT_REGS
>         DISABLE_INTERRUPTS(CLBR_ANY)
>         TRACE_IRQS_OFF_DEBUG
> @@ -1122,13 +1123,13 @@ paranoid_exit_restore:
>         RESTORE_C_REGS
>         REMOVE_PT_GPREGS_FROM_STACK 8
>         INTERRUPT_RETURN
> -END(paranoid_exit)
> +SYM_CODE_END(paranoid_exit)
>
>  /*
>   * Save all registers in pt_regs, and switch gs if needed.
>   * Return: EBX=0: came from user mode; EBX=1: otherwise
>   */
> -ENTRY(error_entry)
> +SYM_CODE_START_LOCAL(error_entry)
>         UNWIND_HINT_FUNC
>         cld
>         SAVE_C_REGS 8
> @@ -1205,7 +1206,7 @@ ENTRY(error_entry)
>         mov     %rax, %rsp
>         decl    %ebx
>         jmp     .Lerror_entry_from_usermode_after_swapgs
> -END(error_entry)
> +SYM_CODE_END(error_entry)
>
>
>  /*
> @@ -1213,14 +1214,14 @@ END(error_entry)
>   *   1: already in kernel mode, don't need SWAPGS
>   *   0: user gsbase is loaded, we need SWAPGS and standard preparation for return to usermode
>   */
> -ENTRY(error_exit)
> +SYM_CODE_START_LOCAL(error_exit)
>         UNWIND_HINT_REGS
>         DISABLE_INTERRUPTS(CLBR_ANY)
>         TRACE_IRQS_OFF
>         testl   %ebx, %ebx
>         jnz     retint_kernel
>         jmp     retint_user
> -END(error_exit)
> +SYM_CODE_END(error_exit)
>
>  /* Runs on exception stack */
>  /* XXX: broken on Xen PV */
> diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
> index e8508156c99d..e1ee50bc161a 100644
> --- a/arch/x86/lib/copy_page_64.S
> +++ b/arch/x86/lib/copy_page_64.S
> @@ -20,7 +20,7 @@ ENTRY(copy_page)
>  ENDPROC(copy_page)
>  EXPORT_SYMBOL(copy_page)
>
> -ENTRY(copy_page_regs)
> +SYM_FUNC_START_LOCAL(copy_page_regs)
>         subq    $2*8,   %rsp
>         movq    %rbx,   (%rsp)
>         movq    %r12,   1*8(%rsp)
> @@ -85,4 +85,4 @@ ENTRY(copy_page_regs)
>         movq    1*8(%rsp), %r12
>         addq    $2*8, %rsp
>         ret
> -ENDPROC(copy_page_regs)
> +SYM_FUNC_END(copy_page_regs)
> diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
> index 4911b1c61aa8..728703c47d58 100644
> --- a/arch/x86/lib/memcpy_64.S
> +++ b/arch/x86/lib/memcpy_64.S
> @@ -27,7 +27,7 @@
>   * rax original destination
>   */
>  SYM_FUNC_START_ALIAS(__memcpy)
> -ENTRY(memcpy)
> +SYM_FUNC_START_LOCAL(memcpy)
>         ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \
>                       "jmp memcpy_erms", X86_FEATURE_ERMS
>
> @@ -39,7 +39,7 @@ ENTRY(memcpy)
>         movl %edx, %ecx
>         rep movsb
>         ret
> -ENDPROC(memcpy)
> +SYM_FUNC_END(memcpy)
>  SYM_FUNC_END_ALIAS(__memcpy)
>  EXPORT_SYMBOL(memcpy)
>  EXPORT_SYMBOL(__memcpy)
> @@ -48,14 +48,14 @@ EXPORT_SYMBOL(__memcpy)
>   * memcpy_erms() - enhanced fast string memcpy. This is faster and
>   * simpler than memcpy. Use memcpy_erms when possible.
>   */
> -ENTRY(memcpy_erms)
> +SYM_FUNC_START_LOCAL(memcpy_erms)
>         movq %rdi, %rax
>         movq %rdx, %rcx
>         rep movsb
>         ret
> -ENDPROC(memcpy_erms)
> +SYM_FUNC_END(memcpy_erms)
>
> -ENTRY(memcpy_orig)
> +SYM_FUNC_START_LOCAL(memcpy_orig)
>         movq %rdi, %rax
>
>         cmpq $0x20, %rdx
> @@ -180,7 +180,7 @@ ENTRY(memcpy_orig)
>
>  .Lend:
>         retq
> -ENDPROC(memcpy_orig)
> +SYM_FUNC_END(memcpy_orig)
>
>  #ifndef CONFIG_UML
>  /*
> diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
> index 0d3a1d341e60..c63ae9987612 100644
> --- a/arch/x86/lib/memset_64.S
> +++ b/arch/x86/lib/memset_64.S
> @@ -58,16 +58,16 @@ EXPORT_SYMBOL(__memset)
>   *
>   * rax   original destination
>   */
> -ENTRY(memset_erms)
> +SYM_FUNC_START_LOCAL(memset_erms)
>         movq %rdi,%r9
>         movb %sil,%al
>         movq %rdx,%rcx
>         rep stosb
>         movq %r9,%rax
>         ret
> -ENDPROC(memset_erms)
> +SYM_FUNC_END(memset_erms)
>
> -ENTRY(memset_orig)
> +SYM_FUNC_START_LOCAL(memset_orig)
>         movq %rdi,%r10
>
>         /* expand byte value  */
> @@ -138,4 +138,4 @@ ENTRY(memset_orig)
>         subq %r8,%rdx
>         jmp .Lafter_bad_alignment
>  .Lfinal:
> -ENDPROC(memset_orig)
> +SYM_FUNC_END(memset_orig)
> diff --git a/arch/x86/platform/efi/efi_thunk_64.S b/arch/x86/platform/efi/efi_thunk_64.S
> index ff85d28c50f2..d18697df1fe9 100644
> --- a/arch/x86/platform/efi/efi_thunk_64.S
> +++ b/arch/x86/platform/efi/efi_thunk_64.S
> @@ -66,7 +66,7 @@ ENDPROC(efi64_thunk)
>   *
>   * This function must be invoked with a 1:1 mapped stack.
>   */
> -ENTRY(__efi64_thunk)
> +SYM_FUNC_START_LOCAL(__efi64_thunk)
>         movl    %ds, %eax
>         push    %rax
>         movl    %es, %eax
> @@ -113,14 +113,14 @@ ENTRY(__efi64_thunk)
>         or      %rcx, %rax
>  1:
>         ret
> -ENDPROC(__efi64_thunk)
> +SYM_FUNC_END(__efi64_thunk)
>
> -ENTRY(efi_exit32)
> +SYM_FUNC_START_LOCAL(efi_exit32)
>         movq    func_rt_ptr(%rip), %rax
>         push    %rax
>         mov     %rdi, %rax
>         ret
> -ENDPROC(efi_exit32)
> +SYM_FUNC_END(efi_exit32)
>
>         .code32
>  /*
> @@ -128,7 +128,7 @@ ENDPROC(efi_exit32)
>   *
>   * The stack should represent the 32-bit calling convention.
>   */
> -ENTRY(efi_enter32)
> +SYM_FUNC_START_LOCAL(efi_enter32)
>         movl    $__KERNEL_DS, %eax
>         movl    %eax, %ds
>         movl    %eax, %es
> @@ -144,7 +144,7 @@ ENTRY(efi_enter32)
>         pushl   %eax
>
>         lret
> -ENDPROC(efi_enter32)
> +SYM_FUNC_END(efi_enter32)
>
>         .data
>         .balign 8
> diff --git a/arch/x86/xen/xen-pvh.S b/arch/x86/xen/xen-pvh.S
> index 1b78837bad06..ba5aad3b3d6a 100644
> --- a/arch/x86/xen/xen-pvh.S
> +++ b/arch/x86/xen/xen-pvh.S
> @@ -54,7 +54,7 @@
>   * charge of setting up it's own stack, GDT and IDT.
>   */
>
> -ENTRY(pvh_start_xen)
> +SYM_CODE_START_LOCAL(pvh_start_xen)
>         cld
>
>         lgdt (_pa(gdt))
> @@ -133,7 +133,7 @@ ENTRY(pvh_start_xen)
>
>         ljmp $__BOOT_CS, $_pa(startup_32)
>  #endif
> -END(pvh_start_xen)
> +SYM_CODE_END(pvh_start_xen)
>
>         .section ".init.data","aw"
>         .balign 8
> --
> 2.14.2
>

[toc] | [prev] | [next] | [standalone]


#1743056 — [PATCH v4 10/27] x86: head, annotate data appropriatelly

FromJiri Slaby <jslaby@suse.cz>
Date2017-10-02 11:20 +0200
Subject[PATCH v4 10/27] x86: head, annotate data appropriatelly
Message-ID<uw53k-5uV-35@gated-at.bofh.it>
In reply to#1743054
Use the new SYM_DATA_SIMPLE and SYM_DATA_END in both 32 and 64 bit heads.
In the 64-bit version, define also SYM_DATA_START_PAGE_ALIGNED locally
using the new SYM_START. It is used in the code instead of NEXT_PAGE()
which was defined in this file and has been using the obsolete macro
GLOBAL().

Now, the data in the 64-bit object file look sane:
Value   Size Type    Bind   Vis      Ndx Name
  0000  4096 OBJECT  GLOBAL DEFAULT   15 init_level4_pgt
  1000  4096 OBJECT  GLOBAL DEFAULT   15 level3_kernel_pgt
  2000  2048 OBJECT  GLOBAL DEFAULT   15 level2_kernel_pgt
  3000  4096 OBJECT  GLOBAL DEFAULT   15 level2_fixmap_pgt
  4000  4096 OBJECT  GLOBAL DEFAULT   15 level1_fixmap_pgt
  5000     2 OBJECT  GLOBAL DEFAULT   15 early_gdt_descr
  5002     8 OBJECT  LOCAL  DEFAULT   15 early_gdt_descr_base
  500a     8 OBJECT  GLOBAL DEFAULT   15 phys_base
  0000     8 OBJECT  GLOBAL DEFAULT   17 initial_code
  0008     8 OBJECT  GLOBAL DEFAULT   17 initial_gs
  0010     8 OBJECT  GLOBAL DEFAULT   17 initial_stack
  0000     4 OBJECT  GLOBAL DEFAULT   19 early_recursion_flag
  1000  4096 OBJECT  GLOBAL DEFAULT   19 early_level4_pgt
  2000 0x40000 OBJECT  GLOBAL DEFAULT   19 early_dynamic_pgts
  0000  4096 OBJECT  GLOBAL DEFAULT   22 empty_zero_page

All have correct size and type.

Note, that we can now see that it might be worth pushing
early_recursion_flag after early_dynamic_pgts -- we are wasting almost
4K of .init.data.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
---
 arch/x86/kernel/head_32.S | 28 ++++++++++---------
 arch/x86/kernel/head_64.S | 70 +++++++++++++++++++++++++----------------------
 2 files changed, 53 insertions(+), 45 deletions(-)

diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index bcf07134a31e..5bf2a7fe2da7 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -504,8 +504,7 @@ ENDPROC(early_ignore_irq)
 
 __INITDATA
 	.align 4
-GLOBAL(early_recursion_flag)
-	.long 0
+SYM_DATA_SIMPLE(early_recursion_flag, .long 0)
 
 __REFDATA
 	.align 4
@@ -543,7 +542,7 @@ EXPORT_SYMBOL(empty_zero_page)
 __PAGE_ALIGNED_DATA
 	/* Page-aligned for the benefit of paravirt? */
 	.align PAGE_SIZE
-ENTRY(initial_page_table)
+SYM_DATA_START(initial_page_table)
 	.long	pa(initial_pg_pmd+PGD_IDENT_ATTR),0	/* low identity map */
 # if KPMDS == 3
 	.long	pa(initial_pg_pmd+PGD_IDENT_ATTR),0
@@ -561,17 +560,17 @@ ENTRY(initial_page_table)
 #  error "Kernel PMDs should be 1, 2 or 3"
 # endif
 	.align PAGE_SIZE		/* needs to be page-sized too */
+SYM_DATA_END(initial_page_table)
 #endif
 
 .data
 .balign 4
-ENTRY(initial_stack)
-	/*
-	 * The SIZEOF_PTREGS gap is a convention which helps the in-kernel
-	 * unwinder reliably detect the end of the stack.
-	 */
-	.long init_thread_union + THREAD_SIZE - SIZEOF_PTREGS - \
-	      TOP_OF_KERNEL_STACK_PADDING;
+/*
+ * The SIZEOF_PTREGS gap is a convention which helps the in-kernel unwinder
+ * reliably detect the end of the stack.
+ */
+SYM_DATA_SIMPLE(initial_stack, .long init_thread_union + THREAD_SIZE -
+		SIZEOF_PTREGS - TOP_OF_KERNEL_STACK_PADDING)
 
 __INITRODATA
 int_msg:
@@ -592,22 +591,25 @@ int_msg:
 	ALIGN
 # early boot GDT descriptor (must use 1:1 address mapping)
 	.word 0				# 32 bit align gdt_desc.address
-boot_gdt_descr:
+SYM_DATA_START(boot_gdt_descr)
 	.word __BOOT_DS+7
 	.long boot_gdt - __PAGE_OFFSET
+SYM_DATA_END(boot_gdt_descr)
 
 # boot GDT descriptor (later on used by CPU#0):
 	.word 0				# 32 bit align gdt_desc.address
-ENTRY(early_gdt_descr)
+SYM_DATA_START(early_gdt_descr)
 	.word GDT_ENTRIES*8-1
 	.long gdt_page			/* Overwritten for secondary CPUs */
+SYM_DATA_END(early_gdt_descr)
 
 /*
  * The boot_gdt must mirror the equivalent in setup.S and is
  * used only for booting.
  */
 	.align L1_CACHE_BYTES
-ENTRY(boot_gdt)
+SYM_DATA_START(boot_gdt)
 	.fill GDT_ENTRY_BOOT_CS,8,0
 	.quad 0x00cf9a000000ffff	/* kernel 4GB code at 0x00000000 */
 	.quad 0x00cf92000000ffff	/* kernel 4GB data at 0x00000000 */
+SYM_DATA_END(boot_gdt)
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index a2668b2ced90..f134b1f61256 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -257,16 +257,14 @@ ENDPROC(start_cpu0)
 	/* Both SMP bootup and ACPI suspend change these variables */
 	__REFDATA
 	.balign	8
-	GLOBAL(initial_code)
-	.quad	x86_64_start_kernel
-	GLOBAL(initial_gs)
-	.quad	INIT_PER_CPU_VAR(irq_stack_union)
-	GLOBAL(initial_stack)
-	/*
-	 * The SIZEOF_PTREGS gap is a convention which helps the in-kernel
-	 * unwinder reliably detect the end of the stack.
-	 */
-	.quad  init_thread_union + THREAD_SIZE - SIZEOF_PTREGS
+SYM_DATA_SIMPLE(initial_code,	.quad x86_64_start_kernel)
+SYM_DATA_SIMPLE(initial_gs,	.quad INIT_PER_CPU_VAR(irq_stack_union))
+/*
+ * The SIZEOF_PTREGS gap is a convention which helps the in-kernel unwinder
+ * reliably detect the end of the stack.
+ */
+SYM_DATA_SIMPLE(initial_stack,
+		.quad init_thread_union + THREAD_SIZE - SIZEOF_PTREGS)
 	__FINITDATA
 
 	__INIT
@@ -335,12 +333,10 @@ SYM_CODE_END(early_idt_handler_common)
 	__INITDATA
 
 	.balign 4
-GLOBAL(early_recursion_flag)
-	.long 0
+SYM_DATA_SIMPLE(early_recursion_flag, .long 0)
 
-#define NEXT_PAGE(name) \
-	.balign	PAGE_SIZE; \
-GLOBAL(name)
+#define SYM_DATA_START_PAGE_ALIGNED(name)			\
+	SYM_START(name, SYM_V_GLOBAL, .balign PAGE_SIZE)
 
 /* Automate the creation of 1 to 1 mapping pmd entries */
 #define PMDS(START, PERM, COUNT)			\
@@ -351,54 +347,62 @@ GLOBAL(name)
 	.endr
 
 	__INITDATA
-NEXT_PAGE(early_top_pgt)
+SYM_DATA_START_PAGE_ALIGNED(early_top_pgt)
 	.fill	511,8,0
 #ifdef CONFIG_X86_5LEVEL
 	.quad	level4_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
 #else
 	.quad	level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
 #endif
+SYM_DATA_END(early_top_pgt)
 
-NEXT_PAGE(early_dynamic_pgts)
+SYM_DATA_START_PAGE_ALIGNED(early_dynamic_pgts)
 	.fill	512*EARLY_DYNAMIC_PAGE_TABLES,8,0
+SYM_DATA_END(early_dynamic_pgts)
 
 	.data
 
 #ifndef CONFIG_XEN
-NEXT_PAGE(init_top_pgt)
+SYM_DATA_START_PAGE_ALIGNED(init_top_pgt)
 	.fill	512,8,0
+SYM_DATA_END(init_top_pgt)
 #else
-NEXT_PAGE(init_top_pgt)
+SYM_DATA_START_PAGE_ALIGNED(init_top_pgt)
 	.quad   level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC
 	.org    init_top_pgt + PGD_PAGE_OFFSET*8, 0
 	.quad   level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC
 	.org    init_top_pgt + PGD_START_KERNEL*8, 0
 	/* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
 	.quad   level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
+SYM_DATA_END(init_top_pgt)
 
-NEXT_PAGE(level3_ident_pgt)
+SYM_DATA_START_PAGE_ALIGNED(level3_ident_pgt)
 	.quad	level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC
 	.fill	511, 8, 0
-NEXT_PAGE(level2_ident_pgt)
+SYM_DATA_END(level3_ident_pgt)
+SYM_DATA_START_PAGE_ALIGNED(level2_ident_pgt)
 	/* Since I easily can, map the first 1G.
 	 * Don't set NX because code runs from these pages.
 	 */
 	PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
+SYM_DATA_END(level2_ident_pgt)
 #endif
 
 #ifdef CONFIG_X86_5LEVEL
-NEXT_PAGE(level4_kernel_pgt)
+SYM_DATA_START_PAGE_ALIGNED(level4_kernel_pgt)
 	.fill	511,8,0
 	.quad	level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
+SYM_DATA_END(level4_kernel_pgt)
 #endif
 
-NEXT_PAGE(level3_kernel_pgt)
+SYM_DATA_START_PAGE_ALIGNED(level3_kernel_pgt)
 	.fill	L3_START_KERNEL,8,0
 	/* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */
 	.quad	level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE_NOENC
 	.quad	level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
+SYM_DATA_END(level3_kernel_pgt)
 
-NEXT_PAGE(level2_kernel_pgt)
+SYM_DATA_START_PAGE_ALIGNED(level2_kernel_pgt)
 	/*
 	 * 512 MB kernel mapping. We spend a full page on this pagetable
 	 * anyway.
@@ -411,25 +415,26 @@ NEXT_PAGE(level2_kernel_pgt)
 	 */
 	PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
 		KERNEL_IMAGE_SIZE/PMD_SIZE)
+SYM_DATA_END(level2_kernel_pgt)
 
-NEXT_PAGE(level2_fixmap_pgt)
+SYM_DATA_START_PAGE_ALIGNED(level2_fixmap_pgt)
 	.fill	506,8,0
 	.quad	level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE_NOENC
 	/* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
 	.fill	5,8,0
+SYM_DATA_END(level2_fixmap_pgt)
 
-NEXT_PAGE(level1_fixmap_pgt)
+SYM_DATA_START_PAGE_ALIGNED(level1_fixmap_pgt)
 	.fill	512,8,0
+SYM_DATA_END(level1_fixmap_pgt)
 
 #undef PMDS
 
 	.data
 	.align 16
-	.globl early_gdt_descr
-early_gdt_descr:
-	.word	GDT_ENTRIES*8-1
-early_gdt_descr_base:
-	.quad	INIT_PER_CPU_VAR(gdt_page)
+
+SYM_DATA_SIMPLE(early_gdt_descr, .word GDT_ENTRIES*8-1)
+SYM_DATA_SIMPLE_LOCAL(early_gdt_descr_base, .quad INIT_PER_CPU_VAR(gdt_page))
 
 /* This must match the first entry in level2_kernel_pgt */
 SYM_DATA_SIMPLE(phys_base, .quad 0x0000000000000000)
@@ -438,7 +443,8 @@ EXPORT_SYMBOL(phys_base)
 #include "../../x86/xen/xen-head.S"
 
 	__PAGE_ALIGNED_BSS
-NEXT_PAGE(empty_zero_page)
+SYM_DATA_START_PAGE_ALIGNED(empty_zero_page)
 	.skip PAGE_SIZE
+SYM_DATA_END(empty_zero_page)
 EXPORT_SYMBOL(empty_zero_page)
 
-- 
2.14.2

[toc] | [prev] | [next] | [standalone]


#1743057 — [PATCH v4 22/27] x86_64: assembly, change all ENTRY+END to SYM_CODE_*

FromJiri Slaby <jslaby@suse.cz>
Date2017-10-02 11:20 +0200
Subject[PATCH v4 22/27] x86_64: assembly, change all ENTRY+END to SYM_CODE_*
Message-ID<uw53l-5uV-61@gated-at.bofh.it>
In reply to#1743054
Here, we change all code which is not marked as functions. In other
words, this code has been using END, not ENDPROC. So switch all of this
to appropriate new markings SYM_CODE_START and SYM_CODE_END.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: xen-devel@lists.xenproject.org
---
 arch/x86/entry/entry_64.S        | 48 ++++++++++++++++++++--------------------
 arch/x86/entry/entry_64_compat.S |  8 +++----
 arch/x86/kernel/ftrace_64.S      | 16 +++++++-------
 arch/x86/xen/xen-asm_64.S        |  4 ++--
 arch/x86/xen/xen-head.S          |  8 +++----
 5 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index ff4964dac2dc..02e15a18e132 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -43,11 +43,11 @@
 .section .entry.text, "ax"
 
 #ifdef CONFIG_PARAVIRT
-ENTRY(native_usergs_sysret64)
+SYM_CODE_START(native_usergs_sysret64)
 	UNWIND_HINT_EMPTY
 	swapgs
 	sysretq
-END(native_usergs_sysret64)
+SYM_CODE_END(native_usergs_sysret64)
 #endif /* CONFIG_PARAVIRT */
 
 .macro TRACE_IRQS_IRETQ
@@ -135,7 +135,7 @@ END(native_usergs_sysret64)
  * with them due to bugs in both AMD and Intel CPUs.
  */
 
-ENTRY(entry_SYSCALL_64)
+SYM_CODE_START(entry_SYSCALL_64)
 	UNWIND_HINT_EMPTY
 	/*
 	 * Interrupts are off on entry.
@@ -322,7 +322,7 @@ syscall_return_via_sysret:
 opportunistic_sysret_failed:
 	SWAPGS
 	jmp	restore_c_regs_and_iret
-END(entry_SYSCALL_64)
+SYM_CODE_END(entry_SYSCALL_64)
 
 SYM_CODE_START_LOCAL(stub_ptregs_64)
 	/*
@@ -352,11 +352,11 @@ SYM_CODE_START_LOCAL(stub_ptregs_64)
 SYM_CODE_END(stub_ptregs_64)
 
 .macro ptregs_stub func
-ENTRY(ptregs_\func)
+SYM_CODE_START(ptregs_\func)
 	UNWIND_HINT_FUNC
 	leaq	\func(%rip), %rax
 	jmp	stub_ptregs_64
-END(ptregs_\func)
+SYM_CODE_END(ptregs_\func)
 .endm
 
 /* Instantiate ptregs_stub for each ptregs-using syscall */
@@ -369,7 +369,7 @@ END(ptregs_\func)
  * %rdi: prev task
  * %rsi: next task
  */
-ENTRY(__switch_to_asm)
+SYM_CODE_START(__switch_to_asm)
 	UNWIND_HINT_FUNC
 	/*
 	 * Save callee-saved registers
@@ -400,7 +400,7 @@ ENTRY(__switch_to_asm)
 	popq	%rbp
 
 	jmp	__switch_to
-END(__switch_to_asm)
+SYM_CODE_END(__switch_to_asm)
 
 /*
  * A newly forked process directly context switches into this address.
@@ -409,7 +409,7 @@ END(__switch_to_asm)
  * rbx: kernel thread func (NULL for user thread)
  * r12: kernel thread arg
  */
-ENTRY(ret_from_fork)
+SYM_CODE_START(ret_from_fork)
 	UNWIND_HINT_EMPTY
 	movq	%rax, %rdi
 	call	schedule_tail			/* rdi: 'prev' task parameter */
@@ -436,14 +436,14 @@ ENTRY(ret_from_fork)
 	 */
 	movq	$0, RAX(%rsp)
 	jmp	2b
-END(ret_from_fork)
+SYM_CODE_END(ret_from_fork)
 
 /*
  * Build the entry stubs with some assembler magic.
  * We pack 1 stub into every 8-byte block.
  */
 	.align 8
-ENTRY(irq_entries_start)
+SYM_CODE_START(irq_entries_start)
     vector=FIRST_EXTERNAL_VECTOR
     .rept (FIRST_SYSTEM_VECTOR - FIRST_EXTERNAL_VECTOR)
 	UNWIND_HINT_IRET_REGS
@@ -452,7 +452,7 @@ ENTRY(irq_entries_start)
 	.align	8
 	vector=vector+1
     .endr
-END(irq_entries_start)
+SYM_CODE_END(irq_entries_start)
 
 .macro DEBUG_ENTRY_ASSERT_IRQS_OFF
 #ifdef CONFIG_DEBUG_ENTRY
@@ -737,14 +737,14 @@ SYM_CODE_END(common_interrupt)
  * APIC interrupts.
  */
 .macro apicinterrupt3 num sym do_sym
-ENTRY(\sym)
+SYM_CODE_START(\sym)
 	UNWIND_HINT_IRET_REGS
 	ASM_CLAC
 	pushq	$~(\num)
 .Lcommon_\sym:
 	interrupt \do_sym
 	jmp	ret_from_intr
-END(\sym)
+SYM_CODE_END(\sym)
 .endm
 
 /* Make sure APIC interrupt handlers end up in the irqentry section: */
@@ -806,7 +806,7 @@ apicinterrupt IRQ_WORK_VECTOR			irq_work_interrupt		smp_irq_work_interrupt
 #define CPU_TSS_IST(x) PER_CPU_VAR(cpu_tss) + (TSS_ist + ((x) - 1) * 8)
 
 .macro idtentry sym do_sym has_error_code:req paranoid=0 shift_ist=-1
-ENTRY(\sym)
+SYM_CODE_START(\sym)
 	UNWIND_HINT_IRET_REGS offset=8
 
 	/* Sanity check */
@@ -895,7 +895,7 @@ ENTRY(\sym)
 
 	jmp	error_exit			/* %ebx: no swapgs flag */
 	.endif
-END(\sym)
+SYM_CODE_END(\sym)
 .endm
 
 idtentry divide_error			do_divide_error			has_error_code=0
@@ -1010,7 +1010,7 @@ SYM_CODE_END(xen_do_hypervisor_callback)
  * We distinguish between categories by comparing each saved segment register
  * with its current contents: any discrepancy means we in category 1.
  */
-ENTRY(xen_failsafe_callback)
+SYM_CODE_START(xen_failsafe_callback)
 	UNWIND_HINT_EMPTY
 	movl	%ds, %ecx
 	cmpw	%cx, 0x10(%rsp)
@@ -1042,7 +1042,7 @@ ENTRY(xen_failsafe_callback)
 	SAVE_EXTRA_REGS
 	ENCODE_FRAME_POINTER
 	jmp	error_exit
-END(xen_failsafe_callback)
+SYM_CODE_END(xen_failsafe_callback)
 
 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
 	xen_hvm_callback_vector xen_evtchn_do_upcall
@@ -1225,7 +1225,7 @@ SYM_CODE_END(error_exit)
 
 /* Runs on exception stack */
 /* XXX: broken on Xen PV */
-ENTRY(nmi)
+SYM_CODE_START(nmi)
 	UNWIND_HINT_IRET_REGS
 	/*
 	 * We allow breakpoints in NMIs. If a breakpoint occurs, then
@@ -1567,15 +1567,15 @@ nmi_restore:
 	 * mode, so this cannot result in a fault.
 	 */
 	INTERRUPT_RETURN
-END(nmi)
+SYM_CODE_END(nmi)
 
-ENTRY(ignore_sysret)
+SYM_CODE_START(ignore_sysret)
 	UNWIND_HINT_EMPTY
 	mov	$-ENOSYS, %eax
 	sysret
-END(ignore_sysret)
+SYM_CODE_END(ignore_sysret)
 
-ENTRY(rewind_stack_do_exit)
+SYM_CODE_START(rewind_stack_do_exit)
 	UNWIND_HINT_FUNC
 	/* Prevent any naive code from trying to unwind to our caller. */
 	xorl	%ebp, %ebp
@@ -1585,4 +1585,4 @@ ENTRY(rewind_stack_do_exit)
 	UNWIND_HINT_FUNC sp_offset=PTREGS_SIZE
 
 	call	do_exit
-END(rewind_stack_do_exit)
+SYM_CODE_END(rewind_stack_do_exit)
diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
index b0d0584f5a61..4815a8115c90 100644
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -181,7 +181,7 @@ ENDPROC(entry_SYSENTER_compat)
  * esp  user stack
  * 0(%esp) arg6
  */
-ENTRY(entry_SYSCALL_compat)
+SYM_CODE_START(entry_SYSCALL_compat)
 	/* Interrupts are off on entry. */
 	swapgs
 
@@ -261,7 +261,7 @@ sysret32_from_system_call:
 	movq	RSP-ORIG_RAX(%rsp), %rsp
 	swapgs
 	sysretl
-END(entry_SYSCALL_compat)
+SYM_CODE_END(entry_SYSCALL_compat)
 
 /*
  * 32-bit legacy system call entry.
@@ -289,7 +289,7 @@ END(entry_SYSCALL_compat)
  * edi  arg5
  * ebp  arg6
  */
-ENTRY(entry_INT80_compat)
+SYM_CODE_START(entry_INT80_compat)
 	/*
 	 * Interrupts are off on entry.
 	 */
@@ -338,7 +338,7 @@ ENTRY(entry_INT80_compat)
 	TRACE_IRQS_ON
 	SWAPGS
 	jmp	restore_regs_and_iret
-END(entry_INT80_compat)
+SYM_CODE_END(entry_INT80_compat)
 
 ENTRY(stub32_clone)
 	/*
diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S
index 1ce977394fbe..3e20eb31cca6 100644
--- a/arch/x86/kernel/ftrace_64.S
+++ b/arch/x86/kernel/ftrace_64.S
@@ -149,7 +149,7 @@ SYM_FUNC_START(function_hook)
 	retq
 SYM_FUNC_END(function_hook)
 
-ENTRY(ftrace_caller)
+SYM_CODE_START(ftrace_caller)
 	/* save_mcount_regs fills in first two parameters */
 	save_mcount_regs
 
@@ -183,9 +183,9 @@ SYM_CODE_INNER_LABEL_NOALIGN(ftrace_graph_call, SYM_V_GLOBAL)
 /* This is weak to keep gas from relaxing the jumps */
 WEAK(ftrace_stub)
 	retq
-END(ftrace_caller)
+SYM_CODE_END(ftrace_caller)
 
-ENTRY(ftrace_regs_caller)
+SYM_CODE_START(ftrace_regs_caller)
 	/* Save the current flags before any operations that can change them */
 	pushfq
 
@@ -254,12 +254,12 @@ SYM_CODE_INNER_LABEL_NOALIGN(ftrace_regs_caller_end, SYM_V_GLOBAL)
 
 	jmp ftrace_epilogue
 
-END(ftrace_regs_caller)
+SYM_CODE_END(ftrace_regs_caller)
 
 
 #else /* ! CONFIG_DYNAMIC_FTRACE */
 
-ENTRY(function_hook)
+SYM_CODE_START(function_hook)
 	cmpq $ftrace_stub, ftrace_trace_function
 	jnz trace
 
@@ -290,11 +290,11 @@ trace:
 	restore_mcount_regs
 
 	jmp fgraph_trace
-END(function_hook)
+SYM_CODE_END(function_hook)
 #endif /* CONFIG_DYNAMIC_FTRACE */
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-ENTRY(ftrace_graph_caller)
+SYM_CODE_START(ftrace_graph_caller)
 	/* Saves rbp into %rdx and fills first parameter  */
 	save_mcount_regs
 
@@ -312,7 +312,7 @@ ENTRY(ftrace_graph_caller)
 	restore_mcount_regs
 
 	retq
-END(ftrace_graph_caller)
+SYM_CODE_END(ftrace_graph_caller)
 
 SYM_CODE_START_NOALIGN(return_to_handler)
 	subq  $24, %rsp
diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
index 4afa50c40f12..d18d2118a80a 100644
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -17,11 +17,11 @@
 #include <linux/linkage.h>
 
 .macro xen_pv_trap name
-ENTRY(xen_\name)
+SYM_CODE_START(xen_\name)
 	pop %rcx
 	pop %r11
 	jmp  \name
-END(xen_\name)
+SYM_CODE_END(xen_\name)
 .endm
 
 xen_pv_trap divide_error
diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
index 124941d09b2b..83c64ece680d 100644
--- a/arch/x86/xen/xen-head.S
+++ b/arch/x86/xen/xen-head.S
@@ -19,7 +19,7 @@
 
 #ifdef CONFIG_XEN_PV
 	__INIT
-ENTRY(startup_xen)
+SYM_CODE_START(startup_xen)
 	UNWIND_HINT_EMPTY
 	cld
 
@@ -35,13 +35,13 @@ ENTRY(startup_xen)
 	mov $init_thread_union+THREAD_SIZE, %_ASM_SP
 
 	jmp xen_start_kernel
-END(startup_xen)
+SYM_CODE_END(startup_xen)
 	__FINIT
 #endif
 
 .pushsection .text
 	.balign PAGE_SIZE
-ENTRY(hypercall_page)
+SYM_CODE_START(hypercall_page)
 	.rept (PAGE_SIZE / 32)
 		UNWIND_HINT_EMPTY
 		.skip 32
@@ -52,7 +52,7 @@ ENTRY(hypercall_page)
 	.type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32
 #include <asm/xen-hypercalls.h>
 #undef HYPERCALL
-END(hypercall_page)
+SYM_CODE_END(hypercall_page)
 .popsection
 
 	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz "linux")
-- 
2.14.2

[toc] | [prev] | [next] | [standalone]


#1743225 — Re: [PATCH v4 22/27] x86_64: assembly, change all ENTRY+END to SYM_CODE_*

FromBoris Ostrovsky <boris.ostrovsky@oracle.com>
Date2017-10-02 22:50 +0200
SubjectRe: [PATCH v4 22/27] x86_64: assembly, change all ENTRY+END to SYM_CODE_*
Message-ID<uwfP4-ur-19@gated-at.bofh.it>
In reply to#1743057
On 10/02/2017 05:12 AM, Jiri Slaby wrote:
> Here, we change all code which is not marked as functions. In other
> words, this code has been using END, not ENDPROC. So switch all of this
> to appropriate new markings SYM_CODE_START and SYM_CODE_END.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: xen-devel@lists.xenproject.org

For Xen bits:

Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

[toc] | [prev] | [next] | [standalone]


#1743196 — Re: [PATCH v4 23/27] x86_64: assembly, change all ENTRY+ENDPROC to SYM_FUNC_*

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2017-10-02 14:50 +0200
SubjectRe: [PATCH v4 23/27] x86_64: assembly, change all ENTRY+ENDPROC to SYM_FUNC_*
Message-ID<uw8kz-7kS-35@gated-at.bofh.it>
In reply to#1743054
On Monday, October 2, 2017 11:12:42 AM CEST Jiri Slaby wrote:
> These are all functions which are invoked from elsewhere, so we annotate
> them as global using the new SYM_FUNC_START. And their ENDPROC's by
> SYM_FUNC_END.
> 
> And make sure ENTRY/ENDPROC is not defined on X86_64, given these were
> the last users.
> 
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: x86@kernel.org
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Matt Fleming <matt@codeblueprint.co.uk>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: linux-crypto@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-efi@vger.kernel.org
> Cc: xen-devel@lists.xenproject.org
> ---
>  arch/x86/boot/compressed/efi_thunk_64.S            |  4 +-
>  arch/x86/boot/compressed/head_64.S                 | 16 ++++----
>  arch/x86/crypto/aes-i586-asm_32.S                  |  8 ++--
>  arch/x86/crypto/aes-x86_64-asm_64.S                |  4 +-
>  arch/x86/crypto/aes_ctrby8_avx-x86_64.S            | 12 +++---
>  arch/x86/crypto/aesni-intel_asm.S                  | 44 +++++++++++-----------
>  arch/x86/crypto/aesni-intel_avx-x86_64.S           | 24 ++++++------
>  arch/x86/crypto/blowfish-x86_64-asm_64.S           | 16 ++++----
>  arch/x86/crypto/camellia-aesni-avx-asm_64.S        | 24 ++++++------
>  arch/x86/crypto/camellia-aesni-avx2-asm_64.S       | 24 ++++++------
>  arch/x86/crypto/camellia-x86_64-asm_64.S           | 16 ++++----
>  arch/x86/crypto/cast5-avx-x86_64-asm_64.S          | 16 ++++----
>  arch/x86/crypto/cast6-avx-x86_64-asm_64.S          | 24 ++++++------
>  arch/x86/crypto/chacha20-avx2-x86_64.S             |  4 +-
>  arch/x86/crypto/chacha20-ssse3-x86_64.S            |  8 ++--
>  arch/x86/crypto/crc32-pclmul_asm.S                 |  4 +-
>  arch/x86/crypto/crc32c-pcl-intel-asm_64.S          |  4 +-
>  arch/x86/crypto/crct10dif-pcl-asm_64.S             |  4 +-
>  arch/x86/crypto/des3_ede-asm_64.S                  |  8 ++--
>  arch/x86/crypto/ghash-clmulni-intel_asm.S          |  8 ++--
>  arch/x86/crypto/poly1305-avx2-x86_64.S             |  4 +-
>  arch/x86/crypto/poly1305-sse2-x86_64.S             |  8 ++--
>  arch/x86/crypto/salsa20-x86_64-asm_64.S            | 12 +++---
>  arch/x86/crypto/serpent-avx-x86_64-asm_64.S        | 24 ++++++------
>  arch/x86/crypto/serpent-avx2-asm_64.S              | 24 ++++++------
>  arch/x86/crypto/serpent-sse2-x86_64-asm_64.S       |  8 ++--
>  arch/x86/crypto/sha1-mb/sha1_mb_mgr_flush_avx2.S   |  8 ++--
>  arch/x86/crypto/sha1-mb/sha1_mb_mgr_submit_avx2.S  |  4 +-
>  arch/x86/crypto/sha1-mb/sha1_x8_avx2.S             |  4 +-
>  arch/x86/crypto/sha1_avx2_x86_64_asm.S             |  4 +-
>  arch/x86/crypto/sha1_ni_asm.S                      |  4 +-
>  arch/x86/crypto/sha1_ssse3_asm.S                   |  4 +-
>  arch/x86/crypto/sha256-avx-asm.S                   |  4 +-
>  arch/x86/crypto/sha256-avx2-asm.S                  |  4 +-
>  .../crypto/sha256-mb/sha256_mb_mgr_flush_avx2.S    |  8 ++--
>  .../crypto/sha256-mb/sha256_mb_mgr_submit_avx2.S   |  4 +-
>  arch/x86/crypto/sha256-mb/sha256_x8_avx2.S         |  4 +-
>  arch/x86/crypto/sha256-ssse3-asm.S                 |  4 +-
>  arch/x86/crypto/sha256_ni_asm.S                    |  4 +-
>  arch/x86/crypto/sha512-avx-asm.S                   |  4 +-
>  arch/x86/crypto/sha512-avx2-asm.S                  |  4 +-
>  .../crypto/sha512-mb/sha512_mb_mgr_flush_avx2.S    |  8 ++--
>  .../crypto/sha512-mb/sha512_mb_mgr_submit_avx2.S   |  4 +-
>  arch/x86/crypto/sha512-mb/sha512_x4_avx2.S         |  4 +-
>  arch/x86/crypto/sha512-ssse3-asm.S                 |  4 +-
>  arch/x86/crypto/twofish-avx-x86_64-asm_64.S        | 24 ++++++------
>  arch/x86/crypto/twofish-x86_64-asm_64-3way.S       |  8 ++--
>  arch/x86/crypto/twofish-x86_64-asm_64.S            |  8 ++--
>  arch/x86/entry/entry_64.S                          | 10 ++---
>  arch/x86/entry/entry_64_compat.S                   |  8 ++--
>  arch/x86/kernel/acpi/wakeup_64.S                   |  8 ++--
>  arch/x86/kernel/head_64.S                          | 12 +++---
>  arch/x86/lib/checksum_32.S                         |  8 ++--
>  arch/x86/lib/clear_page_64.S                       | 12 +++---
>  arch/x86/lib/cmpxchg16b_emu.S                      |  4 +-
>  arch/x86/lib/cmpxchg8b_emu.S                       |  4 +-
>  arch/x86/lib/copy_page_64.S                        |  4 +-
>  arch/x86/lib/copy_user_64.S                        | 16 ++++----
>  arch/x86/lib/csum-copy_64.S                        |  4 +-
>  arch/x86/lib/getuser.S                             | 16 ++++----
>  arch/x86/lib/hweight.S                             |  8 ++--
>  arch/x86/lib/iomap_copy_64.S                       |  4 +-
>  arch/x86/lib/memcpy_64.S                           |  4 +-
>  arch/x86/lib/memmove_64.S                          |  4 +-
>  arch/x86/lib/memset_64.S                           |  4 +-
>  arch/x86/lib/msr-reg.S                             |  8 ++--
>  arch/x86/lib/putuser.S                             | 16 ++++----
>  arch/x86/lib/rwsem.S                               | 20 +++++-----
>  arch/x86/mm/mem_encrypt_boot.S                     |  8 ++--
>  arch/x86/platform/efi/efi_stub_64.S                |  4 +-
>  arch/x86/platform/efi/efi_thunk_64.S               |  4 +-
>  arch/x86/power/hibernate_asm_64.S                  |  8 ++--

For the hibernate changes:

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

[toc] | [prev] | [next] | [standalone]


#1743258 — Re: [PATCH v4 23/27] x86_64: assembly, change all ENTRY+ENDPROC to SYM_FUNC_*

FromBoris Ostrovsky <boris.ostrovsky@oracle.com>
Date2017-10-02 22:50 +0200
SubjectRe: [PATCH v4 23/27] x86_64: assembly, change all ENTRY+ENDPROC to SYM_FUNC_*
Message-ID<uwfP9-ur-111@gated-at.bofh.it>
In reply to#1743054
On 10/02/2017 05:12 AM, Jiri Slaby wrote:
> These are all functions which are invoked from elsewhere, so we annotate
> them as global using the new SYM_FUNC_START. And their ENDPROC's by
> SYM_FUNC_END.
>
> And make sure ENTRY/ENDPROC is not defined on X86_64, given these were
> the last users.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: x86@kernel.org
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Matt Fleming <matt@codeblueprint.co.uk>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Cc: Juergen Gross <jgross@suse.com>
> Cc: linux-crypto@vger.kernel.org
> Cc: linux-pm@vger.kernel.org
> Cc: linux-efi@vger.kernel.org
> Cc: xen-devel@lists.xenproject.org

For Xen bits:

Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web