Skip to contentSkip to conversation

x86/microcode update on systems without INITRD

PATCH New Markus Trippelsdorf 12 participants 61 messages Nov 19, 2015 – Mar 9, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

It looks like the ability to update x86/microcode without using an initrd was removed this merge window.

Why?

I've used "echo -n 1 >| /sys/devices/system/cpu/microcode/reload" in my init script for years without any issues.

Signature · 1 line
Markus
#1 lore raw
Quoted 2 lines · Markus Trippelsdorf

It looks like the ability to update x86/microcode without using an initrd was removed this merge window.

Whoops, that shouldnt've happened. Will debug it tomorrow and provide a fix.

Thanks for letting me know.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#2 lore raw
Quoted 6 lines · Borislav Petkov
Quoted 2 lines · Markus Trippelsdorf

It looks like the ability to update x86/microcode without using an initrd was removed this merge window.

Whoops, that shouldnt've happened. Will debug it tomorrow and provide a fix.

Btw, you should consider changing your setup to use the initrd for loading microcode early because microcode should be loaded as early as possible.

The ".../reload" method is aimed at updating microcode on long-running boxes without rebooting them. And that means those updates need to be tested first in a lab environment before running them on the production systems because not every microcode patch can be applied late. Some shouldn't be even tried.

Anyway, the hunk below seems to work in my guest here, I'll run it on the rest of the boxes tomorrow. In case you want to give it a try before:

---

arch/x86/kernel/cpu/microcode/core.c +1 -0
index 3aaffb601c91..faec7120c508 100644
@@ -698,3 +698,4 @@ int __init microcode_init(void)
 	return error;
 
 }
+late_initcall(microcode_init);
arch/x86/kernel/setup.c +0 -2
index 29db25f9a745..d2bbe343fda7 100644
@@ -1250,8 +1250,6 @@ void __init setup_arch(char **cmdline_p)
 	if (efi_enabled(EFI_BOOT))
 		efi_apply_memmap_quirks();
 #endif
-
-	microcode_init();
 }
 
 #ifdef CONFIG_X86_32

---

Thanks!

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#3 lore raw
Quoted 11 lines · Borislav Petkov
Quoted 6 lines · Borislav Petkov
Quoted 2 lines · Markus Trippelsdorf

It looks like the ability to update x86/microcode without using an initrd was removed this merge window.

Whoops, that shouldnt've happened. Will debug it tomorrow and provide a fix.

Anyway, the hunk below seems to work in my guest here, I'll run it on the rest of the boxes tomorrow. In case you want to give it a try before:

Your patch works fine. Thanks.
But of course it needs this additional patch, otherwise the microcode loader wouldn't build at all:

arch/x86/Kconfig +0 -1
index db3622f22b61..52c6964e24bd 100644
@@ -1126,7 +1126,6 @@ config MICROCODE
 	bool "CPU microcode loading support"
 	default y
 	depends on CPU_SUP_AMD || CPU_SUP_INTEL
-	depends on BLK_DEV_INITRD
 	select FW_LOADER
 	---help---
 
Signature · 1 line
Markus
#4 lore raw
Quoted 6 lines · Markus Trippelsdorf
Quoted 5 lines · Borislav Petkov
Quoted 4 lines · Borislav Petkov
Quoted 2 lines · Markus Trippelsdorf

It looks like the ability to update x86/microcode without using an initrd was removed this merge window.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Whoops, that shouldnt've happened. Will debug it tomorrow and provide a fix.

Anyway, the hunk below seems to work in my guest here, I'll run it on the rest of the boxes tomorrow. In case you want to give it a try before:

Your patch works fine. Thanks.

Thanks for testing.

Quoted 8 lines

But of course it needs this additional patch, otherwise the microcode loader wouldn't build at all:

arch/x86/Kconfig +0 -0
index db3622f22b61..52c6964e24bd 100644

arch/x86/Kconfig config MICROCODE · line 1130

Quoted 6 lines
arch/x86/Kconfig +0 -1
@@ -1126,7 +1126,6 @@ config MICROCODE
 	bool "CPU microcode loading support"
 	default y
 	depends on CPU_SUP_AMD || CPU_SUP_INTEL
-	depends on BLK_DEV_INITRD
 	select FW_LOADER
 	---help---

That dependency is a must as the early loader needs the initrd support.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#5 lore raw
Quoted 21 lines · Borislav Petkov
Quoted 6 lines · Markus Trippelsdorf
Quoted 5 lines · Borislav Petkov
Quoted 4 lines · Borislav Petkov
Quoted 2 lines · Markus Trippelsdorf

It looks like the ability to update x86/microcode without using an initrd was removed this merge window.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Whoops, that shouldnt've happened. Will debug it tomorrow and provide a fix.

Anyway, the hunk below seems to work in my guest here, I'll run it on the rest of the boxes tomorrow. In case you want to give it a try before:

Your patch works fine. Thanks.

Thanks for testing.

Quoted 3 lines

But of course it needs this additional patch, otherwise the microcode loader wouldn't build at all:

Quoted 13 lines

arch/x86/Kconfig config MICROCODE · line 1130

Quoted 11 lines
arch/x86/Kconfig +0 -1
index db3622f22b61..52c6964e24bd 100644
@@ -1126,7 +1126,6 @@ config MICROCODE
 	bool "CPU microcode loading support"
 	default y
 	depends on CPU_SUP_AMD || CPU_SUP_INTEL
-	depends on BLK_DEV_INITRD
 	select FW_LOADER
 	---help---

That dependency is a must as the early loader needs the initrd support.

Well, BLK_DEV_INITRD is not set in my config and it works just fine...

Signature · 1 line
Markus
#6 lore raw
Quoted 1 line · Markus Trippelsdorf

Well, BLK_DEV_INITRD is not set in my config and it works just fine...

I'm assuming with "works just fine" you mean, you can load microcode.

Again, as I explained previously, you should consider moving to the early method with an initrd. The late method is a fallback for certain setups and the early method should be the preferred one.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#7 lore raw

PATCH 1/1 x86/microcode: Initialize the driver late when facilities are up

From: Borislav Petkov <[email protected]>
Date: Fri, 20 Nov 2015 00:05:24 +0100
Subject: [PATCH] x86/microcode: Initialize the driver late when facilities are up

Running microcode_init() from setup_arch() is a bad idea because not even kmalloc() is ready at that point and the loader does all kinds of allocations and init/registration with various subsystems.

Make it a late initcall when required facilities are initialized so that the microcode driver initialization can succeed too.

---
 arch/x86/kernel/cpu/microcode/core.c | 1 +
 arch/x86/kernel/setup.c              | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/cpu/microcode/core.c +1 -0
index 7fc27f1cca58..b3e94ef461fd 100644
@@ -698,3 +698,4 @@ int __init microcode_init(void)
 	return error;
 
 }
+late_initcall(microcode_init);
arch/x86/kernel/setup.c +0 -2
index 29db25f9a745..d2bbe343fda7 100644
@@ -1250,8 +1250,6 @@ void __init setup_arch(char **cmdline_p)
 	if (efi_enabled(EFI_BOOT))
 		efi_apply_memmap_quirks();
 #endif
-
-	microcode_init();
 }
 
 #ifdef CONFIG_X86_32
Signature · 4 lines
2.3.5

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#8 lore raw

[tip:x86/urgent] x86/microcode: Initialize the driver late when facilities are up

x86/microcode: Initialize the driver late when facilities are up
Commit-ID:  2d5be37d686c4dae8e60d20283d6f44ac2c44f65
Gitweb:     http://git.kernel.org/tip/2d5be37d686c4dae8e60d20283d6f44ac2c44f65
Author:     Borislav Petkov <[email protected]>
AuthorDate: Fri, 20 Nov 2015 12:24:00 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 23 Nov 2015 10:39:49 +0100

x86/microcode: Initialize the driver late when facilities are up

Running microcode_init() from setup_arch() is a bad idea because not even kmalloc() is ready at that point and the loader does all kinds of allocations and init/registration with various subsystems.

Make it a late initcall when required facilities are initialized so that the microcode driver initialization can succeed too.

---
 arch/x86/kernel/cpu/microcode/core.c | 1 +
 arch/x86/kernel/setup.c              | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/cpu/microcode/core.c +1 -0
index 7fc27f1..b3e94ef 100644
@@ -698,3 +698,4 @@ int __init microcode_init(void)
 	return error;
 
 }
+late_initcall(microcode_init);
arch/x86/kernel/setup.c +0 -2
index 29db25f..d2bbe34 100644
@@ -1250,8 +1250,6 @@ void __init setup_arch(char **cmdline_p)
 	if (efi_enabled(EFI_BOOT))
 		efi_apply_memmap_quirks();
 #endif
-
-	microcode_init();
 }
 
 #ifdef CONFIG_X86_32
#9 lore raw
In reply to Borislav Petkov
Quoted 21 lines · Borislav Petkov
Quoted 6 lines · Markus Trippelsdorf
Quoted 5 lines · Borislav Petkov
Quoted 4 lines · Borislav Petkov
Quoted 2 lines · Markus Trippelsdorf

It looks like the ability to update x86/microcode without using an initrd was removed this merge window.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Whoops, that shouldnt've happened. Will debug it tomorrow and provide a fix.

Anyway, the hunk below seems to work in my guest here, I'll run it on the rest of the boxes tomorrow. In case you want to give it a try before:

Your patch works fine. Thanks.

Thanks for testing.

Quoted 3 lines

But of course it needs this additional patch, otherwise the microcode loader wouldn't build at all:

Quoted 13 lines

arch/x86/Kconfig config MICROCODE · line 1130

Quoted 11 lines
arch/x86/Kconfig +0 -1
index db3622f22b61..52c6964e24bd 100644
@@ -1126,7 +1126,6 @@ config MICROCODE
 	bool "CPU microcode loading support"
 	default y
 	depends on CPU_SUP_AMD || CPU_SUP_INTEL
-	depends on BLK_DEV_INITRD
 	select FW_LOADER
 	---help---

That dependency is a must as the early loader needs the initrd support.

I just diffed my 4.3 config with the 4.4 config and saw that the whole Microcode stuff was silently dropped by a normal "make oldconfig".

Wouldn't be something like this much nicer to give a hint?

arch/x86/Kconfig +1 -1
index db3622f..75523a0 100644
@@ -1126,7 +1126,7 @@ config MICROCODE
        bool "CPU microcode loading support"
        default y
        depends on CPU_SUP_AMD || CPU_SUP_INTEL
-       depends on BLK_DEV_INITRD
+       select BLK_DEV_INITRD
        select FW_LOADER
        ---help---
 

At least I would have noticed it?

Thomas

#10 lore raw
Quoted 2 lines · Thomas Voegtle

I just diffed my 4.3 config with the 4.4 config and saw that the whole Microcode stuff was silently dropped by a normal "make oldconfig".

Can you send me that 4.3 config please?

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#11 lore raw
Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Thomas Voegtle

