Skip to contentSkip to conversation

x86/rdrand: disable RDSEED on AMD Cyan Skillfish

PATCH Applied Mikhail Paulyshka 4 participants 14 messages May 24, 2025 – Jul 8, 2025 x86

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/rdrand: disable RDSEED on AMD Cyan Skillfish

AMD Cyan Skillfish (Family 17h, Model 47h, Stepping 0h) has an error that causes RDSEED to always return 0xffffffff, while RDRAND works correctly.

This patch masks the RDSEED cap for this CPU so that both /proc/cpuinfo and direct CPUID read report RDSEED as unavailable.

v2:
* Limit changes to AMD Cyan Skillfish
* Replace the runtime RDSEED sanity check with a simple family/model/stepping match

---
 arch/x86/include/asm/msr-index.h       | 1 +
 arch/x86/kernel/cpu/rdrand.c           | 9 +++++++++
 tools/arch/x86/include/asm/msr-index.h | 1 +
 3 files changed, 11 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
index e7d2f460fcc6..2333f4e7bc2f 100644
@@ -624,6 +624,7 @@
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
 #define MSR_AMD_PPIN_CTL		0xc00102f0
 #define MSR_AMD_PPIN			0xc00102f1
+#define MSR_AMD64_CPUID_FN_7		0xc0011002
 #define MSR_AMD64_CPUID_FN_1		0xc0011004
 #define MSR_AMD64_LS_CFG		0xc0011020
 #define MSR_AMD64_DC_CFG		0xc0011022
arch/x86/kernel/cpu/rdrand.c +9 -0
index eeac00d20926..c474d0a5c317 100644
@@ -11,6 +11,7 @@
 #include <asm/processor.h>
 #include <asm/archrandom.h>
 #include <asm/sections.h>
+#include <asm/msr.h>
 
 /*
  * RDRAND has Built-In-Self-Test (BIST) that runs on every invocation.
@@ -47,4 +48,12 @@ void x86_init_rdrand(struct cpuinfo_x86 *c)
 		clear_cpu_cap(c, X86_FEATURE_RDSEED);
 		pr_emerg("RDRAND is not reliable on this platform; disabling.\n");
 	}
+
+	/* disable RDSEED on AMD Cyan Skillfish because of hw bug */
+	if (c->x86_vendor == X86_VENDOR_AMD && c->x86 == 0x17 &&
+	    c->x86_model == 0x47 && c->x86_stepping == 0x0) {
+		clear_cpu_cap(c, X86_FEATURE_RDSEED);
+		msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
+		pr_emerg("RDSEED is not reliable on this platform; disabling.\n");
+	}
 }
tools/arch/x86/include/asm/msr-index.h +1 -0
index e6134ef2263d..8b48a54b627a 100644
@@ -616,6 +616,7 @@
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
 #define MSR_AMD_PPIN_CTL		0xc00102f0
 #define MSR_AMD_PPIN			0xc00102f1
+#define MSR_AMD64_CPUID_FN_7		0xc0011002
 #define MSR_AMD64_CPUID_FN_1		0xc0011004
 #define MSR_AMD64_LS_CFG		0xc0011020
 #define MSR_AMD64_DC_CFG		0xc0011022
Signature · 1 line
2.49.0
maintainer
#1 lore raw
Quoted 5 lines · Mikhail Paulyshka

AMD Cyan Skillfish (Family 17h, Model 47h, Stepping 0h) has an error that causes RDSEED to always return 0xffffffff, while RDRAND works correctly.

This patch masks the RDSEED cap for this CPU so that both

s/This patch masks/Mask/

Quoted 7 lines

/proc/cpuinfo and direct CPUID read report RDSEED as unavailable.

v2:
* Limit changes to AMD Cyan Skillfish
* Replace the runtime RDSEED sanity check with a simple family/model/stepping match

Changelog stuff goes...

Quoted 3 lines

---

<--- ... here, under the "---" so that patch handling scripts can ignore it.

Quoted 30 lines
 arch/x86/include/asm/msr-index.h       | 1 +
 arch/x86/kernel/cpu/rdrand.c           | 9 +++++++++
 tools/arch/x86/include/asm/msr-index.h | 1 +
 3 files changed, 11 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
index e7d2f460fcc6..2333f4e7bc2f 100644
@@ -624,6 +624,7 @@
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
 #define MSR_AMD_PPIN_CTL		0xc00102f0
 #define MSR_AMD_PPIN			0xc00102f1
