Skip to contentSkip to conversation

x86/AMD: deal with RDSEED issues

PATCH In review Jan Beulich 2 participants 5 messages Dec 16, 2025

lore
Share & tools
lore
#0 lore raw

v3 cover x86/AMD: deal with RDSEED issues

Both patches also want 'x86/CPU: extend is_forced_cpu_cap()'s "reach"' in place.

1: disable RDSEED on Fam17 model 47 stepping 0
2: disable RDSEED on problematic Zen5

Jan

#1 lore raw

PATCH v3 1/2 x86/AMD: disable RDSEED on Fam17 model 47 stepping 0

This particular variant has an error that causes RDSEED to always return 0xffffffff, while RDRAND works correctly.

Inspired by Linux commit 5b937a1ed64ebeba8876e398110a5790ad77407c ("x86/rdrand: Disable RDSEED on AMD Cyan Skillfish").

Like for RDRAND, permit a command line override to be used to keep RDSEED enabled.

---
Considering how it is described, I didn't think probing RDSEED (like we do for RDRAND) would be necessary.

Am I going too far in also updating cpuidmask_defaults here, or is us not doing so for the RDRAND disabling actually an oversight?

Using warning_add() may not be quite appropriate, as we don't really mean the admin to possibly override this with "cpuid=rdseed" (that's only a last resort, in case the issue is yet more limited in scope). But mere printk() would feel like hiding the information in the middle of lots of other output.
---
v2: Correctly check model, not (again) family.

xen/arch/x86/cpu/amd.c +18 -0
@@ -1102,6 +1102,24 @@ static void cf_check init_amd(struct cpu
 		}
 		break;
 
+	case 0x17:
+		/*
+		 * Fam17 model 47 stepping 0 has an error that causes RDSEED to
+		 * always return 0xffffffff (while RDRAND works correctly).
+		 */
+		if (c == &boot_cpu_data &&
+		    c->model == 0x47 && c->stepping == 0 &&
+		    cpu_has(c, X86_FEATURE_RDSEED) &&
+		    !is_forced_cpu_cap(X86_FEATURE_RDSEED)) {
+			static const char __initconst text[] =
+				"RDSEED is unreliable on this hardware; disabling its exposure\n";
+
+			setup_clear_cpu_cap(X86_FEATURE_RDSEED);
+			cpuidmask_defaults._7ab0 &= ~cpufeat_mask(X86_FEATURE_RDSEED);
+			warning_add(text);
+		}
+		break;
+
 	case 0x19:
 		/*
 		 * Zen3 (Fam19h model < 0x10) parts are not susceptible to
xen/arch/x86/cpu-policy.c +4 -0
@@ -123,6 +123,10 @@ static void __init cf_check _parse_xen_c
     else if ( feat == X86_FEATURE_RDRAND &&
               (cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_RDRAND)) )
         setup_force_cpu_cap(X86_FEATURE_RDRAND);
+    else if ( feat == X86_FEATURE_RDSEED &&
+              cpuid_eax(0) >= 7 &&
+              (cpuid_count_ebx(7, 0) & cpufeat_mask(X86_FEATURE_RDSEED)) )
+        setup_force_cpu_cap(X86_FEATURE_RDSEED);
 }
 
 static int __init cf_check parse_xen_cpuid(const char *s)
#2 lore raw

PATCH v3 2/2 x86/AMD: disable RDSEED on problematic Zen5

In reply to Jan Beulich

This particular variant has an error that causes 16- and 32-bit forms of RDSEED to frequently return 0 while still signaling success (CF=1). Refer to AMD-SB-7055 / CVE-2025-62626.

Relevant data taken from Linux commits 607b9fb2ce24 ("x86/CPU/AMD: Add RDSEED fix for Zen5") and e1a97a627cd0 ("x86/CPU/AMD: Add additional fixed RDSEED microcode revisions").

Like for the other RDSEED issue, the same command line override can be used to keep RDSEED enabled.

---
See "x86/AMD: disable RDSEED on Fam17 model 47 stepping 0" for pending opens.

The choice of using AVX-IFMA to tell Zen6 from Zen5 is somewhat arbitrary; a few other features could equally(?) well be used.

I will admit that I was on the edge of switching to a table-based approach. (I'm also not happy with the case 0x44 layout, but keeping the "break" on the earlier line triggers [imo bogusly] gcc's "misleading indentation" warning. We could of course move yet farther away from the Linux originals and use switch(curr_rev >> 8), like we do in zenbleed_use_chickenbit() and amd_check_entrysign().)
---
v3: Incorporate another Linux commit. Cover Zen6, assuming it is
universally unaffected.
v2: New.

xen/arch/x86/cpu/amd.c +44 -0
@@ -863,6 +863,28 @@ static void cf_check fam17_disable_c6(vo
 	wrmsrl(MSR_AMD_CSTATE_CFG, val & mask);
 }
 
+static noinline bool __init zen5_rdseed_good(const struct cpuinfo_x86 *c)
+{
+    unsigned int curr_rev = this_cpu(cpu_sig).rev, fixed_rev = ~0;
+
+    switch ( c->model )
+    {
+    case 0x02: if ( c->stepping == 1 ) fixed_rev = 0x0b00215a; break;
+    case 0x08: if ( c->stepping == 1 ) fixed_rev = 0x0b008121; break;
+    case 0x11: if ( c->stepping == 0 ) fixed_rev = 0x0b101054; break;
+    case 0x24: if ( c->stepping == 0 ) fixed_rev = 0x0b204037; break;
+    case 0x44: if ( c->stepping == 0 ) fixed_rev = 0x0b404035;
+               if ( c->stepping == 1 ) fixed_rev = 0x0b404108;
+               break;
+    case 0x60: if ( c->stepping == 0 ) fixed_rev = 0x0b600037; break;
+    case 0x68: if ( c->stepping == 0 ) fixed_rev = 0x0b608038; break;
+    case 0x70: if ( c->stepping == 0 ) fixed_rev = 0x0b700037; break;
+    default:   if ( cpu_has_avx_ifma ) fixed_rev = 0 /* Zen6 */; break;
+    }
+
+    return curr_rev >= fixed_rev;
+}
+
 static bool zenbleed_use_chickenbit(void)
 {
     unsigned int curr_rev;
@@ -1130,6 +1152,28 @@ static void cf_check init_amd(struct cpu
 		    !cpu_has(c, X86_FEATURE_BTC_NO))
 			setup_force_cpu_cap(X86_FEATURE_BTC_NO);
 		break;
+
+	case 0x1a:
+		/*
+		 * Zen5 have an error that causes the 16- and 32-bit forms of
+		 * RDSEED to frequently return 0 while signaling success (CF=1).
+		 * Sadly at the time of writing the fixed microcode revision is
+		 * known for only two of the models.
+		 */
+		if (c == &boot_cpu_data &&
+		    cpu_has(c, X86_FEATURE_RDSEED) &&
+		    !is_forced_cpu_cap(X86_FEATURE_RDSEED)) {
+			static const char __initconst text[] =
+				"RDSEED32 is unreliable on this hardware; disabling its exposure\n";
+
+			if (zen5_rdseed_good(c))
+				break;
+
+			setup_clear_cpu_cap(X86_FEATURE_RDSEED);
+			cpuidmask_defaults._7ab0 &= ~cpufeat_mask(X86_FEATURE_RDSEED);
+			warning_add(text);
+		}
+		break;
 	}
 
 	display_cacheinfo(c);
