[PATCH v3 05/29] x86: assembly, add ENDPROC to functions

From: Jiri Slaby
Date: Fri Apr 21 2017 - 10:23:07 EST


Some functions are annotated as ENTRY or GLOBAL, but their ends are not
annotated at all. This means:
* the annotations are not paired and we cannot deal with such functions
e.g. in objtool
* the symbols are not marked as functions in the object file
* there are no sizes of the functions in the object file

So fix this by adding ENDPROC to each such case.

Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
Cc: <x86@xxxxxxxxxx>
Cc: "Rafael J. Wysocki" <rjw@xxxxxxxxxxxxx>
Cc: Pavel Machek <pavel@xxxxxx>
Cc: <linux-pm@xxxxxxxxxxxxxxx>
Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
Cc: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Juergen Gross <jgross@xxxxxxxx> [xen parts]
Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
Cc: lguest@xxxxxxxxxxxxxxxx
---
arch/x86/boot/compressed/head_64.S | 1 +
arch/x86/entry/entry_32.S | 1 +
arch/x86/entry/entry_64_compat.S | 1 +
arch/x86/kernel/acpi/wakeup_32.S | 2 ++
arch/x86/kernel/ftrace_32.S | 1 +
arch/x86/kernel/ftrace_64.S | 1 +
arch/x86/kernel/head_32.S | 1 +
arch/x86/lguest/head_32.S | 4 ++++
arch/x86/math-emu/div_Xsig.S | 1 +
arch/x86/math-emu/div_small.S | 2 +-
arch/x86/math-emu/mul_Xsig.S | 4 +++-
arch/x86/math-emu/polynom_Xsig.S | 1 +
arch/x86/math-emu/reg_norm.S | 2 ++
arch/x86/math-emu/reg_round.S | 2 ++
arch/x86/math-emu/reg_u_add.S | 1 +
arch/x86/math-emu/reg_u_div.S | 2 ++
arch/x86/math-emu/reg_u_mul.S | 1 +
arch/x86/math-emu/reg_u_sub.S | 1 +
arch/x86/math-emu/round_Xsig.S | 4 ++--
arch/x86/math-emu/shr_Xsig.S | 1 +
arch/x86/math-emu/wm_shrx.S | 2 ++
arch/x86/math-emu/wm_sqrt.S | 1 +
arch/x86/platform/olpc/xo1-wakeup.S | 1 +
arch/x86/power/hibernate_asm_32.S | 3 +++
arch/x86/power/hibernate_asm_64.S | 2 ++
arch/x86/realmode/rm/reboot.S | 1 +
arch/x86/realmode/rm/trampoline_32.S | 2 ++
arch/x86/realmode/rm/trampoline_64.S | 4 ++++
arch/x86/realmode/rm/wakeup_asm.S | 1 +
arch/x86/xen/xen-asm_32.S | 3 ++-
arch/x86/xen/xen-asm_64.S | 2 ++
arch/x86/xen/xen-head.S | 3 ++-
drivers/lguest/x86/switcher_32.S | 1 +
33 files changed, 54 insertions(+), 6 deletions(-)

diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index 146751091801..3e5752efccff 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -310,6 +310,7 @@ ENTRY(startup_64)
*/
leaq relocated(%rbx), %rax
jmp *%rax
+ENDPROC(startup_64)

#ifdef CONFIG_EFI_STUB

diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index a546b84aec01..afeeb389e9aa 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -356,6 +356,7 @@ GLOBAL(__begin_SYSENTER_singlestep_region)
ENTRY(xen_sysenter_target)
addl $5*4, %esp /* remove xen-provided frame */
jmp .Lsysenter_past_esp
+ENDPROC(xen_sysenter_target)
#endif

/*
diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
index 966c09ffd62d..14dc2f259e2f 100644
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -353,3 +353,4 @@ GLOBAL(stub32_clone)
*/
xchg %r8, %rcx
jmp sys_clone
+ENDPROC(stub32_clone)
diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
index 0c26b1b44e51..ea9a29e6a96c 100644
--- a/arch/x86/kernel/acpi/wakeup_32.S
+++ b/arch/x86/kernel/acpi/wakeup_32.S
@@ -38,6 +38,7 @@ wakeup_pmode_return:
# jump to place where we left off
movl saved_eip, %eax
jmp *%eax
+ENDPROC(wakeup_pmode_return)

