[PATCH v2] arch/x86/microcode: Mark early_parse_cmdline() as __init

Yu Peng posted 1 patch 1 month, 2 weeks ago
There is a newer version of this series
arch/x86/kernel/cpu/microcode/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] arch/x86/microcode: Mark early_parse_cmdline() as __init
Posted by Yu Peng 1 month, 2 weeks ago
From: Yu Peng <pengyu@kylinos.com>

Fix section mismatch warning reported by modpost:
  .text:early_parse_cmdline() -> .init.data:boot_command_line

The function early_parse_cmdline() is only called during init and
accesses init data, so mark it __init to match its usage.

Signed-off-by: Yu Peng <pengyu@kylinos.com>
---
 arch/x86/kernel/cpu/microcode/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Changes in v2:
  - Resend to add correct email.
  - No code changes.
  
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index d7baec8ec0b4..ccc83b0bf63c 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -136,7 +136,7 @@ bool __init microcode_loader_disabled(void)
 	return dis_ucode_ldr;
 }
 
-static void early_parse_cmdline(void)
+static void __init early_parse_cmdline(void)
 {
 	char cmd_buf[64] = {};
 	char *s, *p = cmd_buf;
-- 
2.43.0
Re: [PATCH v2] arch/x86/microcode: Mark early_parse_cmdline() as __init
Posted by Borislav Petkov 1 month, 2 weeks ago
On Wed, Oct 29, 2025 at 04:16:44PM +0800, Yu Peng wrote:
> From: Yu Peng <pengyu@kylinos.com>
> 
> Fix section mismatch warning reported by modpost:
>   .text:early_parse_cmdline() -> .init.data:boot_command_line

How do you trigger this?

CONFIG_DEBUG_SECTION_MISMATCH=y
CONFIG_SECTION_MISMATCH_WARN_ONLY=y

in my config doesn't cause anything.

That's because

$ readelf -s vmlinux | grep early_parse_cmdline

doesn't give anything because my compiler inlines it anyway.

So it must be something about your .config or toolchain or whatnot, which
causes it.

I mean, the patch is obviously correct but I'd still like to know how it
triggers.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
Re: [PATCH v2] arch/x86/microcode: Mark early_parse_cmdline() as __init
Posted by Yu Peng 1 month, 2 weeks ago
在 2025/10/29 20:38, Borislav Petkov 写道:
> On Wed, Oct 29, 2025 at 04:16:44PM +0800, Yu Peng wrote:
>> From: Yu Peng <pengyu@kylinos.com>
>>
>> Fix section mismatch warning reported by modpost:
>>    .text:early_parse_cmdline() -> .init.data:boot_command_line
> 
> How do you trigger this?
> 

I found a minimal reproducer: i386_defconfig enable these two options:

CONFIG_GCOV_KERNEL=y
CONFIG_GCOV_PROFILE_ALL=y

On my toolchain (GCC 13.2), this combination instruments the function 
and prevents it from being inlined, which then triggers the modpost error.

Thanks,

-- 
Regards, Yu Peng

Re: [PATCH v2] arch/x86/microcode: Mark early_parse_cmdline() as __init
Posted by Borislav Petkov 1 month, 2 weeks ago
On Thu, Oct 30, 2025 at 01:03:52PM +0800, Yu Peng wrote:
> I found a minimal reproducer: i386_defconfig enable these two options:
> 
> CONFIG_GCOV_KERNEL=y
> CONFIG_GCOV_PROFILE_ALL=y
> 
> On my toolchain (GCC 13.2), this combination instruments the function and
> prevents it from being inlined, which then triggers the modpost error.

Nah, this doesn't help. Anyway, I'll take the patch as it is obvious.

Btw, please do not send your patch so many times - you can simply say what
needs to be fixed and I'll fix it up before applying. Maintainers are not in
a shooting gallery for patches.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
[PATCH v4] arch/x86/microcode: Mark early_parse_cmdline() as __init
Posted by Yu Peng 1 month, 2 weeks ago
Fix section mismatch warning reported by modpost:
  .text:early_parse_cmdline() -> .init.data:boot_command_line

The function early_parse_cmdline() is only called during init and
accesses init data, so mark it __init to match its usage.

Signed-off-by: Yu Peng <pengyu@kylinos.cn>
---
 arch/x86/kernel/cpu/microcode/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Changes in v4:
  - Resend to fix broken mail thread (v3 was not sent as a reply).

Changes in v3:
  - Fix Signed-off-by email address.

Changes in v2:
  - Resend to add correct email.
  - No code changes.
  
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index d7baec8ec0b4..ccc83b0bf63c 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -136,7 +136,7 @@ bool __init microcode_loader_disabled(void)
 	return dis_ucode_ldr;
 }
 
-static void early_parse_cmdline(void)
+static void __init early_parse_cmdline(void)
 {
 	char cmd_buf[64] = {};
 	char *s, *p = cmd_buf;
-- 
2.43.0
[tip: x86/microcode] x86/microcode: Mark early_parse_cmdline() as __init
Posted by tip-bot2 for Yu Peng 1 month, 2 weeks ago
The following commit has been merged into the x86/microcode branch of tip:

Commit-ID:     ca8313fd83399ea1d18e695c2ae9b259985c9e1f
Gitweb:        https://git.kernel.org/tip/ca8313fd83399ea1d18e695c2ae9b259985c9e1f
Author:        Yu Peng <pengyu@kylinos.cn>
AuthorDate:    Thu, 30 Oct 2025 20:37:57 +08:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Thu, 30 Oct 2025 14:33:31 +01:00

x86/microcode: Mark early_parse_cmdline() as __init

Fix section mismatch warning reported by modpost:

  .text:early_parse_cmdline() -> .init.data:boot_command_line

The function early_parse_cmdline() is only called during init and accesses
init data, so mark it __init to match its usage.

  [ bp: This happens only when the toolchain fails to inline the function and
    I haven't been able to reproduce it with any toolchain I'm using. Patch is
    obviously correct regardless. ]

Signed-off-by: Yu Peng <pengyu@kylinos.cn>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://patch.msgid.link/all/20251030123757.1410904-1-pengyu@kylinos.cn
---
 arch/x86/kernel/cpu/microcode/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index d7baec8..ccc83b0 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -136,7 +136,7 @@ bool __init microcode_loader_disabled(void)
 	return dis_ucode_ldr;
 }
 
-static void early_parse_cmdline(void)
+static void __init early_parse_cmdline(void)
 {
 	char cmd_buf[64] = {};
 	char *s, *p = cmd_buf;