[PATCH] powerpc: Revert removing of _INIT_GLOBAL(), _STATIC() and _INIT_STATIC()

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE4430d

7 messages, 3 authors, 2014-07-22 · open the first message on its own page

[PATCH] powerpc: Revert removing of _INIT_GLOBAL(), _STATIC() and _INIT_STATIC()

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2014-07-15 00:12:10

I wanted to test some new ftrace code on my PASemi electra powerpc box.
But unfortunately it failed to build. It failed with this:

  LD      init/built-in.o
arch/powerpc/kernel/head_64.o:arch/powerpc/kernel/exceptions-64s.S:874:
  relocation truncated to fit: R_PPC64_REL14 against `.text'+1c90
Makefile:864: recipe for target 'vmlinux' failed


Bisecting it lead me down to this commit:

commit 6a3bab90cf78bc579638525cb76ac240f8253803
Author: Anton Blanchard [off-list ref]
Date:   Tue Feb 4 16:06:11 2014 +1100

    powerpc: Remove some unnecessary uses of _GLOBAL() and _STATIC()
    
    There is no need to create a function descriptor for functions
    called locally out of assembly.


And by reverting this and:

commit a0e971ffb9d9dae3b9892fb548bd2497db758f60
Author: Anton Blanchard [off-list ref]
Date:   Tue Feb 4 16:06:25 2014 +1100

    powerpc: Remove _INIT_GLOBAL(), _STATIC() and _INIT_STATIC()
    
    Now there are no users of _INIT_GLOBAL(), _STATIC() and
    _INIT_STATIC() we can remove them.

My box builds and boots again.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 9ea266e..1baf197 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -217,6 +217,20 @@ name: \
 	addi r2,r2,(.TOC.-0b)@l; \
 	.localentry name,.-name
 
+#define _INIT_GLOBAL(name) \
+	__REF; \
+	.align 2 ; \
+	.globl name; \
+	.globl GLUE(.,name); \
+	.section ".opd","aw"; \
+name: \
+	.quad GLUE(.,name); \
+	.quad .TOC.@tocbase; \
+	.quad 0; \
+	.previous; \
+	.type GLUE(.,name),@function; \
+GLUE(.,name):
+
 #define _KPROBE(name) \
 	.section ".kprobes.text","a"; \
 	.align 2 ; \
@@ -265,6 +279,30 @@ GLUE(.,name):
 
 #endif
 
+#define _STATIC(name) \
+	.section ".text"; \
+	.align 2 ; \
+	.section ".opd","aw"; \
+name: \
+	.quad GLUE(.,name); \
+	.quad .TOC.@tocbase; \
+	.quad 0; \
+	.previous; \
+	.type GLUE(.,name),@function; \
+GLUE(.,name):
+
+#define _INIT_STATIC(name) \
+	__REF; \
+	.align 2 ; \
+	.section ".opd","aw"; \
+name: \
+	.quad GLUE(.,name); \
+	.quad .TOC.@tocbase; \
+	.quad 0; \
+	.previous; \
+	.type GLUE(.,name),@function; \
+GLUE(.,name):
+
 #else /* 32-bit */
 
 #define _ENTRY(n)	\
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index bb9cac6..ce0c55d 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -1580,14 +1580,14 @@ _GLOBAL(book3e_secondary_thread_init)
 	mflr	r28
 	b	3b
 
-init_core_book3e:
+_STATIC(init_core_book3e)
 	/* Establish the interrupt vector base */
 	LOAD_REG_IMMEDIATE(r3, interrupt_base_book3e)
 	mtspr	SPRN_IVPR,r3
 	sync
 	blr
 
-init_thread_book3e:
+_STATIC(init_thread_book3e)
 	lis	r3,(SPRN_EPCR_ICM | SPRN_EPCR_GICM)@h
 	mtspr	SPRN_EPCR,r3
 
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index a7d36b1..220c5a9 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1586,7 +1586,7 @@ power4_fixup_nap:
  * Hash table stuff
  */
 	.align	7
-do_hash_page:
+_STATIC(do_hash_page)
 	std	r3,_DAR(r1)
 	std	r4,_DSISR(r1)
 
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index a95145d..b8986af 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -299,7 +299,7 @@ generic_secondary_common_init:
  * Assumes we're mapped EA == RA if the MMU is on.
  */
 #ifdef CONFIG_PPC_BOOK3S
-__mmu_off:
+_STATIC(__mmu_off)
 	mfmsr	r3
 	andi.	r0,r3,MSR_IR|MSR_DR
 	beqlr
@@ -324,7 +324,7 @@ __mmu_off:
  *                 DT block, r4 is a physical pointer to the kernel itself
  *
  */
-__start_initialization_multiplatform:
+_GLOBAL(__start_initialization_multiplatform)
 	/* Make sure we are running in 64 bits mode */
 	bl	enable_64b_mode
 
@@ -376,7 +376,7 @@ __start_initialization_multiplatform:
 	b	__after_prom_start
 #endif /* CONFIG_PPC_BOOK3E */
 
-__boot_from_prom:
+_INIT_STATIC(__boot_from_prom)
 #ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE
 	/* Save parameters */
 	mr	r31,r3
@@ -414,7 +414,7 @@ __boot_from_prom:
 	 * from OF while CONFIG_PPC_OF_BOOT_TRAMPOLINE isn't selected */
 	trap
 
-__after_prom_start:
+_STATIC(__after_prom_start)
 #ifdef CONFIG_RELOCATABLE
 	/* process relocations for the final address of the kernel */
 	lis	r25,PAGE_OFFSET@highest	/* compute virtual base of kernel */
@@ -674,7 +674,7 @@ _GLOBAL(start_secondary_resume)
 /*
  * This subroutine clobbers r11 and r12
  */
-enable_64b_mode:
+_GLOBAL(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 */
@@ -715,7 +715,7 @@ p_toc:	.llong	__toc_start + 0x8000 - 0b
 /*
  * This is where the main kernel code starts.
  */
-start_here_multiplatform:
+_INIT_STATIC(start_here_multiplatform)
 	/* set up the TOC */
 	bl      relative_toc
 	tovirt(r2,r2)

Re: [PATCH] powerpc: Revert removing of _INIT_GLOBAL(), _STATIC() and _INIT_STATIC()

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2014-07-15 02:06:20

On Mon, 2014-07-14 at 20:12 -0400, Steven Rostedt wrote:
I wanted to test some new ftrace code on my PASemi electra powerpc box.
But unfortunately it failed to build. It failed with this:

  LD      init/built-in.o
arch/powerpc/kernel/head_64.o:arch/powerpc/kernel/exceptions-64s.S:874:
  relocation truncated to fit: R_PPC64_REL14 against `.text'+1c90