bogus_magic:
jmp bogus_magic
@@ -86,6 +87,7 @@ ret_point:
call restore_registers
call restore_processor_state
ret
+ENDPROC(do_suspend_lowlevel)

.data
ALIGN
diff --git a/arch/x86/kernel/ftrace_32.S b/arch/x86/kernel/ftrace_32.S
index 30bc4af8b0de..89f8324e9a68 100644
--- a/arch/x86/kernel/ftrace_32.S
+++ b/arch/x86/kernel/ftrace_32.S
@@ -168,6 +168,7 @@ GLOBAL(ftrace_regs_call)
lea 3*4(%esp), %esp /* Skip orig_ax, ip and cs */

jmp .Lftrace_ret
+ENDPROC(ftrace_regs_caller)
#else /* ! CONFIG_DYNAMIC_FTRACE */

ENTRY(function_hook)
diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S
index 823e31577333..a915729c0246 100644
--- a/arch/x86/kernel/ftrace_64.S
+++ b/arch/x86/kernel/ftrace_64.S
@@ -329,4 +329,5 @@ GLOBAL(return_to_handler)
movq (%rsp), %rax
addq $24, %rsp
jmp *%rdi
+ENDPROC(return_to_handler)
#endif
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 1f85ee8f9439..e2acba5b0f2f 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -173,6 +173,7 @@ num_subarch_entries = (. - subarch_entries) / 4
#else
jmp .Ldefault_entry
#endif /* CONFIG_PARAVIRT */
+ENDPROC(startup_32)

#ifdef CONFIG_HOTPLUG_CPU
/*
diff --git a/arch/x86/lguest/head_32.S b/arch/x86/lguest/head_32.S
index d5ae63f5ec5d..b11a989de062 100644
--- a/arch/x86/lguest/head_32.S
+++ b/arch/x86/lguest/head_32.S
@@ -48,6 +48,7 @@ ENTRY(lguest_entry)

/* Jumps are relative: we're running __PAGE_OFFSET too low. */
jmp lguest_init+__PAGE_OFFSET
+ENDPROC(lguest_entry)

/*G:055
* We create a macro which puts the assembler code between lgstart_ and lgend_
@@ -110,6 +111,7 @@ send_interrupts:
/* Put eax back the way we found it. */
popl %eax
ret
+ENDPROC(lg_irq_enable)

/*
* Finally, the "popf" or "restore flags" routine. The %eax register holds the
@@ -131,6 +133,7 @@ ENTRY(lg_restore_fl)
jnz send_interrupts
/* Again, the normal path has used no extra registers. Clever, huh? */
ret
+ENDPROC(lg_restore_fl)
/*:*/

/* These demark the EIP where host should never deliver interrupts. */
@@ -190,3 +193,4 @@ ENTRY(lguest_iret)
popl %ss:lguest_data+LGUEST_DATA_irq_enabled
lguest_noirq_iret:
iret
+ENDPROC(lguest_iret)
diff --git a/arch/x86/math-emu/div_Xsig.S b/arch/x86/math-emu/div_Xsig.S
index f77ba3058b31..066996dba6a2 100644
--- a/arch/x86/math-emu/div_Xsig.S
+++ b/arch/x86/math-emu/div_Xsig.S
@@ -363,3 +363,4 @@ L_bugged_2:
pop %ebx
jmp L_exit
#endif /* PARANOID */
+ENDPROC(div_Xsig)
diff --git a/arch/x86/math-emu/div_small.S b/arch/x86/math-emu/div_small.S
index 47099628fa4c..2c71527bd917 100644
--- a/arch/x86/math-emu/div_small.S
+++ b/arch/x86/math-emu/div_small.S
@@ -44,4 +44,4 @@ ENTRY(FPU_div_small)

leave
ret
-
+ENDPROC(FPU_div_small)
diff --git a/arch/x86/math-emu/mul_Xsig.S b/arch/x86/math-emu/mul_Xsig.S
index 717785a53eb4..22e0631bb85a 100644
--- a/arch/x86/math-emu/mul_Xsig.S
+++ b/arch/x86/math-emu/mul_Xsig.S
@@ -62,6 +62,7 @@ ENTRY(mul32_Xsig)
popl %esi
leave
ret
+ENDPROC(mul32_Xsig)


ENTRY(mul64_Xsig)
@@ -114,6 +115,7 @@ ENTRY(mul64_Xsig)
popl %esi
leave
ret
+ENDPROC(mul64_Xsig)



