Re: [PATCH v4 03/16] powerpc: Fix objtool unannotated intra-function call warnings

Naveen N. Rao
2022-10-10T11:35:42Z

Sathvika Vasireddy wrote:
> Objtool throws unannotated intra-function call warnings in the following
> assembly files:
>
> arch/powerpc/kernel/vector.o: warning: objtool: .text+0x53c: unannotated intra-function call
>
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x60: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x124: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5d4: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x5dc: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xcb8: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0xd0c: unannotated intra-function call
> arch/powerpc/kvm/book3s_hv_rmhandlers.o: warning: objtool: .text+0x1030: unannotated intra-function call
>
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x358: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x728: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4d94: unannotated intra-function call
> arch/powerpc/kernel/head_64.o: warning: objtool: .text+0x4ec4: unannotated intra-function call
>
> arch/powerpc/kvm/book3s_hv_interrupts.o: warning: objtool: .text+0x6c: unannotated intra-function call
> arch/powerpc/kernel/misc_64.o: warning: objtool: .text+0x64: unannotated intra-function call
>
> Objtool does not add STT_NOTYPE symbols with size 0 to the rbtree, which
> is why find_call_destination() function is not able to find the
> destination symbol for 'bl' instruction. For such symbols, objtool is
> throwing unannotated intra-function call warnings in assembly files. Fix
> these warnings by annotating those symbols with SYM_FUNC_START_LOCAL and
> SYM_FUNC_END macros, inorder to set symbol type to STT_FUNC and symbol
> size accordingly.
>
> Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
> ---
> arch/powerpc/kernel/exceptions-64s.S | 7 +++++--
> arch/powerpc/kernel/head_64.S | 7 +++++--
> arch/powerpc/kernel/misc_64.S | 4 +++-
> arch/powerpc/kernel/vector.S | 4 +++-
> arch/powerpc/kvm/book3s_hv_interrupts.S | 4 +++-
> arch/powerpc/kvm/book3s_hv_rmhandlers.S | 22 +++++++++++++++-------
> 6 files changed, 34 insertions(+), 14 deletions(-)

Applying this to powerpc/merge today shows two small conflicts:

>
> diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
> index 3d0dc133a9ae..56a31424c8b0 100644
> --- a/arch/powerpc/kernel/exceptions-64s.S
> +++ b/arch/powerpc/kernel/exceptions-64s.S
> @@ -13,6 +13,7 @@
> *
> */
>
> +#include <linux/linkage.h>
> #include <asm/hw_irq.h>
> #include <asm/exception-64s.h>
> #include <asm/ptrace.h>
> @@ -3075,7 +3076,7 @@ CLOSE_FIXED_SECTION(virt_trampolines);
> USE_TEXT_SECTION()
>
> /* MSR[RI] should be clear because this uses SRR[01] */
> -enable_machine_check:
> +SYM_FUNC_START_LOCAL(enable_machine_check)

This is now a _GLOBAL(), so this hunk and the below
SYM_FUNC_END(enable_machine_check) change can be dropped.

> mflr r0
> bcl 20,31,$+4
> 0: mflr r3
> @@ -3087,9 +3088,10 @@ enable_machine_check:
> RFI_TO_KERNEL
> 1: mtlr r0
> blr
> +SYM_FUNC_END(enable_machine_check)
>
> /* MSR[RI] should be clear because this uses SRR[01] */
> -disable_machine_check:
> +SYM_FUNC_START_LOCAL(disable_machine_check)
> mflr r0
> bcl 20,31,$+4
> 0: mflr r3
> @@ -3102,3 +3104,4 @@ disable_machine_check:
> RFI_TO_KERNEL
> 1: mtlr r0
> blr
> +SYM_FUNC_END(disable_machine_check)
> diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
> index cf2c08902c05..10e2d43420d0 100644
> --- a/arch/powerpc/kernel/head_64.S
> +++ b/arch/powerpc/kernel/head_64.S
> @@ -18,6 +18,7 @@
> * variants.
> */
>
> +#include <linux/linkage.h>
> #include <linux/threads.h>
> #include <linux/init.h>
> #include <asm/reg.h>
> @@ -465,7 +466,7 @@ generic_secondary_common_init:
> * Assumes we're mapped EA == RA if the MMU is on.
> */
> #ifdef CONFIG_PPC_BOOK3S
> -__mmu_off:
> +SYM_FUNC_START_LOCAL(__mmu_off)
> mfmsr r3
> andi. r0,r3,MSR_IR|MSR_DR
> beqlr
> @@ -476,6 +477,7 @@ __mmu_off:
> sync
> rfid
> b . /* prevent speculative execution */
> +SYM_FUNC_END(__mmu_off)
> #endif
>
>
> @@ -869,7 +871,7 @@ _GLOBAL(start_secondary_resume)
> /*
> * This subroutine clobbers r11 and r12
> */
> -enable_64b_mode:
> +SYM_FUNC_START_LOCAL(enable_64b_mode)
> mfmsr r11 /* grab the current MSR */
> #ifdef CONFIG_PPC_BOOK3E
> oris r11,r11,0x8000 /* CM bit set, we'll set ICM later */
> @@ -881,6 +883,7 @@ enable_64b_mode:
> isync
> #endif
> blr
> +SYM_FUNC_END(enable_64b_mode)
>
> /*
> * This puts the TOC pointer into r2, offset by 0x8000 (as expected
> diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
> index fd6d8d3a548e..b36fb89ff718 100644
> --- a/arch/powerpc/kernel/misc_64.S
> +++ b/arch/powerpc/kernel/misc_64.S
> @@ -9,6 +9,7 @@
> * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
> */
>
> +#include <linux/linkage.h>
> #include <linux/sys.h>
> #include <asm/unistd.h>
> #include <asm/errno.h>
> @@ -353,7 +354,7 @@ _GLOBAL(kexec_smp_wait)
> *
> * don't overwrite r3 here, it is live for kexec_wait above.
> */
> -real_mode: /* assume normal blr return */
> +SYM_FUNC_START_LOCAL(real_mode) /* assume normal blr return */
> #ifdef CONFIG_PPC_BOOK3E

The #ifdef is now for CONFIG_PPC_BOOK3E_64.

The rest of the series apply properly.

- Naveen