I just diffed my 4.3 config with the 4.4 config and saw that the whole Microcode stuff was silently dropped by a normal "make oldconfig".

Can you send me that 4.3 config please?

Attached. It is a little bit unusual config without modules etc.

But doesn't dropping Microcde stuff in the config happen to anyone who hasn't INITRD stuff switched on?

Thomas

#12 lore raw
Quoted 6 lines · Thomas Voegtle
Quoted 4 lines · Borislav Petkov
Quoted 2 lines · Thomas Voegtle

I just diffed my 4.3 config with the 4.4 config and saw that the whole Microcode stuff was silently dropped by a normal "make oldconfig".

Quoted 6 lines
Quoted 1 line

Can you send me that 4.3 config please?

Attached. It is a little bit unusual config without modules etc.

But doesn't dropping Microcde stuff in the config happen to anyone who hasn't INITRD stuff switched on?

Yes. But, as I wrote above, if you simply drop the BLK_DEV_INITRD dependency, it will work just fine.
I also don't use modules and the firmware gets applied at boot time.

...

[    2.573261] EDAC amd64: MCT channel count: 2
[    2.573401] EDAC MC0: Giving out device to module amd64_edac controller F10h: DEV 0000:00:18.2 (INTERRUPT)
[    2.573414] EDAC PCI0: Giving out device to module amd64_edac controller EDAC PCI controller: DEV 0000:00:18.2 (POLLED)
[    2.573424] hidraw: raw HID events driver (C) Jiri Kosina
[    2.573449] usbcore: registered new interface driver usbhid
[    2.573449] usbhid: USB HID core driver
[    2.573770] usbcore: registered new interface driver snd-usb-audio
[    2.573786] Netfilter messages via NETLINK v0.30.
[    2.573797] nf_conntrack version 0.5.0 (65536 buckets, 262144 max)
[    2.573966] ctnetlink v0.93: registering with nfnetlink.
[    2.574427] ip_tables: (C) 2000-2006 Netfilter Core Team
[    2.574477] NET: Registered protocol family 17
[    2.574487] 9pnet: Installing 9P2000 support
[    2.574717] microcode: CPU0: patch_level=0x010000db
[    2.574724] microcode: CPU1: patch_level=0x010000db
[    2.574731] microcode: CPU2: patch_level=0x010000db
[    2.574736] microcode: CPU3: patch_level=0x010000db
[    2.574761] microcode: Microcode Update Driver: v2.01 <[email protected]>, Peter Oruba
[    2.574876] registered taskstats version 1
[    2.575132] Btrfs loaded

...

Signature · 1 line
Markus
#13 lore raw
Quoted 9 lines · Markus Trippelsdorf
Quoted 8 lines · Thomas Voegtle
Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Thomas Voegtle

I just diffed my 4.3 config with the 4.4 config and saw that the whole Microcode stuff was silently dropped by a normal "make oldconfig".

Can you send me that 4.3 config please?

Quoted 7 lines
Quoted 4 lines

Attached. It is a little bit unusual config without modules etc.

But doesn't dropping Microcde stuff in the config happen to anyone who hasn't INITRD stuff switched on?

Yes. But, as I wrote above, if you simply drop the BLK_DEV_INITRD dependency, it will work just fine.

That's not an option for me.

For me this is a serious regression, when a normal make oldconfig silently drops a feature which I had switched on before.

Thomas

#14 lore raw
In reply to Markus Trippelsdorf
Quoted 34 lines · On Thu, 7 Jan 2016 13:41:11 +0100 Markus Trippelsdorf <[email protected]>…
Quoted 7 lines · Thomas Voegtle
Quoted 5 lines · Borislav Petkov
Quoted 3 lines · Thomas Voegtle

I just diffed my 4.3 config with the 4.4 config and saw that the whole Microcode stuff was silently dropped by a normal "make oldconfig".

Quoted 6 lines
Quoted 1 line

Can you send me that 4.3 config please?

Attached. It is a little bit unusual config without modules etc.

But doesn't dropping Microcde stuff in the config happen to anyone who hasn't INITRD stuff switched on?

Yes. But, as I wrote above, if you simply drop the BLK_DEV_INITRD dependency, it will work just fine.
I also don't use modules and the firmware gets applied at boot time.

...

[    2.573261] EDAC amd64: MCT channel count: 2
[    2.573401] EDAC MC0: Giving out device to module amd64_edac

controller F10h: DEV 0000:00:18.2 (INTERRUPT) [ 2.573414] EDAC
PCI0: Giving out device to module amd64_edac controller EDAC PCI
controller: DEV 0000:00:18.2 (POLLED) [ 2.573424] hidraw: raw HID
events driver (C) Jiri Kosina [ 2.573449] usbcore: registered new
interface driver usbhid [ 2.573449] usbhid: USB HID core driver

[    2.573770] usbcore: registered new interface driver snd-usb-audio
[    2.573786] Netfilter messages via NETLINK v0.30. [    2.573797]

nf_conntrack version 0.5.0 (65536 buckets, 262144 max) [ 2.573966]
ctnetlink v0.93: registering with nfnetlink. [ 2.574427]
ip_tables: (C) 2000-2006 Netfilter Core Team [ 2.574477] NET:
Registered protocol family 17 [ 2.574487] 9pnet: Installing 9P2000
support [ 2.574717] microcode: CPU0: patch_level=0x010000db

Quoted 8 lines
[    2.574724] microcode: CPU1: patch_level=0x010000db
[    2.574731] microcode: CPU2: patch_level=0x010000db
[    2.574736] microcode: CPU3: patch_level=0x010000db
[    2.574761] microcode: Microcode Update Driver: v2.01

<[email protected]>, Peter Oruba [ 2.574876] registered
taskstats version 1 [ 2.575132] Btrfs loaded
...

I'm not sure what you mean by "drop the BLK_DEV_INITRD dependency", but my microcode does not get loaded unless I have BLK_DEV_INITRD=Y in my .config.

I don't use initrd, but I do use modules.

Mike.

#15 lore raw
Quoted 46 lines · Mike Keehan
Quoted 34 lines · On Thu, 7 Jan 2016 13:41:11 +0100 Markus Trippelsdorf <[email protected]>…
Quoted 7 lines · Thomas Voegtle
Quoted 5 lines · Borislav Petkov
Quoted 3 lines · Thomas Voegtle

I just diffed my 4.3 config with the 4.4 config and saw that the whole Microcode stuff was silently dropped by a normal "make oldconfig".

Quoted 6 lines
Quoted 1 line

Can you send me that 4.3 config please?

Attached. It is a little bit unusual config without modules etc.

But doesn't dropping Microcde stuff in the config happen to anyone who hasn't INITRD stuff switched on?

Yes. But, as I wrote above, if you simply drop the BLK_DEV_INITRD dependency, it will work just fine.
I also don't use modules and the firmware gets applied at boot time.

...

[    2.573261] EDAC amd64: MCT channel count: 2
[    2.573401] EDAC MC0: Giving out device to module amd64_edac

controller F10h: DEV 0000:00:18.2 (INTERRUPT) [ 2.573414] EDAC
PCI0: Giving out device to module amd64_edac controller EDAC PCI
controller: DEV 0000:00:18.2 (POLLED) [ 2.573424] hidraw: raw HID
events driver (C) Jiri Kosina [ 2.573449] usbcore: registered new
interface driver usbhid [ 2.573449] usbhid: USB HID core driver

[    2.573770] usbcore: registered new interface driver snd-usb-audio
[    2.573786] Netfilter messages via NETLINK v0.30. [    2.573797]

nf_conntrack version 0.5.0 (65536 buckets, 262144 max) [ 2.573966]
ctnetlink v0.93: registering with nfnetlink. [ 2.574427]
ip_tables: (C) 2000-2006 Netfilter Core Team [ 2.574477] NET:
Registered protocol family 17 [ 2.574487] 9pnet: Installing 9P2000
support [ 2.574717] microcode: CPU0: patch_level=0x010000db

Quoted 8 lines
[    2.574724] microcode: CPU1: patch_level=0x010000db
[    2.574731] microcode: CPU2: patch_level=0x010000db
[    2.574736] microcode: CPU3: patch_level=0x010000db
[    2.574761] microcode: Microcode Update Driver: v2.01

<[email protected]>, Peter Oruba [ 2.574876] registered
taskstats version 1 [ 2.575132] Btrfs loaded
...

Quoted 5 lines

I'm not sure what you mean by "drop the BLK_DEV_INITRD dependency", but my microcode does not get loaded unless I have BLK_DEV_INITRD=Y in my .config.

I don't use initrd, but I do use modules.

I mean:

arch/x86/Kconfig +0 -1
index db3622f22b61..52c6964e24bd 100644
@@ -1126,7 +1126,6 @@ config MICROCODE
        bool "CPU microcode loading support"
        default y
        depends on CPU_SUP_AMD || CPU_SUP_INTEL
-       depends on BLK_DEV_INITRD
        select FW_LOADER
        ---help---
 
Signature · 1 line
Markus
#16 lore raw
In reply to Thomas Voegtle
Quoted 1 line · Thomas Voegtle

Attached. It is a little bit unusual config without modules etc.

Ok, I see it.

Please do a proper patch explaining why we're changing "depends on" to "select" and we can try it, see who complains then and why.

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#17 lore raw
Quoted 7 lines · Borislav Petkov
Quoted 1 line · Thomas Voegtle

Attached. It is a little bit unusual config without modules etc.

Ok, I see it.

Please do a proper patch explaining why we're changing "depends on" to "select" and we can try it, see who complains then and why.

Neither "depends on" nor "select" makes sense to me here. The driver apparently works without it, and simply having BLK_DEV_INITRD enabled doesn't prevent improper (according to some people) use of the driver. If updating microcode is inherently unsafe when a real disk is mounted, the driver ought to detect this and refuse the operation (possibly with an override option).

Signature · 1 line
Måns Rullgård
#18 lore raw
Quoted 2 lines · Måns Rullgård

Neither "depends on" nor "select" makes sense to me here. The driver apparently works without it,

The driver works without it if you build your microcode into the kernel.

There are use cases where building microcode into the kernel is *not* a viable option so we have to support both builtin microcode and microcode from the initrd.

Quoted 5 lines

and simply having BLK_DEV_INITRD enabled doesn't prevent improper (according to some people) use of the driver. If updating microcode is inherently unsafe when a real disk is mounted, the driver ought to detect this and refuse the operation (possibly with an override option).

Huh, what?

-ENOPARSE.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#19 lore raw
Quoted 9 lines · Borislav Petkov
Quoted 2 lines · Måns Rullgård

Neither "depends on" nor "select" makes sense to me here. The driver apparently works without it,

The driver works without it if you build your microcode into the kernel.

There are use cases where building microcode into the kernel is *not* a viable option so we have to support both builtin microcode and microcode from the initrd.

How is an initrd different from a real filesystem as seen by the microcode update driver?

Quoted 9 lines
Quoted 5 lines

