Skip to contentSkip to conversation

x86: mark native_set_p4d() as __always_inline

PATCH In review Arnd Bergmann 3 participants 3 messages Jun 5, 2018 – Jun 6, 2018 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: mark native_set_p4d() as __always_inline

When CONFIG_OPTIMIZE_INLINING is enabled, the function native_set_p4d() may not be fully inlined into the caller, resulting in a false-positive warning about an access to the __pgtable_l5_enabled variable from a non-__init function, despite the original caller being an __init function:

WARNING: vmlinux.o(.text.unlikely+0x1429): Section mismatch in reference from the function native_set_p4d() to the variable .init.data:__pgtable_l5_enabled
WARNING: vmlinux.o(.text.unlikely+0x1429): Section mismatch in reference from the function native_p4d_clear() to the variable .init.data:__pgtable_l5_enabled The function native_set_p4d() references
the variable __initdata __pgtable_l5_enabled.
This is often because native_set_p4d lacks a __initdata
annotation or the annotation of __pgtable_l5_enabled is wrong.

Marking the native_set_p4d function and its caller native_p4d_clear() avoids this problem.

I did not bisect the original cause, but I assume this is related to the recent rework that turned pgtable_l5_enabled() into an inline function, which in turn caused the compiler to make different inlining decisions.

Fixes ad3fe525b950 ("x86/mm: Unify pgtable_l5_enabled usage in early boot code")
---
 arch/x86/include/asm/pgtable_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/pgtable_64.h +2 -2
index 3c5385f9a88f..0fdcd21dadbd 100644
@@ -216,7 +216,7 @@ static inline pgd_t pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd)
 }
 #endif
 
-static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
+static __always_inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
 {
 	pgd_t pgd;
 
@@ -230,7 +230,7 @@ static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
 	*p4dp = native_make_p4d(native_pgd_val(pgd));
 }
 
-static inline void native_p4d_clear(p4d_t *p4d)
+static __always_inline void native_p4d_clear(p4d_t *p4d)
 {
 	native_set_p4d(p4d, native_make_p4d(0));
 }
Signature · 1 line
2.9.0
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Arnd Bergmann

When CONFIG_OPTIMIZE_INLINING is enabled, the function native_set_p4d() may not be fully inlined into the caller, resulting in a false-positive warning about an access to the __pgtable_l5_enabled variable from a non-__init function, despite the original caller being an __init function:

WARNING: vmlinux.o(.text.unlikely+0x1429): Section mismatch in reference from the function native_set_p4d() to the variable .init.data:__pgtable_l5_enabled
WARNING: vmlinux.o(.text.unlikely+0x1429): Section mismatch in reference from the function native_p4d_clear() to the variable .init.data:__pgtable_l5_enabled The function native_set_p4d() references
the variable __initdata __pgtable_l5_enabled.
This is often because native_set_p4d lacks a __initdata
annotation or the annotation of __pgtable_l5_enabled is wrong.

Marking the native_set_p4d function and its caller native_p4d_clear() avoids this problem.

Quoted 7 lines

I did not bisect the original cause, but I assume this is related to the recent rework that turned pgtable_l5_enabled() into an inline function, which in turn caused the compiler to make different inlining decisions.

Fixes ad3fe525b950 ("x86/mm: Unify pgtable_l5_enabled usage in early boot code")

Thanks for fixing this.

Do you have a clue which native_set_p4d() call causes the issue?

Signature · 1 line
 Kirill A. Shutemov
#2 lore raw

[tip:x86/urgent] x86: Mark native_set_p4d() as __always_inline

In reply to Arnd Bergmann
x86: Mark native_set_p4d() as __always_inline
Commit-ID:  046c0dbec0238c25b7526c26c9a9687664229ce2
Gitweb:     https://git.kernel.org/tip/046c0dbec0238c25b7526c26c9a9687664229ce2
Author:     Arnd Bergmann <[email protected]>
AuthorDate: Tue, 5 Jun 2018 13:35:15 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Wed, 6 Jun 2018 12:09:45 +0200

x86: Mark native_set_p4d() as __always_inline

When CONFIG_OPTIMIZE_INLINING is enabled, the function native_set_p4d() may not be fully inlined into the caller, resulting in a false-positive warning about an access to the __pgtable_l5_enabled variable from a non-__init function, despite the original caller being an __init function:

WARNING: vmlinux.o(.text.unlikely+0x1429): Section mismatch in reference from the function native_set_p4d() to the variable .init.data:__pgtable_l5_enabled
WARNING: vmlinux.o(.text.unlikely+0x1429): Section mismatch in reference from the function native_p4d_clear() to the variable .init.data:__pgtable_l5_enabled

The function native_set_p4d() references the variable __initdata __pgtable_l5_enabled. This is often because native_set_p4d lacks a __initdata annotation or the annotation of __pgtable_l5_enabled is wrong.

Marking the native_set_p4d function and its caller native_p4d_clear() avoids this problem.

I did not bisect the original cause, but I assume this is related to the recent rework that turned pgtable_l5_enabled() into an inline function, which in turn caused the compiler to make different inlining decisions.

Fixes ad3fe525b950 ("x86/mm: Unify pgtable_l5_enabled usage in early boot code")
Cc Greg Kroah-Hartman <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Zi Yan <[email protected]>
Cc Naoya Horiguchi <[email protected]>
---
 arch/x86/include/asm/pgtable_64.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/include/asm/pgtable_64.h +2 -2
index 877bc27718ae..c750112cb416 100644
@@ -216,7 +216,7 @@ static inline pgd_t pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd)
 }
 #endif
 
-static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
+static __always_inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
 {
 	pgd_t pgd;
 
@@ -230,7 +230,7 @@ static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d)
 	*p4dp = native_make_p4d(native_pgd_val(pgd));
 }
 
-static inline void native_p4d_clear(p4d_t *p4d)
+static __always_inline void native_p4d_clear(p4d_t *p4d)
 {
 	native_set_p4d(p4d, native_make_p4d(0));
 }