Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] x86/pm: Save AMD CPUID leaf 7 across S3
@ 2026-08-04 10:13 Sean Rhodes
  2026-08-04 18:49 ` Borislav Petkov
  0 siblings, 1 reply; 12+ messages in thread
From: Sean Rhodes @ 2026-08-04 10:13 UTC (permalink / raw)
  To: x86
  Cc: Rafael J. Wysocki, Pavel Machek, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, H. Peter Anvin, linux-pm,
	linux-kernel

Some AMD systems return from S3 with the boot CPU CPUID leaf 7
override MSR reset. On Byte/Cezanne, CPUID leaf 7 EBX becomes
0x219c9fb9 on CPU0 after S3 even though XTEST still raises #UD.
Userspace can then select RTM-optimised glibc paths and fault after
resume.

The x86 suspend code already has a small MSR save/restore list for
firmware-modified MSRs and restores it after resume microcode has been
loaded. Add MSR_AMD64_CPUID_FN_7 for the AMD families that can modify
this MSR during CPU init so the pre-suspend CPUID mask is restored
before tasks are thawed.

This covers family 17h, 19h, and 1Ah: family 17h has the Cyan Skillfish
RDSEED leaf-7 quirk, family 19h covers the observed Cezanne issue, and
family 1Ah has the Zen5 RDSEED leaf-7 quirk.

Tested on StarBook Mk V (Byte/Cezanne, 26.07 firmware):
- without this restore, dmesg showed "ACPI: PM: Low-level resume complete"
  and "PM: suspend exit"; the post-S3 CPUID probe showed CPU0 leaf 7 EBX
  0x219c9fb9 with hle=1 rtm=1 while XTEST still raised #UD.
- a temporary PM resume hook clearing the same MSR logged
  "CPU0 MSR_AMD64_CPUID_FN_7 0x219c9fb9 -> 0x219c97a9"; the post-S3 probe
  showed hle=0 rtm=0 on all CPUs.
- this patch booted on Byte and registered the MSR save path; dmesg showed
  "x86/pm: AMD family 0x19 CPU detected"; pm_test freezer/devices/platform/
  processors/core passed with the same boot ID.

Tested-by: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
---
 arch/x86/power/cpu.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
index 702f30eaf9c4..b85061f4cee4 100644
--- a/arch/x86/power/cpu.c
+++ b/arch/x86/power/cpu.c
@@ -467,9 +467,24 @@ static int msr_save_cpuid_features(const struct x86_cpu_id *c)
 	return msr_build_context(cpuid_msr_id, ARRAY_SIZE(cpuid_msr_id));
 }
 
+static int msr_save_amd_leaf7_cpuid_features(const struct x86_cpu_id *c)
+{
+	u32 cpuid_msr_id[] = {
+		MSR_AMD64_CPUID_FN_7,
+	};
+
+	pr_info("x86/pm: AMD family %#x CPU detected, saving CPUID leaf 7 MSR across suspend.\n",
+		c->family);
+
+	return msr_build_context(cpuid_msr_id, ARRAY_SIZE(cpuid_msr_id));
+}
+
 static const struct x86_cpu_id msr_save_cpu_table[] = {
 	X86_MATCH_VENDOR_FAM(AMD, 0x15, &msr_save_cpuid_features),
 	X86_MATCH_VENDOR_FAM(AMD, 0x16, &msr_save_cpuid_features),
+	X86_MATCH_VENDOR_FAM(AMD, 0x17, &msr_save_amd_leaf7_cpuid_features),
+	X86_MATCH_VENDOR_FAM(AMD, 0x19, &msr_save_amd_leaf7_cpuid_features),
+	X86_MATCH_VENDOR_FAM(AMD, 0x1a, &msr_save_amd_leaf7_cpuid_features),
 	{}
 };
 

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

end of thread, other threads:[~2026-08-12  7:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04 10:13 [PATCH] x86/pm: Save AMD CPUID leaf 7 across S3 Sean Rhodes
2026-08-04 18:49 ` Borislav Petkov
2026-08-04 19:22   ` Sean Rhodes
2026-08-06  1:29     ` Borislav Petkov
2026-08-10 18:31       ` Mario Limonciello
2026-08-10 19:42         ` Sean Rhodes
2026-08-10 20:07           ` Mario Limonciello
2026-08-10 21:33             ` Borislav Petkov
2026-08-11 18:25               ` Mario Limonciello
2026-08-11 18:40                 ` Borislav Petkov
2026-08-11 18:45                   ` Mario Limonciello
2026-08-12  7:42   ` David Laight

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