x86/ucode: Work around Granite Rapids erraturm GNR98
PATCH 1/1 x86/ucode: Work around Granite Rapids erraturm GNR98
Block loads which are known to hang the system.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Teddy Astie <[email protected]>
A more complete solution is in the works, but it's taken 4 months to get this much published...
--- xen/arch/x86/cpu/microcode/intel.c | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
xen/arch/x86/cpu/microcode/intel.c +31 -0
@@ -27,6 +27,7 @@#include <xen/string.h> #include <xen/xmalloc.h> +#include <asm/intel-family.h> #include <asm/msr.h> #include <asm/processor.h> #include <asm/system.h>
@@ -273,6 +274,35 @@ static bool microcode_fits_cpu(const struct microcode_patch *mc)return false; } +static bool microcode_safe_to_load (const struct microcode_patch *mc) +{ +struct cpu_signature *cpu_sig = &this_cpu (cpu_sig); + +/* +* Treat pre-production as always safe - anyone using pre-production +* microcode knows what they are doing, and can keep any resulting pieces. +*/ +if ( cpu_sig->rev <0 || mc->rev <0 ) +return true; + +/* +* GNR98. Granite Rapids systems hang when loading new ucode on +* sufficiently old firmware. +*/ +if ( boot_cpu_data.vfm ==INTEL_GRANITERAPIDS_X && + boot_cpu_data.stepping ==1 && (cpu_sig->pf &0x95 ) && + cpu_sig->rev <0x01000405 && + mc->rev >0x01000405 ) + { +printk_once (XENLOG_WARNING +"microcode: Granite Rapids erratum GNR98 detected. Skipping ucode 0x%08x\n" +"microcode: Firmware update recommended\n" , mc->rev); +return false; + } + +return true; +} + static int cf_check intel_compare(const struct microcode_patch *old,const struct microcode_patch *new) {
@@ -365,6 +395,7 @@ static struct microcode_patch *cf_check intel_ucode_parse(* one with higher revision. */ if (microcode_fits_cpu (mc) && +microcode_safe_to_load (mc) && (!saved ||compare_revisions (saved->rev, mc->rev) ==NEW_UCODE ) ) saved = mc;
Signature · 1 line
2.39.5
Le 03/09/2026 à 00:14, Andrew Cooper a écrit :
Quoted 29 lines
Block loads which are known to hang the system.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Teddy Astie <[email protected]>A more complete solution is in the works, but it's taken 4 months to get this much published...
--- xen/arch/x86/cpu/microcode/intel.c | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)xen/arch/x86/cpu/microcode/intel.c +1
-0@@ -27,6 +27,7 @@#include <xen/string.h> #include <xen/xmalloc.h> +#include <asm/intel-family.h> #include <asm/msr.h> #include <asm/processor.h> #include <asm/system.h> @@ -273,6 +274,35 @@ static bool microcode_fits_cpu(const struct microcode_patch *mc)return false; }
xen/arch/x86/cpu/microcode/intel.c static bool microcode_fits_cpu(const struct microcode_patch *mc) · line 285
Quoted 10 lines
xen/arch/x86/cpu/microcode/intel.c +9
-0+static bool microcode_safe_to_load (const struct microcode_patch *mc) +{ +struct cpu_signature *cpu_sig = &this_cpu (cpu_sig); + +/* +* Treat pre-production as always safe - anyone using pre-production +* microcode knows what they are doing, and can keep any resulting pieces. +*/ +if ( cpu_sig->rev <0 || mc->rev <0 )
cpu_sig->rev can't be negative as it's unsigned int.
I guess that's something to fix in our struct cpu_signature and how we get it. Though the structure is shared with AMD, and I don't know if it also uses "negative" revisions for non-production ucode (PPR doesn't tell anything in that regard).
Quoted 24 lines
xen/arch/x86/cpu/microcode/intel.c +20
-0+return true; + +/* +* GNR98. Granite Rapids systems hang when loading new ucode on +* sufficiently old firmware. +*/ +if ( boot_cpu_data.vfm ==INTEL_GRANITERAPIDS_X && + boot_cpu_data.stepping ==1 && (cpu_sig->pf &0x95 ) && + cpu_sig->rev <0x01000405 && + mc->rev >0x01000405 ) + { +printk_once (XENLOG_WARNING +"microcode: Granite Rapids erratum GNR98 detected. Skipping ucode 0x%08x\n" +"microcode: Firmware update recommended\n" , mc->rev); +return false; + } + +return true; +} + static int cf_check intel_compare(const struct microcode_patch *old,const struct microcode_patch *new) {
xen/arch/x86/cpu/microcode/intel.c static struct microcode_patch *cf_check intel_ucode_parse( · line 401
Quoted 7 lines
xen/arch/x86/cpu/microcode/intel.c +1
-0@@ -365,6 +395,7 @@ static struct microcode_patch *cf_check intel_ucode_parse(* one with higher revision. */ if (microcode_fits_cpu (mc) && +microcode_safe_to_load (mc) && (!saved ||compare_revisions (saved->rev, mc->rev) ==NEW_UCODE ) ) saved = mc;
The rest looks good to me; as my concern is unrelated to change itself (and doesn't affect production microcode anyway).
Quoted 5 lines · Teddy Astie
Le 03/09/2026 à 00:14, Andrew Cooper a écrit :
Quoted 4 lines
xen/arch/x86/cpu/microcode/intel.c +0
-0@@ -273,6 +274,35 @@ static bool microcode_fits_cpu(const struct microcode_patch *mc)return false; }
Quoted 11 lines
xen/arch/x86/cpu/microcode/intel.c static bool microcode_fits_cpu(const struct microcode_patch *mc) · line 285
Quoted 9 lines
xen/arch/x86/cpu/microcode/intel.c +9
-0+static bool microcode_safe_to_load (const struct microcode_patch *mc) +{ +struct cpu_signature *cpu_sig = &this_cpu (cpu_sig); + +/* +* Treat pre-production as always safe - anyone using pre-production +* microcode knows what they are doing, and can keep any resulting pieces. +*/ +if ( cpu_sig->rev <0 || mc->rev <0 )
cpu_sig->revcan't be negative as it's unsigned int.
With that I'm surprised the compiler doesn't flag this as "condition is always false" or alike. Surely Misra isn't going to like it either.
Jan
Quoted 41 lines · Teddy Astie
Le 03/09/2026 à 00:14, Andrew Cooper a écrit :
Quoted 40 lines
Block loads which are known to hang the system.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Teddy Astie <[email protected]>A more complete solution is in the works, but it's taken 4 months to get this
much published...
---
xen/arch/x86/cpu/microcode/intel.c| 31 ++++++++++++++++++++++++++++++1 file changed, 31 insertions(+)xen/arch/x86/cpu/microcode/intel.c +0
-0@@ -27,6 +27,7 @@ #include <xen/string.h> #include <xen/xmalloc.h>+#include <
asm/intel-family.h>
#include <asm/msr.h>
#include <asm/processor.h>
#include <asm/system.h>xen/arch/x86/cpu/microcode/intel.c +5
-0@@ -273,6 +274,35 @@ static bool microcode_fits_cpu(const struct microcode_patch *mc) return false; } +static bool microcode_safe_to_load(const struct microcode_patch *mc) +{ + struct cpu_signature *cpu_sig = &this_cpu(cpu_sig); + + /* +* Treat pre-production as always safe - anyone using pre-production
+ * microcode knows what they are doing, and can keep any resulting pieces.
Quoted 8 lines
Quoted 2 lines
+ */
+ if (cpu_sig->rev< 0 ||mc->rev< 0 )
cpu_sig->revcan't be negative as it's unsigned int.
I guess that's something to fix in our structcpu_signatureand how we get it. Though the structure is shared with AMD, and I don't know if it also uses "negative" revisions for non-production ucode (PPR doesn't tell anything in that regard).
Oops, yes. To answer Jan's question, GCC was perfectly happy with the logic in this form.
The field needs casting locally. It's officially unsigned according to both Intel and AMD, despite Intel actually using it as a sign-magnitude number indicating debugness.
Quoted 41 lines
Quoted 29 lines
+ return true;
+
+ /*
+ * GNR98. Granite Rapids systems hang when loading new ucode on + * sufficiently old firmware.
+ */
+ if ( boot_cpu_data.vfm ==INTEL_GRANITERAPIDS_X&&
+ boot_cpu_data.stepping == 1 && (cpu_sig->pf&0x95) && +cpu_sig->rev<0x01000405&&
+ mc->rev >0x01000405)
+ {
+ printk_once(XENLOG_WARNING
+ "microcode: Granite Rapids erratum GNR98 detected. Skipping ucode 0x%08x\n"
+ "microcode: Firmware update recommended\n",mc->rev);
+ return false;
+ }xen/arch/x86/cpu/microcode/intel.c +4
-0+ + return true; +} +static int
cf_checkintel_compare(
const structmicrocode_patch*old, const structmicrocode_patch*new)
{xen/arch/x86/cpu/microcode/intel.c +0
-0@@ -365,6 +395,7 @@ static struct microcode_patch *cf_checkintel_ucode_parse(
Quoted 8 lines
* one with higher revision.
*/
if (microcode_fits_cpu(mc)&&
+microcode_safe_to_load(mc)&&
(!saved ||compare_revisions(saved->rev, mc->rev)==NEW_UCODE) )
saved = mc;The rest looks good to me; as my concern is unrelated to change itself (and doesn't affect production microcode anyway).
Quoted 1 line
Reviewed-by Teddy Astie <[email protected]>
Thanks.
~Andrew
Quoted 13 lines · Andrew Cooper
xen/arch/x86/cpu/microcode/intel.c +9
-0@@ -273,6 +274,35 @@ static bool microcode_fits_cpu(const struct microcode_patch *mc)return false; } +static bool microcode_safe_to_load (const struct microcode_patch *mc) +{ +struct cpu_signature *cpu_sig = &this_cpu (cpu_sig); + +/* +* Treat pre-production as always safe - anyone using pre-production +* microcode knows what they are doing, and can keep any resulting pieces. +*/ +if ( cpu_sig->rev <0 || mc->rev <0 )
xen/arch/x86/cpu/microcode/intel.c static bool microcode_fits_cpu(const struct microcode_patch *mc) · line 295
Quoted 10 lines
xen/arch/x86/cpu/microcode/intel.c +10
-0+return true; + +/* +* GNR98. Granite Rapids systems hang when loading new ucode on +* sufficiently old firmware. +*/ +if ( boot_cpu_data.vfm ==INTEL_GRANITERAPIDS_X && + boot_cpu_data.stepping ==1 && (cpu_sig->pf &0x95 ) && + cpu_sig->rev <0x01000405 && + mc->rev >0x01000405 )
The erratum text says "to 0x1000405 or later". Question is whether that's correct, as it would mean that it's impossible to update from earlier than 0x1000405. Then the workaround text says exactly this.
xen/arch/x86/cpu/microcode/intel.c static bool microcode_fits_cpu(const struct microcode_patch *mc) · line 300
Quoted 5 lines
xen/arch/x86/cpu/microcode/intel.c +5
-0+ { +printk_once (XENLOG_WARNING +"microcode: Granite Rapids erratum GNR98 detected. Skipping ucode 0x%08x\n" +"microcode: Firmware update recommended\n" , mc->rev); +return false;
Should we additionally taint the system?
Jan
Quoted 19 lines · Jan Beulich
Quoted 18 lines · Andrew Cooper
xen/arch/x86/cpu/microcode/intel.c +14
-0@@ -273,6 +274,35 @@ static bool microcode_fits_cpu(const struct microcode_patch *mc)return false; } +static bool microcode_safe_to_load (const struct microcode_patch *mc) +{ +struct cpu_signature *cpu_sig = &this_cpu (cpu_sig); + +/* +* Treat pre-production as always safe - anyone using pre-production +* microcode knows what they are doing, and can keep any resulting pieces. +*/ +if ( cpu_sig->rev <0 || mc->rev <0 ) +return true; + +/* +* GNR98. Granite Rapids systems hang when loading new ucode on +* sufficiently old firmware.
Quoted 8 lines
xen/arch/x86/cpu/microcode/intel.c static bool microcode_fits_cpu(const struct microcode_patch *mc) · line 295
Quoted 5 lines
xen/arch/x86/cpu/microcode/intel.c +5
-0+*/ +if ( boot_cpu_data.vfm ==INTEL_GRANITERAPIDS_X && + boot_cpu_data.stepping ==1 && (cpu_sig->pf &0x95 ) && + cpu_sig->rev <0x01000405 && + mc->rev >0x01000405 )The erratum text says "to
0x1000405or later". Question is whether that's correct, as it would mean that it's impossible to update from earlier than0x1000405. Then the workaround text says exactly this.
"Correct" is complicated.
The text is technically correct when considering all pre-production microcode that Intel had during development. It is not correct for production systems where OEMs followed instruction about which first version to use. Specifically, 0x01000405 does load safely on the first production-certified firmware.
Critically, >= breaks the aforementioned "more complete solution" (which can safely load up to latest even on old firmware) where I'm still waiting on Intel to adjust the blobs in the ucode repository.
Quoted 6 lines
xen/arch/x86/cpu/microcode/intel.c static bool microcode_fits_cpu(const struct microcode_patch *mc) · line 300
Quoted 5 lines
xen/arch/x86/cpu/microcode/intel.c +5
-0+ { +printk_once (XENLOG_WARNING +"microcode: Granite Rapids erratum GNR98 detected. Skipping ucode 0x%08x\n" +"microcode: Firmware update recommended\n" , mc->rev); +return false;Should we additionally taint the system?
Why? We've done nothing to make it potentially unstable/problematic.
~Andrew
Quoted 37 lines · Andrew Cooper
Quoted 19 lines · Jan Beulich
Quoted 18 lines · Andrew Cooper
xen/arch/x86/cpu/microcode/intel.c +14
-0@@ -273,6 +274,35 @@ static bool microcode_fits_cpu(const struct microcode_patch *mc)return false; } +static bool microcode_safe_to_load (const struct microcode_patch *mc) +{ +struct cpu_signature *cpu_sig = &this_cpu (cpu_sig); + +/* +* Treat pre-production as always safe - anyone using pre-production +* microcode knows what they are doing, and can keep any resulting pieces. +*/ +if ( cpu_sig->rev <0 || mc->rev <0 ) +return true; + +/* +* GNR98. Granite Rapids systems hang when loading new ucode on +* sufficiently old firmware. Quoted 8 lines
xen/arch/x86/cpu/microcode/intel.c static bool microcode_fits_cpu(const struct microcode_patch *mc) · line 295
Quoted 5 lines
xen/arch/x86/cpu/microcode/intel.c +5
-0+*/ +if ( boot_cpu_data.vfm ==INTEL_GRANITERAPIDS_X && + boot_cpu_data.stepping ==1 && (cpu_sig->pf &0x95 ) && + cpu_sig->rev <0x01000405 && + mc->rev >0x01000405 )The erratum text says "to
0x1000405or later". Question is whether that's correct, as it would mean that it's impossible to update from earlier than0x1000405. Then the workaround text says exactly this."Correct" is complicated.
The text is technically correct when considering all pre-production microcode that Intel had during development. It is not correct for production systems where OEMs followed instruction about which first version to use. Specifically,
0x01000405does load safely on the first production-certified firmware.
Quoted 3 lines
Critically, >= breaks the aforementioned "more complete solution" (which can safely load up to latest even on old firmware) where I'm still waiting on Intel to adjust the blobs in the ucode repository.
Can this difference to the erratum text then please be mentioned in the description (or even a code comment)?
Quoted 8 lines
Quoted 6 lines
xen/arch/x86/cpu/microcode/intel.c static bool microcode_fits_cpu(const struct microcode_patch *mc) · line 300
Quoted 5 lines
xen/arch/x86/cpu/microcode/intel.c +5
-0+ { +printk_once (XENLOG_WARNING +"microcode: Granite Rapids erratum GNR98 detected. Skipping ucode 0x%08x\n" +"microcode: Firmware update recommended\n" , mc->rev); +return false;Should we additionally taint the system?
Why? We've done nothing to make it potentially unstable/problematic.
We've done nothing, literally. That leaves the system in potentially problematic state (newer ucode available, which likely addresses known issues).
Jan