+#define MSR_AMD64_CPUID_FN_7		0xc0011002
 #define MSR_AMD64_CPUID_FN_1		0xc0011004
 #define MSR_AMD64_LS_CFG		0xc0011020
 #define MSR_AMD64_DC_CFG		0xc0011022
arch/x86/kernel/cpu/rdrand.c +1 -0
index eeac00d20926..c474d0a5c317 100644
@@ -11,6 +11,7 @@
 #include <asm/processor.h>
 #include <asm/archrandom.h>
 #include <asm/sections.h>
+#include <asm/msr.h>
 
 /*
  * RDRAND has Built-In-Self-Test (BIST) that runs on every invocation.

arch/x86/kernel/cpu/rdrand.c void x86_init_rdrand(struct cpuinfo_x86 *c) · line 52

Quoted 5 lines
arch/x86/kernel/cpu/rdrand.c +2 -0
@@ -47,4 +48,12 @@ void x86_init_rdrand(struct cpuinfo_x86 *c)
 		clear_cpu_cap(c, X86_FEATURE_RDSEED);
 		pr_emerg("RDRAND is not reliable on this platform; disabling.\n");
 	}
+
+	/* disable RDSEED on AMD Cyan Skillfish because of hw bug */

Not a hw bug - "... has an error" above was closer :-)

Quoted 13 lines
arch/x86/kernel/cpu/rdrand.c +6 -0
+	if (c->x86_vendor == X86_VENDOR_AMD && c->x86 == 0x17 &&
+	    c->x86_model == 0x47 && c->x86_stepping == 0x0) {
+		clear_cpu_cap(c, X86_FEATURE_RDSEED);
+		msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
+		pr_emerg("RDSEED is not reliable on this platform; disabling.\n");
+	}
 }
tools/arch/x86/include/asm/msr-index.h +0 -0
index e6134ef2263d..8b48a54b627a 100644

tools/arch/x86/include/asm/msr-index.h line 622

Quoted 7 lines
tools/arch/x86/include/asm/msr-index.h +1 -0
@@ -616,6 +616,7 @@
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
 #define MSR_AMD_PPIN_CTL		0xc00102f0
 #define MSR_AMD_PPIN			0xc00102f1
+#define MSR_AMD64_CPUID_FN_7		0xc0011002
 #define MSR_AMD64_CPUID_FN_1		0xc0011004
 #define MSR_AMD64_LS_CFG		0xc0011020
 #define MSR_AMD64_DC_CFG		0xc0011022

In any case, those are just minor nits which can be dealt with when applying.

Otherwise, patch looks good, thanks.

We have merge window upcoming next week so I'll take it after that but it is on my list of patches to take after the MW.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
maintainer
#2 lore raw
In reply to Mikhail Paulyshka
Quoted 13 lines · Mikhail Paulyshka

AMD Cyan Skillfish (Family 17h, Model 47h, Stepping 0h) has an error that causes RDSEED to always return 0xffffffff, while RDRAND works correctly.

This patch masks the RDSEED cap for this CPU so that both /proc/cpuinfo and direct CPUID read report RDSEED as unavailable.

v2:
* Limit changes to AMD Cyan Skillfish
* Replace the runtime RDSEED sanity check with a simple family/model/stepping match

Quoted 6 lines
---
 arch/x86/include/asm/msr-index.h       | 1 +
 arch/x86/kernel/cpu/rdrand.c           | 9 +++++++++
 tools/arch/x86/include/asm/msr-index.h | 1 +
 3 files changed, 11 insertions(+)

Does this one work too?

---
From: Mikhail Paulyshka <[email protected]>
Date: Sat, 24 May 2025 17:53:19 +0300
Subject: [PATCH] x86/rdrand: Disable RDSEED on AMD Cyan Skillfish

AMD Cyan Skillfish (Family 17h, Model 47h, Stepping 0h) has an error that causes RDSEED to always return 0xffffffff, while RDRAND works correctly.

Mask the RDSEED cap for this CPU so that both /proc/cpuinfo and direct CPUID read report RDSEED as unavailable.

[ bp: Move to amd.c, massage. ]

---
 arch/x86/include/asm/msr-index.h       | 1 +
 arch/x86/kernel/cpu/amd.c              | 7 +++++++
 tools/arch/x86/include/asm/msr-index.h | 1 +
 3 files changed, 9 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
