Skip to contentSkip to conversation

x86/microcode: Do not select FW_LOADER

PATCH Applied Herbert Xu 4 participants 11 messages Jun 10, 2020 – Jun 15, 2020

Subsystems (2)
lore
Share & tools
lore

Herbert Xu

author
#0 lore raw

PATCH 1/1 x86/microcode: Do not select FW_LOADER

The x86 microcode support works just fine without FW_LOADER. In fact these days most people load them early in boot so FW_LOADER never gets into the picture anyway.

People who need the FW_LOADER capability can still enable it.

arch/x86/Kconfig +0 -3
index 1d6104ea8af0..8aac7a65bfbb 100644
@@ -1296,7 +1296,6 @@ config MICROCODE
 	bool "CPU microcode loading support"
 	default y
 	depends on CPU_SUP_AMD || CPU_SUP_INTEL
-	select FW_LOADER
 	---help---
 	  If you say Y here, you will be able to update the microcode on
 	  Intel and AMD processors. The Intel support is for the IA32 family,
@@ -1318,7 +1317,6 @@ config MICROCODE_INTEL
 	bool "Intel microcode loading support"
 	depends on MICROCODE
 	default MICROCODE
-	select FW_LOADER
 	---help---
 	  This options enables microcode patch loading support for Intel
 	  processors.
@@ -1330,7 +1328,6 @@ config MICROCODE_INTEL
 config MICROCODE_AMD
 	bool "AMD microcode loading support"
 	depends on MICROCODE
-	select FW_LOADER
 	---help---
 	  If you select this option, microcode patch loading support for AMD
 	  processors will be enabled.
arch/x86/kernel/cpu/microcode/core.c +0 -2
index 7019d4b2df0c..5524ea15b3df 100644
@@ -145,7 +145,6 @@ extern struct builtin_fw __end_builtin_fw[];
 
 bool get_builtin_firmware(struct cpio_data *cd, const char *name)
 {
-#ifdef CONFIG_FW_LOADER
 	struct builtin_fw *b_fw;
 
 	for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
@@ -155,7 +154,6 @@ bool get_builtin_firmware(struct cpio_data *cd, const char *name)
 			return true;
 		}
 	}
-#endif
 	return false;
 }
 
Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#1 lore raw
Quoted 3 lines · Herbert Xu

The x86 microcode support works just fine without FW_LOADER. In fact these days most people load them early in boot so FW_LOADER never gets into the picture anyway.

What's the use case here?

$ git grep -E "select.*FW_LOADER" | wc -l
132

so this thing gets selected anyway, practically.

Also, I'm working on removing that homegrown get_builtin_firmware() and use the one in the fw loader:

https://lkml.kernel.org/r/[email protected]

Leaving in the rest for reference.

Quoted 56 lines

People who need the FW_LOADER capability can still enable it.

arch/x86/Kconfig +0 -3
index 1d6104ea8af0..8aac7a65bfbb 100644
@@ -1296,7 +1296,6 @@ config MICROCODE
 	bool "CPU microcode loading support"
 	default y
 	depends on CPU_SUP_AMD || CPU_SUP_INTEL
-	select FW_LOADER
 	---help---
 	  If you say Y here, you will be able to update the microcode on
 	  Intel and AMD processors. The Intel support is for the IA32 family,
@@ -1318,7 +1317,6 @@ config MICROCODE_INTEL
 	bool "Intel microcode loading support"
 	depends on MICROCODE
 	default MICROCODE
-	select FW_LOADER
 	---help---
 	  This options enables microcode patch loading support for Intel
 	  processors.
@@ -1330,7 +1328,6 @@ config MICROCODE_INTEL
 config MICROCODE_AMD
 	bool "AMD microcode loading support"
 	depends on MICROCODE
-	select FW_LOADER
 	---help---
 	  If you select this option, microcode patch loading support for AMD
 	  processors will be enabled.
arch/x86/kernel/cpu/microcode/core.c +0 -2
index 7019d4b2df0c..5524ea15b3df 100644
@@ -145,7 +145,6 @@ extern struct builtin_fw __end_builtin_fw[];
 
 bool get_builtin_firmware(struct cpio_data *cd, const char *name)
 {
-#ifdef CONFIG_FW_LOADER
 	struct builtin_fw *b_fw;
 
 	for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
@@ -155,7 +154,6 @@ bool get_builtin_firmware(struct cpio_data *cd, const char *name)
 			return true;
 		}
 	}
-#endif
 	return false;
 }
 
Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
author
#2 lore raw
Quoted 6 lines · Borislav Petkov
Quoted 3 lines · Herbert Xu

The x86 microcode support works just fine without FW_LOADER. In fact these days most people load them early in boot so FW_LOADER never gets into the picture anyway.

What's the use case here?

Because MICROCODE is the only thing on my system that pulls it into the kernel.