and simply having BLK_DEV_INITRD enabled doesn't prevent improper (according to some people) use of the driver. If updating microcode is inherently unsafe when a real disk is mounted, the driver ought to detect this and refuse the operation (possibly with an override option).

Huh, what?

-ENOPARSE.

The objection against removing the dependency was that updating microcode "late" isn't safe. I don't see how turning on BLK_DEV_INITRD stops anyone doing those allegedly unsafe updates anyway.

Signature · 1 line
Måns Rullgård
#20 lore raw
Quoted 2 lines · Måns Rullgård

How is an initrd different from a real filesystem as seen by the microcode update driver?

For starters, initrd is available much earlier, even before paging is enabled on 32-bit, for example. See find_cpio_data().

Quoted 3 lines

The objection against removing the dependency was that updating microcode "late" isn't safe. I don't see how turning on BLK_DEV_INITRD stops anyone doing those allegedly unsafe updates anyway.

No one is stopping anyone from doing late updates. It is a valid use case, and we have to support it. And late updates are not necessarily unsafe, per se.

Lemme put it this way: it is a lot less unproblematic to do early updates. Mind you, there's no 100% guarantee that early updates would always work either. It all depends on what the microcode patch does. But they do work 99,9999999...% of the time. :)

IOW, I haven't heard of an early update breaking the machine. But it is possible.

So the *general* flow should be that people enable BLK_DEV_INITRD, put the microcode in there and it gets updated as early as possible. This is what the distros do and it is the most tested path. The other possibilities are there too, but only for cases where initrd is out of the question.

I hope that makes it more clear.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#21 lore raw
Quoted 20 lines · Borislav Petkov
Quoted 2 lines · Måns Rullgård

How is an initrd different from a real filesystem as seen by the microcode update driver?

For starters, initrd is available much earlier, even before paging is enabled on 32-bit, for example. See find_cpio_data().

Quoted 3 lines

The objection against removing the dependency was that updating microcode "late" isn't safe. I don't see how turning on BLK_DEV_INITRD stops anyone doing those allegedly unsafe updates anyway.

No one is stopping anyone from doing late updates. It is a valid use case, and we have to support it. And late updates are not necessarily unsafe, per se.

Lemme put it this way: it is a lot less unproblematic to do early updates. Mind you, there's no 100% guarantee that early updates would always work either. It all depends on what the microcode patch does. But they do work 99,9999999...% of the time. :)

Quoted 8 lines

IOW, I haven't heard of an early update breaking the machine. But it is possible.

So the *general* flow should be that people enable BLK_DEV_INITRD, put the microcode in there and it gets updated as early as possible. This is what the distros do and it is the most tested path. The other possibilities are there too, but only for cases where initrd is out of the question.

But you take the choice away from people like me, who don't need initrd at all. BLK_DEV_INITRD is a superfluous dependency in this case, because microcode update works perfectly well without it.

Signature · 1 line
Markus
#22 lore raw
Quoted 3 lines · Markus Trippelsdorf

But you take the choice away from people like me, who don't need initrd at all. BLK_DEV_INITRD is a superfluous dependency in this case, because microcode update works perfectly well without it.

Damn, you have a valid point too. I need to think about it...

... well, the only thing I can think of right now is to remove the dependency on BLK_DEV_INITRD completely - I believe this is what you proposed initially Markus - and add a BIG FAT SUGGESTION to Kconfig saying that people should strive for enabling early microcode loading if possible.

This is the only way I see we can handle "make oldconfig" without BLK_DEV_INITRD and microcode built-in into the kernel cases relatively fair.

Hmmm.

Or I could hack "oldconfig" to issue that warning... Lemme think about it and see how much Michal would scream at me for it. :-)

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#23 lore raw
Quoted 5 lines · Borislav Petkov
Quoted 3 lines · Markus Trippelsdorf

But you take the choice away from people like me, who don't need initrd at all. BLK_DEV_INITRD is a superfluous dependency in this case, because microcode update works perfectly well without it.

Quoted 7 lines

Damn, you have a valid point too. I need to think about it...

... well, the only thing I can think of right now is to remove the dependency on BLK_DEV_INITRD completely - I believe this is what you proposed initially Markus - and add a BIG FAT SUGGESTION to Kconfig saying that people should strive for enabling early microcode loading if possible.

That seems perfectly reasonable to me.

Signature · 1 line
Måns Rullgård
#24 lore raw
In reply to Borislav Petkov
Quoted 13 lines · Borislav Petkov
Quoted 3 lines · Markus Trippelsdorf

But you take the choice away from people like me, who don't need initrd at all. BLK_DEV_INITRD is a superfluous dependency in this case, because microcode update works perfectly well without it.

Damn, you have a valid point too. I need to think about it...

... well, the only thing I can think of right now is to remove the dependency on BLK_DEV_INITRD completely - I believe this is what you proposed initially Markus - and add a BIG FAT SUGGESTION to Kconfig saying that people should strive for enabling early microcode loading if possible.

Quoted 8 lines

This is the only way I see we can handle "make oldconfig" without BLK_DEV_INITRD and microcode built-in into the kernel cases relatively fair.

Hmmm.

Or I could hack "oldconfig" to issue that warning... Lemme think about it and see how much Michal would scream at me for it. :-)

You can add a conditional comment like this

comment "WARNING: Early microcode loader requires initramfs support"

	depends on MICROCODE && !BLK_DEV_INITRD

and hope that somebody reads it.

Michal

#25 lore raw
Quoted 6 lines · Michal Marek

You can add a conditional comment like this

comment "WARNING: Early microcode loader requires initramfs support"

	depends on MICROCODE && !BLK_DEV_INITRD

and hope that somebody reads it.

Actually, I was thinking about something which gets printed when doing "make oldconfig". In addition to the Kconfig text. I'll take a look once the stupid cold goes away...

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#26 lore raw
Quoted 10 lines · Borislav Petkov
Quoted 6 lines · Michal Marek

You can add a conditional comment like this

comment "WARNING: Early microcode loader requires initramfs support"

	depends on MICROCODE && !BLK_DEV_INITRD

and hope that somebody reads it.

Actually, I was thinking about something which gets printed when doing "make oldconfig". In addition to the Kconfig text.

The comments are printed during make oldconfig if a symbol in the current menu needs updating. Which is probably not the case here, both MICROCODE and BLK_DEV_INITRD are existing symbols.

Quoted 2 lines

I'll take a look once
the stupid cold goes away...

Oh, get well soon.

Michal

#27 lore raw
Quoted 3 lines · Michal Marek

The comments are printed during make oldconfig if a symbol in the current menu needs updating. Which is probably not the case here, both MICROCODE and BLK_DEV_INITRD are existing symbols.

Right, and the problem is that "make oldconfig" sees that BLK_DEV_INITRD is not enabled in that case and disables CONFIG_MICROCODE too. So by the time the comment gets evaluated, CONFIG_MICROCODE is off so no workie.

I tried a different thing, see below. It is a bit lengthly but it does what it should and we can always extend it for other stuff later as it might turn useful, according to my suspicion :-)

With Thomas' config it says:

$ make oldconfig
You have CONFIG_MICROCODE enabled without BLK_DEV_INITRD. Enable
it and make sure microcode is added to your initrd as explained in
Documentation/x86/early-microcode.txt

scripts/kconfig/Makefile:85: recipe for target 'oldconfig' failed make[1]: *** [oldconfig] Error 1
Makefile:531: recipe for target 'oldconfig' failed
make: *** [oldconfig] Error 2

It needs to be made to look at CONFIG_MODULES and make that warning just a hint. I'll have to think about it more...

Thoughts?

---
 arch/x86/scripts/check-configs.sh | 41 +++++++++++++++++++++++++++++++++++++++
 scripts/kconfig/Makefile          |  3 +++
 2 files changed, 44 insertions(+)
 create mode 100644 arch/x86/scripts/check-configs.sh
arch/x86/scripts/check-configs.sh new file +41 -0
new file mode 100644
index 000000000000..51ae9bde6965
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+if [ "$1" != "oldconfig" ]; then
+	exit 0
+fi
+
+srctree=$2
+ARCH="$3"
+UNAME_RELEASE=$(uname -r)
+
+KCONFIGS=".config /lib/modules/$UNAME_RELEASE/.config /etc/kernel-config /boot/config-$UNAME_RELEASE"
+
+if [ "$ARCH" = "X86_32" ]; then
+	KCONFIGS="$KCONFIGS $srctree/arch/x86/configs/i386_defconfig"
+else
+	KCONFIGS="$KCONFIGS $srctree/arch/x86/configs/x86_64_defconfig"
+fi
+
+for k in $KCONFIGS;
+do
+	if [ -e $k ]; then
+		OLD_CONFIG=$k
+		break
+	fi
+done
+
+if [ -z "$OLD_CONFIG" ]; then exit 0; fi
+
+# Check optimal microcode loader .config settings
+if ! grep -q MICROCODE $OLD_CONFIG; then
+	exit 0
+fi
+
+MSG="You have CONFIG_MICROCODE enabled without BLK_DEV_INITRD. Enable\n\
+it and make sure microcode is added to your initrd as explained in\n\
+Documentation/x86/early-microcode.txt\n"
+
+if ! grep -v "^#" $OLD_CONFIG | grep -q BLK_DEV_INITRD; then
+	echo -e $MSG
+	exit 1
+fi
scripts/kconfig/Makefile +3 -0
index d79cba4ce3eb..136ae9744efc 100644
@@ -81,6 +81,9 @@ simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
 PHONY += $(simple-targets)
 
 $(simple-targets): $(obj)/conf
+ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/scripts/check-configs.sh),)
+	$(Q)$(CONFIG_SHELL) $(srctree)/arch/$(SRCARCH)/scripts/check-configs.sh $@ $(srctree) $(ARCH)
+endif
 	$< $(silent) --$@ $(Kconfig)
 
 PHONY += oldnoconfig savedefconfig defconfig
Signature · 4 lines
2.3.5

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#28 lore raw
Quoted 20 lines · Borislav Petkov
Quoted 3 lines · Michal Marek

The comments are printed during make oldconfig if a symbol in the current menu needs updating. Which is probably not the case here, both MICROCODE and BLK_DEV_INITRD are existing symbols.

Right, and the problem is that "make oldconfig" sees that BLK_DEV_INITRD is not enabled in that case and disables CONFIG_MICROCODE too. So by the time the comment gets evaluated, CONFIG_MICROCODE is off so no workie.

I tried a different thing, see below. It is a bit lengthly but it does what it should and we can always extend it for other stuff later as it might turn useful, according to my suspicion :-)

With Thomas' config it says:

$ make oldconfig
You have CONFIG_MICROCODE enabled without BLK_DEV_INITRD. Enable
it and make sure microcode is added to your initrd as explained in
Documentation/x86/early-microcode.txt
Quoted 4 lines

scripts/kconfig/Makefile:85: recipe for target 'oldconfig' failed make[1]: *** [oldconfig] Error 1
Makefile:531: recipe for target 'oldconfig' failed
make: *** [oldconfig] Error 2