index b7dded3c8113..5cfb5d74dd5f 100644
@@ -628,6 +628,7 @@
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
 #define MSR_AMD_PPIN_CTL		0xc00102f0
 #define MSR_AMD_PPIN			0xc00102f1
+#define MSR_AMD64_CPUID_FN_7		0xc0011002
 #define MSR_AMD64_CPUID_FN_1		0xc0011004
 #define MSR_AMD64_LS_CFG		0xc0011020
 #define MSR_AMD64_DC_CFG		0xc0011022
arch/x86/kernel/cpu/amd.c +7 -0
index 93da466dfe2c..c2ef5ab4a9e3 100644
@@ -930,6 +930,13 @@ static void init_amd_zen2(struct cpuinfo_x86 *c)
 	init_spectral_chicken(c);
 	fix_erratum_1386(c);
 	zen2_zenbleed_check(c);
+
+	/* Disable RDSEED on AMD Cyan Skillfish because of an error. */
+	if (c->x86_model == 0x47 && c->x86_stepping == 0x0) {
+		clear_cpu_cap(c, X86_FEATURE_RDSEED);
+		msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
+		pr_emerg("RDSEED is not reliable on this platform; disabling.\n");
+	}
 }
 
 static void init_amd_zen3(struct cpuinfo_x86 *c)
tools/arch/x86/include/asm/msr-index.h +1 -0
index e7d2f460fcc6..2333f4e7bc2f 100644
@@ -624,6 +624,7 @@
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
 #define MSR_AMD_PPIN_CTL		0xc00102f0
 #define MSR_AMD_PPIN			0xc00102f1
+#define MSR_AMD64_CPUID_FN_7		0xc0011002
 #define MSR_AMD64_CPUID_FN_1		0xc0011004
 #define MSR_AMD64_LS_CFG		0xc0011020
 #define MSR_AMD64_DC_CFG		0xc0011022
Signature · 7 lines
2.43.0

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#3 lore raw

arch/x86/kernel/cpu/amd.c static void init_amd_zen2(struct cpuinfo_x86 *c) · line 939

Quoted 6 lines · Borislav Petkov
arch/x86/kernel/cpu/amd.c +6 -0
+	/* Disable RDSEED on AMD Cyan Skillfish because of an error. */
+	if (c->x86_model == 0x47 && c->x86_stepping == 0x0) {
+		clear_cpu_cap(c, X86_FEATURE_RDSEED);
+		msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
+		pr_emerg("RDSEED is not reliable on this platform; disabling.\n");
+	}

Heh, maybe if x86_init_rdrand() did RDSEED too, this wouldn't have slipped through QA.

#4 lore raw
Quoted 2 lines · Dave Hansen

Heh, maybe if x86_init_rdrand() did RDSEED too, this wouldn't have slipped through QA.

This might be interesting to you: in V1 of this patch set, there was an RDSEED sanity check, and Intel's CI detected broken RDSEED on Comet Lake:

https://lore.kernel.org/all/[email protected]/

maintainer
#5 lore raw
Quoted 8 lines · Mikhail Paulyshka
Quoted 2 lines · Dave Hansen

Heh, maybe if x86_init_rdrand() did RDSEED too, this wouldn't have slipped through QA.

This might be interesting to you: in V1 of this patch set, there was an RDSEED sanity check, and Intel's CI detected broken RDSEED on Comet Lake:

https://lore.kernel.org/all/[email protected]/

Right, I'm being told this is preproduction hw:

[    2.823625][    T1] smpboot: CPU0: Genuine Intel(R) CPU 0000 @ 3.30GHz (family: 0x6, model: 0xa5, stepping: 0x1)

and strictly speaking, RDSEED *can* fail due to resources exhaustion etc
- doesn't necessarily mean it is broken.

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#6 lore raw
In reply to Mikhail Paulyshka
Quoted 8 lines · Mikhail Paulyshka
Quoted 2 lines · Dave Hansen

Heh, maybe if x86_init_rdrand() did RDSEED too, this wouldn't have slipped through QA.

This might be interesting to you: in V1 of this patch set, there was an RDSEED sanity check, and Intel's CI detected broken RDSEED on Comet Lake:

https://lore.kernel.org/all/[email protected]/

Just to be clear, I'd call that *A* Comet Lake system. Saying it's "broken on Comet Lake" kinda implies that they're all broken.

I'd definitely want to rule out a single wonky system first, like it being on some old weird microcode.