Makefile:864: recipe for target 'vmlinux' failed
Weird ... what are your gcc and binutils versions ? Smells like a
toolchain issue to me but I need to dig a bit more. Doesn't hit any
of my test configs here.

Cheers,
Ben.
quoted hunk
Bisecting it lead me down to this commit:

commit 6a3bab90cf78bc579638525cb76ac240f8253803
Author: Anton Blanchard [off-list ref]
Date:   Tue Feb 4 16:06:11 2014 +1100

    powerpc: Remove some unnecessary uses of _GLOBAL() and _STATIC()
    
    There is no need to create a function descriptor for functions
    called locally out of assembly.


And by reverting this and:

commit a0e971ffb9d9dae3b9892fb548bd2497db758f60
Author: Anton Blanchard [off-list ref]
Date:   Tue Feb 4 16:06:25 2014 +1100

    powerpc: Remove _INIT_GLOBAL(), _STATIC() and _INIT_STATIC()
    
    Now there are no users of _INIT_GLOBAL(), _STATIC() and
    _INIT_STATIC() we can remove them.

My box builds and boots again.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 9ea266e..1baf197 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -217,6 +217,20 @@ name: \
 	addi r2,r2,(.TOC.-0b)@l; \
 	.localentry name,.-name
 
+#define _INIT_GLOBAL(name) \
+	__REF; \
+	.align 2 ; \
+	.globl name; \
+	.globl GLUE(.,name); \
+	.section ".opd","aw"; \
+name: \
+	.quad GLUE(.,name); \
+	.quad .TOC.@tocbase; \
+	.quad 0; \
+	.previous; \
+	.type GLUE(.,name),@function; \
+GLUE(.,name):
+
 #define _KPROBE(name) \
 	.section ".kprobes.text","a"; \
 	.align 2 ; \