But this is wrong. Microcode update doesn't need initrd.

Signature · 1 line
Måns Rullgård
#29 lore raw
Quoted 1 line · Måns Rullgård

But this is wrong. Microcode update doesn't need initrd.

You need to read my mail to the end:

Quoted 2 lines

It needs to be made to look at CONFIG_MODULES and make that warning just a hint. I'll have to think about it more...

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#30 lore raw
Quoted 7 lines · Borislav Petkov
Quoted 1 line · Måns Rullgård

But this is wrong. Microcode update doesn't need initrd.

You need to read my mail to the end:

Quoted 2 lines

It needs to be made to look at CONFIG_MODULES and make that warning just a hint. I'll have to think about it more...

What do modules have to do with anything?

Signature · 1 line
Måns Rullgård
#31 lore raw
Quoted 1 line · Måns Rullgård

What do modules have to do with anything?

I'm trying to address Markus' case where he spoke of having modules off and building everything into the kernel. But CONFIG_MODULES is wrong here, I'm not going to grep for it. As I said, I'll have to think about it more.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#32 lore raw

RFC PATCH 1/1 x86/kconfig: Sanity-check config file during oldconfig

From: Borislav Petkov <[email protected]>

Thomas Voegtle reported that doing oldconfig with a .config which has CONFIG_MICROCODE enabled but BLK_DEV_INITRD disabled prevents the microcode loading mechanism from being built.

Add a short script which hooks into the "make oldconfig" handling and sanity-checks the config file for that discrepancy. It issues a message which should hopefully sensitize the user to that issue and point her into the right direction.

The other useful thing with this solution is that it can be extended to other config file sanity-checking, should the need arise.

Cc Markus Trippelsdorf <[email protected]>
Cc Måns Rullgård <[email protected]>
---
 arch/x86/scripts/check-configs.sh | 44 +++++++++++++++++++++++++++++++++++++++
 scripts/kconfig/Makefile          |  3 +++
 2 files changed, 47 insertions(+)
 create mode 100644 arch/x86/scripts/check-configs.sh
arch/x86/scripts/check-configs.sh new file +44 -0
new file mode 100644
index 000000000000..775d07e37df5
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+if [ "$1" != "oldconfig" ]; then
+	exit 0
+fi
+
+srctree=$2
+ARCH="$3"
+UNAME_RELEASE=$(uname -r)
+
+CONFIGS=".config /lib/modules/$UNAME_RELEASE/.config /etc/kernel-config /boot/config-$UNAME_RELEASE"
+
+if [ "$ARCH" = "X86_32" ]; then
+	CONFIGS="$CONFIGS $srctree/arch/x86/configs/i386_defconfig"
+else
+	CONFIGS="$CONFIGS $srctree/arch/x86/configs/x86_64_defconfig"
+fi
+
+for c in $CONFIGS;
+do
+	if [ -e $c ]; then
+		OLD_CONFIG=$c
+		break
+	fi
+done
+
+if [ -z "$OLD_CONFIG" ]; then exit 0; fi
+
+# Check optimal microcode loader .config settings
+if ! grep -v "^#" $OLD_CONFIG | grep -q MICROCODE; then
+	exit 0
+fi
+
+MSG="\nYou have CONFIG_MICROCODE enabled without BLK_DEV_INITRD. The preferred\n\
+way is to enable it and make sure microcode is added to your initrd as\n\
+explained in Documentation/x86/early-microcode.txt. This is also the\n\
+most tested method as the majority of distros do it. Alternatively, and\n\
+if you don't want to enable modules, you should make sure the microcode\n\
+is built into the kernel.\n"
+
+if ! grep -v "^#" $OLD_CONFIG | grep -q BLK_DEV_INITRD; then
+	echo -e $MSG
+	read -p "Press any key... "
+fi
scripts/kconfig/Makefile +3 -0
index d79cba4ce3eb..136ae9744efc 100644
@@ -81,6 +81,9 @@ simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
 PHONY += $(simple-targets)
 
 $(simple-targets): $(obj)/conf
+ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/scripts/check-configs.sh),)
+	$(Q)$(CONFIG_SHELL) $(srctree)/arch/$(SRCARCH)/scripts/check-configs.sh $@ $(srctree) $(ARCH)
+endif
 	$< $(silent) --$@ $(Kconfig)
 
 PHONY += oldnoconfig savedefconfig defconfig
Signature · 4 lines
2.3.5

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#33 lore raw

Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig

Quoted 87 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

Thomas Voegtle reported that doing oldconfig with a .config which has CONFIG_MICROCODE enabled but BLK_DEV_INITRD disabled prevents the microcode loading mechanism from being built.

Add a short script which hooks into the "make oldconfig" handling and sanity-checks the config file for that discrepancy. It issues a message which should hopefully sensitize the user to that issue and point her into the right direction.

The other useful thing with this solution is that it can be extended to other config file sanity-checking, should the need arise.

Cc Markus Trippelsdorf <[email protected]>
Cc Måns Rullgård <[email protected]>

---
arch/x86/scripts/check-configs.sh | 44 +++++++++++++++++++++++++++++++++++++++
scripts/kconfig/Makefile | 3 +++

2 files changed, 47 insertions(+)

create mode 100644 arch/x86/scripts/check-configs.sh

arch/x86/scripts/check-configs.sh new file +44 -0
new file mode 100644
index 000000000000..775d07e37df5
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+if [ "$1" != "oldconfig" ]; then
+	exit 0
+fi
+
+srctree=$2
+ARCH="$3"
+UNAME_RELEASE=$(uname -r)
+
+CONFIGS=".config /lib/modules/$UNAME_RELEASE/.config /etc/kernel-config /boot/config-$UNAME_RELEASE"
+
+if [ "$ARCH" = "X86_32" ]; then
+	CONFIGS="$CONFIGS $srctree/arch/x86/configs/i386_defconfig"
+else
+	CONFIGS="$CONFIGS $srctree/arch/x86/configs/x86_64_defconfig"
+fi
+
+for c in $CONFIGS;
+do
+	if [ -e $c ]; then
+		OLD_CONFIG=$c
+		break
+	fi
+done
+
+if [ -z "$OLD_CONFIG" ]; then exit 0; fi
+
+# Check optimal microcode loader .config settings
+if ! grep -v "^#" $OLD_CONFIG | grep -q MICROCODE; then
+	exit 0
+fi
+
+MSG="\nYou have CONFIG_MICROCODE enabled without BLK_DEV_INITRD. The preferred\n\
+way is to enable it and make sure microcode is added to your initrd as\n\
+explained in Documentation/x86/early-microcode.txt. This is also the\n\
+most tested method as the majority of distros do it. Alternatively, and\n\
+if you don't want to enable modules, you should make sure the microcode\n\
+is built into the kernel.\n"
+
+if ! grep -v "^#" $OLD_CONFIG | grep -q BLK_DEV_INITRD; then
+	echo -e $MSG
+	read -p "Press any key... "
+fi
scripts/kconfig/Makefile +0 -0
index d79cba4ce3eb..136ae9744efc 100644
@@ -81,6 +81,9 @@ simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
 PHONY += $(simple-targets)
 

$(simple-targets): $(obj)/conf

scripts/kconfig/Makefile +3 -0
+ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/scripts/check-configs.sh),)
+	$(Q)$(CONFIG_SHELL) $(srctree)/arch/$(SRCARCH)/scripts/check-configs.sh $@ $(srctree) $(ARCH)
+endif
	$< $(silent) --$@ $(Kconfig)
Quoted 2 lines

PHONY += oldnoconfig savedefconfig defconfig

My problem was, CONFIG_MICROCODE got dropped silently, and yes that is fixed for me with this patch.
But I think this is a little bit odd way to fix it, but I don't have a better idea.

What's with olddefconfig and silentoldconfig ?

btw that patch has to go to stable 4.4, too

Thomas

#34 lore raw

Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig

Quoted 3 lines · Thomas Voegtle

My problem was, CONFIG_MICROCODE got dropped silently, and yes that is fixed for me with this patch. But I think this is a little bit odd way to fix it, but I don't have a better idea.

Me neither. The problem is, I need to grep the config that goes into the "oldconfig" *before* scripts/kconfig/conf gets a hold of it and satisfies deps and thus turns off CONFIG_MICROCODE in the process. This is a simpler solution short of hacking scripts/kconfig/conf and it can be used for other stuff we might need in arch/x86/

Quoted 1 line

What's with olddefconfig

Yes, I'll update the patch.

Quoted 1 line

and silentoldconfig ?

This one is funny. Makefile's help says:

silentoldconfig - Same as oldconfig, but quietly, additionally update deps

and yet doing

$ make silentoldconfig

is not very silent and goes through all new prompts asking me about them.

Regarding this issue, yes, I'll add its name to the script too.

Quoted 1 line

btw that patch has to go to stable 4.4, too

Sure, once we agree on the approach.

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#35 lore raw

Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig

Quoted 8 lines · Borislav Petkov
Quoted 3 lines · Thomas Voegtle

My problem was, CONFIG_MICROCODE got dropped silently, and yes that is fixed for me with this patch. But I think this is a little bit odd way to fix it, but I don't have a better idea.

Me neither. The problem is, I need to grep the config that goes into the "oldconfig" *before* scripts/kconfig/conf gets a hold of it and satisfies deps and thus turns off CONFIG_MICROCODE in the process.

Wasn't the idea *not* to disable CONFIG_MICROCODE?

Quoted 11 lines

This is a simpler solution short of hacking scripts/kconfig/conf and it can be used for other stuff we might need in arch/x86/

Quoted 1 line

What's with olddefconfig

Yes, I'll update the patch.

Quoted 1 line

and silentoldconfig ?

This one is funny. Makefile's help says:

Quoted 7 lines

silentoldconfig - Same as oldconfig, but quietly, additionally update deps

and yet doing

$ make silentoldconfig

is not very silent and goes through all new prompts asking me about them.

It asks about new options but doesn't print (as many) unchanged ones. That makes it more silent. olddefconfig asks no questions and sets new options to their defaults.

Signature · 1 line
Måns Rullgård
#36 lore raw

Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig

Quoted 2 lines · Måns Rullgård

It asks about new options but doesn't print (as many) unchanged ones. That makes it more silent.

So it should be called

make moresilentoldconfigbutnotcompletelyconfig

or so.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#37 lore raw

Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig

In reply to Måns Rullgård
Quoted 1 line · Måns Rullgård

Wasn't the idea *not* to disable CONFIG_MICROCODE?

Is the error message not understandable?

+MSG="\nYou have CONFIG_MICROCODE enabled without BLK_DEV_INITRD. The preferred\n\
+way is to enable it and make sure microcode is added to your initrd as\n\
+explained in Documentation/x86/early-microcode.txt. This is also the\n\
+most tested method as the majority of distros do it. Alternatively, and\n\
+if you don't want to enable modules, you should make sure the microcode\n\
+is built into the kernel.\n"

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#38 lore raw

Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig

