Skip to contentSkip to conversation

Late microcode

PATCH In review Josh Poimboeuf 4 participants 6 messages Aug 9, 2018 – Aug 10, 2018

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

PATCH 1/1 Late microcode

From: Josh Poimboeuf <[email protected]>
Subject: [PATCH] x86/microcode: Allow late microcode loading with SMT disabled

The kernel unnecessarily prevents late microcode loading when SMT is disabled. It should be safe to allow it if all the primary threads are online.

---
 arch/x86/kernel/cpu/microcode/core.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/microcode/core.c +12 -4
index 08286269fd24..b9bc8a1a584e 100644
@@ -509,12 +509,20 @@ static struct platform_device	*microcode_pdev;
 
 static int check_online_cpus(void)
 {
-	if (num_online_cpus() == num_present_cpus())
-		return 0;
+	unsigned int cpu;
 
-	pr_err("Not all CPUs online, aborting microcode update.\n");
+	/*
+	 * Make sure all CPUs are online.  It's fine for SMT to be disabled if
+	 * all the primary threads are still online.
+	 */
+	for_each_present_cpu(cpu) {
+		if (topology_is_primary_thread(cpu) && !cpu_online(cpu)) {
+			pr_err("Not all CPUs online, aborting microcode update.\n");
+			return -EINVAL;
+		}
+	}
 
-	return -EINVAL;
+	return 0;
 }
 
 static atomic_t late_cpus_in;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 6 lines · speck for Josh Poimboeuf

From: Josh Poimboeuf <[email protected]>
Subject: [PATCH] x86/microcode: Allow late microcode loading with SMT disabled

The kernel unnecessarily prevents late microcode loading when SMT is disabled. It should be safe to allow it if all the primary threads are online.

Yes that should be safe.

Quoted 22 lines
---
 arch/x86/kernel/cpu/microcode/core.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
arch/x86/kernel/cpu/microcode/core.c +5 -3
index 08286269fd24..b9bc8a1a584e 100644
@@ -509,12 +509,20 @@ static struct platform_device	*microcode_pdev;
 
 static int check_online_cpus(void)
 {
-	if (num_online_cpus() == num_present_cpus())
-		return 0;
+	unsigned int cpu;
 
-	pr_err("Not all CPUs online, aborting microcode update.\n");
+	/*
+	 * Make sure all CPUs are online.  It's fine for SMT to be disabled if
+	 * all the primary threads are still online.
+	 */

arch/x86/kernel/cpu/microcode/core.c static struct platform_device *microcode_pdev; · line 526

Quoted 10 lines
arch/x86/kernel/cpu/microcode/core.c +7 -1
+	for_each_present_cpu(cpu) {
+		if (topology_is_primary_thread(cpu) && !cpu_online(cpu)) {
+			pr_err("Not all CPUs online, aborting microcode update.\n");
+			return -EINVAL;
+		}
+	}
 
-	return -EINVAL;
+	return 0;
 }

I'll pick that up tomorrow. Camp fire is more interesting than this ....

#2 lore raw
Quoted 10 lines · speck for Thomas Gleixner
Quoted 6 lines · speck for Josh Poimboeuf

From: Josh Poimboeuf <[email protected]>
Subject: [PATCH] x86/microcode: Allow late microcode loading with SMT disabled

The kernel unnecessarily prevents late microcode loading when SMT is disabled. It should be safe to allow it if all the primary threads are online.

Yes that should be safe.

... since the microcode engine is shared between the threads so when the offlined ones come online, they will see updated microcode. Which is, probably, ok.

Oh well, let's try it:

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 12 lines · speck for Borislav Petkov
Quoted 10 lines · speck for Thomas Gleixner

On Thu, 9 Aug 2018, speck for Josh Poimboeuf wrote:

Quoted 6 lines

From: Josh Poimboeuf <[email protected]>
Subject: [PATCH] x86/microcode: Allow late microcode loading with SMT disabled
The kernel unnecessarily prevents late microcode loading when SMT is disabled.  It should be safe to allow it if all the primary threads are online.


Yes that should be safe.

Quoted 7 lines

... since the microcode engine is shared between the threads so when the offlined ones come online, they will see updated microcode. Which is, probably, ok.

Oh well, let's try it:

I've pushed this to all the branches; we'll let Thomas enjoy the ashes of the camp fire for a little longer.

4.9 didn't actually have that online check at all. It does now.

#4 lore raw
Quoted 4 lines · speck for David Woodhouse

I've pushed this to all the branches; we'll let Thomas enjoy the ashes of the camp fire for a little longer.

4.9 didn't actually have that online check at all. It does now.

You probably should drop it altogether instead because the online check is part of a series containing a synchronization dance to make late microcode upgrade more robust. And looking at 4.9.119, it doesn't have them backported so you could safely ignore that fix for 4.9, I'd say...

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 10 lines · speck for Borislav Petkov
Quoted 4 lines · speck for David Woodhouse

I've pushed this to all the branches; we'll let Thomas enjoy the ashes of the camp fire for a little longer.

4.9 didn't actually have that online check at all. It does now.

You probably should drop it altogether instead because the online check is part of a series containing a synchronization dance to make late microcode upgrade more robust. And looking at 4.9.119, it doesn't have them backported so you could safely ignore that fix for 4.9, I'd say...

Yeah it was a close thing — but the 'only upgrade if we can do all CPUs' part can stand alone anyway, even without the other changes.