@@ -265,6 +279,30 @@ GLUE(.,name):
 
 #endif
 
+#define _STATIC(name) \
+	.section ".text"; \
+	.align 2 ; \
+	.section ".opd","aw"; \
+name: \
+	.quad GLUE(.,name); \
+	.quad .TOC.@tocbase; \
+	.quad 0; \
+	.previous; \
+	.type GLUE(.,name),@function; \
+GLUE(.,name):
+
+#define _INIT_STATIC(name) \
+	__REF; \
+	.align 2 ; \
+	.section ".opd","aw"; \
+name: \
+	.quad GLUE(.,name); \
+	.quad .TOC.@tocbase; \
+	.quad 0; \
+	.previous; \
+	.type GLUE(.,name),@function; \
+GLUE(.,name):
+
 #else /* 32-bit */
 
 #define _ENTRY(n)	\
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index bb9cac6..ce0c55d 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -1580,14 +1580,14 @@ _GLOBAL(book3e_secondary_thread_init)
 	mflr	r28
 	b	3b
 
-init_core_book3e:
+_STATIC(init_core_book3e)
 	/* Establish the interrupt vector base */
 	LOAD_REG_IMMEDIATE(r3, interrupt_base_book3e)
 	mtspr	SPRN_IVPR,r3
 	sync
 	blr
 
-init_thread_book3e:
+_STATIC(init_thread_book3e)
 	lis	r3,(SPRN_EPCR_ICM | SPRN_EPCR_GICM)@h
 	mtspr	SPRN_EPCR,r3
 
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index a7d36b1..220c5a9 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -1586,7 +1586,7 @@ power4_fixup_nap:
  * Hash table stuff
  */
 	.align	7
-do_hash_page:
+_STATIC(do_hash_page)
 	std	r3,_DAR(r1)
 	std	r4,_DSISR(r1)
 
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index a95145d..b8986af 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -299,7 +299,7 @@ generic_secondary_common_init:
  * Assumes we're mapped EA == RA if the MMU is on.
  */
 #ifdef CONFIG_PPC_BOOK3S
-__mmu_off:
+_STATIC(__mmu_off)
 	mfmsr	r3
 	andi.	r0,r3,MSR_IR|MSR_DR
 	beqlr
@@ -324,7 +324,7 @@ __mmu_off:
  *                 DT block, r4 is a physical pointer to the kernel itself
  *
  */
-__start_initialization_multiplatform:
+_GLOBAL(__start_initialization_multiplatform)
 	/* Make sure we are running in 64 bits mode */
 	bl	enable_64b_mode
 
@@ -376,7 +376,7 @@ __start_initialization_multiplatform:
 	b	__after_prom_start
 #endif /* CONFIG_PPC_BOOK3E */
 
-__boot_from_prom:
+_INIT_STATIC(__boot_from_prom)
 #ifdef CONFIG_PPC_OF_BOOT_TRAMPOLINE
 	/* Save parameters */
 	mr	r31,r3
@@ -414,7 +414,7 @@ __boot_from_prom:
 	 * from OF while CONFIG_PPC_OF_BOOT_TRAMPOLINE isn't selected */
 	trap
 
-__after_prom_start:
+_STATIC(__after_prom_start)
 #ifdef CONFIG_RELOCATABLE
 	/* process relocations for the final address of the kernel */
 	lis	r25,PAGE_OFFSET@highest	/* compute virtual base of kernel */
@@ -674,7 +674,7 @@ _GLOBAL(start_secondary_resume)
 /*
  * This subroutine clobbers r11 and r12
  */
