linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Don't change the section in _GLOBAL()
@ 2016-09-15  0:40 Michael Ellerman
  2016-09-15  3:54 ` Nicholas Piggin
  2016-09-20 13:07 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Ellerman @ 2016-09-15  0:40 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: npiggin

Currently the _GLOBAL() macro unilaterally sets the assembler section to
".text" at the start of the macro. This is rude as the caller may be
using a different section.

So let the caller decide which section to emit the code into. On big
endian we do need to switch to the ".opd" section to emit the OPD, but
do that with pushsection/popsection, thereby leaving the original
section intact.

The only place I could find where this requires changes to the code is
in misc_32.S, where we need to switch back to ".text" after
flush_icache_range() which is in ".kprobes.text".

I verified that the order of all entries in System.map is unchanged
after this patch. The actual addresses shift around slightly so you
can't just diff the System.map.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---

If anyone can think of a better method to verify we are still emitting
everything in the same sections let me know.


 arch/powerpc/include/asm/ppc_asm.h | 8 ++------
 arch/powerpc/kernel/misc_32.S      | 3 +++
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index d5d5b5e348f2..479287045166 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -201,14 +201,12 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
 #ifdef PPC64_ELF_ABI_v2
 
 #define _GLOBAL(name) \
-	.section ".text"; \
 	.align 2 ; \
 	.type name,@function; \
 	.globl name; \
 name:
 
 #define _GLOBAL_TOC(name) \
-	.section ".text"; \
 	.align 2 ; \
 	.type name,@function; \
 	.globl name; \
@@ -232,16 +230,15 @@ name:
 #define GLUE(a,b) XGLUE(a,b)
 
 #define _GLOBAL(name) \
-	.section ".text"; \
 	.align 2 ; \
 	.globl name; \
 	.globl GLUE(.,name); \
-	.section ".opd","aw"; \
+	.pushsection ".opd","aw"; \
 name: \
 	.quad GLUE(.,name); \
 	.quad .TOC.@tocbase; \
 	.quad 0; \
-	.previous; \
+	.popsection; \
 	.type GLUE(.,name),@function; \
 GLUE(.,name):
 
@@ -272,7 +269,6 @@ GLUE(.,name):
 n:
 
 #define _GLOBAL(n)	\
-	.text;		\
 	.stabs __stringify(n:F-1),N_FUN,0,0,n;\
 	.globl n;	\
 n:
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index d9c912b6e632..64fb1138961f 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -358,6 +358,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
 	sync				/* additional sync needed on g4 */
 	isync
 	blr
+
+.previous
+
 /*
  * Flush a particular page from the data cache to RAM.
  * Note: this is necessary because the instruction cache does *not*
-- 
2.7.4

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

* Re: [PATCH] powerpc: Don't change the section in _GLOBAL()
  2016-09-15  0:40 [PATCH] powerpc: Don't change the section in _GLOBAL() Michael Ellerman
@ 2016-09-15  3:54 ` Nicholas Piggin
  2016-09-20 13:07 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Nicholas Piggin @ 2016-09-15  3:54 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

On Thu, 15 Sep 2016 10:40:20 +1000
Michael Ellerman <mpe@ellerman.id.au> wrote:

> Currently the _GLOBAL() macro unilaterally sets the assembler section to
> ".text" at the start of the macro. This is rude as the caller may be
> using a different section.
> 
> So let the caller decide which section to emit the code into. On big
> endian we do need to switch to the ".opd" section to emit the OPD, but
> do that with pushsection/popsection, thereby leaving the original
> section intact.
> 
> The only place I could find where this requires changes to the code is
> in misc_32.S, where we need to switch back to ".text" after
> flush_icache_range() which is in ".kprobes.text".
> 
> I verified that the order of all entries in System.map is unchanged
> after this patch. The actual addresses shift around slightly so you
> can't just diff the System.map.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Excellent, thanks for going through it.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

> ---
> 
> If anyone can think of a better method to verify we are still emitting
> everything in the same sections let me know.
> 
> 
>  arch/powerpc/include/asm/ppc_asm.h | 8 ++------
>  arch/powerpc/kernel/misc_32.S      | 3 +++
>  2 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
> index d5d5b5e348f2..479287045166 100644
> --- a/arch/powerpc/include/asm/ppc_asm.h
> +++ b/arch/powerpc/include/asm/ppc_asm.h
> @@ -201,14 +201,12 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
>  #ifdef PPC64_ELF_ABI_v2
>  
>  #define _GLOBAL(name) \
> -	.section ".text"; \
>  	.align 2 ; \
>  	.type name,@function; \
>  	.globl name; \
>  name:
>  
>  #define _GLOBAL_TOC(name) \
> -	.section ".text"; \
>  	.align 2 ; \
>  	.type name,@function; \
>  	.globl name; \
> @@ -232,16 +230,15 @@ name:
>  #define GLUE(a,b) XGLUE(a,b)
>  
>  #define _GLOBAL(name) \
> -	.section ".text"; \
>  	.align 2 ; \
>  	.globl name; \
>  	.globl GLUE(.,name); \
> -	.section ".opd","aw"; \
> +	.pushsection ".opd","aw"; \
>  name: \
>  	.quad GLUE(.,name); \
>  	.quad .TOC.@tocbase; \
>  	.quad 0; \
> -	.previous; \
> +	.popsection; \

I think you can still use .section and .previous here, but it's
much of a muchness.

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

* Re: powerpc: Don't change the section in _GLOBAL()
  2016-09-15  0:40 [PATCH] powerpc: Don't change the section in _GLOBAL() Michael Ellerman
  2016-09-15  3:54 ` Nicholas Piggin
@ 2016-09-20 13:07 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2016-09-20 13:07 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: npiggin

On Thu, 2016-15-09 at 00:40:20 UTC, Michael Ellerman wrote:
> Currently the _GLOBAL() macro unilaterally sets the assembler section to
> ".text" at the start of the macro. This is rude as the caller may be
> using a different section.
> 
> So let the caller decide which section to emit the code into. On big
> endian we do need to switch to the ".opd" section to emit the OPD, but
> do that with pushsection/popsection, thereby leaving the original
> section intact.
> 
> The only place I could find where this requires changes to the code is
> in misc_32.S, where we need to switch back to ".text" after
> flush_icache_range() which is in ".kprobes.text".
> 
> I verified that the order of all entries in System.map is unchanged
> after this patch. The actual addresses shift around slightly so you
> can't just diff the System.map.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

Applied to powerpc next.

https://git.kernel.org/powerpc/c/bea2dccccfd47ef3f8612f1265

cheers

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

end of thread, other threads:[~2016-09-20 13:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-15  0:40 [PATCH] powerpc: Don't change the section in _GLOBAL() Michael Ellerman
2016-09-15  3:54 ` Nicholas Piggin
2016-09-20 13:07 ` 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).