mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/1] x86/rdrand: disable RDSEED on AMD Cyan Skillfish
@ 2025-05-24 14:53 Mikhail Paulyshka
  2025-05-24 16:11 ` Borislav Petkov
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Mikhail Paulyshka @ 2025-05-24 14:53 UTC (permalink / raw)
  To: Borislav Petkov, Mario Limonciello, Thomas Gleixner, Ingo Molnar,
	Dave Hansen, x86, linux-kernel
  Cc: 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

Signed-off-by: Mikhail Paulyshka <me@mixaill.net>
---
 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(+)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index e7d2f460fcc6..2333f4e7bc2f 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -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
diff --git a/arch/x86/kernel/cpu/rdrand.c b/arch/x86/kernel/cpu/rdrand.c
index eeac00d20926..c474d0a5c317 100644
--- a/arch/x86/kernel/cpu/rdrand.c
+++ b/arch/x86/kernel/cpu/rdrand.c
@@ -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");
+	}
 }
diff --git a/tools/arch/x86/include/asm/msr-index.h b/tools/arch/x86/include/asm/msr-index.h
index e6134ef2263d..8b48a54b627a 100644
--- a/tools/arch/x86/include/asm/msr-index.h
+++ b/tools/arch/x86/include/asm/msr-index.h
@@ -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
-- 
2.49.0


^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: [PATCH v2 1/1] x86/rdrand: disable RDSEED on AMD Cyan Skillfish
@ 2026-01-14 20:52 Travis B
  2026-01-14 21:28 ` Borislav Petkov
  0 siblings, 1 reply; 19+ messages in thread
From: Travis B @ 2026-01-14 20:52 UTC (permalink / raw)
  To: me; +Cc: bp, dave.hansen, linux-kernel, mario.limonciello, mingo, tglx, x86

Hello, I realize this is now post-merge but I have feedback:

> pr_emerg("RDSEED is not reliable on this platform; disabling.\n");

I think that pr_emerg is an inappropriate message level
for the RDSEED disable notices; it is not a system-halting error
by any means and is expected on this hardware.

These should be pr_notice_once instead.
(the message is also shown dozens of times in a row currently)

Currently users of BC-250 have no way of disabling the RDSEED
disabled notice messages on startup without hiding all other
real error messages due to it currently logging at EMERGENCY
level.

It is probably a good idea to do this in the Zen5 version
of the RDSEED disabling as well.

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-01-15 10:29 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-24 14:53 [PATCH v2 1/1] x86/rdrand: disable RDSEED on AMD Cyan Skillfish Mikhail Paulyshka
2025-05-24 16:11 ` Borislav Petkov
2025-06-17 20:05 ` Borislav Petkov
2025-06-17 20:21   ` Dave Hansen
2025-07-07 10:17     ` Mikhail Paulyshka
2025-07-07 15:25       ` Borislav Petkov
2025-07-07 15:34       ` Dave Hansen
2025-07-06 16:42   ` Mikhail Paulyshka
2025-07-06 17:07     ` Borislav Petkov
2025-07-06 20:31       ` Mikhail Paulyshka
2025-07-08 14:50     ` [tip: x86/urgent] x86/CPU/AMD: Disable INVLPGB on Zen2 tip-bot2 for Mikhail Paulyshka
2025-07-08 19:50     ` tip-bot2 for Mikhail Paulyshka
2025-07-08 14:50 ` [tip: x86/urgent] x86/rdrand: Disable RDSEED on AMD Cyan Skillfish tip-bot2 for Mikhail Paulyshka
2025-07-08 19:50 ` tip-bot2 for Mikhail Paulyshka
2026-01-14 20:52 [PATCH v2 1/1] x86/rdrand: disable " Travis B
2026-01-14 21:28 ` Borislav Petkov
2026-01-14 21:41   ` Travis B
2026-01-14 22:09     ` Travis B
2026-01-15 10:28     ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®