arch/x86/scripts/check-configs.sh line 39

Quoted 11 lines · Borislav Petkov
Quoted 1 line · Måns Rullgård

Wasn't the idea *not* to disable CONFIG_MICROCODE?

Is the error message not understandable?

arch/x86/scripts/check-configs.sh new file +6 -0
+MSG="\nYou have CONFIG_MICROCODE enabled without BLK_DEV_INITRD. The preferred\n\
+way is to enable it and make sure microcode is added to your initrd as\n\
+explained in Documentation/x86/early-microcode.txt. This is also the\n\
+most tested method as the majority of distros do it. Alternatively, and\n\
+if you don't want to enable modules, you should make sure the microcode\n\
+is built into the kernel.\n"

I understand and disagree. I think you're being overzealous in trying to bludgeon people into doing things the way you think they should be done.

Quoted 1 line

From the point of view of the actual update mechanism, what difference

does it make where the microcode data was retrieved from? If you want to warn about what you consider "unsafe" updates, do that when the update happens instead. With this patch, simply enabling BLK_DEV_INITRD will shut up the warning even if an initrd is never actually used. Also, what do modules have to do with anything?

Signature · 1 line
Måns Rullgård
#39 lore raw

Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig

Quoted 3 lines · Måns Rullgård

I understand and disagree. I think you're being overzealous in trying to bludgeon people into doing things the way you think they should be done.

So I did explain why it is better to do microcode updates from the initrd. And nowhere in that explanation I am "bludgeoning" people into doing things the way I want. Which is silly, I'd never even *think* of wanting to do that - I have enough other shit to deal with.

But I guess you're reading it the way you wanna read it so I'm going to leave you thinking whatever you want to think.

Quoted 6 lines

From the point of view of the actual update mechanism, what difference does it make where the microcode data was retrieved from? If you want to warn about what you consider "unsafe" updates, do that when the update happens instead. With this patch, simply enabling BLK_DEV_INITRD will shut up the warning even if an initrd is never actually used. Also, what do modules have to do with anything?

This reads like your mail from a couple of days ago. Which leads me to think that you haven't understood at all what I've been writing this whole time.

So I'm going to stop wasting time with you.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#40 lore raw

Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig

Quoted 9 lines · Borislav Petkov
Quoted 3 lines · Måns Rullgård

I understand and disagree. I think you're being overzealous in trying to bludgeon people into doing things the way you think they should be done.

So I did explain why it is better to do microcode updates from the initrd. And nowhere in that explanation I am "bludgeoning" people into doing things the way I want. Which is silly, I'd never even *think* of wanting to do that - I have enough other shit to deal with.

Forcing users to press a damn key on the keyboard after your pointless warning message sure feels like bludgeoning to me.

Quoted 10 lines
Quoted 6 lines

From the point of view of the actual update mechanism, what difference does it make where the microcode data was retrieved from? If you want to warn about what you consider "unsafe" updates, do that when the update happens instead. With this patch, simply enabling BLK_DEV_INITRD will shut up the warning even if an initrd is never actually used. Also, what do modules have to do with anything?

This reads like your mail from a couple of days ago. Which leads me to think that you haven't understood at all what I've been writing this whole time.

Clearly you didn't explain it very well.

Signature · 1 line
Måns Rullgård
#41 lore raw

[RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig)

In reply to Borislav Petkov

( I've Cc:-ed Linus, Greg and Andrew, to see whether doing something like what I
suggest below in the x86 architecture would be acceptable. )

Quoted 10 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

Thomas Voegtle reported that doing oldconfig with a .config which has CONFIG_MICROCODE enabled but BLK_DEV_INITRD disabled prevents the microcode loading mechanism from being built.

Add a short script which hooks into the "make oldconfig" handling and sanity-checks the config file for that discrepancy. It issues a message which should hopefully sensitize the user to that issue and point her into the right direction.

So it would be much better to just do such things automatically, and only allow 'safe' combination of options - without the user having to do anything.

The guiding principle is: kernel configuration is (still...) our worst barrier of entry for new users/developers, and kernel configuration still sucks very much from a UI point of view.

In fact our kernel configuration UI and workflow is still so bad that it's an effort to stay current even with a standalone and working .config, even for experienced kernel developers...

Adding a (somewhat hacky) post processing script and forcing users to read something 99% of them does not have a clue about is a step in the wrong direction, IMHO.

So can we do something more intelligent instead, such as modifying the Kconfigs in a way that it's not possible to have CONFIG_MICROCODE enabled while BLK_DEV_INITRD is disabled?

I'd be fine with a 'select BLK_DEV_INITRD' for example. If people doing super specialized setups disagree because they really need that nonsensical combination of config options, they can complain and provide a better solution.

In fact on x86 I'd suggest we go farther than that and add a core set of selects that can be disabled only through a sufficiently scary "I really know I'm doing something utmost weird" (and default disabled) config option.

Quoted 1 line

From my own randconfig testing I can give a core list of must-have kernel options,

without which most distros (Fedora, RHEL, Ubuntu, SuSE) won't boot properly:

+config FORCE_MINIMALLY_SANE_CONFIG
+ bool
+ default y
+
+ # so that capset() works (sudo, etc.):
+ select SECURITY
+ select SECURITY_CAPABILITIES
+ select BINFMT_ELF
+
+ select SYSFS
+ select SYSFS_DEPRECATED
+ select PROC_FS
+ select FUTEX
+
+ # newer systemd silently relies on the presence of the epoll system call:
+ select EPOLL
+ select ANON_INODES
+
+ # newer systemd silently hangs durig early init without these:
+ select PROC_SYSCTL
+ select SYSCTL
+ select POSIX_MQUEUE
+ select POSIX_MQUEUE_SYSCTL
+
+ # systemd needs this syscall:
+ select FHANDLE
+
+ # systemd needs devtmpfs: "systemd[1]: Failed to mount devtmpfs at /dev: No such device"
+ select DEVTMPFS
+
+ # systemd needs tmpfs: "systemd[1]: Failed to mount tmpfs at /sys/fs/cgroup: No such file or directory"
+ select SHMEM
+ select TMPFS
+
+ # systemd needs timerfd syscalls: "[ 8.198625] systemd[1]: Failed to create timerfd: Function not implemented^"
+ select TIMERFD
+
+ # systemd needs signalfd support: "[ 45.536725] systemd[1]: Failed to allocate manager object: Function not implemented"
+ select SIGNALFD
+
+ # systemd hangs during bootup without cgroup support:
+ select CGROUPS
+
+ # systemd fails during bootup without this option, with a nonsensical message: "[DEPEND] Dependency failed for File System Check on /dev/sda1."
+ select FILE_LOCKING
+
+ # systemd fails during bootup without this option:
+ select FSNOTIFY
+ select INOTIFY_USER
+
+ # won't boot otherwise:
+ select RD_GZIP
+ select BLK_DEV_INITRD
+
+ # old F6 userspace needs vsyscalls:
+ select X86_VSYSCALL_EMULATION if X86_64
+ select IA32_EMULATION if X86_64

And yes, many of these options are members of the 'SystemD debuggability Hall Of Shame'... It cost me many, many days of painful config-bisection to figure the often obscure dependencies out, so we might as well upstream this information.

Many braincells died to bring us this information!

Note that some of these have sub-dependencies (and super-dependencies) so the list isn't complete from a Kconfig language POV - but it lists most of the 'must have' leaf features and would form a good starting point.

The idea is that if you have this option enabled, the rest of kernel config should be 'fool proof' - or at least failures should be a lot more obvious (such as a missing hardware driver or a missing filesystem driver).

I'd keep this option x86-only at least initially, because that's still the space where most of our newbie testers come from, and because I'd like to see how this evolves before trying to generalize it to 44 architectures...

Also, I'd not try to be per distro, I'd use a single superset of such config
options: from a usability POV it's _much_ better to have a few more options enabled in a .config of thousands of entries, than to accidentally have the one option not enabled that your user-space somehow critically depends on ...

Thoughs?

Thanks,

Ingo

#42 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig)

Quoted 36 lines · Ingo Molnar

( I've Cc:-ed Linus, Greg and Andrew, to see whether doing something like what I
suggest below in the x86 architecture would be acceptable. )

Quoted 10 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

Thomas Voegtle reported that doing oldconfig with a .config which has CONFIG_MICROCODE enabled but BLK_DEV_INITRD disabled prevents the microcode loading mechanism from being built.

Add a short script which hooks into the "make oldconfig" handling and sanity-checks the config file for that discrepancy. It issues a message which should hopefully sensitize the user to that issue and point her into the right direction.

So it would be much better to just do such things automatically, and only allow 'safe' combination of options - without the user having to do anything.

The guiding principle is: kernel configuration is (still...) our worst barrier of entry for new users/developers, and kernel configuration still sucks very much from a UI point of view.

In fact our kernel configuration UI and workflow is still so bad that it's an effort to stay current even with a standalone and working .config, even for experienced kernel developers...

Adding a (somewhat hacky) post processing script and forcing users to read something 99% of them does not have a clue about is a step in the wrong direction, IMHO.

So can we do something more intelligent instead, such as modifying the Kconfigs in a way that it's not possible to have CONFIG_MICROCODE enabled while BLK_DEV_INITRD is disabled?

Quoted 7 lines

I'd be fine with a 'select BLK_DEV_INITRD' for example. If people doing super specialized setups disagree because they really need that nonsensical combination of config options, they can complain and provide a better solution.

In fact on x86 I'd suggest we go farther than that and add a core set of selects that can be disabled only through a sufficiently scary "I really know I'm doing something utmost weird" (and default disabled) config option.

This is essential. Because, believe it or not, there are still users out there that don't use systemd. And to force enable totally superfluous config options for them would be bad.

So, as long as this "systemd config" could be easily disabled, your approach looks fine and would definitely be helpful to many mainstream distro users.

Signature · 1 line
Markus
#43 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig)

Quoted 41 lines · Markus Trippelsdorf
Quoted 40 lines · Ingo Molnar

( I've Cc:-ed Linus, Greg and Andrew, to see whether doing something like what I
suggest below in the x86 architecture would be acceptable. )

Quoted 10 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

Thomas Voegtle reported that doing oldconfig with a .config which has CONFIG_MICROCODE enabled but BLK_DEV_INITRD disabled prevents the microcode loading mechanism from being built.

Add a short script which hooks into the "make oldconfig" handling and sanity-checks the config file for that discrepancy. It issues a message which should hopefully sensitize the user to that issue and point her into the right direction.

So it would be much better to just do such things automatically, and only allow 'safe' combination of options - without the user having to do anything.

The guiding principle is: kernel configuration is (still...) our worst barrier of entry for new users/developers, and kernel configuration still sucks very much from a UI point of view.

In fact our kernel configuration UI and workflow is still so bad that it's an effort to stay current even with a standalone and working .config, even for experienced kernel developers...

Adding a (somewhat hacky) post processing script and forcing users to read something 99% of them does not have a clue about is a step in the wrong direction, IMHO.

