Skip to content

Commit a77a94f

Browse files
suryasaimadhuKAGA-KOKO
authored andcommitted
x86/microcode: Default-disable late loading
It is dangerous and it should not be used anyway - there's a nice early loading already. Requested-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 181b6f4 commit a77a94f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

arch/x86/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,17 @@ config MICROCODE_AMD
13501350
If you select this option, microcode patch loading support for AMD
13511351
processors will be enabled.
13521352

1353+
config MICROCODE_LATE_LOADING
1354+
bool "Late microcode loading (DANGEROUS)"
1355+
default n
1356+
depends on MICROCODE
1357+
help
1358+
Loading microcode late, when the system is up and executing instructions
1359+
is a tricky business and should be avoided if possible. Just the sequence
1360+
of synchronizing all cores and SMT threads is one fragile dance which does
1361+
not guarantee that cores might not softlock after the loading. Therefore,
1362+
use this at your own risk. Late loading taints the kernel too.
1363+
13531364
config X86_MSR
13541365
tristate "/dev/cpu/*/msr - Model-specific register support"
13551366
help

arch/x86/kernel/cpu/common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,7 @@ void cpu_init_secondary(void)
22222222
}
22232223
#endif
22242224

2225+
#ifdef CONFIG_MICROCODE_LATE_LOADING
22252226
/*
22262227
* The microcode loader calls this upon late microcode load to recheck features,
22272228
* only when microcode has been updated. Caller holds microcode_mutex and CPU
@@ -2251,6 +2252,7 @@ void microcode_check(void)
22512252
pr_warn("x86/CPU: CPU features have changed after loading microcode, but might not take effect.\n");
22522253
pr_warn("x86/CPU: Please consider either early loading through initrd/built-in or a potential BIOS update.\n");
22532254
}
2255+
#endif
22542256

22552257
/*
22562258
* Invoked from core CPU hotplug code after hotplug operations

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ static int apply_microcode_on_target(int cpu)
376376
/* fake device for request_firmware */
377377
static struct platform_device *microcode_pdev;
378378

379+
#ifdef CONFIG_MICROCODE_LATE_LOADING
379380
/*
380381
* Late loading dance. Why the heavy-handed stomp_machine effort?
381382
*
@@ -543,6 +544,9 @@ static ssize_t reload_store(struct device *dev,
543544
return ret;
544545
}
545546

547+
static DEVICE_ATTR_WO(reload);
548+
#endif
549+
546550
static ssize_t version_show(struct device *dev,
547551
struct device_attribute *attr, char *buf)
548552
{
@@ -559,7 +563,6 @@ static ssize_t pf_show(struct device *dev,
559563
return sprintf(buf, "0x%x\n", uci->cpu_sig.pf);
560564
}
561565

562-
static DEVICE_ATTR_WO(reload);
563566
static DEVICE_ATTR(version, 0444, version_show, NULL);
564567
static DEVICE_ATTR(processor_flags, 0444, pf_show, NULL);
565568

@@ -712,7 +715,9 @@ static int mc_cpu_down_prep(unsigned int cpu)
712715
}
713716

714717
static struct attribute *cpu_root_microcode_attrs[] = {
718+
#ifdef CONFIG_MICROCODE_LATE_LOADING
715719
&dev_attr_reload.attr,
720+
#endif
716721
NULL
717722
};
718723

0 commit comments

Comments
 (0)