linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/microcode: Fix the microcode load on CPU hotplug for real
@ 2019-06-18 20:31 Thomas Gleixner
  2019-06-18 20:34 ` Borislav Petkov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Thomas Gleixner @ 2019-06-18 20:31 UTC (permalink / raw)
  To: LKML; +Cc: x86, Borislav Petkov

A recent change moved the microcode loader hotplug callback into the early
startup phase, which is running with interrupts disabled. It missed that
the callbacks invoke sysfs functions which might sleep causing nice 'might
sleep' splats with proper debugging enabled.

Split the callbacks and only load the microcode in the early startup phase
and move the sysfs handling back into the later threaded and preemptible
bringup phase where it was before.

Fixes: 78f4e932f776 ("x86/microcode, cpuhotplug: Add a microcode loader CPU hotplug callback")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
---
 arch/x86/kernel/cpu/microcode/core.c |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -789,13 +789,16 @@ static struct syscore_ops mc_syscore_ops
 	.resume			= mc_bp_resume,
 };
 
-static int mc_cpu_online(unsigned int cpu)
+static int mc_cpu_starting(unsigned int cpu)
 {
-	struct device *dev;
-
-	dev = get_cpu_device(cpu);
 	microcode_update_cpu(cpu);
 	pr_debug("CPU%d added\n", cpu);
+	return 0;
+}
+
+static int mc_cpu_online(unsigned int cpu)
+{
+	struct device *dev = get_cpu_device(cpu);
 
 	if (sysfs_create_group(&dev->kobj, &mc_attr_group))
 		pr_err("Failed to create group for CPU%d\n", cpu);
@@ -872,7 +875,9 @@ int __init microcode_init(void)
 		goto out_ucode_group;
 
 	register_syscore_ops(&mc_syscore_ops);
-	cpuhp_setup_state_nocalls(CPUHP_AP_MICROCODE_LOADER, "x86/microcode:online",
+	cpuhp_setup_state_nocalls(CPUHP_AP_MICROCODE_LOADER, "x86/microcode:starting",
+				  mc_cpu_starting, NULL);
+	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "x86/microcode:online",
 				  mc_cpu_online, mc_cpu_down_prep);
 
 	pr_info("Microcode Update Driver: v%s.", DRIVER_VERSION);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/microcode: Fix the microcode load on CPU hotplug for real
  2019-06-18 20:31 [PATCH] x86/microcode: Fix the microcode load on CPU hotplug for real Thomas Gleixner
@ 2019-06-18 20:34 ` Borislav Petkov
  2019-06-19  7:31 ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
  2019-06-26 17:20 ` [PATCH] " Evan Green
  2 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2019-06-18 20:34 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, x86

On Tue, Jun 18, 2019 at 10:31:40PM +0200, Thomas Gleixner wrote:
> A recent change moved the microcode loader hotplug callback into the early
> startup phase, which is running with interrupts disabled. It missed that
> the callbacks invoke sysfs functions which might sleep causing nice 'might
> sleep' splats with proper debugging enabled.
> 
> Split the callbacks and only load the microcode in the early startup phase
> and move the sysfs handling back into the later threaded and preemptible
> bringup phase where it was before.
> 
> Fixes: 78f4e932f776 ("x86/microcode, cpuhotplug: Add a microcode loader CPU hotplug callback")
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: stable@vger.kernel.org
> ---
>  arch/x86/kernel/cpu/microcode/core.c |   15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)

Acked-by: Borislav Petkov <bp@suse.de>

Thanks for fixing that!

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:x86/urgent] x86/microcode: Fix the microcode load on CPU hotplug for real
  2019-06-18 20:31 [PATCH] x86/microcode: Fix the microcode load on CPU hotplug for real Thomas Gleixner
  2019-06-18 20:34 ` Borislav Petkov
@ 2019-06-19  7:31 ` tip-bot for Thomas Gleixner
  2019-06-26 17:20 ` [PATCH] " Evan Green
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Thomas Gleixner @ 2019-06-19  7:31 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: tglx, x86, linux-kernel, mingo, mingo, hpa, bp

