Skip to contentSkip to conversation

x86/ucode: Add option to scan microcode by default

PATCH Superseded Ross Lagerwall 3 participants 5 messages Feb 17, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/ucode: Add option to scan microcode by default

A lot of systems automatically add microcode to the initrd so it can be useful as a vendor policy to always scan for microcode. Add a Kconfig option to allow setting the default behaviour.

The default behaviour is unchanged since the new option defaults to "no".

---
 xen/arch/x86/Kconfig              | 11 +++++++++++
 xen/arch/x86/cpu/microcode/core.c |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
xen/arch/x86/Kconfig +11 -0
index 9cdd04721afa..b806d8bc3319 100644
@@ -383,6 +383,17 @@ config ALTP2M
 
 	  If unsure, stay with defaults.
 
+config UCODE_SCAN_DEFAULT
+	def_bool n
+	prompt "Scan for microcode by default"
+	help
+	  During boot, Xen can scan the multiboot images for a CPIO archive
+	  containing CPU microcode to be loaded.
+
+	  Enabling this option will cause Xen to scan for it by default.
+
+	  If unsure, say N.
+
 endmenu
 
 source "common/Kconfig"
xen/arch/x86/cpu/microcode/core.c +1 -1
index 87283cff1de4..de00c22b4bd6 100644
@@ -100,7 +100,7 @@ static struct microcode_patch *microcode_cache;
  * location we require that they are not both active together.
  */
 static int __initdata opt_mod_idx;
-static bool __initdata opt_scan;
+static bool __initdata opt_scan = IS_ENABLED(CONFIG_UCODE_SCAN_DEFAULT);
 
 /*
  * Used by the EFI path only, when xen.cfg identifies an explicit microcode
Signature · 1 line
2.48.1
#1 lore raw
Quoted 4 lines · Ross Lagerwall

A lot of systems automatically add microcode to the initrd so it can be useful as a vendor policy to always scan for microcode. Add a Kconfig option to allow setting the default behaviour.

Quoted 8 lines

The default behaviour is unchanged since the new option defaults to "no".

---
 xen/arch/x86/Kconfig              | 11 +++++++++++
 xen/arch/x86/cpu/microcode/core.c |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

Please also update the command line doc accordingly.

xen/arch/x86/Kconfig config ALTP2M · line 387

Quoted 8 lines
xen/arch/x86/Kconfig +2 -0
@@ -383,6 +383,17 @@ config ALTP2M
 
 	  If unsure, stay with defaults.
 
+config UCODE_SCAN_DEFAULT
+	def_bool n

Just "bool" will suffice.

Also can you please send patches To: the list, with maintainers Cc:-ed?

Jan

#2 lore raw
Quoted 8 lines · Jan Beulich
Quoted 7 lines · Ross Lagerwall

A lot of systems automatically add microcode to the initrd so it can be useful as a vendor policy to always scan for microcode. Add a Kconfig option to allow setting the default behaviour.

The default behaviour is unchanged since the new option defaults to "no".

Quoted 6 lines
Quoted 5 lines
---
 xen/arch/x86/Kconfig              | 11 +++++++++++
 xen/arch/x86/cpu/microcode/core.c |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

Please also update the command line doc accordingly.

I've got an open task to fix both the cmdline and sphinx docs WRT changes in 4.20.  I could do this too.

~Andrew

#3 lore raw
In reply to Ross Lagerwall
Quoted 8 lines · Ross Lagerwall

A lot of systems automatically add microcode to the initrd so it can be useful as a vendor policy to always scan for microcode. Add a Kconfig option to allow setting the default behaviour.

The default behaviour is unchanged since the new option defaults to "no".

I'm pretty sure this is safe on 4.20.

Prior versions of Xen need the fix to make idx/scan be mutually exclusive, which hasn't been backported yet IIRC.

Quoted 10 lines
---
 xen/arch/x86/Kconfig              | 11 +++++++++++
 xen/arch/x86/cpu/microcode/core.c |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
xen/arch/x86/Kconfig +0 -0
index 9cdd04721afa..b806d8bc3319 100644

xen/arch/x86/Kconfig config ALTP2M · line 391

Quoted 9 lines
xen/arch/x86/Kconfig +6 -0
@@ -383,6 +383,17 @@ config ALTP2M
 
 	  If unsure, stay with defaults.
 
+config UCODE_SCAN_DEFAULT
+	def_bool n
+	prompt "Scan for microcode by default"
+	help
+	  During boot, Xen can scan the multiboot images for a CPIO archive
+	  containing CPU microcode to be loaded.

", which is Linux's mechanism for early microcode loading."

This is quite an important point to cover.

xen/arch/x86/Kconfig config ALTP2M · line 395

Quoted 4 lines
xen/arch/x86/Kconfig +4 -0
+
+	  Enabling this option will cause Xen to scan for it by default.
+
+	  If unsure, say N.

Personally I don't like this "If unsure", because it's almost always redundant with the default.

In this case, it really ought to be "set if you have a Linux dom0", which in turn begs the question as to whether it ought to be bool y.

~Andrew

#4 lore raw
Quoted 48 lines · Andrew Cooper
Quoted 8 lines · Ross Lagerwall

A lot of systems automatically add microcode to the initrd so it can be useful as a vendor policy to always scan for microcode. Add a Kconfig option to allow setting the default behaviour.

The default behaviour is unchanged since the new option defaults to "no".

I'm pretty sure this is safe on 4.20.

Prior versions of Xen need the fix to make idx/scan be mutually exclusive, which hasn't been backported yet IIRC.

Quoted 10 lines
---
 xen/arch/x86/Kconfig              | 11 +++++++++++
 xen/arch/x86/cpu/microcode/core.c |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)
xen/arch/x86/Kconfig +0 -0
index 9cdd04721afa..b806d8bc3319 100644

xen/arch/x86/Kconfig config ALTP2M · line 391

Quoted 9 lines
xen/arch/x86/Kconfig +6 -0
@@ -383,6 +383,17 @@ config ALTP2M
 
        If unsure, stay with defaults.
 
+config UCODE_SCAN_DEFAULT
+     def_bool n
+     prompt "Scan for microcode by default"
+     help
+       During boot, Xen can scan the multiboot images for a CPIO archive
+       containing CPU microcode to be loaded.

", which is Linux's mechanism for early microcode loading."

This is quite an important point to cover.

xen/arch/x86/Kconfig config ALTP2M · line 395

Quoted 4 lines
xen/arch/x86/Kconfig +4 -0
+
+       Enabling this option will cause Xen to scan for it by default.
+
+       If unsure, say N.

Personally I don't like this "If unsure", because it's almost always redundant with the default.

Quoted 3 lines

In this case, it really ought to be "set if you have a Linux dom0", which in turn begs the question as to whether it ought to be bool y.

I agree with you that changing the default to yes is probably a good idea but I think it would be better to separate making it configurable from changing the default behaviour.

Ross