#7 lore raw
In reply to Borislav Petkov
Quoted 1 line · Borislav Petkov

Does this one work too?

It works, however, there is another issue with the BC250 that appeared since Linux 6.15.

Commit 4afeb0ed1753ebcad93ee3b45427ce85e9c8ec40 ( x86/mm: Enable broadcast TLB invalidation for multi-threaded processes)[1], merged in Linux 6.15-rc1, breaks the device — it starts to oops and panic under any load [2].

[1] https://docs.google.com/spreadsheets/d/1kJleOY5k-YREGak1pQhVWIGckA9YA3OWJyCbybZbk00/edit?gid=0#gid=0
[2] https://mixaill.net/linux-kernel-lists/bc250_log_invlpgb-1.txt

Clearing the X86_FEATURE_INVLPGB cap helps and the device works normally again.

It would be great to have this change backported to 6.15 and 6.16 as the device is currently unstable with these kernels.

---
From 064c91c5f3fc02a6eecd6b0b7cf074e2d0eb75aa Mon Sep 17 00:00:00 2001
From: Mikhail Paulyshka <[email protected]>
Date: Sun, 6 Jul 2025 01:46:46 +0300
Subject: [PATCH 2/2] x86/cpu/amd: disable INVLPGB on AMD Cyan Skillfish

AMD Cyan Skillfish (Family 17h, Model 47h, Stepping 0h) has an issue that causes system oopses and panics when performing TLB flush using INVLPGB.

Clearing the X86_FEATURE_INVLPGB flag restoring system stability.

---
 arch/x86/kernel/cpu/amd.c | 6 ++++++

 1 file changed, 6 insertions(+)
arch/x86/kernel/cpu/amd.c +0 -0
index 21072f84071a..89b74203396e 100644
@@ -935,6 +935,12 @@ static void init_amd_zen2(struct cpuinfo_x86 *c)

         msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18); pr_emerg("RDSEED is not reliable on this platform; disabling.\n"); }
+
+    /* Disable INVLPGB on AMD Cyan Skillfish because of an error */ +    if (c->x86_model == 0x47 && c->x86_stepping == 0x0) {
+        clear_cpu_cap(c, X86_FEATURE_INVLPGB);
+        pr_emerg("INVLPGB is not reliable on this platform; disabling.\n"); +    }
 }

 static void init_amd_zen3(struct cpuinfo_x86 *c)

Signature · 1 line
2.50.0
maintainer
#8 lore raw
Quoted 9 lines · Mikhail Paulyshka
Quoted 1 line · Borislav Petkov

Does this one work too?

It works, however, there is another issue with the BC250 that appeared since Linux 6.15.

Commit 4afeb0ed1753ebcad93ee3b45427ce85e9c8ec40 ( x86/mm: Enable broadcast TLB invalidation for multi-threaded processes)[1], merged in Linux 6.15-rc1, breaks the device — it starts to oops and panic under any load [2].

Looks like it GPs because CR4.PCID == 0.

Looks weird, we need to check PCID support somewhere, it seems.

Ok, let's get a common code base - 6.15. Pls boot it, send me full dmesg again, your .config and the output of

cpuid -1r

Thx.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
#9 lore raw
Quoted 5 lines · Borislav Petkov

Looks like it GPs because CR4.PCID == 0.

Looks weird, we need to check PCID support somewhere, it seems.

Ok, let's get a common code base - 6.15. Pls boot it, send me full dmesg again

dmesg with vanilla 6.15.0:
https://mixaill.net/linux-kernel-lists/bc250_log_invlpgb-2-dmesg.txt

Quoted 1 line

your .config

https://raw.githubusercontent.com/openSUSE/kernel-source/4552ba89cbebd55482508c4ba4fc290df58f9386/config/x86_64/vanilla

Quoted 1 line

and the output of cpuid -1r

https://mixaill.net/linux-kernel-lists/bc250_log_invlpgb-2-cpuid.txt

#10 lore raw

[tip: x86/urgent] x86/CPU/AMD: Disable INVLPGB on Zen2

In reply to Mikhail Paulyshka
The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     5a97aa3a4f1f19656aea5c76c1da66ce9dc5ddaf
Gitweb:        https://git.kernel.org/tip/5a97aa3a4f1f19656aea5c76c1da66ce9dc5ddaf
Author:        Mikhail Paulyshka <[email protected]>
AuthorDate:    Tue, 08 Jul 2025 16:39:10 +02:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Tue, 08 Jul 2025 16:41:59 +02:00

