Skip to contentSkip to conversation

x86, amd_ucode: Skip microcode updates for final levels

PATCH Superseded Aravind Gopalakrishnan 3 participants 6 messages Jul 30, 2015 – Jul 31, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, amd_ucode: Skip microcode updates for final levels

Some of older[Fam10h] systems require that the microcode versions that it comes up with should not be updated by the microcode driver. Otherwise, system hangs are known to occur.

In this patch, we check for those microcode versions and abort the update process if existing microcode level is already applied by the BIOS.

A linux version of the patch has already made it into tip-
http://marc.info/?l=linux-kernel&m=143703405627170

---
 xen/arch/x86/microcode_amd.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
xen/arch/x86/microcode_amd.c +31 -0
index f79b397..c958a47 100644
@@ -347,6 +347,30 @@ static int container_fast_forward(const void *data, size_t size_left, size_t *of
     return 0;
 }
 
+static unsigned int final_levels[] = {
+    0x01000098,
+    0x0100009f,
+    0x010000af,
+    0
+};
+
+static bool_t check_final_patch_levels(int cpu)
+{
+    /*
+     * Check the current patch levels on the cpu. If they are equal to
+     * any of the 'final_levels', then we should not update the microcode
+     * patch on the cpu as system will hang otherwise.
+     */
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
+    int i;
+
+    for ( i = 0; final_levels[i]; i++ )
+        if ( uci->cpu_sig.rev == final_levels[i] )
+            return 1;
+
+    return 0;
+}
+
 static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize)
 {
     struct microcode_amd *mc_amd, *mc_old;
@@ -369,6 +393,13 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize)
         goto out;
     }
 
+    if ( check_final_patch_levels(cpu) )
+    {
+        pr_debug("microcode: Cannot update microcode patch on the cpu as we hit a final level\n");
+        error = -EPERM;
+        goto out;
+    }
+
     mc_amd = xmalloc(struct microcode_amd);
     if ( !mc_amd )
     {
Signature · 1 line
1.9.1
#1 lore raw
Quoted 21 lines · Aravind Gopalakrishnan

Some of older[Fam10h] systems require that the microcode versions that it comes up with should not be updated by the microcode driver. Otherwise, system hangs are known to occur.

In this patch, we check for those microcode versions and abort the update process if existing microcode level is already applied by the BIOS.

A linux version of the patch has already made it into tip-
http://marc.info/?l=linux-kernel&m=143703405627170

---
  xen/arch/x86/microcode_amd.c | 31 +++++++++++++++++++++++++++++++
  1 file changed, 31 insertions(+)
xen/arch/x86/microcode_amd.c +0 -0
index f79b397..c958a47 100644

xen/arch/x86/microcode_amd.c static int container_fast_forward(const void *data, size_t size_left, size_t *of · line 355

Quoted 9 lines
xen/arch/x86/microcode_amd.c +6 -0
@@ -347,6 +347,30 @@ static int container_fast_forward(const void *data, size_t size_left, size_t *of
      return 0;
  }
 
+static unsigned int final_levels[] = {
+    0x01000098,
+    0x0100009f,
+    0x010000af,
+    0
+};

Are these values documented somewhere?

-boris

Quoted 35 lines
xen/arch/x86/microcode_amd.c +25 -0
+
+static bool_t check_final_patch_levels(int cpu)
+{
+    /*
+     * Check the current patch levels on the cpu. If they are equal to
+     * any of the 'final_levels', then we should not update the microcode
+     * patch on the cpu as system will hang otherwise.
+     */
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
+    int i;
+
+    for ( i = 0; final_levels[i]; i++ )
+        if ( uci->cpu_sig.rev == final_levels[i] )
+            return 1;
+
+    return 0;
+}
+
  static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize)
  {
      struct microcode_amd *mc_amd, *mc_old;
@@ -369,6 +393,13 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize)
          goto out;
      }
 
