[PATCH 03/10] x86: boot, annotate functions properly

From: Jiri Slaby
Date: Fri Feb 17 2017 - 05:50:17 EST


1) GLOBAL is meant for global symbols, but not functions. Use ENTRY
which is dedicated for global functions.
2) Finish every function with ENDPROC.

Note that efi_pe_entry is not a start of a function, it is the middle of
startup_64 -- annotate as such.

Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: <x86@xxxxxxxxxx>

---

The alternative to the startup_64 change would be to move efi_pe_entry
out of startup_64 which actually makes more sense, but I am afraid I
cannot test the result properly. See what it is now:
.org 0x200
ENTRY(startup_64)
#ifdef CONFIG_EFI_STUB
jmp preferred_addr
GLOBAL(efi_pe_entry)
... ; a lot of assembly (efi_pe_entry)
leaq preferred_addr(%rax), %rax
jmp *%rax
preferred_addr:
#endif
... ; a lot of assembly (startup_64)
ENDPROC(startup_64)

What about:
.org 0x200
ENTRY(startup_64)
... ; a lot of assembly (startup_64)
ENDPROC(startup_64)

#ifdef CONFIG_EFI_STUB
ENTRY(efi_pe_entry)
... ; a lot of assembly (efi_pe_entry)
leaq startup_64(%rax), %rax
jmp *%rax
ENDPROC(efi_pe_entry)
#endif
This solution is at the end of the series as RFC.
---
arch/x86/boot/compressed/head_64.S | 3 ++-
arch/x86/boot/copy.S | 12 ++++++------
arch/x86/boot/pmjump.S | 4 ++--
3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 4d85e600db78..59eccbc46ad7 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -250,7 +250,7 @@ ENTRY(startup_64)
*/
jmp preferred_addr

-ENTRY(efi_pe_entry)
+GLOBAL(efi_pe_entry)
movq %rcx, efi64_config(%rip) /* Handle */
movq %rdx, efi64_config+8(%rip) /* EFI System table pointer */

@@ -369,6 +369,7 @@ preferred_addr:
*/
leaq relocated(%rbx), %rax
jmp *%rax
+ENDPROC(startup_64)

#ifdef CONFIG_EFI_STUB
.org 0x390
diff --git a/arch/x86/boot/copy.S b/arch/x86/boot/copy.S
index 1eb7d298b47d..44133dd0218e 100644
--- a/arch/x86/boot/copy.S
+++ b/arch/x86/boot/copy.S
@@ -17,7 +17,7 @@
.code16
.text

-GLOBAL(memcpy)
+ENTRY(memcpy)
pushw %si
pushw %di
movw %ax, %di
@@ -33,7 +33,7 @@ GLOBAL(memcpy)
retl
ENDPROC(memcpy)

-GLOBAL(memset)
+ENTRY(memset)
pushw %di
movw %ax, %di
movzbl %dl, %eax
@@ -48,7 +48,7 @@ GLOBAL(memset)
retl
ENDPROC(memset)

-GLOBAL(copy_from_fs)
+ENTRY(copy_from_fs)
pushw %ds
pushw %fs
popw %ds
@@ -57,7 +57,7 @@ GLOBAL(copy_from_fs)
retl
ENDPROC(copy_from_fs)

-GLOBAL(copy_to_fs)
+ENTRY(copy_to_fs)
pushw %es
pushw %fs
popw %es
@@ -67,7 +67,7 @@ GLOBAL(copy_to_fs)
ENDPROC(copy_to_fs)

#if 0 /* Not currently used, but can be enabled as needed */
-GLOBAL(copy_from_gs)
+ENTRY(copy_from_gs)
pushw %ds
pushw %gs
popw %ds
@@ -76,7 +76,7 @@ GLOBAL(copy_from_gs)
retl
ENDPROC(copy_from_gs)

-GLOBAL(copy_to_gs)
+ENTRY(copy_to_gs)
pushw %es
pushw %gs
popw %es
diff --git a/arch/x86/boot/pmjump.S b/arch/x86/boot/pmjump.S
index 3e0edc6d2a20..6528f78a79b5 100644
--- a/arch/x86/boot/pmjump.S
+++ b/arch/x86/boot/pmjump.S
@@ -23,7 +23,7 @@
/*
* void protected_mode_jump(u32 entrypoint, u32 bootparams);
*/
-GLOBAL(protected_mode_jump)
+ENTRY(protected_mode_jump)
movl %edx, %esi # Pointer to boot_params table

xorl %ebx, %ebx
@@ -48,7 +48,7 @@ ENDPROC(protected_mode_jump)

.code32
.section ".text32","ax"
-GLOBAL(in_pm32)
+ENTRY(in_pm32)
# Set up data segments for flat 32-bit mode
movl %ecx, %ds
movl %ecx, %es
--
2.11.1