Skip to contentSkip to conversation

powerpc: fix function annotations to avoid section mismatch warnings with gcc-10

PATCH Applied Vladis Dronov 4 participants 7 messages Jul 29, 2020 – Aug 2, 2020 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: fix function annotations to avoid section mismatch warnings with gcc-10

Certain warnings are emitted for powerpc code when building with a gcc-10 toolset:

WARNING: modpost: vmlinux.o(.text.unlikely+0x377c): Section mismatch in reference from the function remove_pmd_table() to the function .meminit.text:split_kernel_mapping()
The function remove_pmd_table() references
the function __meminit split_kernel_mapping().
This is often because remove_pmd_table lacks a __meminit annotation or the annotation of split_kernel_mapping is wrong.

Add the appropriate __init and __meminit annotations to make modpost not complain. In all the cases there are just a single callsite from another __init or __meminit function:

__meminit remove_pagetable() -> remove_pud_table() -> remove_pmd_table() __init prom_init() -> setup_secure_guest()
__init xive_spapr_init() -> xive_spapr_disabled()

---
 arch/powerpc/kernel/prom_init.c          | 4 ++--
 arch/powerpc/mm/book3s64/radix_pgtable.c | 4 ++--
 arch/powerpc/sysdev/xive/spapr.c         | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
arch/powerpc/kernel/prom_init.c +2 -2
index 90c604d00b7d..f6ca7f450361 100644
@@ -3262,7 +3262,7 @@ static int enter_secure_mode(unsigned long kbase, unsigned long fdt)
 /*
  * Call the Ultravisor to transfer us to secure memory if we have an ESM blob.
  */
-static void setup_secure_guest(unsigned long kbase, unsigned long fdt)
+static void __init setup_secure_guest(unsigned long kbase, unsigned long fdt)
 {
 	int ret;
 
@@ -3292,7 +3292,7 @@ static void setup_secure_guest(unsigned long kbase, unsigned long fdt)
 	}
 }
 #else
-static void setup_secure_guest(unsigned long kbase, unsigned long fdt)
+static void __init setup_secure_guest(unsigned long kbase, unsigned long fdt)
 {
 }
 #endif /* CONFIG_PPC_SVM */
arch/powerpc/mm/book3s64/radix_pgtable.c +2 -2
index bb00e0cba119..b868c07110e3 100644
@@ -800,7 +800,7 @@ static void __meminit split_kernel_mapping(unsigned long addr, unsigned long end
 	pte_clear(&init_mm, addr, pte);
 }
 