So can we do something more intelligent instead, such as modifying the Kconfigs in a way that it's not possible to have CONFIG_MICROCODE enabled while BLK_DEV_INITRD is disabled?

I'd be fine with a 'select BLK_DEV_INITRD' for example. If people doing super specialized setups disagree because they really need that nonsensical combination of config options, they can complain and provide a better solution.

Quoted 7 lines
Quoted 3 lines

In fact on x86 I'd suggest we go farther than that and add a core set of selects that can be disabled only through a sufficiently scary "I really know I'm doing something utmost weird" (and default disabled) config option.

This is essential. Because, believe it or not, there are still users out there that don't use systemd. And to force enable totally superfluous config options for them would be bad.

Well, I think the argument I raised later on is important:

Quoted 3 lines
Quoted 3 lines

[...] from a usability POV it's _much_ better to have a few more options
enabled in a .config of thousands of entries, than to accidentally have the one option not enabled that your user-space somehow critically depends on ...

I.e. the costs of quirks are _massively_ assymetric: having an extra system call or compat option quirk enabled is essentially unmeasurable for those who don't technically need them, while it can be a big and hard to debug show-stopper for others.

'default y' was supposed to cover such cases, but arguably it's too opaque, I think we need a separate, more obvious layer - such as the CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y option I suggested.

Quoted 2 lines

So, as long as this "systemd config" could be easily disabled, your approach looks fine and would definitely be helpful to many mainstream distro users.

It sure can be easily disabled, that's a given.

The key point is that I'd like "naively configured" kernels to work on just about any Linux distro that allow kernel testing - so the superset of all quirks should be included - as long as enabling a quirk does not break things (and none of the ones I listed do as far as I've tested).

Thanks,

Ingo

#44 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig)

Quoted 2 lines · Ingo Molnar

The key point is that I'd like "naively configured" kernels to work on just about any Linux distro that allow kernel testing

Vehemently yes!

This is magnitudes more important than having a couple of passive kilobytes dangling in the kernel image.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#45 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig)

In reply to Ingo Molnar
Quoted 36 lines · Ingo Molnar
(quoted diff) +35 -0
+	# newer systemd silently relies on the presence of the epoll system call:
+	select EPOLL
+	select ANON_INODES
+
+	# newer systemd silently hangs durig early init without these:
+	select PROC_SYSCTL
+	select SYSCTL
+	select POSIX_MQUEUE
+	select POSIX_MQUEUE_SYSCTL
+
+	# systemd needs this syscall:
+	select FHANDLE
+
+	# systemd needs devtmpfs: "systemd[1]: Failed to mount devtmpfs at /dev: No such device"
+	select DEVTMPFS
+
+	# systemd needs tmpfs: "systemd[1]: Failed to mount tmpfs at /sys/fs/cgroup: No such file or directory"
+	select SHMEM
+	select TMPFS
+
+	# systemd needs timerfd syscalls: "[    8.198625] systemd[1]: Failed to create timerfd: Function not implemented^"
+	select TIMERFD
+
+	# systemd needs signalfd support: "[   45.536725] systemd[1]: Failed to allocate manager object: Function not implemented"
+	select SIGNALFD
+
+	# systemd hangs during bootup without cgroup support:
+	select CGROUPS
+
+	# systemd fails during bootup without this option, with a nonsensical message: "[DEPEND] Dependency failed for File System Check on /dev/sda1."
+	select FILE_LOCKING
+
+	# systemd fails during bootup without this option:
+	select FSNOTIFY
+	select INOTIFY_USER
Quoted 5 lines

And yes, many of these options are members of the 'SystemD debuggability Hall Of Shame'... It cost me many, many days of painful config-bisection to figure the often obscure dependencies out, so we might as well upstream this information.

Many braincells died to bring us this information!

So why not group those under CONFIG_SYSTEMD_BLOWS? I still dont have a machine with that turd on.

#46 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig)

Quoted 37 lines · Peter Zijlstra
Quoted 35 lines · Ingo Molnar
(quoted diff) +35 -0
+	# newer systemd silently relies on the presence of the epoll system call:
+	select EPOLL
+	select ANON_INODES
+
+	# newer systemd silently hangs durig early init without these:
+	select PROC_SYSCTL
+	select SYSCTL
+	select POSIX_MQUEUE
+	select POSIX_MQUEUE_SYSCTL
+
+	# systemd needs this syscall:
+	select FHANDLE
+
+	# systemd needs devtmpfs: "systemd[1]: Failed to mount devtmpfs at /dev: No such device"
+	select DEVTMPFS
+
+	# systemd needs tmpfs: "systemd[1]: Failed to mount tmpfs at /sys/fs/cgroup: No such file or directory"
+	select SHMEM
+	select TMPFS
+
+	# systemd needs timerfd syscalls: "[    8.198625] systemd[1]: Failed to create timerfd: Function not implemented^"
+	select TIMERFD
+
+	# systemd needs signalfd support: "[   45.536725] systemd[1]: Failed to allocate manager object: Function not implemented"
+	select SIGNALFD
+
+	# systemd hangs during bootup without cgroup support:
+	select CGROUPS
+
+	# systemd fails during bootup without this option, with a nonsensical message: "[DEPEND] Dependency failed for File System Check on /dev/sda1."
+	select FILE_LOCKING
+
+	# systemd fails during bootup without this option:
+	select FSNOTIFY
+	select INOTIFY_USER
Quoted 8 lines
Quoted 5 lines

And yes, many of these options are members of the 'SystemD debuggability Hall Of Shame'... It cost me many, many days of painful config-bisection to figure the often obscure dependencies out, so we might as well upstream this information.

Many braincells died to bring us this information!

So why not group those under CONFIG_SYSTEMD_BLOWS? I still dont have a machine with that turd on.

I'd definitely (try to) list the reasons for each quirk in the Kconfig lines (as I did above), but I'd still keep a single generic option not tied to systemd in particular, for the following reasons:

- I am using many systemd systems, so the quirks are naturally mostly systemd related. There might be more non-systemd quirks that I never triggered personally. They can be added once people trigger them.

- Also, even that considered, not all of the options I listed are systemd quirks, as I still have a single (albeit simple) non-systemd test machine.

- I'd like to have a single superset option that principally makes the kernel 'just work' for newbie testers - without them having to be even aware of whether their distro version uses systemd or something else.

Thanks,

Ingo

#47 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig)

In reply to Ingo Molnar
Quoted 3 lines · Ingo Molnar

In fact our kernel configuration UI and workflow is still so bad that it's an effort to stay current even with a standalone and working .config, even for experienced kernel developers...

Tell me about it. SCSI SAS recent breakage case-in-point...

Quoted 3 lines

Adding a (somewhat hacky) post processing script and forcing users to read something 99% of them does not have a clue about is a step in the wrong direction, IMHO.

Yeah, so I have a different idea how to fix it. I'm going to drop both

depends on BLK_DEV_INITRD
select FW_LOADER

and make it build with or without them enabled so that people are free to do whatever they want and not get the feeling that I'm forcing shit down their throats.

HOWEVER(!), this, IMHO, won't help with the normal users because then they'd have to read Kconfig:

+         The preferred method to load microcode is described in
+         Documentation/x86/early-microcode.txt. For that you need to enable
+         CONFIG_BLK_DEV_INITRD in order for the loader to be able to scan the
+         initrd for microcode blobs.

+ Alternatively, you can build-in the microcode into the kernel. For
+ that you need the functionality behind CONFIG_FW_LOADER.

and figure out what to do exactly to have microcode applied.

And this is crap, IMO.

It should JustWork.

I dunno, maybe I should do a separate config option which let people choose between FW_LOADER and BLK_DEV_INITRD if CONFIG_MICROCODE is enabled. I need to hack it in and see what it becomes.

Anyway, I'm just giving my example here as a POV for the discussion.

Quoted 3 lines

So can we do something more intelligent instead, such as modifying the Kconfigs in a way that it's not possible to have CONFIG_MICROCODE enabled while BLK_DEV_INITRD is disabled?

I'm working on untangling CONFIG_MICROCODE from BLK_DEV_INITRD so you won't need to touch the Kconfig. See above.

Quoted 4 lines

I'd be fine with a 'select BLK_DEV_INITRD' for example. If people doing super specialized setups disagree because they really need that nonsensical combination of config options, they can complain and provide a better solution.

Yeah, people complained that they don't want to run with initrds.

Quoted 4 lines

In fact on x86 I'd suggest we go farther than that and add a core set of selects that can be disabled only through a sufficiently scary "I really know I'm doing something utmost weird" (and default disabled) config option.

CONFIG_EXPERT_MORE

?

Quoted 7 lines

From my own randconfig testing I can give a core list of must-have kernel options, without which most distros (Fedora, RHEL, Ubuntu, SuSE) won't boot properly:

(quoted diff) +3 -0
+config FORCE_MINIMALLY_SANE_CONFIG
+	bool
+	default y

...

Quoted 6 lines

And yes, many of these options are members of the 'SystemD debuggability Hall Of Shame'... It cost me many, many days of painful config-bisection to figure the often obscure dependencies out, so we might as well upstream this information.

Many braincells died to bring us this information!

I know *exactly* what you're talking about!

Yeah, so having an option select *sane* settings but leaving the possibility to change that for expert users makes sense.

...

Quoted 4 lines

The idea is that if you have this option enabled, the rest of kernel config should be 'fool proof' - or at least failures should be a lot more obvious (such as a missing hardware driver or a missing filesystem driver).

Yap.

...

Quoted 1 line

Thoughs?

Sounds like a good idea to me.

Thanks.

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#48 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y

In reply to Ingo Molnar
Quoted 3 lines · Ingo Molnar

In fact on x86 I'd suggest we go farther than that and add a core set of selects that can be disabled only through a sufficiently scary "I really know I'm doing something utmost weird" (and default disabled) config option.

Agreed.

Review

Quoted 6 lines

From my own randconfig testing I can give a core list of must-have kernel options, without which most distros (Fedora, RHEL, Ubuntu, SuSE) won't boot properly:

(quoted diff) +3 -0
+config FORCE_MINIMALLY_SANE_CONFIG
+	bool
+	default y

You should add a prompt so that the option can be disabled. Or make it default !EXPERT, to have a single "I know what I'm doing"-type of option.

Michal

#49 lore raw

Re: [RFC] CONFIG_GENERIC_BOOTABLE_CONFIG=y

Quoted 11 lines · Michal Marek
Quoted 3 lines · Ingo Molnar

In fact on x86 I'd suggest we go farther than that and add a core set of selects that can be disabled only through a sufficiently scary "I really know I'm doing something utmost weird" (and default disabled) config option.

Agreed.

Quoted 3 lines

From my own randconfig testing I can give a core list of must-have kernel options, without which most distros (Fedora, RHEL, Ubuntu, SuSE) won't boot properly:

Quoted 6 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+config FORCE_MINIMALLY_SANE_CONFIG
+	bool
+	default y