+    if ( check_final_patch_levels(cpu) )
+    {
+        pr_debug("microcode: Cannot update microcode patch on the cpu as we hit a final level\n");
+        error = -EPERM;
+        goto out;
+    }
+
      mc_amd = xmalloc(struct microcode_amd);
      if ( !mc_amd )
      {
#2 lore raw
In reply to Aravind Gopalakrishnan
Quoted 21 lines · Aravind Gopalakrishnan

Some of older[Fam10h] systems require that the microcode versions that it comes up with should not be updated by the microcode driver. Otherwise, system hangs are known to occur.

In this patch, we check for those microcode versions and abort the update process if existing microcode level is already applied by the BIOS.

A linux version of the patch has already made it into tip-
http://marc.info/?l=linux-kernel&m=143703405627170

---
 xen/arch/x86/microcode_amd.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
xen/arch/x86/microcode_amd.c +0 -0
index f79b397..c958a47 100644

xen/arch/x86/microcode_amd.c static int container_fast_forward(const void *data, size_t size_left, size_t *of · line 349

Quoted 3 lines
xen/arch/x86/microcode_amd.c +0 -0
@@ -347,6 +347,30 @@ static int container_fast_forward(const void *data, size_t size_left, size_t *of
     return 0;
 }
 

Please include the same comment as the Linux patch, explaining that these microcode versions can't be updated from.

I would also like to see some documentation from AMD concerning this.

Quoted 6 lines
xen/arch/x86/microcode_amd.c +6 -0
+static unsigned int final_levels[] = {
+    0x01000098,
+    0x0100009f,
+    0x010000af,
+    0
+};

xen/arch/x86/microcode_amd.c static int container_fast_forward(const void *data, size_t size_left, size_t *of · line 365

Quoted 10 lines
xen/arch/x86/microcode_amd.c +10 -0
+
+static bool_t check_final_patch_levels(int cpu)
+{
+    /*
+     * Check the current patch levels on the cpu. If they are equal to
+     * any of the 'final_levels', then we should not update the microcode
+     * patch on the cpu as system will hang otherwise.
+     */
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
+    int i;

unsigned

xen/arch/x86/microcode_amd.c static int container_fast_forward(const void *data, size_t size_left, size_t *of · line 367

Quoted 2 lines
xen/arch/x86/microcode_amd.c +2 -0
+
+    for ( i = 0; final_levels[i]; i++ )

ARRAY_SIZE(), and drop the 0 on the end of the list.

Quoted 10 lines
xen/arch/x86/microcode_amd.c +6 -0
+        if ( uci->cpu_sig.rev == final_levels[i] )
+            return 1;
+
+    return 0;
+}
+
 static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize)
 {
     struct microcode_amd *mc_amd, *mc_old;

xen/arch/x86/microcode_amd.c static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize) · line 398

Quoted 6 lines
xen/arch/x86/microcode_amd.c +3 -0
@@ -369,6 +393,13 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize)
         goto out;
     }
 
+    if ( check_final_patch_levels(cpu) )
+    {
+        pr_debug("microcode: Cannot update microcode patch on the cpu as we hit a final level\n");

pr_debug() is compiled out completely. I would suggest printk(XENLOG_INFO instead.

~Andrew

Quoted 7 lines
xen/arch/x86/microcode_amd.c +4 -0
+        error = -EPERM;
+        goto out;
+    }
+
     mc_amd = xmalloc(struct microcode_amd);
     if ( !mc_amd )
     {
#3 lore raw
Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Aravind Gopalakrishnan

Some of older[Fam10h] systems require that the microcode versions that it comes up with should not be updated by the microcode driver. Otherwise, system hangs are known to occur.

In this patch, we check for those microcode versions and abort the update process if existing microcode level is already applied by the BIOS.

A linux version of the patch has already made it into tip-
http://marc.info/?l=linux-kernel&m=143703405627170

---
  xen/arch/x86/microcode_amd.c | 31 +++++++++++++++++++++++++++++++
  1 file changed, 31 insertions(+)
Quoted 10 lines

xen/arch/x86/microcode_amd.c static int container_fast_forward(const void *data, size_t size_left, size_t *of · line 349

Quoted 8 lines
xen/arch/x86/microcode_amd.c +0 -0
index f79b397..c958a47 100644
@@ -347,6 +347,30 @@ static int container_fast_forward(const void *data, size_t size_left, size_t *of
      return 0;
  }
 

Please include the same comment as the Linux patch, explaining that these microcode versions can't be updated from.

Ok, will do that.

Quoted 1 line

I would also like to see some documentation from AMD concerning this.

(hopefully) answering Boris' question too here-

So, the patch id values have only been obtained empirically.
The Linux patch provides the bug reference for this:https://bugzilla.suse.com/show_bug.cgi?id=913996 (It's a fairly long thread but the gist of it is that people predominantly seem to be experiencing system hang issues when they try to update microcode levels from these patch ids: 0x01000098, 0x0100009f, 0x010000af)

From discussing about it internally, we gathered that OS/hypervisor cannot reliably perform microcode updates beyond these specified levels due to HW issues.

Quoted 9 lines
Quoted 9 lines
xen/arch/x86/microcode_amd.c +9 -0
+static unsigned int final_levels[] = {
+    0x01000098,
+    0x0100009f,
+    0x010000af,
+    0
+};
+
+static bool_t check_final_patch_levels(int cpu)
+{
Quoted 8 lines

xen/arch/x86/microcode_amd.c static int container_fast_forward(const void *data, size_t size_left, size_t *of · line 365

Quoted 7 lines
xen/arch/x86/microcode_amd.c +7 -0
+    /*
+     * Check the current patch levels on the cpu. If they are equal to
+     * any of the 'final_levels', then we should not update the microcode
+     * patch on the cpu as system will hang otherwise.
+     */
+    struct ucode_cpu_info *uci = &per_cpu(ucode_cpu_info, cpu);
+    int i;

unsigned

Will fix this.

Quoted 3 lines

xen/arch/x86/microcode_amd.c static int container_fast_forward(const void *data, size_t size_left, size_t *of · line 367

Quoted 2 lines
xen/arch/x86/microcode_amd.c +2 -0
+
+    for ( i = 0; final_levels[i]; i++ )

ARRAY_SIZE(), and drop the 0 on the end of the list.

Ok, will fix.

Quoted 13 lines
Quoted 13 lines
xen/arch/x86/microcode_amd.c +6 -0
+        if ( uci->cpu_sig.rev == final_levels[i] )
+            return 1;
+
+    return 0;
+}
+
  static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize)
  {
      struct microcode_amd *mc_amd, *mc_old;
@@ -369,6 +393,13 @@ static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize)
          goto out;
      }
 
Quoted 5 lines

xen/arch/x86/microcode_amd.c static int cpu_request_microcode(int cpu, const void *buf, size_t bufsize) · line 398

Quoted 3 lines
xen/arch/x86/microcode_amd.c +3 -0
+    if ( check_final_patch_levels(cpu) )
+    {
+        pr_debug("microcode: Cannot update microcode patch on the cpu as we hit a final level\n");

pr_debug() is compiled out completely. I would suggest printk(XENLOG_INFO instead.

Ok, Will fix this and send out a V2 with the changes.

Thanks,
-Aravind.

#4 lore raw
Quoted 45 lines · Aravind Gopalakrishnan
Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Aravind Gopalakrishnan

Some of older[Fam10h] systems require that the microcode versions that it comes up with should not be updated by the microcode driver. Otherwise, system hangs are known to occur.

In this patch, we check for those microcode versions and abort the update process if existing microcode level is already applied by the BIOS.

A linux version of the patch has already made it into tip-
http://marc.info/?l=linux-kernel&m=143703405627170

---
  xen/arch/x86/microcode_amd.c | 31 +++++++++++++++++++++++++++++++
  1 file changed, 31 insertions(+)
Quoted 12 lines

xen/arch/x86/microcode_amd.c static int container_fast_forward(const void · line 350

Quoted 10 lines
xen/arch/x86/microcode_amd.c +0 -0
index f79b397..c958a47 100644
@@ -347,6 +347,30 @@ static int container_fast_forward(const void
 *data, size_t size_left, size_t *of
      return 0;
  }
 

Please include the same comment as the Linux patch, explaining that these microcode versions can't be updated from.

Ok, will do that.

Quoted 1 line

I would also like to see some documentation from AMD concerning this.

(hopefully) answering Boris' question too here-

So, the patch id values have only been obtained empirically. The Linux patch provides the bug reference for this:https://bugzilla.suse.com/show_bug.cgi?id=913996 (It's a fairly long thread but the gist of it is that people predominantly seem to be experiencing system hang issues when they try to update microcode levels from these patch ids:
0x01000098, 0x0100009f, 0x010000af)

Quoted 3 lines

From discussing about it internally, we gathered that OS/hypervisor cannot reliably perform microcode updates beyond these specified levels due to HW issues.

Ok - please include this information in the comment as well please.

~Andrew

#5 lore raw
Quoted 9 lines · Andrew Cooper
Quoted 9 lines

So, the patch id values have only been obtained empirically. The Linux patch provides the bug reference for this:https://bugzilla.suse.com/show_bug.cgi?id=913996 (It's a fairly long thread but the gist of it is that people predominantly seem to be experiencing system hang issues when they try to update microcode levels from these patch ids:
0x01000098, 0x0100009f, 0x010000af)

Quoted 5 lines
Quoted 3 lines

From discussing about it internally, we gathered that OS/hypervisor
cannot reliably perform microcode updates beyond these specified levels due to HW issues.

Ok - please include this information in the comment as well please.

Will do that.

Thanks,
-Aravind.