2015-11-19 21:43:07

by Markus Trippelsdorf

[permalink] [raw]
Subject: x86/microcode update on systems without INITRD

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.

--
Markus


2015-11-19 21:55:47

by Borislav Petkov

[permalink] [raw]
Subject: Re: x86/microcode update on systems without INITRD

On Thu, Nov 19, 2015 at 10:43:01PM +0100, Markus Trippelsdorf wrote:
> 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.

--
Regards/Gruss,
Boris.

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

2015-11-19 22:58:32

by Borislav Petkov

[permalink] [raw]
Subject: Re: x86/microcode update on systems without INITRD

On Thu, Nov 19, 2015 at 10:55:43PM +0100, Borislav Petkov wrote:
> On Thu, Nov 19, 2015 at 10:43:01PM +0100, Markus Trippelsdorf wrote:
> > 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:

---
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index 3aaffb601c91..faec7120c508 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -698,3 +698,4 @@ int __init microcode_init(void)
return error;

}
+late_initcall(microcode_init);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 29db25f9a745..d2bbe343fda7 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -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!

--
Regards/Gruss,
Boris.

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

2015-11-20 07:19:25

by Markus Trippelsdorf

[permalink] [raw]
Subject: Re: x86/microcode update on systems without INITRD

On 2015.11.19 at 23:58 +0100, Borislav Petkov wrote:
> On Thu, Nov 19, 2015 at 10:55:43PM +0100, Borislav Petkov wrote:
> > On Thu, Nov 19, 2015 at 10:43:01PM +0100, Markus Trippelsdorf wrote:
> > > 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:

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index db3622f22b61..52c6964e24bd 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -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---


--
Markus

2015-11-20 08:27:22

by Borislav Petkov

[permalink] [raw]
Subject: Re: x86/microcode update on systems without INITRD

On Fri, Nov 20, 2015 at 08:19:20AM +0100, Markus Trippelsdorf wrote:
> On 2015.11.19 at 23:58 +0100, Borislav Petkov wrote:
> > On Thu, Nov 19, 2015 at 10:55:43PM +0100, Borislav Petkov wrote:
> > > On Thu, Nov 19, 2015 at 10:43:01PM +0100, Markus Trippelsdorf wrote:
> > > > 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.

Thanks for testing.

> But of course it needs this additional patch, otherwise the microcode
> loader wouldn't build at all:
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index db3622f22b61..52c6964e24bd 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -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.

--
Regards/Gruss,
Boris.

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

2015-11-20 08:33:53

by Markus Trippelsdorf

[permalink] [raw]
Subject: Re: x86/microcode update on systems without INITRD

On 2015.11.20 at 09:27 +0100, Borislav Petkov wrote:
> On Fri, Nov 20, 2015 at 08:19:20AM +0100, Markus Trippelsdorf wrote:
> > On 2015.11.19 at 23:58 +0100, Borislav Petkov wrote:
> > > On Thu, Nov 19, 2015 at 10:55:43PM +0100, Borislav Petkov wrote:
> > > > On Thu, Nov 19, 2015 at 10:43:01PM +0100, Markus Trippelsdorf wrote:
> > > > > 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.
>
> Thanks for testing.
>
> > But of course it needs this additional patch, otherwise the microcode
> > loader wouldn't build at all:
> >
> > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> > index db3622f22b61..52c6964e24bd 100644
> > --- a/arch/x86/Kconfig
> > +++ b/arch/x86/Kconfig
> > @@ -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...

--
Markus

2015-11-20 08:48:58

by Borislav Petkov

[permalink] [raw]
Subject: Re: x86/microcode update on systems without INITRD

On Fri, Nov 20, 2015 at 09:33:48AM +0100, Markus Trippelsdorf wrote:
> 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.

--
Regards/Gruss,
Boris.

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

2015-11-20 11:24:05

by Borislav Petkov

[permalink] [raw]
Subject: [PATCH] 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.

Reported-and-tested-by: Markus Trippelsdorf <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
---
arch/x86/kernel/cpu/microcode/core.c | 1 +
arch/x86/kernel/setup.c | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index 7fc27f1cca58..b3e94ef461fd 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -698,3 +698,4 @@ int __init microcode_init(void)
return error;

}
+late_initcall(microcode_init);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 29db25f9a745..d2bbe343fda7 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -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
--
2.3.5

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

Subject: [tip:x86/urgent] 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.

Reported-and-tested-by: Markus Trippelsdorf <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/kernel/cpu/microcode/core.c | 1 +
arch/x86/kernel/setup.c | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index 7fc27f1..b3e94ef 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -698,3 +698,4 @@ int __init microcode_init(void)
return error;

}
+late_initcall(microcode_init);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 29db25f..d2bbe34 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -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