Skip to content

Commit 632ff61

Browse files
committed
x86/microcode: Add microcode= cmdline parsing
Add a "microcode=" command line argument after which all options can be passed in a comma-separated list. Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Sohil Mehta <sohil.mehta@intel.com> Reviewed-by: Chang S. Bae <chang.seok.bae@intel.com> Link: https://lore.kernel.org/20250820135043.19048-2-bp@kernel.org
1 parent 8550423 commit 632ff61

3 files changed

Lines changed: 30 additions & 8 deletions

File tree

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,8 +3767,12 @@
37673767

37683768
mga= [HW,DRM]
37693769

3770-
microcode.force_minrev= [X86]
3771-
Format: <bool>
3770+
microcode= [X86] Control the behavior of the microcode loader.
3771+
Available options, comma separated:
3772+
3773+
dis_ucode_ldr: disable the microcode loader
3774+
3775+
force_minrev:
37723776
Enable or disable the microcode minimal revision
37733777
enforcement for the runtime microcode loader.
37743778

arch/x86/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ config MICROCODE_LATE_LOADING
13401340
use this at your own risk. Late loading taints the kernel unless the
13411341
microcode header indicates that it is safe for late loading via the
13421342
minimal revision check. This minimal revision check can be enforced on
1343-
the kernel command line with "microcode.minrev=Y".
1343+
the kernel command line with "microcode=force_minrev".
13441344

13451345
config MICROCODE_LATE_FORCE_MINREV
13461346
bool "Enforce late microcode loading minimal revision check"
@@ -1356,7 +1356,7 @@ config MICROCODE_LATE_FORCE_MINREV
13561356
revision check fails.
13571357

13581358
This minimal revision check can also be controlled via the
1359-
"microcode.minrev" parameter on the kernel command line.
1359+
"microcode=force_minrev" parameter on the kernel command line.
13601360

13611361
If unsure say Y.
13621362

arch/x86/kernel/cpu/microcode/core.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@
4343
#include "internal.h"
4444

4545
static struct microcode_ops *microcode_ops;
46-
static bool dis_ucode_ldr = false;
46+
static bool dis_ucode_ldr;
4747

4848
bool force_minrev = IS_ENABLED(CONFIG_MICROCODE_LATE_FORCE_MINREV);
49-
module_param(force_minrev, bool, S_IRUSR | S_IWUSR);
5049

5150
/*
5251
* Synchronization.
@@ -126,13 +125,32 @@ bool __init microcode_loader_disabled(void)
126125
return dis_ucode_ldr;
127126
}
128127

128+
static void early_parse_cmdline(void)
129+
{
130+
char cmd_buf[64] = {};
131+
char *s, *p = cmd_buf;
132+
133+
if (cmdline_find_option(boot_command_line, "microcode", cmd_buf, sizeof(cmd_buf)) > 0) {
134+
while ((s = strsep(&p, ","))) {
135+
if (!strcmp("force_minrev", s))
136+
force_minrev = true;
137+
138+
if (!strcmp(s, "dis_ucode_ldr"))
139+
dis_ucode_ldr = true;
140+
}
141+
}
142+
143+
/* old, compat option */
144+
if (cmdline_find_option_bool(boot_command_line, "dis_ucode_ldr") > 0)
145+
dis_ucode_ldr = true;
146+
}
147+
129148
void __init load_ucode_bsp(void)
130149
{
131150
unsigned int cpuid_1_eax;
132151
bool intel = true;
133152

134-
if (cmdline_find_option_bool(boot_command_line, "dis_ucode_ldr") > 0)
135-
dis_ucode_ldr = true;
153+
early_parse_cmdline();
136154

137155
if (microcode_loader_disabled())
138156
return;

0 commit comments

Comments
 (0)