llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] MIPS: Fix check_bugs() modpost warning
@ 2023-04-21 16:11 Nathan Chancellor
  2023-04-21 16:11 ` [PATCH v2 1/2] MIPS: Mark check_bugs() as __init Nathan Chancellor
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nathan Chancellor @ 2023-04-21 16:11 UTC (permalink / raw)
  To: tsbogend
  Cc: ndesaulniers, linux-mips, linux-kernel, llvm, patches,
	Naresh Kamboju, Nathan Chancellor

Hi all,

This series fixes a modpost warning visible in -next from check_bugs()
and helps avoid a potential, albeit unlikely, warning from
check_bugs_early().

---
Changes in v2:
- Now two separate patches: one to avoid current check_bugs() warning
  and one to avoid potential check_bugs_early() warning.
- Sink body of check_bugs_early() into setup_arch() directly, rather
  than marking it as __init (Nick).
- Add Naresh's reported-by to patch 1, which came after v1 was sent.
- Reword commit messages to note that there is not a problem at run time
  because check_bugs() and check_bugs_early(), while not marked __init,
  are only called from __init functions; modpost does not know this
  though, hence the warning.
- Link to v1: https://lore.kernel.org/r/20230419-mips-check_bugs-init-attribute-v1-1-91e6eed55b89@kernel.org

---
Nathan Chancellor (2):
      MIPS: Mark check_bugs() as __init
      MIPS: Sink body of check_bugs_early() into its only call site

 arch/mips/include/asm/bugs.h | 8 +-------
 arch/mips/kernel/setup.c     | 3 ++-
 2 files changed, 3 insertions(+), 8 deletions(-)
---
base-commit: 6a8f57ae2eb07ab39a6f0ccad60c760743051026
change-id: 20230419-mips-check_bugs-init-attribute-026103bdb255

Best regards,
-- 
Nathan Chancellor <nathan@kernel.org>


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

* [PATCH v2 1/2] MIPS: Mark check_bugs() as __init
  2023-04-21 16:11 [PATCH v2 0/2] MIPS: Fix check_bugs() modpost warning Nathan Chancellor
@ 2023-04-21 16:11 ` Nathan Chancellor
  2023-04-21 16:11 ` [PATCH v2 2/2] MIPS: Sink body of check_bugs_early() into its only call site Nathan Chancellor
  2023-04-22 21:30 ` [PATCH v2 0/2] MIPS: Fix check_bugs() modpost warning Thomas Bogendoerfer
  2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2023-04-21 16:11 UTC (permalink / raw)
  To: tsbogend
  Cc: ndesaulniers, linux-mips, linux-kernel, llvm, patches,
	Naresh Kamboju, Nathan Chancellor

After commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING
forcibly"), a compiler may choose not to inline a function marked with
just 'inline'. If check_bugs() is not inlined into start_kernel(), which
occurs when building with clang after commit 9ea7e6b62c2b ("init: Mark
[arch_call_]rest_init() __noreturn"), modpost complains with:

  WARNING: modpost: vmlinux.o: section mismatch in reference: check_bugs (section: .text) -> check_bugs32 (section: .init.text)

check_bugs() is only called from start_kernel(), which itself is marked
__init, so there would not be any issues at run time. Make it obvious to
modpost that this call chain is safe by marking check_bugs() as __init,
which fixes the warning.

Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Link: https://lore.kernel.org/CA+G9fYt+4e57Gdy6cix=LeNK6XqWoui8du=mZWu=cf8vPYocKw@mail.gmail.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/mips/include/asm/bugs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/bugs.h b/arch/mips/include/asm/bugs.h
index d72dc6e1cf3c..047e14227c45 100644
--- a/arch/mips/include/asm/bugs.h
+++ b/arch/mips/include/asm/bugs.h
@@ -30,7 +30,7 @@ static inline void check_bugs_early(void)
 		check_bugs64_early();
 }
 