Quoted 4 lines

Also, I'm working on removing that homegrown get_builtin_firmware() and use the one in the fw loader:

https://lkml.kernel.org/r/[email protected]

That shouldn't be a problem. That function can simply move under another (hidden) Kconfig option that gets selected by both MICROCODE and FW_LOADER.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#3 lore raw
Quoted 2 lines · Herbert Xu

Because MICROCODE is the only thing on my system that pulls it into the kernel.

That's a very interesting system you have.

Quoted 3 lines

That shouldn't be a problem. That function can simply move under another (hidden) Kconfig option that gets selected by both MICROCODE and FW_LOADER.

Out Kconfig symbols space is a mess and I'd prefer not to add another one if there's no good reason for it.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
author
#4 lore raw
Quoted 3 lines · Borislav Petkov

Out Kconfig symbols space is a mess and I'd prefer not to add another one if there's no good reason for it.

Adding two thousand lines of code to the kernel when you only need a few lines is ridiculous. Worse those two thousand lines increase the attack surface to the kernel because they're exposed to user- space.

Adding a hidden Kconfig symbol for the sake of reducing the kernel attack surface would seem worthwhile. In fact this isn't even an issue right now because you are still using the custom function.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#5 lore raw
Quoted 4 lines · Herbert Xu

Adding two thousand lines of code to the kernel when you only need a few lines is ridiculous. Worse those two thousand lines increase the attack surface to the kernel because they're exposed to user- space.

Why isn't *this* in your commit message?

Quoted 2 lines

Adding a hidden Kconfig symbol for the sake of reducing the kernel attack surface would seem worthwhile.

And that.

Quoted 2 lines

In fact this isn't even an issue right now because you are still using the custom function.

Actually, I'd prefer your version which doesn't depend on FW_LOADER at all for the above reasons.

Please resubmit with amended commit message, adding the justification for the change.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
author
#6 lore raw

PATCH v2 1/1 x86/microcode: Do not select FW_LOADER

Quoted 2 lines · Borislav Petkov

Why isn't *this* in your commit message?

Sure, here it is.

---8<---
The x86 microcode support works just fine without FW_LOADER. In fact these days most people load them early in boot so FW_LOADER never gets into the picture anyway.

As almost everyone on x86 needs to enable MICROCODE this by extension means that FW_LOADER is always built into the kernel even if nothing uses it. The FW_LOADER system is about two thousand lines long and contains user-space facing interfaces that could potentially provide an entry point into the kernel (or beyond).

This patch removes the unnecessary select of FW_LOADER by MICROCODE. People who need the FW_LOADER capability can still enable it.

arch/x86/Kconfig +0 -3
index 1d6104ea8af0..8aac7a65bfbb 100644
@@ -1296,7 +1296,6 @@ config MICROCODE
 	bool "CPU microcode loading support"
 	default y
 	depends on CPU_SUP_AMD || CPU_SUP_INTEL
-	select FW_LOADER
 	---help---
 	  If you say Y here, you will be able to update the microcode on
 	  Intel and AMD processors. The Intel support is for the IA32 family,
@@ -1318,7 +1317,6 @@ config MICROCODE_INTEL
 	bool "Intel microcode loading support"
 	depends on MICROCODE
 	default MICROCODE
-	select FW_LOADER
 	---help---
 	  This options enables microcode patch loading support for Intel
 	  processors.
@@ -1330,7 +1328,6 @@ config MICROCODE_INTEL
 config MICROCODE_AMD
 	bool "AMD microcode loading support"
 	depends on MICROCODE
-	select FW_LOADER
 	---help---
 	  If you select this option, microcode patch loading support for AMD
 	  processors will be enabled.
arch/x86/kernel/cpu/microcode/core.c +0 -2
index 7019d4b2df0c..5524ea15b3df 100644
@@ -145,7 +145,6 @@ extern struct builtin_fw __end_builtin_fw[];
 
 bool get_builtin_firmware(struct cpio_data *cd, const char *name)
 {
-#ifdef CONFIG_FW_LOADER
 	struct builtin_fw *b_fw;
 
 	for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
@@ -155,7 +154,6 @@ bool get_builtin_firmware(struct cpio_data *cd, const char *name)
 			return true;
 		}
 	}
-#endif
 	return false;
 }
 
Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#7 lore raw
In reply to Borislav Petkov
Quoted 5 lines · Borislav Petkov

Also, I'm working on removing that homegrown get_builtin_firmware() and use the one in the fw loader:

https://lkml.kernel.org/r/[email protected]

I would like to still encourage this, even with this patch in place, as I think it makes this a proper call, and reflects better how the firmware loader is used exactly.

FWIW, firmware loader will be changed soon to not be modular, and just built-in or disabled.

Luis