You should add a prompt so that the option can be disabled. Or make it default !EXPERT, to have a single "I know what I'm doing"-type of option.

Yeah, it sure should be interactive. This was pasted from my automated testing that isn't interested in unbootable kernels.

So it should be something like:

	config GENERIC_BOOTABLE_CONFIG
	bool "Enable kernel options that are needed to boot typical Linux distributions"
	default y
	...

(I removed the 'SANE' naming as disabling this option is obviously not 'insane'.)

Thanks,

Ingo

#50 lore raw

Re: [RFC] CONFIG_GENERIC_BOOTABLE_CONFIG=y

Quoted 10 lines · Ingo Molnar

So it should be something like:

config GENERIC_BOOTABLE_CONFIG
bool "Enable kernel options that are needed to boot typical Linux distributions" default y
...

(I removed the 'SANE' naming as disabling this option is obviously not 'insane'.)

I think we should just make it distro-specific rather than claiming it is generic (and inevitably failing).

So we could have a config option for SYSTEMD, which selects stuff systemd wants, and then distros that use systemd can select that etc.

It shouldn't be about just bootability either. Some of the networking options end up being security-critical (ie your firewall might not work if you don't have the right options enabled, leaving you wide open after you boot).

Done right, you should be able to

(a) select your CPU (and things like "do you want virtualization etc")
(b) select your distro
(c) select your drivers

and pretty much be done with it.

Linus

#51 lore raw

Re: [RFC] CONFIG_GENERIC_BOOTABLE_CONFIG=y

Quoted 15 lines · Linus Torvalds
Quoted 10 lines · Ingo Molnar

So it should be something like:

config GENERIC_BOOTABLE_CONFIG
bool "Enable kernel options that are needed to boot typical Linux distributions" default y
...

(I removed the 'SANE' naming as disabling this option is obviously not 'insane'.)

I think we should just make it distro-specific rather than claiming it is generic (and inevitably failing).

Quoted 7 lines

So we could have a config option for SYSTEMD, which selects stuff systemd wants, and then distros that use systemd can select that etc.

It shouldn't be about just bootability either. Some of the networking options end up being security-critical (ie your firewall might not work if you don't have the right options enabled, leaving you wide open after you boot).

It might be worth looking at Gentoo's kernel patches, they've had one for a while now (I think roughly a year and a half) that does pretty much this, you get options for each of their officially supported init systems (OpenRC, and SystemD, although the systemd option is not anywhere near as complete as what was proposed here), one for portage (which needs some specific namespace stuff for sandboxing builds), and I think one for udev. Theirs however uses depends instead of selects, but I think that fits a bit better (If I tell the config to make sure I can boot using a particular init system, I expect it to not let me change things that would prevent me from booting using that init system).

#52 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y

In reply to Ingo Molnar
Quoted 3 lines · Ingo Molnar

So can we do something more intelligent instead, such as modifying the Kconfigs in a way that it's not possible to have CONFIG_MICROCODE enabled while BLK_DEV_INITRD is disabled?

The problem with *any* approach involving Kconfig is that it still leaves users free to load microcode whenever they want, even if they're not supposed to. Doing so apparently works correctly (almost) every time (how does it fail if it does?), and no warnings are issued to suggest it might be a bad idea. Force-enabling BLK_DEV_INITRD isn't going to make anyone change their boot scripts. Many might not even notice that it got silently enabled. So what purpose does it serve to play games with the config when it has no actual impact on the usage of the driver?

I'd also like to get a coherent answer to why microcode update is preferably done from an initrd as opposed to shortly after mounting a regular disk. My systems seem perfectly happy doing the latter.

Signature · 1 line
Måns Rullgård
#53 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y

Dne 19.1.2016 v 13:29 Måns Rullgård napsal(a):

Quoted 2 lines

Force-enabling BLK_DEV_INITRD isn't going to make anyone change their boot scripts.

If you are on a regular distro, /sbin/installkernel should do the right
thing: Run mkinitrd / dracut and if the tools are recent enough and there is a microcode update for your CPU, a cpio with the microcode blob will be prepended to the initrd. So this is more or less covered.

Quoted 3 lines

I'd also like to get a coherent answer to why microcode update is preferably done from an initrd as opposed to shortly after mounting a regular disk. My systems seem perfectly happy doing the latter.

It's not even done *from* the initrd but way earlier. We learned the hard way when Intel released a microcode update for Haswell which disabled TSX: Userspace did not expect the feature flags to change and previously valid instructions to start trapping. This can in principle happen again and with any vendor.

Michal

#54 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y

Quoted 8 lines · Michal Marek

Dne 19.1.2016 v 13:29 Måns Rullgård napsal(a):

Quoted 2 lines

Force-enabling BLK_DEV_INITRD isn't going to make anyone change their boot scripts.

If you are on a regular distro, /sbin/installkernel should do the right
thing: Run mkinitrd / dracut and if the tools are recent enough and there is a microcode update for your CPU, a cpio with the microcode blob will be prepended to the initrd. So this is more or less covered.

I'd be rather cross if something suddenly started building initrds on my systems. To me they're just a useless level of complexity to maintain. (I'm not denying they can be useful to others.)

Quoted 9 lines
Quoted 3 lines

I'd also like to get a coherent answer to why microcode update is preferably done from an initrd as opposed to shortly after mounting a regular disk. My systems seem perfectly happy doing the latter.

It's not even done *from* the initrd but way earlier. We learned the hard way when Intel released a microcode update for Haswell which disabled TSX: Userspace did not expect the feature flags to change and previously valid instructions to start trapping. This can in principle happen again and with any vendor.

OK, I can see how that might be a problem.

Signature · 1 line
Måns Rullgård
#55 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig)

In reply to Ingo Molnar
Quoted 1 line · Ingo Molnar
(quoted diff) +1 -0
+	select SYSFS_DEPRECATED

...

Quoted 3 lines

And yes, many of these options are members of the 'SystemD debuggability Hall Of Shame'... It cost me many, many days of painful config-bisection to figure the often obscure dependencies out, so we might as well upstream this information.

And you've got it wrong ;)

http://cgit.freedesktop.org/systemd/systemd/tree/README#n54

udev will fail to work with the legacy sysfs layout:
CONFIG_SYSFS_DEPRECATED=n

Signature · 1 line
 Kirill A. Shutemov
#56 lore raw

Re: [RFC] CONFIG_FORCE_MINIMALLY_SANE_CONFIG=y (was: Re: [RFC PATCH] x86/kconfig: Sanity-check config file during oldconfig)

Quoted 8 lines · Kirill A. Shutemov
Quoted 1 line · Ingo Molnar
(quoted diff) +1 -0
+	select SYSFS_DEPRECATED

...

Quoted 3 lines

And yes, many of these options are members of the 'SystemD debuggability Hall Of Shame'... It cost me many, many days of painful config-bisection to figure the often obscure dependencies out, so we might as well upstream this information.

Quoted 6 lines

And you've got it wrong ;)

http://cgit.freedesktop.org/systemd/systemd/tree/README#n54

udev will fail to work with the legacy sysfs layout:
CONFIG_SYSFS_DEPRECATED=n

That's with new systemd. The Fedora 19 system I tested it on certainly failed in the way I documented it.

So we now have a kernel option that breaks older SystemD if unset, and breaks newer SystemD if set.

Bravo!

Thanks,

Ingo

#57 lore raw
In reply to Borislav Petkov
Quoted 6 lines · Borislav Petkov
Quoted 2 lines · Måns Rullgård

How is an initrd different from a real filesystem as seen by the microcode update driver?

For starters, initrd is available much earlier, even before paging is enabled on 32-bit, for example. See find_cpio_data().

Yes, but the microcode driver doesn't care about this AFAICT.

Quoted 7 lines
Quoted 3 lines

The objection against removing the dependency was that updating microcode "late" isn't safe. I don't see how turning on BLK_DEV_INITRD stops anyone doing those allegedly unsafe updates anyway.

No one is stopping anyone from doing late updates. It is a valid use case, and we have to support it. And late updates are not necessarily unsafe, per se.

So it's meant to be supported, good.

Quoted 5 lines

Lemme put it this way: it is a lot less unproblematic to do early updates. Mind you, there's no 100% guarantee that early updates would always work either. It all depends on what the microcode patch does. But they do work 99,9999999...% of the time. :)

Quoted 8 lines

IOW, I haven't heard of an early update breaking the machine. But it is possible.

So the *general* flow should be that people enable BLK_DEV_INITRD, put the microcode in there and it gets updated as early as possible. This is what the distros do and it is the most tested path. The other possibilities are there too, but only for cases where initrd is out of the question.

Yes, that's the common case, and those users will have BLK_DEV_INITRD enabled anyway. Now why should someone who, for whatever reasons, is doing microcode updates late be forced to enable BLK_DEV_INITRD even though he doesn't use it?

Signature · 1 line
Måns Rullgård
#58 lore raw
In reply to Thomas Voegtle
Quoted 2 lines · Thomas Voegtle

I just diffed my 4.3 config with the 4.4 config and saw that the whole Microcode stuff was silently dropped by a normal "make oldconfig".

Ok, here's a different version.

It takes care of the oldconfig aspect, you'd still need to either prepare an initrd with the microcode or build it into the kernel. Ask if something's not clear.

It works fine in qemu+kvm but I'll run it on my boxes before I queue it for stable.

Thanks.

---
From: Borislav Petkov <[email protected]>
Date: Mon, 18 Jan 2016 19:07:08 +0100
Subject: [PATCH] x86/microcode: Untangle from BLK_DEV_INITRD

Thomas Voegtle reported that doing oldconfig with a .config which has CONFIG_MICROCODE enabled but BLK_DEV_INITRD disabled prevents the microcode loading mechanism from being built.

So untangle it from the BLK_DEV_INITRD dependency so that oldconfig doesn't turn it off and add an explanatory text to its Kconfig help what the supported methods for supplying microcode are.

Follow-on work will do the same with CONFIG_FW_LOADER. This patch is kept minimal for stable backporting.

---
 arch/x86/Kconfig                      | 12 ++++++------
 arch/x86/include/asm/microcode.h      | 26 ++++++++++++++++++++++++++
 arch/x86/kernel/cpu/microcode/intel.c | 14 ++++----------
 3 files changed, 36 insertions(+), 16 deletions(-)
arch/x86/Kconfig +6 -6
index db3622f22b61..9743b8bb500e 100644
@@ -1126,10 +1126,8 @@ config MICROCODE
 	bool "CPU microcode loading support"
 	default y
 	depends on CPU_SUP_AMD || CPU_SUP_INTEL
-	depends on BLK_DEV_INITRD
 	select FW_LOADER
 	---help---
-
 	  If you say Y here, you will be able to update the microcode on
 	  certain Intel and AMD processors. The Intel support is for the
 	  IA32 family, e.g. Pentium Pro, Pentium II, Pentium III, Pentium 4,
@@ -1137,11 +1135,13 @@ config MICROCODE
 	  obviously need the actual microcode binary data itself which is not
 	  shipped with the Linux kernel.
 
-	  This option selects the general module only, you need to select
-	  at least one vendor specific module as well.
+	  The preferred method to load microcode is described in
+	  Documentation/x86/early-microcode.txt. For that you need to enable
+	  CONFIG_BLK_DEV_INITRD in order for the loader to be able to scan the
+	  initrd for microcode blobs.
 
-	  To compile this driver as a module, choose M here: the module
-	  will be called microcode.
+	  Alternatively, you can build-in the microcode into the kernel. For
+	  that you need the functionality behind CONFIG_FW_LOADER.
 
 config MICROCODE_INTEL
 	bool "Intel microcode loading support"
arch/x86/include/asm/microcode.h +26 -0
index 34e62b1dcfce..712b24ed3a64 100644
@@ -2,6 +2,7 @@
 #define _ASM_X86_MICROCODE_H
 
 #include <linux/earlycpio.h>
+#include <linux/initrd.h>
 
 #define native_rdmsr(msr, val1, val2)			\
 do {							\
@@ -168,4 +169,29 @@ static inline void reload_early_microcode(void)			{ }
 static inline bool
 get_builtin_firmware(struct cpio_data *cd, const char *name)	{ return false; }
 #endif
+
+static inline unsigned long get_initrd_start(void)
+{
+#ifdef CONFIG_BLK_DEV_INITRD
+	return initrd_start;
+#else
+	return 0;
+#endif
+}
+
+static inline unsigned long get_initrd_start_addr(void)
+{
+#ifdef CONFIG_BLK_DEV_INITRD
+#ifdef CONFIG_X86_32
+	unsigned long *initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start);
+
+	return (unsigned long)__pa_nodebug(*initrd_start_p);
+#else
+	return get_initrd_start();
+#endif
+#else /* CONFIG_BLK_DEV_INITRD */
+	return 0;
+#endif
+}
+
 #endif /* _ASM_X86_MICROCODE_H */
arch/x86/kernel/cpu/microcode/intel.c +4 -10
index ce47402eb2f9..eea5978a0e33 100644
@@ -694,7 +694,7 @@ int __init save_microcode_in_initrd_intel(void)
 	if (count == 0)
 		return ret;
 
-	copy_initrd_ptrs(mc_saved, mc_saved_in_initrd, initrd_start, count);
+	copy_initrd_ptrs(mc_saved, mc_saved_in_initrd, get_initrd_start(), count);
 	ret = save_microcode(&mc_saved_data, mc_saved, count);
 	if (ret)
 		pr_err("Cannot save microcode patches from initrd.\n");
@@ -752,20 +752,14 @@ void load_ucode_intel_ap(void)
 	struct mc_saved_data *mc_saved_data_p;
 	struct ucode_cpu_info uci;
 	unsigned long *mc_saved_in_initrd_p;
-	unsigned long initrd_start_addr;
 	enum ucode_state ret;
 #ifdef CONFIG_X86_32
-	unsigned long *initrd_start_p;
 
-	mc_saved_in_initrd_p =
-		(unsigned long *)__pa_nodebug(mc_saved_in_initrd);
+	mc_saved_in_initrd_p = (unsigned long *)__pa_nodebug(mc_saved_in_initrd);
 	mc_saved_data_p = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data);
