[PATCH] powerpc/64: mark __boot_from_prom and start_here_common as __ref

Desnes A. Nunes do Rosario desnesn at linux.ibm.com
Wed Jul 17 05:48:29 AEST 2019


Functions `__boot_from_prom` and `start_here_common` are "init code" in
the sense that they are only executed at boot time, nevertheless they
should not be tagged as __init since this will carry them to a different
section located at the very end of kernel text. If the TOC is not set up,
the kernel may not be able to tolerate a branch trampoline to reach the
init function.

Thus, these functions should be marked as `__ref` and the assembler must
be reminded to insert the code that follows into the last active section
by the use of the `.previous` directive. This will allow the powerpc
kernel to be built with CONFIG_SECTION_MISMATCH_WARN_ONLY disabled and
quieten the following modpost warnings during compilation:

    WARNING: vmlinux.o(.text+0x2ad4): Section mismatch in reference from the variable __boot_from_prom to the function .init.text:prom_init()
    The function __boot_from_prom() references
    the function __init prom_init().
    This is often because __boot_from_prom lacks a __init
    annotation or the annotation of prom_init is wrong.

    WARNING: vmlinux.o(.text+0x2cd0): Section mismatch in reference from the variable start_here_common to the function .init.text:start_kernel()
    The function start_here_common() references
    the function __init start_kernel().
    This is often because start_here_common lacks a __init
    annotation or the annotation of start_kernel is wrong.

Credits: code is based on commit <9c4e4c90ec24> ("powerpc/64: mark
start_here_multiplatform as __ref") and message is based on 2016 patch by
Nicholas Piggin: https://lore.kernel.org/linuxppc-dev/20161222131419.18062-1-npiggin@gmail.com/

Signed-off-by: Desnes A. Nunes do Rosario <desnesn at linux.ibm.com>
---
 arch/powerpc/kernel/head_64.S | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 259be7f6d551..04b34397b656 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -540,6 +540,7 @@ __start_initialization_multiplatform:
 	b	__after_prom_start
 #endif /* CONFIG_PPC_BOOK3E */
 
+__REF
 __boot_from_prom:
 #ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE
 	/* Save parameters */
@@ -577,6 +578,7 @@ __boot_from_prom:
 	/* We never return. We also hit that trap if trying to boot
 	 * from OF while CONFIG_PPC_OF_BOOT_TRAMPOLINE isn't selected */
 	trap
+	.previous
 
 __after_prom_start:
 #ifdef CONFIG_RELOCATABLE
@@ -983,6 +985,7 @@ start_here_multiplatform:
 	.previous
 	/* This is where all platforms converge execution */
 
+__REF
 start_here_common:
 	/* relocation is on at this point */
 	std	r1,PACAKSAVE(r13)
@@ -1003,6 +1006,7 @@ start_here_common:
 
 	/* Not reached */
 	BUG_OPCODE
+	.previous
 
 /*
  * We put a few things here that have to be page-aligned.
-- 
2.18.1



More information about the Linuxppc-dev mailing list