maintainer
#8 lore raw
Quoted 5 lines · Luis Chamberlain
Quoted 4 lines · Borislav Petkov

Also, I'm working on removing that homegrown get_builtin_firmware() and use the one in the fw loader:

Quoted 8 lines
Quoted 1 line

https://lkml.kernel.org/r/[email protected]

I would like to still encourage this, even with this patch in place, as I think it makes this a proper call, and reflects better how the firmware loader is used exactly.

FWIW, firmware loader will be changed soon to not be modular, and just built-in or disabled.

I don't mind doing the work but Herbert has a point - there's no need to require a bunch of code for a trivial function.

What I could do in addition is move that trivial function into a fw-specific header and have it defined unconditionally so that the microcode loader can use it without needing the fw loader.

The testcases stuff then goes ontop.

Yes, no?

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#9 lore raw
Quoted 15 lines · Borislav Petkov
Quoted 5 lines · Luis Chamberlain
Quoted 4 lines · Borislav Petkov

Also, I'm working on removing that homegrown get_builtin_firmware() and use the one in the fw loader:

Quoted 8 lines
Quoted 1 line

https://lkml.kernel.org/r/[email protected]

I would like to still encourage this, even with this patch in place, as I think it makes this a proper call, and reflects better how the firmware loader is used exactly.

FWIW, firmware loader will be changed soon to not be modular, and just built-in or disabled.

Quoted 6 lines

I don't mind doing the work but Herbert has a point - there's no need to require a bunch of code for a trivial function.

What I could do in addition is move that trivial function into a fw-specific header and have it defined unconditionally so that the microcode loader can use it without needing the fw loader.

Would just have to see this part. But sounds like a better place than today.

Quoted 1 line

The testcases stuff then goes ontop.

Sure!

Luis

merge bot Applied
#10 lore raw
In reply to Herbert Xu
The following commit has been merged into the x86/microcode branch of tip:

The following commit has been merged into the x86/microcode branch of tip:

Commit-ID:     c8a59a4d8e3c9e609fa915e39c3628c6dd08aeea
Gitweb:        https://git.kernel.org/tip/c8a59a4d8e3c9e609fa915e39c3628c6dd08aeea
Author:        Herbert Xu <[email protected]>
AuthorDate:    Wed, 10 Jun 2020 21:05:13 +10:00
Committer:     Borislav Petkov <[email protected]>
CommitterDate: Mon, 15 Jun 2020 11:59:19 +02:00

x86/microcode: Do not select FW_LOADER

The x86 microcode support works just fine without FW_LOADER. In fact, these days most people load microcode early during boot so FW_LOADER never gets into the picture anyway.

As almost everyone on x86 needs to enable MICROCODE, this by extension means that FW_LOADER is always built into the kernel even if nothing uses it. The FW_LOADER system is about two thousand lines long and contains user-space facing interfaces that could potentially provide an entry point into the kernel (or beyond).

Remove the unnecessary select of FW_LOADER by MICROCODE. People who need the FW_LOADER capability can still enable it.

[ bp: Massage a bit. ]

---
 arch/x86/Kconfig                     | 3 ---
 arch/x86/kernel/cpu/microcode/core.c | 2 --
 2 files changed, 5 deletions(-)
arch/x86/Kconfig +0 -3
index 6a0cc52..5c44eac 100644
@@ -1292,7 +1292,6 @@ config MICROCODE
 	bool "CPU microcode loading support"
 	default y
 	depends on CPU_SUP_AMD || CPU_SUP_INTEL
-	select FW_LOADER
 	help
 	  If you say Y here, you will be able to update the microcode on
 	  Intel and AMD processors. The Intel support is for the IA32 family,
@@ -1314,7 +1313,6 @@ config MICROCODE_INTEL
 	bool "Intel microcode loading support"
 	depends on MICROCODE
 	default MICROCODE
-	select FW_LOADER
 	help
 	  This options enables microcode patch loading support for Intel
 	  processors.
@@ -1326,7 +1324,6 @@ config MICROCODE_INTEL
 config MICROCODE_AMD
 	bool "AMD microcode loading support"
 	depends on MICROCODE
-	select FW_LOADER
 	help
 	  If you select this option, microcode patch loading support for AMD
 	  processors will be enabled.
arch/x86/kernel/cpu/microcode/core.c +0 -2
index baec68b..ec6f041 100644
@@ -145,7 +145,6 @@ extern struct builtin_fw __end_builtin_fw[];
 
 bool get_builtin_firmware(struct cpio_data *cd, const char *name)
 {
-#ifdef CONFIG_FW_LOADER
 	struct builtin_fw *b_fw;
 
 	for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
@@ -155,7 +154,6 @@ bool get_builtin_firmware(struct cpio_data *cd, const char *name)
 			return true;
 		}
 	}
-#endif
 	return false;
 }