Commit-ID:  5423f5ce5ca410b3646f355279e4e937d452e622
Gitweb:     https://git.kernel.org/tip/5423f5ce5ca410b3646f355279e4e937d452e622
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 18 Jun 2019 22:31:40 +0200
Committer:  Borislav Petkov <bp@suse.de>
CommitDate: Wed, 19 Jun 2019 09:16:35 +0200

x86/microcode: Fix the microcode load on CPU hotplug for real

A recent change moved the microcode loader hotplug callback into the early
startup phase which is running with interrupts disabled. It missed that
the callbacks invoke sysfs functions which might sleep causing nice 'might
sleep' splats with proper debugging enabled.

Split the callbacks and only load the microcode in the early startup phase
and move the sysfs handling back into the later threaded and preemptible
bringup phase where it was before.

Fixes: 78f4e932f776 ("x86/microcode, cpuhotplug: Add a microcode loader CPU hotplug callback")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: stable@vger.kernel.org
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1906182228350.1766@nanos.tec.linutronix.de
---
 arch/x86/kernel/cpu/microcode/core.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index a813987b5552..cb0fdcaf1415 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -789,13 +789,16 @@ static struct syscore_ops mc_syscore_ops = {
 	.resume			= mc_bp_resume,
 };
 
-static int mc_cpu_online(unsigned int cpu)
+static int mc_cpu_starting(unsigned int cpu)
 {
-	struct device *dev;
-
-	dev = get_cpu_device(cpu);
 	microcode_update_cpu(cpu);
 	pr_debug("CPU%d added\n", cpu);
+	return 0;
+}
+
+static int mc_cpu_online(unsigned int cpu)
+{
+	struct device *dev = get_cpu_device(cpu);
 
 	if (sysfs_create_group(&dev->kobj, &mc_attr_group))
 		pr_err("Failed to create group for CPU%d\n", cpu);
@@ -872,7 +875,9 @@ int __init microcode_init(void)
 		goto out_ucode_group;
 
 	register_syscore_ops(&mc_syscore_ops);
-	cpuhp_setup_state_nocalls(CPUHP_AP_MICROCODE_LOADER, "x86/microcode:online",
+	cpuhp_setup_state_nocalls(CPUHP_AP_MICROCODE_LOADER, "x86/microcode:starting",
+				  mc_cpu_starting, NULL);
+	cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "x86/microcode:online",
 				  mc_cpu_online, mc_cpu_down_prep);
 
 	pr_info("Microcode Update Driver: v%s.", DRIVER_VERSION);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] x86/microcode: Fix the microcode load on CPU hotplug for real
  2019-06-18 20:31 [PATCH] x86/microcode: Fix the microcode load on CPU hotplug for real Thomas Gleixner
  2019-06-18 20:34 ` Borislav Petkov
  2019-06-19  7:31 ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
@ 2019-06-26 17:20 ` Evan Green
  2 siblings, 0 replies; 4+ messages in thread
From: Evan Green @ 2019-06-26 17:20 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, x86, Borislav Petkov

On Tue, Jun 18, 2019 at 1:31 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> A recent change moved the microcode loader hotplug callback into the early
> startup phase, which is running with interrupts disabled. It missed that
> the callbacks invoke sysfs functions which might sleep causing nice 'might
> sleep' splats with proper debugging enabled.
>
> Split the callbacks and only load the microcode in the early startup phase
> and move the sysfs handling back into the later threaded and preemptible
> bringup phase where it was before.
>
> Fixes: 78f4e932f776 ("x86/microcode, cpuhotplug: Add a microcode loader CPU hotplug callback")
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

I ran into the bug fixed by this. For 4.19:
Tested-by: Evan Green <evgreen@chromium.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-26 17:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18 20:31 [PATCH] x86/microcode: Fix the microcode load on CPU hotplug for real Thomas Gleixner
2019-06-18 20:34 ` Borislav Petkov
2019-06-19  7:31 ` [tip:x86/urgent] " tip-bot for Thomas Gleixner
2019-06-26 17:20 ` [PATCH] " Evan Green

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).