diff mbox series

powerpc/boot: Fix crt0.S current address branch form

Message ID 20230407040924.231023-1-npiggin@gmail.com (mailing list archive)
State Accepted
Commit cd99dac6ec5fff763852d8ccb8a79f5de50ed830
Headers show
Series powerpc/boot: Fix crt0.S current address branch form | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 6 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 24 jobs.

Commit Message

Nicholas Piggin April 7, 2023, 4:09 a.m. UTC
Use the preferred form of branch-and-link for finding the current
address so objtool doesn't think it is an unannotated intra-function
call.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/boot/crt0.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Ellerman April 8, 2023, 3:44 a.m. UTC | #1
Nicholas Piggin <npiggin@gmail.com> writes:
> Use the preferred form of branch-and-link for finding the current
> address so objtool doesn't think it is an unannotated intra-function
> call.

We don't run objtool on this code in mainline AFAIK. Because BOOTAS
doesn't call it.

Did you actually see a warning, or are you just anticipating that it
would warn about it?

This diff would run it on boot asm and seems to build OK, so maybe we
should do that.

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 08071bac056d..5d3a4c5354d7 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -223,7 +223,7 @@ quiet_cmd_bootcc = BOOTCC  $@
       cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
 
 quiet_cmd_bootas = BOOTAS  $@
-      cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
+      cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< $(cmd_objtool)
 
 quiet_cmd_bootar = BOOTAR  $@
       cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(real-prereqs); mv $@.$$$$ $@


cheers
Michael Ellerman April 12, 2023, 12:57 a.m. UTC | #2
Michael Ellerman <mpe@ellerman.id.au> writes:
> Nicholas Piggin <npiggin@gmail.com> writes:
>> Use the preferred form of branch-and-link for finding the current
>> address so objtool doesn't think it is an unannotated intra-function
>> call.
>
> We don't run objtool on this code in mainline AFAIK. Because BOOTAS
> doesn't call it.

But as Nick pointed out, if you run:

 $ make arch/powerpc/boot/crt0.o

It does run objtool, because it uses the generic cmd_as_o_S rule instead
of the BOOTAS rule.

cheers
Michael Ellerman April 26, 2023, 12:01 p.m. UTC | #3
On Fri, 07 Apr 2023 14:09:24 +1000, Nicholas Piggin wrote:
> Use the preferred form of branch-and-link for finding the current
> address so objtool doesn't think it is an unannotated intra-function
> call.
> 
> 

Applied to powerpc/next.

[1/1] powerpc/boot: Fix crt0.S current address branch form
      https://git.kernel.org/powerpc/c/cd99dac6ec5fff763852d8ccb8a79f5de50ed830

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
index 44544720daae..121cab9d579b 100644
--- a/arch/powerpc/boot/crt0.S
+++ b/arch/powerpc/boot/crt0.S
@@ -51,7 +51,7 @@  _zimage_start:
 _zimage_start_lib:
 	/* Work out the offset between the address we were linked at
 	   and the address where we're running. */
-	bl	.+4
+	bcl	20,31,.+4
 p_base:	mflr	r10		/* r10 now points to runtime addr of p_base */
 #ifndef __powerpc64__
 	/* grab the link address of the dynamic section in r11 */
@@ -274,7 +274,7 @@  prom:
 	mtsrr1	r10
 
 	/* Load FW address, set LR to label 1, and jump to FW */
-	bl	0f
+	bcl	20,31,0f
 0:	mflr	r10
 	addi	r11,r10,(1f-0b)
 	mtlr	r11