All of lore.kernel.org
 help / color / mirror / Atom feed
* [MODERATED] [PATCH] Late microcode
@ 2018-08-09 19:03 Josh Poimboeuf
  2018-08-09 19:13 ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: Josh Poimboeuf @ 2018-08-09 19:03 UTC (permalink / raw)
  To: speck

From: Josh Poimboeuf <jpoimboe@redhat.com>
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.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 arch/x86/kernel/cpu/microcode/core.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index 08286269fd24..b9bc8a1a584e 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -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;
-- 
2.17.1

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

* Re: [PATCH] Late microcode
  2018-08-09 19:03 [MODERATED] [PATCH] Late microcode Josh Poimboeuf
@ 2018-08-09 19:13 ` Thomas Gleixner
  2018-08-10  3:28   ` [MODERATED] " Borislav Petkov
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Gleixner @ 2018-08-09 19:13 UTC (permalink / raw)
  To: speck

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

> From: Josh Poimboeuf <jpoimboe@redhat.com>
> 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.

> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> ---
>  arch/x86/kernel/cpu/microcode/core.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
> index 08286269fd24..b9bc8a1a584e 100644
> --- a/arch/x86/kernel/cpu/microcode/core.c
> +++ b/arch/x86/kernel/cpu/microcode/core.c
> @@ -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;
>  }

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

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

* [MODERATED] Re: [PATCH] Late microcode
  2018-08-09 19:13 ` Thomas Gleixner
@ 2018-08-10  3:28   ` Borislav Petkov
  2018-08-10  7:45     ` David Woodhouse
  0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2018-08-10  3:28 UTC (permalink / raw)
  To: speck

On Thu, Aug 09, 2018 at 09:13:21PM +0200, speck for Thomas Gleixner wrote:
> On Thu, 9 Aug 2018, speck for Josh Poimboeuf wrote:
> 
> > From: Josh Poimboeuf <jpoimboe@redhat.com>
> > 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:

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

-- 
Regards/Gruss,
    Boris.

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

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

* [MODERATED] Re: [PATCH] Late microcode
  2018-08-10  3:28   ` [MODERATED] " Borislav Petkov
@ 2018-08-10  7:45     ` David Woodhouse
  2018-08-10  8:51       ` Borislav Petkov
  0 siblings, 1 reply; 6+ messages in thread
From: David Woodhouse @ 2018-08-10  7:45 UTC (permalink / raw)
  To: speck



On Fri, 2018-08-10 at 05:28 +0200, speck for Borislav Petkov wrote:
> n Thu, Aug 09, 2018 at 09:13:21PM +0200, speck for Thomas Gleixner wrote:
> > On Thu, 9 Aug 2018, speck for Josh Poimboeuf wrote:
> > 
> > > From: Josh Poimboeuf <jpoimboe@redhat.com>
> > > 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:
> 
> Acked-by: Borislav Petkov <bp@suse.de>

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.

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

* [MODERATED] Re: [PATCH] Late microcode
  2018-08-10  7:45     ` David Woodhouse
@ 2018-08-10  8:51       ` Borislav Petkov
  2018-08-10  9:17         ` David Woodhouse
  0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2018-08-10  8:51 UTC (permalink / raw)
  To: speck

On Fri, Aug 10, 2018 at 08:45:20AM +0100, speck for David Woodhouse wrote:
> 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...

-- 
Regards/Gruss,
    Boris.

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

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

* [MODERATED] Re: [PATCH] Late microcode
  2018-08-10  8:51       ` Borislav Petkov
@ 2018-08-10  9:17         ` David Woodhouse
  0 siblings, 0 replies; 6+ messages in thread
From: David Woodhouse @ 2018-08-10  9:17 UTC (permalink / raw)
  To: speck

On Fri, 2018-08-10 at 10:51 +0200, speck for Borislav Petkov wrote:
> On Fri, Aug 10, 2018 at 08:45:20AM +0100, speck for David Woodhouse wrote:
> > 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.

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

end of thread, other threads:[~2018-08-10  9:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-09 19:03 [MODERATED] [PATCH] Late microcode Josh Poimboeuf
2018-08-09 19:13 ` Thomas Gleixner
2018-08-10  3:28   ` [MODERATED] " Borislav Petkov
2018-08-10  7:45     ` David Woodhouse
2018-08-10  8:51       ` Borislav Petkov
2018-08-10  9:17         ` David Woodhouse

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.