#3 lore raw

Re: [PATCH v3 2/2] x86/AMD: disable RDSEED on problematic Zen5

Le 16/12/2025 à 10:03, Jan Beulich a écrit :

Quoted 62 lines

This particular variant has an error that causes 16- and 32-bit forms of RDSEED to frequently return 0 while still signaling success (CF=1). Refer to AMD-SB-7055 / CVE-2025-62626.

Relevant data taken from Linux commits 607b9fb2ce24 ("x86/CPU/AMD: Add RDSEED fix for Zen5") and e1a97a627cd0 ("x86/CPU/AMD: Add additional fixed RDSEED microcode revisions").

Like for the other RDSEED issue, the same command line override can be used to keep RDSEED enabled.

---
See "x86/AMD: disable RDSEED on Fam17 model 47 stepping 0" for pending opens.

The choice of using AVX-IFMA to tell Zen6 from Zen5 is somewhat arbitrary; a few other features could equally(?) well be used.

I will admit that I was on the edge of switching to a table-based approach. (I'm also not happy with the case 0x44 layout, but keeping the "break" on the earlier line triggers [imo bogusly] gcc's "misleading indentation" warning. We could of course move yet farther away from the Linux originals and use switch(curr_rev >> 8), like we do in zenbleed_use_chickenbit() and amd_check_entrysign().)
---
v3: Incorporate another Linux commit. Cover Zen6, assuming it is
universally unaffected.
v2: New.

xen/arch/x86/cpu/amd.c +22 -0
@@ -863,6 +863,28 @@ static void cf_check fam17_disable_c6(vo
  	wrmsrl(MSR_AMD_CSTATE_CFG, val & mask);
  }
 
