Skip to contentSkip to conversation

x86/microcode: Handle negative microcode revisions

PATCH Superseded Andi Kleen 3 participants 3 messages Oct 20, 2018 – Oct 25, 2018

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH v2 1/1 x86/microcode: Handle negative microcode revisions

From: Andi Kleen <[email protected]>

The Intel microcode 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 microcode revision 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 microcode revision 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.

Cc [email protected] # Any supported stable

--
v2: White space changes.

---
 arch/x86/kernel/cpu/microcode/intel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/microcode/intel.c +2 -1
index 16936a24795c..e54d402500d3 100644
@@ -93,7 +93,8 @@ 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;
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Dropping stable.

Quoted 29 lines · Andi Kleen

From: Andi Kleen <[email protected]>

The Intel microcode 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 microcode revision 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 microcode revision 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.

Cc [email protected] # Any supported stable

--
v2: White space changes.

---
 arch/x86/kernel/cpu/microcode/intel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/microcode/intel.c +0 -0
index 16936a24795c..e54d402500d3 100644

arch/x86/kernel/cpu/microcode/intel.c static int find_matching_signature(void *mc, unsigned int csig, int cpf) · line 100

Quoted 9 lines
arch/x86/kernel/cpu/microcode/intel.c +2 -1
@@ -93,7 +93,8 @@ 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;
 

Please incorporate all review comments before sending a new version of your patch.

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
#2 lore raw
Quoted 40 lines · Borislav Petkov

Dropping stable.

Quoted 37 lines · Andi Kleen

From: Andi Kleen <[email protected]>

The Intel microcode 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 microcode revision 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 microcode revision 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.

Cc [email protected] # Any supported stable

--
v2: White space changes.

---
 arch/x86/kernel/cpu/microcode/intel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/microcode/intel.c +2 -1
index 16936a24795c..e54d402500d3 100644
@@ -93,7 +93,8 @@ 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;
 
Quoted 4 lines
Quoted 1 line

Please incorporate all review comments before sending a new version of your patch.

I replaced one more microcodes with microcodes revisions if that is what you meant.

-Andi