linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/64s: Fix section mismatch warnings from boot code
@ 2020-02-25  3:13 Michael Ellerman
  2020-03-26 12:06 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Ellerman @ 2020-02-25  3:13 UTC (permalink / raw)
  To: linuxppc-dev

We currently have two section mismatch warnings:

  The function __boot_from_prom() references
  the function __init prom_init().

  The function start_here_common() references
  the function __init start_kernel().

The warnings are correct, we do have branches from non-init code into
init code, which is freed after boot. But we don't expect to ever
execute any of that early boot code after boot, if we did that would
be a bug. In particular calling into OF after boot would be fatal
because OF is no longer resident.

So for now fix the warnings by marking the relevant functions as
__REF, which puts them in the ".ref.text" section.

This causes some reordering of the functions in the final link:

  @@ -217,10 +217,9 @@
   c00000000000b088 t generic_secondary_common_init
   c00000000000b124 t __mmu_off
   c00000000000b14c t __start_initialization_multiplatform
  -c00000000000b1ac t __boot_from_prom
  -c00000000000b1ec t __after_prom_start
  -c00000000000b260 t p_end
  -c00000000000b27c T copy_and_flush
  +c00000000000b1ac t __after_prom_start
  +c00000000000b220 t p_end
  +c00000000000b23c T copy_and_flush
   c00000000000b300 T __secondary_start
   c00000000000b300 t copy_to_here
   c00000000000b344 t start_secondary_prolog
  @@ -228,8 +227,9 @@
   c00000000000b36c t enable_64b_mode
   c00000000000b388 T relative_toc
   c00000000000b3a8 t p_toc
  -c00000000000b3b0 t start_here_common
  -c00000000000b3d0 t start_here_multiplatform
  +c00000000000b3b0 t __boot_from_prom
  +c00000000000b3f0 t start_here_multiplatform
  +c00000000000b480 t start_here_common
   c00000000000b880 T system_call_common
   c00000000000b974 t system_call
   c00000000000b9dc t system_call_exit

In particular __boot_from_prom moves after copy_to_here, which means
it's not copied to zero in the first stage of copy of the kernel to
zero.

But that's OK, because we only call __boot_from_prom before we do the
copy, so it makes no difference when it's copied. The call sequence
is:
  __start
  -> __start_initialization_multiplatform
     -> __boot_from_prom
        -> __start
           -> __start_initialization_multiplatform
              -> __after_prom_start
                 -> copy_and_flush
                 -> copy_and_flush (relocated to 0)
                    -> start_here_multiplatform
                       -> early_setup

Reported-by: Mauricio Faria de Oliveira <mauricfo@linux.ibm.com>
Reported-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/head_64.S | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index ad79fddb974d..ddfbd02140d9 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -537,6 +537,7 @@ _GLOBAL(generic_secondary_smp_init)
 	b	__after_prom_start
 #endif /* CONFIG_PPC_BOOK3E */
 
+__REF
 __boot_from_prom:
 #ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE
 	/* Save parameters */
@@ -574,6 +575,7 @@ _GLOBAL(generic_secondary_smp_init)
 	/* 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
@@ -977,7 +979,6 @@ __REF
 	RFI
 	b	.	/* prevent speculative execution */
 
-	.previous
 	/* This is where all platforms converge execution */
 
 start_here_common:
@@ -1001,6 +1002,7 @@ __REF
 	/* Not reached */
 	trap
 	EMIT_BUG_ENTRY 0b, __FILE__, __LINE__, 0
+	.previous
 
 /*
  * We put a few things here that have to be page-aligned.
-- 
2.21.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] powerpc/64s: Fix section mismatch warnings from boot code
  2020-02-25  3:13 [PATCH] powerpc/64s: Fix section mismatch warnings from boot code Michael Ellerman
@ 2020-03-26 12:06 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2020-03-26 12:06 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev

On Tue, 2020-02-25 at 03:13:28 UTC, Michael Ellerman wrote:
> We currently have two section mismatch warnings:
> 
>   The function __boot_from_prom() references
>   the function __init prom_init().
> 
>   The function start_here_common() references
>   the function __init start_kernel().
> 
> The warnings are correct, we do have branches from non-init code into
> init code, which is freed after boot. But we don't expect to ever
> execute any of that early boot code after boot, if we did that would
> be a bug. In particular calling into OF after boot would be fatal
> because OF is no longer resident.
> 
> So for now fix the warnings by marking the relevant functions as
> __REF, which puts them in the ".ref.text" section.
> 
> This causes some reordering of the functions in the final link:
> 
>   @@ -217,10 +217,9 @@
>    c00000000000b088 t generic_secondary_common_init
>    c00000000000b124 t __mmu_off
>    c00000000000b14c t __start_initialization_multiplatform
>   -c00000000000b1ac t __boot_from_prom
>   -c00000000000b1ec t __after_prom_start
>   -c00000000000b260 t p_end
>   -c00000000000b27c T copy_and_flush
>   +c00000000000b1ac t __after_prom_start
>   +c00000000000b220 t p_end
>   +c00000000000b23c T copy_and_flush
>    c00000000000b300 T __secondary_start
>    c00000000000b300 t copy_to_here
>    c00000000000b344 t start_secondary_prolog
>   @@ -228,8 +227,9 @@
>    c00000000000b36c t enable_64b_mode
>    c00000000000b388 T relative_toc
>    c00000000000b3a8 t p_toc
>   -c00000000000b3b0 t start_here_common
>   -c00000000000b3d0 t start_here_multiplatform
>   +c00000000000b3b0 t __boot_from_prom
>   +c00000000000b3f0 t start_here_multiplatform
>   +c00000000000b480 t start_here_common
>    c00000000000b880 T system_call_common
>    c00000000000b974 t system_call
>    c00000000000b9dc t system_call_exit
> 
> In particular __boot_from_prom moves after copy_to_here, which means
> it's not copied to zero in the first stage of copy of the kernel to
> zero.
> 
> But that's OK, because we only call __boot_from_prom before we do the
> copy, so it makes no difference when it's copied. The call sequence
> is:
>   __start
>   -> __start_initialization_multiplatform
>      -> __boot_from_prom
>         -> __start
>            -> __start_initialization_multiplatform
>               -> __after_prom_start
>                  -> copy_and_flush
>                  -> copy_and_flush (relocated to 0)
>                     -> start_here_multiplatform
>                        -> early_setup
> 
> Reported-by: Mauricio Faria de Oliveira <mauricfo@linux.ibm.com>
> Reported-by: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Applied to powerpc next.

https://git.kernel.org/powerpc/c/6eeb9b3b9ce588f14a697737a30d0702b5a20293

cheers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-26 12:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25  3:13 [PATCH] powerpc/64s: Fix section mismatch warnings from boot code Michael Ellerman
2020-03-26 12:06 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).