-enable_64b_mode:
+_GLOBAL(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 */
@@ -715,7 +715,7 @@ p_toc:	.llong	__toc_start + 0x8000 - 0b
 /*
  * This is where the main kernel code starts.
  */
-start_here_multiplatform:
+_INIT_STATIC(start_here_multiplatform)
 	/* set up the TOC */
 	bl      relative_toc
 	tovirt(r2,r2)

Re: [PATCH] powerpc: Revert removing of _INIT_GLOBAL(), _STATIC() and _INIT_STATIC()

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2014-07-15 02:13:46

On Tue, 15 Jul 2014 12:05:55 +1000
Benjamin Herrenschmidt [off-list ref] wrote:
On Mon, 2014-07-14 at 20:12 -0400, Steven Rostedt wrote:
quoted
I wanted to test some new ftrace code on my PASemi electra powerpc box.
But unfortunately it failed to build. It failed with this:

  LD      init/built-in.o
arch/powerpc/kernel/head_64.o:arch/powerpc/kernel/exceptions-64s.S:874:
  relocation truncated to fit: R_PPC64_REL14 against `.text'+1c90
Makefile:864: recipe for target 'vmlinux' failed
Weird ... what are your gcc and binutils versions ? Smells like a
toolchain issue to me but I need to dig a bit more. Doesn't hit any
of my test configs here.
I built it from scratch from the mainline source repos.

dist-ppc-gcc (GCC) 4.6.0
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


GNU assembler (GNU Binutils) 2.21
Copyright 2010 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `powerpc64-unknown-linux'.


-- Steve

Re: [PATCH] powerpc: Revert removing of _INIT_GLOBAL(), _STATIC() and _INIT_STATIC()

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2014-07-15 02:16:59

On Tue, 15 Jul 2014 12:05:55 +1000
Benjamin Herrenschmidt [off-list ref] wrote:

Cheers,
Ben.
While I got your attention, could you please ack my patch with subject:

[RFA][PATCH 09/27] powerpc/ftrace: Add call to ftrace_graph_is_dead() in function graph code

so that I can push it through my tree.

Thanks!

-- Steve

Re: [PATCH] powerpc: Revert removing of _INIT_GLOBAL(), _STATIC() and _INIT_STATIC()

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2014-07-21 18:57:04

On Tue, 15 Jul 2014 12:05:55 +1000
Benjamin Herrenschmidt [off-list ref] wrote:
On Mon, 2014-07-14 at 20:12 -0400, Steven Rostedt wrote:
quoted
I wanted to test some new ftrace code on my PASemi electra powerpc box.
But unfortunately it failed to build. It failed with this:

  LD      init/built-in.o
arch/powerpc/kernel/head_64.o:arch/powerpc/kernel/exceptions-64s.S:874:
  relocation truncated to fit: R_PPC64_REL14 against `.text'+1c90
Makefile:864: recipe for target 'vmlinux' failed
Weird ... what are your gcc and binutils versions ? Smells like a
toolchain issue to me but I need to dig a bit more. Doesn't hit any
of my test configs here.
Can you test the attached config with this toolchain and see if you get
the same build bug.

https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.6.3/x86_64-gcc-4.6.3-nolibc_powerpc64-linux.tar.bz2


Thanks!

-- Steve

Re: [PATCH] powerpc: Revert removing of _INIT_GLOBAL(), _STATIC() and _INIT_STATIC()

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2014-07-22 06:14:20

On Mon, 2014-07-21 at 14:56 -0400, Steven Rostedt wrote:
quoted
Weird ... what are your gcc and binutils versions ? Smells like a
toolchain issue to me but I need to dig a bit more. Doesn't hit any
of my test configs here.
Can you test the attached config with this toolchain and see if you get
the same build bug.
Yeah ok, I hit it too, it's one of those issues with the bloody
alternate feature sections getting pushed too far away. Argh.

I'm trying to fix that trainwreck (similar issues also breaks our
allmodconfig), we have a whole mess of problems caused by our
hand crafted assembly growing beyond the reach of conditional
branches with the right set of options.

I'll see what I can do...
https://www.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.6.3/x86_64-gcc-4.6.3-nolibc_powerpc64-linux.tar.bz2

Re: [PATCH] powerpc: Revert removing of _INIT_GLOBAL(), _STATIC() and _INIT_STATIC()

From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2014-07-22 07:00:34

On Tue, 2014-07-22 at 16:13 +1000, Benjamin Herrenschmidt wrote:
On Mon, 2014-07-21 at 14:56 -0400, Steven Rostedt wrote:
quoted
quoted
Weird ... what are your gcc and binutils versions ? Smells like a
toolchain issue to me but I need to dig a bit more. Doesn't hit any
of my test configs here.
Can you test the attached config with this toolchain and see if you get
the same build bug.
Yeah ok, I hit it too, it's one of those issues with the bloody
alternate feature sections getting pushed too far away. Argh.
This should fix it temporarily at least:

  http://patchwork.ozlabs.org/patch/369950/

cheers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help