@@ -173,4 +175,4 @@ ENTRY(mul_Xsig_Xsig)
popl %esi
leave
ret
-
+ENDPROC(mul_Xsig_Xsig)
diff --git a/arch/x86/math-emu/polynom_Xsig.S b/arch/x86/math-emu/polynom_Xsig.S
index 17315c89ff3d..a9aaf414135d 100644
--- a/arch/x86/math-emu/polynom_Xsig.S
+++ b/arch/x86/math-emu/polynom_Xsig.S
@@ -133,3 +133,4 @@ L_accum_done:
popl %esi
leave
ret
+ENDPROC(polynomial_Xsig)
diff --git a/arch/x86/math-emu/reg_norm.S b/arch/x86/math-emu/reg_norm.S
index 8b6352efceef..53ac1a343c69 100644
--- a/arch/x86/math-emu/reg_norm.S
+++ b/arch/x86/math-emu/reg_norm.S
@@ -94,6 +94,7 @@ L_overflow:
call arith_overflow
pop %ebx
jmp L_exit
+ENDPROC(FPU_normalize)



@@ -145,3 +146,4 @@ L_exit_nuo_zero:
popl %ebx
leave
ret
+ENDPROC(FPU_normalize_nuo)
diff --git a/arch/x86/math-emu/reg_round.S b/arch/x86/math-emu/reg_round.S
index d1d4e48b4f67..41af5b208d88 100644
--- a/arch/x86/math-emu/reg_round.S
+++ b/arch/x86/math-emu/reg_round.S
@@ -706,3 +706,5 @@ L_exception_exit:
mov $-1,%eax
jmp fpu_reg_round_special_exit
#endif /* PARANOID */
+
+ENDPROC(FPU_round)
diff --git a/arch/x86/math-emu/reg_u_add.S b/arch/x86/math-emu/reg_u_add.S
index 47c4c2434d85..3b1bc5e9b2f6 100644
--- a/arch/x86/math-emu/reg_u_add.S
+++ b/arch/x86/math-emu/reg_u_add.S
@@ -165,3 +165,4 @@ L_exit:
leave
ret
#endif /* PARANOID */
+ENDPROC(FPU_u_add)
diff --git a/arch/x86/math-emu/reg_u_div.S b/arch/x86/math-emu/reg_u_div.S
index cc00654b6f9a..796eb5ab921b 100644
--- a/arch/x86/math-emu/reg_u_div.S
+++ b/arch/x86/math-emu/reg_u_div.S
@@ -469,3 +469,5 @@ L_exit:
leave
ret
#endif /* PARANOID */
+
+ENDPROC(FPU_u_div)
diff --git a/arch/x86/math-emu/reg_u_mul.S b/arch/x86/math-emu/reg_u_mul.S
index 973f12af97df..6196f68cf3c1 100644
--- a/arch/x86/math-emu/reg_u_mul.S
+++ b/arch/x86/math-emu/reg_u_mul.S
@@ -146,3 +146,4 @@ L_exit:
ret
#endif /* PARANOID */

+ENDPROC(FPU_u_mul)
diff --git a/arch/x86/math-emu/reg_u_sub.S b/arch/x86/math-emu/reg_u_sub.S
index 1b6c24801d22..d115b900919a 100644
--- a/arch/x86/math-emu/reg_u_sub.S
+++ b/arch/x86/math-emu/reg_u_sub.S
@@ -270,3 +270,4 @@ L_exit:
popl %esi
leave
ret
+ENDPROC(FPU_u_sub)
diff --git a/arch/x86/math-emu/round_Xsig.S b/arch/x86/math-emu/round_Xsig.S
index bbe0e87718e4..87c99749a495 100644
--- a/arch/x86/math-emu/round_Xsig.S
+++ b/arch/x86/math-emu/round_Xsig.S
@@ -78,7 +78,7 @@ L_exit:
popl %ebx
leave
ret
-
+ENDPROC(round_Xsig)