-	initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start);
-	initrd_start_addr = (unsigned long)__pa_nodebug(*initrd_start_p);
 #else
-	mc_saved_data_p = &mc_saved_data;
 	mc_saved_in_initrd_p = mc_saved_in_initrd;
-	initrd_start_addr = initrd_start;
+	mc_saved_data_p = &mc_saved_data;
 #endif
 
 	/*
@@ -777,7 +771,7 @@ void load_ucode_intel_ap(void)
 
 	collect_cpu_info_early(&uci);
 	ret = load_microcode(mc_saved_data_p, mc_saved_in_initrd_p,
-			     initrd_start_addr, &uci);
+			     get_initrd_start_addr(), &uci);
 
 	if (ret != UCODE_OK)
 		return;
Signature · 4 lines
2.3.5

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
-- 
#59 lore raw
Quoted 5 lines · Borislav Petkov
Quoted 2 lines · Thomas Voegtle

I just diffed my 4.3 config with the 4.4 config and saw that the whole Microcode stuff was silently dropped by a normal "make oldconfig".

Ok, here's a different version.

I checked that in several ways, took my old 4.3-config, ran it through "make oldconfig" and the others, etc.

Works like a charm.

Thank you,

Thomas

Quoted 148 lines

It takes care of the oldconfig aspect, you'd still need to either prepare an initrd with the microcode or build it into the kernel. Ask if something's not clear.

It works fine in qemu+kvm but I'll run it on my boxes before I queue it for stable.

Thanks.

---
From: Borislav Petkov <[email protected]>
Date: Mon, 18 Jan 2016 19:07:08 +0100
Subject: [PATCH] x86/microcode: Untangle from BLK_DEV_INITRD

Thomas Voegtle reported that doing oldconfig with a .config which has CONFIG_MICROCODE enabled but BLK_DEV_INITRD disabled prevents the microcode loading mechanism from being built.

So untangle it from the BLK_DEV_INITRD dependency so that oldconfig doesn't turn it off and add an explanatory text to its Kconfig help what the supported methods for supplying microcode are.

Follow-on work will do the same with CONFIG_FW_LOADER. This patch is kept minimal for stable backporting.

---

arch/x86/Kconfig                      | 12 ++++++------
arch/x86/include/asm/microcode.h      | 26 ++++++++++++++++++++++++++
arch/x86/kernel/cpu/microcode/intel.c | 14 ++++----------
3 files changed, 36 insertions(+), 16 deletions(-)
arch/x86/Kconfig +6 -6
index db3622f22b61..9743b8bb500e 100644
@@ -1126,10 +1126,8 @@ config MICROCODE
 	bool "CPU microcode loading support"
 	default y
 	depends on CPU_SUP_AMD || CPU_SUP_INTEL
-	depends on BLK_DEV_INITRD
 	select FW_LOADER
 	---help---
-
 	  If you say Y here, you will be able to update the microcode on
 	  certain Intel and AMD processors. The Intel support is for the
 	  IA32 family, e.g. Pentium Pro, Pentium II, Pentium III, Pentium 4,
@@ -1137,11 +1135,13 @@ config MICROCODE
 	  obviously need the actual microcode binary data itself which is not
 	  shipped with the Linux kernel.
 
-	  This option selects the general module only, you need to select
-	  at least one vendor specific module as well.
+	  The preferred method to load microcode is described in
+	  Documentation/x86/early-microcode.txt. For that you need to enable
+	  CONFIG_BLK_DEV_INITRD in order for the loader to be able to scan the
+	  initrd for microcode blobs.
 
-	  To compile this driver as a module, choose M here: the module
-	  will be called microcode.
+	  Alternatively, you can build-in the microcode into the kernel. For
+	  that you need the functionality behind CONFIG_FW_LOADER.
 

config MICROCODE_INTEL
bool "Intel microcode loading support"

arch/x86/include/asm/microcode.h +1 -0
index 34e62b1dcfce..712b24ed3a64 100644
@@ -2,6 +2,7 @@
 #define _ASM_X86_MICROCODE_H
 
 #include <linux/earlycpio.h>
+#include <linux/initrd.h>
 
 #define native_rdmsr(msr, val1, val2)			\
 do {							\
@@ -168,4 +169,29 @@ static inline void reload_early_microcode(void)			{ }

static inline bool
get_builtin_firmware(struct cpio_data *cd, const char *name) { return false; }
#endif

arch/x86/include/asm/microcode.h +25 -0
+
+static inline unsigned long get_initrd_start(void)
+{
+#ifdef CONFIG_BLK_DEV_INITRD
+	return initrd_start;
+#else
+	return 0;
+#endif
+}
+
+static inline unsigned long get_initrd_start_addr(void)
+{
+#ifdef CONFIG_BLK_DEV_INITRD
+#ifdef CONFIG_X86_32
+	unsigned long *initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start);
+
+	return (unsigned long)__pa_nodebug(*initrd_start_p);
+#else
+	return get_initrd_start();
+#endif
+#else /* CONFIG_BLK_DEV_INITRD */
+	return 0;
+#endif
+}
+

#endif /* _ASM_X86_MICROCODE_H */

arch/x86/kernel/cpu/microcode/intel.c +3 -9
index ce47402eb2f9..eea5978a0e33 100644
@@ -694,7 +694,7 @@ int __init save_microcode_in_initrd_intel(void)
 	if (count == 0)
 		return ret;
 
-	copy_initrd_ptrs(mc_saved, mc_saved_in_initrd, initrd_start, count);
+	copy_initrd_ptrs(mc_saved, mc_saved_in_initrd, get_initrd_start(), count);
 	ret = save_microcode(&mc_saved_data, mc_saved, count);
 	if (ret)
 		pr_err("Cannot save microcode patches from initrd.\n");
@@ -752,20 +752,14 @@ void load_ucode_intel_ap(void)
 	struct mc_saved_data *mc_saved_data_p;
 	struct ucode_cpu_info uci;
 	unsigned long *mc_saved_in_initrd_p;
-	unsigned long initrd_start_addr;
 	enum ucode_state ret;
 #ifdef CONFIG_X86_32
-	unsigned long *initrd_start_p;
 
-	mc_saved_in_initrd_p =
-		(unsigned long *)__pa_nodebug(mc_saved_in_initrd);
+	mc_saved_in_initrd_p = (unsigned long *)__pa_nodebug(mc_saved_in_initrd);
 	mc_saved_data_p = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data);
-	initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start);
-	initrd_start_addr = (unsigned long)__pa_nodebug(*initrd_start_p);
 #else
-	mc_saved_data_p = &mc_saved_data;
 	mc_saved_in_initrd_p = mc_saved_in_initrd;
-	initrd_start_addr = initrd_start;
+	mc_saved_data_p = &mc_saved_data;
 #endif
 
 	/*

arch/x86/kernel/cpu/microcode/intel.c void load_ucode_intel_ap(void) · line 777

Quoted 8 lines
arch/x86/kernel/cpu/microcode/intel.c +1 -1
@@ -777,7 +771,7 @@ void load_ucode_intel_ap(void)
 
 	collect_cpu_info_early(&uci);
 	ret = load_microcode(mc_saved_data_p, mc_saved_in_initrd_p,
-			     initrd_start_addr, &uci);
+			     get_initrd_start_addr(), &uci);
 
 	if (ret != UCODE_OK)
 		return;

Thomas

Signature · 1 line
 Thomas V
#60 lore raw
Quoted 4 lines · Thomas Voegtle

I checked that in several ways, took my old 4.3-config, ran it through "make oldconfig" and the others, etc.

Works like a charm.

Cool, thanks for testing.

I'll have a full patchset ready later, if you wanna test it for real, I can let you know.

Thanks!

Signature · 5 lines
Regards/Gruss,
    Boris.

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
--