linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] x86/microcode: Handle negative microcode revisions
@ 2018-10-20  0:11 Andi Kleen
  2018-10-20  8:37 ` Borislav Petkov
  2018-10-20 13:42 ` Thomas Gleixner
  0 siblings, 2 replies; 4+ messages in thread
From: Andi Kleen @ 2018-10-20  0:11 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel, Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

The Intel ucode revision space is unsigned. Inside Intel there are special
microcodes that have the highest bit set, and they are considered to have
a higher revision than any microcodes that don't have this bit set.

The function comparing the microcodes in the Linux driver compares
u32 with int, which ends up being signed extended to long on 64bit
systems. This results in these highest bit set microcodes not loading
because their revision appears negative and smaller than the
existing microcode.

Change the comparison to unsigned. With that the loading works
as expected.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 arch/x86/kernel/cpu/microcode/intel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 16936a24795c..e95cebdd5993 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -93,7 +93,7 @@ static int find_matching_signature(void *mc, unsigned int csig, int cpf)
 /*
  * Returns 1 if update has been found, 0 otherwise.
  */
-static int has_newer_microcode(void *mc, unsigned int csig, int cpf, int new_rev)
+static int has_newer_microcode(void *mc, unsigned int csig, int cpf, unsigned new_rev)
 {
 	struct microcode_header_intel *mc_hdr = mc;
 
-- 
2.17.1


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

* Re: [PATCH v1] x86/microcode: Handle negative microcode revisions
  2018-10-20  0:11 [PATCH v1] x86/microcode: Handle negative microcode revisions Andi Kleen
@ 2018-10-20  8:37 ` Borislav Petkov
  2018-10-20 13:42 ` Thomas Gleixner
  1 sibling, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2018-10-20  8:37 UTC (permalink / raw)
  To: Andi Kleen; +Cc: x86, linux-kernel, Andi Kleen

On Fri, Oct 19, 2018 at 05:11:37PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> The Intel ucode revision space is unsigned. Inside Intel there are special

s/ucode/microcode/g

> microcodes that have the highest bit set, and they are considered to have

s/microcodes/microcode revisions/g

> a higher revision than any microcodes that don't have this bit set.
> 
> The function comparing the microcodes in the Linux driver compares
> u32 with int, which ends up being signed extended to long on 64bit
> systems. This results in these highest bit set microcodes not loading
> because their revision appears negative and smaller than the
> existing microcode.
> 
> Change the comparison to unsigned. With that the loading works
> as expected.
> 
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
>  arch/x86/kernel/cpu/microcode/intel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
> index 16936a24795c..e95cebdd5993 100644
> --- a/arch/x86/kernel/cpu/microcode/intel.c
> +++ b/arch/x86/kernel/cpu/microcode/intel.c
> @@ -93,7 +93,7 @@ static int find_matching_signature(void *mc, unsigned int csig, int cpf)
>  /*
>   * Returns 1 if update has been found, 0 otherwise.
>   */
> -static int has_newer_microcode(void *mc, unsigned int csig, int cpf, int new_rev)
> +static int has_newer_microcode(void *mc, unsigned int csig, int cpf, unsigned new_rev)

I'm gonna let you run checkpatch yourself to find out what the problem
here is.

-- 
Regards/Gruss,
    Boris.

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

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

* Re: [PATCH v1] x86/microcode: Handle negative microcode revisions
  2018-10-20  0:11 [PATCH v1] x86/microcode: Handle negative microcode revisions Andi Kleen
  2018-10-20  8:37 ` Borislav Petkov
@ 2018-10-20 13:42 ` Thomas Gleixner
  2018-10-20 14:13   ` Andi Kleen
  1 sibling, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2018-10-20 13:42 UTC (permalink / raw)
  To: Andi Kleen; +Cc: x86, linux-kernel, Andi Kleen

Andi,

On Fri, 19 Oct 2018, Andi Kleen wrote:
> Change the comparison to unsigned. With that the loading works
> as expected.
>

I assume that wants a fixes tag and needs to be backported to stable,
right?

Thanks,

	tglx

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

* Re: [PATCH v1] x86/microcode: Handle negative microcode revisions
  2018-10-20 13:42 ` Thomas Gleixner
@ 2018-10-20 14:13   ` Andi Kleen
  0 siblings, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2018-10-20 14:13 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Andi Kleen, x86, linux-kernel

On Sat, Oct 20, 2018 at 03:42:05PM +0200, Thomas Gleixner wrote:
> Andi,
> 
> On Fri, 19 Oct 2018, Andi Kleen wrote:
> > Change the comparison to unsigned. With that the loading works
> > as expected.
> >
> 
> I assume that wants a fixes tag and needs to be backported to stable,
> right?

I think the bug was there since the original microcode loader, not
sure I can dig out the right commit id for that (it might be
in linux-historic)

Yes please cc stable for this.

-Andi

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

end of thread, other threads:[~2018-10-20 14:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-20  0:11 [PATCH v1] x86/microcode: Handle negative microcode revisions Andi Kleen
2018-10-20  8:37 ` Borislav Petkov
2018-10-20 13:42 ` Thomas Gleixner
2018-10-20 14:13   ` Andi Kleen

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).