@@ -138,4 +138,4 @@ L_n_exit:
popl %ebx
leave
ret
-
+ENDPROC(norm_Xsig)
diff --git a/arch/x86/math-emu/shr_Xsig.S b/arch/x86/math-emu/shr_Xsig.S
index 31cdd118e918..c8552edeec75 100644
--- a/arch/x86/math-emu/shr_Xsig.S
+++ b/arch/x86/math-emu/shr_Xsig.S
@@ -85,3 +85,4 @@ L_more_than_95:
popl %esi
leave
ret
+ENDPROC(shr_Xsig)
diff --git a/arch/x86/math-emu/wm_shrx.S b/arch/x86/math-emu/wm_shrx.S
index 518428317985..340dd6897f85 100644
--- a/arch/x86/math-emu/wm_shrx.S
+++ b/arch/x86/math-emu/wm_shrx.S
@@ -92,6 +92,7 @@ L_more_than_95:
popl %esi
leave
ret
+ENDPROC(FPU_shrx)


/*---------------------------------------------------------------------------+
@@ -202,3 +203,4 @@ Ls_more_than_95:
popl %esi
leave
ret
+ENDPROC(FPU_shrxs)
diff --git a/arch/x86/math-emu/wm_sqrt.S b/arch/x86/math-emu/wm_sqrt.S
index d258f59564e1..695afae38fdf 100644
--- a/arch/x86/math-emu/wm_sqrt.S
+++ b/arch/x86/math-emu/wm_sqrt.S
@@ -468,3 +468,4 @@ sqrt_more_prec_large:
/* Our estimate is too large */
movl $0x7fffff00,%eax
jmp sqrt_round_result
+ENDPROC(wm_sqrt)
diff --git a/arch/x86/platform/olpc/xo1-wakeup.S b/arch/x86/platform/olpc/xo1-wakeup.S
index 948deb289753..2929091cf7fd 100644
--- a/arch/x86/platform/olpc/xo1-wakeup.S
+++ b/arch/x86/platform/olpc/xo1-wakeup.S
@@ -109,6 +109,7 @@ ret_point:
call restore_registers
call restore_processor_state
ret
+ENDPROC(do_olpc_suspend_lowlevel)

.data
saved_gdt: .long 0,0
diff --git a/arch/x86/power/hibernate_asm_32.S b/arch/x86/power/hibernate_asm_32.S
index 1d0fa0e24070..9480f4b2df94 100644
--- a/arch/x86/power/hibernate_asm_32.S
+++ b/arch/x86/power/hibernate_asm_32.S
@@ -25,6 +25,7 @@ ENTRY(swsusp_arch_suspend)

call swsusp_save
ret
+ENDPROC(swsusp_arch_suspend)

ENTRY(restore_image)
movl mmu_cr4_features, %ecx
@@ -82,3 +83,5 @@ done:
xorl %eax, %eax

ret
+ENDPROC(restore_image)
+
diff --git a/arch/x86/power/hibernate_asm_64.S b/arch/x86/power/hibernate_asm_64.S
index ce8da3a0412c..ec6b26fd3a7e 100644
--- a/arch/x86/power/hibernate_asm_64.S
+++ b/arch/x86/power/hibernate_asm_64.S
@@ -68,6 +68,7 @@ ENTRY(restore_image)
/* jump to relocated restore code */
movq relocated_restore_code(%rip), %rcx
jmpq *%rcx
+ENDPROC(restore_image)

/* code below has been relocated to a safe page */
ENTRY(core_restore_code)
@@ -98,6 +99,7 @@ ENTRY(core_restore_code)
.Ldone:
/* jump to the restore_registers address from the image header */
jmpq *%r8
+ENDPROC(core_restore_code)

/* code below belongs to the image kernel */
.align PAGE_SIZE
diff --git a/arch/x86/realmode/rm/reboot.S b/arch/x86/realmode/rm/reboot.S
index d66c607bdc58..c8855d50f9c1 100644
--- a/arch/x86/realmode/rm/reboot.S
+++ b/arch/x86/realmode/rm/reboot.S
@@ -62,6 +62,7 @@ GLOBAL(machine_real_restart_paging_off)
movl %ecx, %gs
movl %ecx, %ss
ljmpw $8, $1f
+ENDPROC(machine_real_restart_asm)