x86/CPU/AMD: Disable INVLPGB on Zen2

AMD Cyan Skillfish (Family 17h, Model 47h, Stepping 0h) has an issue that causes system oopses and panics when performing TLB flush using INVLPGB.

However, the problem is that that machine has misconfigured CPUID and should not report the INVLPGB bit in the first place. So zap the kernel's representation of the flag so that nothing gets confused.

[ bp: Massage. ]

---
 arch/x86/kernel/cpu/amd.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/cpu/amd.c +3 -0
index e1c4661..1b1ff60 100644
@@ -937,6 +937,9 @@ static void init_amd_zen2(struct cpuinfo_x86 *c)
 		msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
 		pr_emerg("RDSEED is not reliable on this platform; disabling.\n");
 	}
+
+	/* Correct misconfigured CPUID on some clients. */
+	clear_cpu_cap(c, X86_FEATURE_INVLPGB);
 }
 
 static void init_amd_zen3(struct cpuinfo_x86 *c)
#11 lore raw

[tip: x86/urgent] x86/CPU/AMD: Disable INVLPGB on Zen2

In reply to Mikhail Paulyshka
The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     a74bb5f202dabddfea96abc1328fcedae8aa140a
Gitweb:        https://git.kernel.org/tip/a74bb5f202dabddfea96abc1328fcedae8aa140a
Author:        Mikhail Paulyshka <[email protected]>
AuthorDate:    Tue, 08 Jul 2025 16:39:10 +02:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Tue, 08 Jul 2025 21:34:01 +02:00

x86/CPU/AMD: Disable INVLPGB on Zen2

AMD Cyan Skillfish (Family 17h, Model 47h, Stepping 0h) has an issue that causes system oopses and panics when performing TLB flush using INVLPGB.

However, the problem is that that machine has misconfigured CPUID and should not report the INVLPGB bit in the first place. So zap the kernel's representation of the flag so that nothing gets confused.

[ bp: Massage. ]

Fixes 767ae437a32d ("x86/mm: Add INVLPGB feature and Kconfig entry")
---
 arch/x86/kernel/cpu/amd.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/cpu/amd.c +3 -0
index e1c4661..1b1ff60 100644
@@ -937,6 +937,9 @@ static void init_amd_zen2(struct cpuinfo_x86 *c)
 		msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
 		pr_emerg("RDSEED is not reliable on this platform; disabling.\n");
 	}
+
+	/* Correct misconfigured CPUID on some clients. */
+	clear_cpu_cap(c, X86_FEATURE_INVLPGB);
 }
 
 static void init_amd_zen3(struct cpuinfo_x86 *c)
#12 lore raw

[tip: x86/urgent] x86/rdrand: Disable RDSEED on AMD Cyan Skillfish

In reply to Mikhail Paulyshka
The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     dc562662cb2b0bcc7af4ca3cd53e6140ff52a418
Gitweb:        https://git.kernel.org/tip/dc562662cb2b0bcc7af4ca3cd53e6140ff52a418
Author:        Mikhail Paulyshka <[email protected]>
AuthorDate:    Sat, 24 May 2025 17:53:19 +03:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Tue, 08 Jul 2025 16:26:42 +02:00

x86/rdrand: Disable RDSEED on AMD Cyan Skillfish

AMD Cyan Skillfish (Family 17h, Model 47h, Stepping 0h) has an error that causes RDSEED to always return 0xffffffff, while RDRAND works correctly.

Mask the RDSEED cap for this CPU so that both /proc/cpuinfo and direct CPUID read report RDSEED as unavailable.

[ bp: Move to amd.c, massage. ]

---
 arch/x86/include/asm/msr-index.h       | 1 +
 arch/x86/kernel/cpu/amd.c              | 7 +++++++
 tools/arch/x86/include/asm/msr-index.h | 1 +
 3 files changed, 9 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
index b7dded3..5cfb5d7 100644
@@ -628,6 +628,7 @@
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
 #define MSR_AMD_PPIN_CTL		0xc00102f0
 #define MSR_AMD_PPIN			0xc00102f1
+#define MSR_AMD64_CPUID_FN_7		0xc0011002
 #define MSR_AMD64_CPUID_FN_1		0xc0011004
 #define MSR_AMD64_LS_CFG		0xc0011020
 #define MSR_AMD64_DC_CFG		0xc0011022