-static inline void check_bugs(void)
+static inline void __init check_bugs(void)
 {
 	unsigned int cpu = smp_processor_id();
 

-- 
2.40.0


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

* [PATCH v2 2/2] MIPS: Sink body of check_bugs_early() into its only call site
  2023-04-21 16:11 [PATCH v2 0/2] MIPS: Fix check_bugs() modpost warning Nathan Chancellor
  2023-04-21 16:11 ` [PATCH v2 1/2] MIPS: Mark check_bugs() as __init Nathan Chancellor
@ 2023-04-21 16:11 ` Nathan Chancellor
  2023-04-22 21:30 ` [PATCH v2 0/2] MIPS: Fix check_bugs() modpost warning Thomas Bogendoerfer
  2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2023-04-21 16:11 UTC (permalink / raw)
  To: tsbogend
  Cc: ndesaulniers, linux-mips, linux-kernel, llvm, patches, Nathan Chancellor

If check_bugs_early() is not inlined, which a compiler is free to do
after commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING
forcibly"), modpost would warn that check_bugs_early(), a non-init
function, refers to check_bugs64_early(), which is marked __init. This
would not result in any run time issues, as check_bugs_early() is only
called from setup_arch(), which is marked __init.

To avoid this potential warning, just sink the body of
check_bugs_early() into its single call site in setup_arch().

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 arch/mips/include/asm/bugs.h | 6 ------
 arch/mips/kernel/setup.c     | 3 ++-
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/mips/include/asm/bugs.h b/arch/mips/include/asm/bugs.h
index 047e14227c45..653f78f3a685 100644
--- a/arch/mips/include/asm/bugs.h
+++ b/arch/mips/include/asm/bugs.h
@@ -24,12 +24,6 @@ extern void check_bugs64_early(void);
 extern void check_bugs32(void);
 extern void check_bugs64(void);
 
-static inline void check_bugs_early(void)
-{
-	if (IS_ENABLED(CONFIG_CPU_R4X00_BUGS64))
-		check_bugs64_early();
-}
-
 static inline void __init check_bugs(void)
 {
 	unsigned int cpu = smp_processor_id();
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index f1c88f8a1dc5..febdc5564638 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -786,7 +786,8 @@ void __init setup_arch(char **cmdline_p)
 	setup_early_printk();
 #endif
 	cpu_report();
-	check_bugs_early();
+	if (IS_ENABLED(CONFIG_CPU_R4X00_BUGS64))
+		check_bugs64_early();
 
 #if defined(CONFIG_VT)
 #if defined(CONFIG_VGA_CONSOLE)

-- 
2.40.0


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

* Re: [PATCH v2 0/2] MIPS: Fix check_bugs() modpost warning
  2023-04-21 16:11 [PATCH v2 0/2] MIPS: Fix check_bugs() modpost warning Nathan Chancellor
  2023-04-21 16:11 ` [PATCH v2 1/2] MIPS: Mark check_bugs() as __init Nathan Chancellor
  2023-04-21 16:11 ` [PATCH v2 2/2] MIPS: Sink body of check_bugs_early() into its only call site Nathan Chancellor
@ 2023-04-22 21:30 ` Thomas Bogendoerfer
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Bogendoerfer @ 2023-04-22 21:30 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: ndesaulniers, linux-mips, linux-kernel, llvm, patches, Naresh Kamboju

On Fri, Apr 21, 2023 at 09:11:25AM -0700, Nathan Chancellor wrote:
> Hi all,
> 
> This series fixes a modpost warning visible in -next from check_bugs()
> and helps avoid a potential, albeit unlikely, warning from
> check_bugs_early().
> 
> ---
> Changes in v2:
> - Now two separate patches: one to avoid current check_bugs() warning
>   and one to avoid potential check_bugs_early() warning.
> - Sink body of check_bugs_early() into setup_arch() directly, rather
>   than marking it as __init (Nick).
> - Add Naresh's reported-by to patch 1, which came after v1 was sent.
> - Reword commit messages to note that there is not a problem at run time
>   because check_bugs() and check_bugs_early(), while not marked __init,
>   are only called from __init functions; modpost does not know this
>   though, hence the warning.
> - Link to v1: https://lore.kernel.org/r/20230419-mips-check_bugs-init-attribute-v1-1-91e6eed55b89@kernel.org
> 
> ---
> Nathan Chancellor (2):
>       MIPS: Mark check_bugs() as __init
>       MIPS: Sink body of check_bugs_early() into its only call site
> 
>  arch/mips/include/asm/bugs.h | 8 +-------
>  arch/mips/kernel/setup.c     | 3 ++-
>  2 files changed, 3 insertions(+), 8 deletions(-)
> ---
> base-commit: 6a8f57ae2eb07ab39a6f0ccad60c760743051026
> change-id: 20230419-mips-check_bugs-init-attribute-026103bdb255
> 
> Best regards,
> -- 
> Nathan Chancellor <nathan@kernel.org>

series applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

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

end of thread, other threads:[~2023-04-22 21:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-21 16:11 [PATCH v2 0/2] MIPS: Fix check_bugs() modpost warning Nathan Chancellor
2023-04-21 16:11 ` [PATCH v2 1/2] MIPS: Mark check_bugs() as __init Nathan Chancellor
2023-04-21 16:11 ` [PATCH v2 2/2] MIPS: Sink body of check_bugs_early() into its only call site Nathan Chancellor
2023-04-22 21:30 ` [PATCH v2 0/2] MIPS: Fix check_bugs() modpost warning Thomas Bogendoerfer

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).