/*
* This is 16-bit protected mode code to disable paging and the cache,
diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
index 48ddd76bc4c3..aa14fea65aac 100644
--- a/arch/x86/realmode/rm/trampoline_32.S
+++ b/arch/x86/realmode/rm/trampoline_32.S
@@ -56,11 +56,13 @@ ENTRY(trampoline_start)
lmsw %dx # into protected mode

ljmpl $__BOOT_CS, $pa_startup_32
+ENDPROC(trampoline_start)

.section ".text32","ax"
.code32
ENTRY(startup_32) # note: also used from wakeup_asm.S
jmp *%eax
+ENDPROC(startup_32)

.bss
.balign 8
diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
index dac7b20d2f9d..fe21a26a09fe 100644
--- a/arch/x86/realmode/rm/trampoline_64.S
+++ b/arch/x86/realmode/rm/trampoline_64.S
@@ -79,6 +79,8 @@ ENTRY(trampoline_start)
no_longmode:
hlt
jmp no_longmode
+ENDPROC(trampoline_start)
+
#include "../kernel/verify_cpu.S"

.section ".text32","ax"
@@ -116,6 +118,7 @@ ENTRY(startup_32)
* the new gdt/idt that has __KERNEL_CS with CS.L = 1.
*/
ljmpl $__KERNEL_CS, $pa_startup_64
+ENDPROC(startup_32)

.section ".text64","ax"
.code64
@@ -123,6 +126,7 @@ ENTRY(startup_32)
ENTRY(startup_64)
# Now jump into the kernel using virtual addresses
jmpq *tr_start(%rip)
+ENDPROC(startup_64)

.section ".rodata","a"
# Duplicate the global descriptor table
diff --git a/arch/x86/realmode/rm/wakeup_asm.S b/arch/x86/realmode/rm/wakeup_asm.S
index 9e7e14797a72..08203a187446 100644
--- a/arch/x86/realmode/rm/wakeup_asm.S
+++ b/arch/x86/realmode/rm/wakeup_asm.S
@@ -134,6 +134,7 @@ ENTRY(wakeup_start)
#else
jmp trampoline_start
#endif
+ENDPROC(wakeup_start)

bogus_real_magic:
1:
diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
index feb6d40a0860..748beeff6e7d 100644
--- a/arch/x86/xen/xen-asm_32.S
+++ b/arch/x86/xen/xen-asm_32.S
@@ -138,6 +138,7 @@ xen_iret_end_crit:
hyper_iret:
/* put this out of line since its very rarely used */
jmp hypercall_page + __HYPERVISOR_iret * 32
+ENDPROC(xen_iret)

.globl xen_iret_start_crit, xen_iret_end_crit

@@ -220,4 +221,4 @@ ENTRY(xen_iret_crit_fixup)

lea 4(%edi), %esp /* point esp to new frame */
2: jmp xen_do_upcall
-
+ENDPROC(xen_iret_crit_fixup)
diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S
index c3df43141e70..d617bea76039 100644
--- a/arch/x86/xen/xen-asm_64.S
+++ b/arch/x86/xen/xen-asm_64.S
@@ -49,6 +49,7 @@ ENTRY(xen_iret)
1: jmp hypercall_iret
ENDPATCH(xen_iret)
RELOC(xen_iret, 1b+1)
+ENDPROC(xen_iret)

ENTRY(xen_sysret64)
/*
@@ -68,6 +69,7 @@ ENTRY(xen_sysret64)
1: jmp hypercall_iret
ENDPATCH(xen_sysret64)
RELOC(xen_sysret64, 1b+1)
+ENDPROC(xen_sysret64)

/*
* Xen handles syscall callbacks much like ordinary exceptions, which
diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
index 72a8e6adebe6..95eb4978791b 100644
--- a/arch/x86/xen/xen-head.S
+++ b/arch/x86/xen/xen-head.S
@@ -33,7 +33,7 @@ ENTRY(startup_xen)
mov $init_thread_union+THREAD_SIZE, %_ASM_SP

jmp xen_start_kernel
-
+ENDPROC(startup_xen)
__FINIT
#endif

@@ -41,6 +41,7 @@ ENTRY(startup_xen)
.balign PAGE_SIZE
ENTRY(hypercall_page)
.skip PAGE_SIZE
+ENDPROC(hypercall_page)

#define HYPERCALL(n) \
.equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \
diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
index 40634b0db9f7..3318a967f28b 100644
--- a/drivers/lguest/x86/switcher_32.S
+++ b/drivers/lguest/x86/switcher_32.S
@@ -265,6 +265,7 @@ ENTRY(switch_to_guest)
return_to_host:
SWITCH_TO_HOST
iret
+ENDPROC(switch_to_guest)

// We are lead to the second path like so:
// An interrupt, with some cause external
--
2.12.2