-static void remove_pmd_table(pmd_t *pmd_start, unsigned long addr,
+static void __meminit remove_pmd_table(pmd_t *pmd_start, unsigned long addr,
 			     unsigned long end)
 {
 	unsigned long next;
@@ -825,7 +825,7 @@ static void remove_pmd_table(pmd_t *pmd_start, unsigned long addr,
 	}
 }
 
-static void remove_pud_table(pud_t *pud_start, unsigned long addr,
+static void __meminit remove_pud_table(pud_t *pud_start, unsigned long addr,
 			     unsigned long end)
 {
 	unsigned long next;
arch/powerpc/sysdev/xive/spapr.c +1 -1
index f0551a2be9df..1e3674d7ea7b 100644
@@ -768,7 +768,7 @@ static const u8 *get_vec5_feature(unsigned int index)
 	return vec5 + index;
 }
 
-static bool xive_spapr_disabled(void)
+static bool __init xive_spapr_disabled(void)
 {
 	const u8 *vec5_xive;
 
Signature · 1 line
2.26.2
#1 lore raw
Quoted 11 lines · Vladis Dronov

Certain warnings are emitted for powerpc code when building with a gcc-10 toolset:

WARNING: modpost: vmlinux.o(.text.unlikely+0x377c): Section mismatch in reference from the function remove_pmd_table() to the function .meminit.text:split_kernel_mapping()
The function remove_pmd_table() references
the function __meminit split_kernel_mapping().
This is often because remove_pmd_table lacks a __meminit annotation or the annotation of split_kernel_mapping is wrong.

Quoted 7 lines

Add the appropriate __init and __meminit annotations to make modpost not complain. In all the cases there are just a single callsite from another __init or __meminit function:

__meminit remove_pagetable() -> remove_pud_table() -> remove_pmd_table() __init prom_init() -> setup_secure_guest()
__init xive_spapr_init() -> xive_spapr_disabled()

So what changed? These functions were inlined with older compilers, but not anymore?

Segher

#2 lore raw

Hello,

----- Original Message -----

Quoted 23 lines

From: "Segher Boessenkool" <[email protected]>
To: "Vladis Dronov" <[email protected]>
Cc: [email protected], "Aneesh Kumar K . V" <[email protected]>, [email protected], "Paul Mackerras" <[email protected]>
Sent: Wednesday, July 29, 2020 4:49:49 PM
Subject: Re: [PATCH] powerpc: fix function annotations to avoid section mismatch warnings with gcc-10

Quoted 15 lines · Vladis Dronov

Certain warnings are emitted for powerpc code when building with a gcc-10 toolset:

WARNING: modpost: vmlinux.o(.text.unlikely+0x377c): Section mismatch in reference from the function remove_pmd_table() to the function .meminit.text:split_kernel_mapping()
The function remove_pmd_table() references
the function __meminit split_kernel_mapping().
This is often because remove_pmd_table lacks a __meminit annotation or the annotation of split_kernel_mapping is wrong.

Add the appropriate __init and __meminit annotations to make modpost not complain. In all the cases there are just a single callsite from another __init or __meminit function:

Quoted 6 lines
Quoted 3 lines

__meminit remove_pagetable() -> remove_pud_table() -> remove_pmd_table() __init prom_init() -> setup_secure_guest()
__init xive_spapr_init() -> xive_spapr_disabled()

So what changed? These functions were inlined with older compilers, but not anymore?

Yes, exactly. Gcc-10 does not inline them anymore. If this is because of my build system, this can happen to others also.

The same thing was fixed by Linus in e99332e7b4cd ("gcc-10: mark more functions __init to avoid section mismatch warnings").

Quoted 2 lines

Segher

Best regards,
Vladis Dronov | Red Hat, Inc. | The Core Kernel | Senior Software Engineer

#3 lore raw
Quoted 19 lines · Vladis Dronov
Quoted 19 lines
Quoted 18 lines

Certain warnings are emitted for powerpc code when building with a gcc-10 toolset:

WARNING: modpost: vmlinux.o(.text.unlikely+0x377c): Section mismatch in reference from the function remove_pmd_table() to the function .meminit.text:split_kernel_mapping()
The function remove_pmd_table() references
the function __meminit split_kernel_mapping().
This is often because remove_pmd_table lacks a __meminit annotation or the annotation of split_kernel_mapping is wrong.

Add the appropriate __init and __meminit annotations to make modpost not complain. In all the cases there are just a single callsite from another __init or __meminit function:

__meminit remove_pagetable() -> remove_pud_table() -> remove_pmd_table() __init prom_init() -> setup_secure_guest()
__init xive_spapr_init() -> xive_spapr_disabled()

Quoted 8 lines
Quoted 2 lines

So what changed? These functions were inlined with older compilers, but not anymore?

Yes, exactly. Gcc-10 does not inline them anymore. If this is because of my build system, this can happen to others also.

The same thing was fixed by Linus in e99332e7b4cd ("gcc-10: mark more functions __init to avoid section mismatch warnings").

It sounds like this is part of "-finline-functions was retuned" on
<https://gcc.gnu.org/gcc-10/changes.html>? So everyone should see it (no matter what config or build system), and it is a good thing too :-)

Thanks for the confirmation,

Segher

#4 lore raw
Quoted 26 lines · Segher Boessenkool
Quoted 25 lines · Vladis Dronov
Quoted 15 lines
Quoted 15 lines

Certain warnings are emitted for powerpc code when building with a gcc-10 toolset:

WARNING: modpost: vmlinux.o(.text.unlikely+0x377c): Section mismatch in reference from the function remove_pmd_table() to the function .meminit.text:split_kernel_mapping()
The function remove_pmd_table() references
the function __meminit split_kernel_mapping().
This is often because remove_pmd_table lacks a __meminit annotation or the annotation of split_kernel_mapping is wrong.

Add the appropriate __init and __meminit annotations to make modpost not complain. In all the cases there are just a single callsite from another __init or __meminit function:

Quoted 6 lines
Quoted 3 lines

__meminit remove_pagetable() -> remove_pud_table() -> remove_pmd_table() __init prom_init() -> setup_secure_guest()
__init xive_spapr_init() -> xive_spapr_disabled()

So what changed? These functions were inlined with older compilers, but not anymore?

Yes, exactly. Gcc-10 does not inline them anymore. If this is because of my build system, this can happen to others also.

Quoted 6 lines
Quoted 2 lines

The same thing was fixed by Linus in e99332e7b4cd ("gcc-10: mark more functions __init to avoid section mismatch warnings").

It sounds like this is part of "-finline-functions was retuned" on
<https://gcc.gnu.org/gcc-10/changes.html>? So everyone should see it (no matter what config or build system), and it is a good thing too :-)

I haven't seen it in my GCC 10 builds, so there must be some other subtlety. Probably it depends on details of the .config.

cheers

#5 lore raw

Hello, Michael,

----- Original Message -----

Quoted 3 lines

From: "Michael Ellerman" <[email protected]>
Subject: Re: [PATCH] powerpc: fix function annotations to avoid section mismatch warnings with gcc-10

...

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines

So what changed? These functions were inlined with older compilers, but not anymore?

Yes, exactly. Gcc-10 does not inline them anymore. If this is because of my
build system, this can happen to others also.

The same thing was fixed by Linus in e99332e7b4cd ("gcc-10: mark more functions
__init to avoid section mismatch warnings").

Quoted 7 lines
Quoted 3 lines

It sounds like this is part of "-finline-functions was retuned" on
<https://gcc.gnu.org/gcc-10/changes.html>? So everyone should see it (no matter what config or build system), and it is a good thing too :-)

I haven't seen it in my GCC 10 builds, so there must be some other subtlety. Probably it depends on details of the .config.

I've just had this building the latest upstream for the ppc64le with a derivative of the RHEL-8 config. This can probably be a compiler/linker setting, like -O2 versus -O3.

Quoted 1 line

cheers

Best regards,
Vladis Dronov | Red Hat, Inc. | The Core Kernel | Senior Software Engineer

#6 lore raw
In reply to Vladis Dronov
Quoted 11 lines · Vladis Dronov

Certain warnings are emitted for powerpc code when building with a gcc-10 toolset:

WARNING: modpost: vmlinux.o(.text.unlikely+0x377c): Section mismatch in reference from the function remove_pmd_table() to the function .meminit.text:split_kernel_mapping()
The function remove_pmd_table() references
the function __meminit split_kernel_mapping().
This is often because remove_pmd_table lacks a __meminit annotation or the annotation of split_kernel_mapping is wrong.

Quoted 1 line

[...]

Applied to powerpc/next.

[1/1] powerpc: fix function annotations to avoid section mismatch warnings with gcc-10

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

cheers