arch/x86/kernel/cpu/amd.c +7 -0
index 655f44f..e1c4661 100644
@@ -930,6 +930,13 @@ static void init_amd_zen2(struct cpuinfo_x86 *c)
 	init_spectral_chicken(c);
 	fix_erratum_1386(c);
 	zen2_zenbleed_check(c);
+
+	/* Disable RDSEED on AMD Cyan Skillfish because of an error. */
+	if (c->x86_model == 0x47 && c->x86_stepping == 0x0) {
+		clear_cpu_cap(c, X86_FEATURE_RDSEED);
+		msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
+		pr_emerg("RDSEED is not reliable on this platform; disabling.\n");
+	}
 }
 
 static void init_amd_zen3(struct cpuinfo_x86 *c)
tools/arch/x86/include/asm/msr-index.h +1 -0
index b7dded3..5cfb5d7 100644
@@ -628,6 +628,7 @@
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
 #define MSR_AMD_PPIN_CTL		0xc00102f0
 #define MSR_AMD_PPIN			0xc00102f1
+#define MSR_AMD64_CPUID_FN_7		0xc0011002
 #define MSR_AMD64_CPUID_FN_1		0xc0011004
 #define MSR_AMD64_LS_CFG		0xc0011020
 #define MSR_AMD64_DC_CFG		0xc0011022
#13 lore raw

[tip: x86/urgent] x86/rdrand: Disable RDSEED on AMD Cyan Skillfish

In reply to Mikhail Paulyshka
The following commit has been merged into the x86/urgent branch of tip:

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     5b937a1ed64ebeba8876e398110a5790ad77407c
Gitweb:        https://git.kernel.org/tip/5b937a1ed64ebeba8876e398110a5790ad77407c
Author:        Mikhail Paulyshka <[email protected]>
AuthorDate:    Sat, 24 May 2025 17:53:19 +03:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Tue, 08 Jul 2025 21:33:26 +02:00

x86/rdrand: Disable RDSEED on AMD Cyan Skillfish

AMD Cyan Skillfish (Family 17h, Model 47h, Stepping 0h) has an error that causes RDSEED to always return 0xffffffff, while RDRAND works correctly.

Mask the RDSEED cap for this CPU so that both /proc/cpuinfo and direct CPUID read report RDSEED as unavailable.

[ bp: Move to amd.c, massage. ]

---
 arch/x86/include/asm/msr-index.h       | 1 +
 arch/x86/kernel/cpu/amd.c              | 7 +++++++
 tools/arch/x86/include/asm/msr-index.h | 1 +
 3 files changed, 9 insertions(+)
arch/x86/include/asm/msr-index.h +1 -0
index b7dded3..5cfb5d7 100644
@@ -628,6 +628,7 @@
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
 #define MSR_AMD_PPIN_CTL		0xc00102f0
 #define MSR_AMD_PPIN			0xc00102f1
+#define MSR_AMD64_CPUID_FN_7		0xc0011002
 #define MSR_AMD64_CPUID_FN_1		0xc0011004
 #define MSR_AMD64_LS_CFG		0xc0011020
 #define MSR_AMD64_DC_CFG		0xc0011022
arch/x86/kernel/cpu/amd.c +7 -0
index 655f44f..e1c4661 100644
@@ -930,6 +930,13 @@ static void init_amd_zen2(struct cpuinfo_x86 *c)
 	init_spectral_chicken(c);
 	fix_erratum_1386(c);
 	zen2_zenbleed_check(c);
+
+	/* Disable RDSEED on AMD Cyan Skillfish because of an error. */
+	if (c->x86_model == 0x47 && c->x86_stepping == 0x0) {
+		clear_cpu_cap(c, X86_FEATURE_RDSEED);
+		msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18);
+		pr_emerg("RDSEED is not reliable on this platform; disabling.\n");
+	}
 }
 
 static void init_amd_zen3(struct cpuinfo_x86 *c)
tools/arch/x86/include/asm/msr-index.h +1 -0
index b7dded3..5cfb5d7 100644
@@ -628,6 +628,7 @@
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
 #define MSR_AMD_PPIN_CTL		0xc00102f0
 #define MSR_AMD_PPIN			0xc00102f1
+#define MSR_AMD64_CPUID_FN_7		0xc0011002
 #define MSR_AMD64_CPUID_FN_1		0xc0011004
 #define MSR_AMD64_LS_CFG		0xc0011020
 #define MSR_AMD64_DC_CFG		0xc0011022