+static noinline bool __init zen5_rdseed_good(const struct cpuinfo_x86 *c)
+{
+    unsigned int curr_rev = this_cpu(cpu_sig).rev, fixed_rev = ~0;
+
+    switch ( c->model )
+    {
+    case 0x02: if ( c->stepping == 1 ) fixed_rev = 0x0b00215a; break;
+    case 0x08: if ( c->stepping == 1 ) fixed_rev = 0x0b008121; break;
+    case 0x11: if ( c->stepping == 0 ) fixed_rev = 0x0b101054; break;
+    case 0x24: if ( c->stepping == 0 ) fixed_rev = 0x0b204037; break;
+    case 0x44: if ( c->stepping == 0 ) fixed_rev = 0x0b404035;
+               if ( c->stepping == 1 ) fixed_rev = 0x0b404108;
+               break;
+    case 0x60: if ( c->stepping == 0 ) fixed_rev = 0x0b600037; break;
+    case 0x68: if ( c->stepping == 0 ) fixed_rev = 0x0b608038; break;
+    case 0x70: if ( c->stepping == 0 ) fixed_rev = 0x0b700037; break;
+    default:   if ( cpu_has_avx_ifma ) fixed_rev = 0 /* Zen6 */; break;
+    }
+
+    return curr_rev >= fixed_rev;
+}
+
  static bool zenbleed_use_chickenbit(void)
  {
      unsigned int curr_rev;

xen/arch/x86/cpu/amd.c static void cf_check init_amd(struct cpu · line 1161

Quoted 10 lines
xen/arch/x86/cpu/amd.c +7 -0
@@ -1130,6 +1152,28 @@ static void cf_check init_amd(struct cpu
  		    !cpu_has(c, X86_FEATURE_BTC_NO))
  			setup_force_cpu_cap(X86_FEATURE_BTC_NO);
  		break;
+
+	case 0x1a:
+		/*
+		 * Zen5 have an error that causes the 16- and 32-bit forms of
+		 * RDSEED to frequently return 0 while signaling success (CF=1).
+		 * Sadly at the time of writing the fixed microcode revision is
+		 * known for only two of the models.

Is it still two models ?

Quoted 5 lines
xen/arch/x86/cpu/amd.c +5 -0
+		 */
+		if (c == &boot_cpu_data &&
+		    cpu_has(c, X86_FEATURE_RDSEED) &&
+		    !is_forced_cpu_cap(X86_FEATURE_RDSEED)) {
+			static const char __initconst text[] =

xen/arch/x86/cpu/amd.c static void cf_check init_amd(struct cpu · line 1176

Quoted 10 lines
xen/arch/x86/cpu/amd.c +10 -0
+				"RDSEED32 is unreliable on this hardware; disabling its exposure\n";
+
+			if (zen5_rdseed_good(c))
+				break;
+
+			setup_clear_cpu_cap(X86_FEATURE_RDSEED);
+			cpuidmask_defaults._7ab0 &= ~cpufeat_mask(X86_FEATURE_RDSEED);
+			warning_add(text);
+		}
+		break;

Do we still want to disable if we are running in a hypervisor; we can expect the host to emulate the instructions to workaround the issue ?

xen/arch/x86/cpu/amd.c static void cf_check init_amd(struct cpu · line 1179

Quoted 5 lines
xen/arch/x86/cpu/amd.c +0 -0
  	}
 
  	display_cacheinfo(c);

--
Teddy Astie | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

#4 lore raw

Re: [PATCH v3 2/2] x86/AMD: disable RDSEED on problematic Zen5

Quoted 14 lines · Teddy Astie

Le 16/12/2025 à 10:03, Jan Beulich a écrit :

xen/arch/x86/cpu/amd.c static void cf_check init_amd(struct cpu · line 1161

Quoted 11 lines
xen/arch/x86/cpu/amd.c +7 -0
@@ -1130,6 +1152,28 @@ static void cf_check init_amd(struct cpu
  		    !cpu_has(c, X86_FEATURE_BTC_NO))
  			setup_force_cpu_cap(X86_FEATURE_BTC_NO);
  		break;
+
+	case 0x1a:
+		/*
+		 * Zen5 have an error that causes the 16- and 32-bit forms of
+		 * RDSEED to frequently return 0 while signaling success (CF=1).
+		 * Sadly at the time of writing the fixed microcode revision is
+		 * known for only two of the models.

Is it still two models ?

Oops - s/two/some/. Thanks for noticing.

Quoted 10 lines
Quoted 10 lines
xen/arch/x86/cpu/amd.c +10 -0
+		 */
+		if (c == &boot_cpu_data &&
+		    cpu_has(c, X86_FEATURE_RDSEED) &&
+		    !is_forced_cpu_cap(X86_FEATURE_RDSEED)) {
+			static const char __initconst text[] =
+				"RDSEED32 is unreliable on this hardware; disabling its exposure\n";
+
+			if (zen5_rdseed_good(c))
+				break;
+
Quoted 8 lines

xen/arch/x86/cpu/amd.c static void cf_check init_amd(struct cpu · line 1176

Quoted 5 lines
xen/arch/x86/cpu/amd.c +5 -0
+			setup_clear_cpu_cap(X86_FEATURE_RDSEED);
+			cpuidmask_defaults._7ab0 &= ~cpufeat_mask(X86_FEATURE_RDSEED);
+			warning_add(text);
+		}
+		break;

Do we still want to disable if we are running in a hypervisor; we can expect the host to emulate the instructions to workaround the issue ?

That would only work if we knew the host intercepts that insn. We don't ourselves, so I can't see us legitimately expecting anyone else to do so. Plus while I'm aware RDSEED can be intercepted on VMX, I'm unaware of there being equivalent functionality on SVM (PM vol 3 does not yield any hit when searching for RDSEED).

Jan