linux/arch/x86/kernel
Rong Zhang e6416c2dfe x86/CPU/AMD: Prevent reset reasons from being retained across reboot
The S5_RESET_STATUS register is parsed on boot and printed to kmsg.
However, this could sometimes be misleading and lead to users wasting a
lot of time on meaningless debugging for two reasons:

* Some bits are never cleared by hardware. It's the software's
responsibility to clear them as per the Processor Programming Reference
(see [1]).

* Some rare hardware-initiated platform resets do not update the
register at all.

In both cases, a previous reboot could leave its trace in the register,
resulting in users seeing unrelated reboot reasons while debugging random
reboots afterward.

Write the read value back to the register in order to clear all reason bits
since they are write-1-to-clear while the others must be preserved.

  [1]: https://bugzilla.kernel.org/show_bug.cgi?id=206537#attach_303991

  [ bp: Massage commit message. ]

Fixes: ab81310287 ("x86/CPU/AMD: Print the reason for the last reset")
Signed-off-by: Rong Zhang <i@rong.moe>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
Cc: <stable@kernel.org>
Link: https://lore.kernel.org/all/20250913144245.23237-1-i@rong.moe/
2025-10-15 21:38:06 +02:00
..
acpi x86/acpi/cstate: Remove open coded check for cpu_feature_enabled() 2025-09-22 19:16:51 +02:00
apic x86/apic/savic: Do not use snp_abort() 2025-09-04 13:12:51 +02:00
cpu x86/CPU/AMD: Prevent reset reasons from being retained across reboot 2025-10-15 21:38:06 +02:00
fpu kernel-6.18-rc1.clone3 2025-09-29 10:36:50 -07:00
kprobes kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI 2025-09-24 14:29:14 -07:00
.gitignore
Makefile kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI 2025-09-24 14:29:14 -07:00
alternative.c - Remove a bunch of asm implementing condition flags testing in KVM's 2025-10-11 11:19:16 -07:00
amd_gart_64.c x86/platform/amd: Move the <asm/amd_nb.h> header to <asm/amd/nb.h> 2025-04-14 09:34:14 +02:00
amd_nb.c x86/cpuid: Set <asm/cpuid/api.h> as the main CPUID header 2025-05-15 18:23:55 +02:00
amd_node.c x86/platform/amd: Move the <asm/amd_node.h> header to <asm/amd/node.h> 2025-04-14 09:34:17 +02:00
aperture_64.c x86/platform/amd: Move the <asm/amd_nb.h> header to <asm/amd/nb.h> 2025-04-14 09:34:14 +02:00
apm_32.c
asm-offsets.c x86/fred: Play nice with invoking asm_fred_entry_from_kvm() on non-FRED hardware 2025-08-18 14:23:08 +02:00
asm-offsets_32.c x86/asm-offsets: Export certain 'struct cpuinfo_x86' fields for 64-bit asm use too 2025-05-15 09:12:07 +02:00
asm-offsets_64.c
audit_64.c
bootflag.c
callthunks.c x86/alternatives: Rename 'apply_relocation()' to 'text_poke_apply_relocation()' 2025-04-11 11:01:35 +02:00
cet.c x86/msr: Add explicit includes of <asm/msr.h> 2025-05-02 10:23:47 +02:00
cfi.c x86/traps: Clarify KCFI instruction layout 2025-09-04 21:59:07 +02:00
check.c
cpuid.c
crash.c x86/kexec: fix potential cmem->ranges out of memory 2025-09-13 17:32:54 -07:00
crash_dump_32.c
crash_dump_64.c
devicetree.c
doublefault_32.c
dumpstack.c x86/nmi: Consolidate NMI panic variables 2025-04-01 22:25:56 +02:00
dumpstack_32.c
dumpstack_64.c
e820.c x86/e820: temporarily enable KHO scratch for memory below 1M 2025-05-12 23:50:41 -07:00
early-quirks.c
early_printk.c Linux 6.15-rc4 2025-05-06 12:03:03 +02:00
ebda.c
eisa.c
espfix_64.c
fred.c x86/msr: Add explicit includes of <asm/msr.h> 2025-05-02 10:23:47 +02:00
ftrace.c x86/ftrace: enable EXECMEM_ROX_CACHE for ftrace allocations 2025-08-02 12:06:12 -07:00
ftrace_32.S
ftrace_64.S
head32.c x86/microcode: Consolidate the loader enablement checking 2025-05-05 10:51:00 +02:00
head64.c x86/boot: Create a confined code area for startup code 2025-09-03 18:00:01 +02:00
head_32.S x86/boot: Move startup code out of __head section 2025-09-03 18:06:04 +02:00
head_64.S x86/boot: Move startup code out of __head section 2025-09-03 18:06:04 +02:00
hpet.c x86/cpuid: Set <asm/cpuid/api.h> as the main CPUID header 2025-05-15 18:23:55 +02:00
hw_breakpoint.c
i8237.c
i8253.c x86/i8253: Call clockevent_i8253_disable() with interrupts disabled 2025-04-11 07:28:20 +02:00
i8259.c
ibt_selftest.S
idt.c
io_delay.c
ioport.c x86/iopl: Cure TIF_IO_BITMAP inconsistencies 2025-06-03 15:56:39 +02:00
irq.c x86/irq: Plug vector setup race 2025-08-04 23:34:03 +02:00
irq_32.c
irq_64.c
irq_work.c
irqflags.S
irqinit.c x86/fred: Install system vector handlers even if FRED isn't fully enabled 2025-08-18 14:23:08 +02:00
itmt.c x86/itmt: Add debugfs file to show core priorities 2025-07-07 22:35:51 +02:00
jailhouse.c x86/cpuid: Rename hypervisor_cpuid_base()/for_each_possible_hypervisor_cpuid_base() to cpuid_base_hypervisor()/for_each_possible_cpuid_base_hypervisor() 2025-05-16 10:54:47 +02:00
jump_label.c x86/alternatives: Rename 'text_poke_queue()' to 'smp_text_poke_batch_add()' 2025-04-11 11:01:33 +02:00
kdebugfs.c
kexec-bzimage64.c x86/kexec: carry forward the boot DTB on kexec 2025-09-13 17:32:43 -07:00
kgdb.c x86/traps: Initialize DR7 by writing its architectural reset value 2025-06-24 13:15:52 -07:00
ksysfs.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
kvm.c x86/kvm: Prefer native qspinlock for dedicated vCPUs irrespective of PV_UNHALT 2025-09-11 08:58:37 -07:00
kvmclock.c x86/pvops/msr: Refactor pv_cpu_ops.write_msr{,_safe}() 2025-05-02 10:36:36 +02:00
ldt.c
machine_kexec_32.c x86/mm: Fix _pgd_alloc() for Xen PV mode 2025-04-23 07:49:14 -07:00
machine_kexec_64.c - Remove a bunch of asm implementing condition flags testing in KVM's 2025-10-11 11:19:16 -07:00
mmconf-fam10h_64.c x86/msr: Rename 'wrmsrl()' to 'wrmsrq()' 2025-04-10 11:58:33 +02:00
module.c Merge commit 'its-for-linus-20250509-merge' into x86/core, to resolve conflicts 2025-05-13 10:47:10 +02:00
mpparse.c
msr.c
nmi.c x86/nmi: Improve NMI duration console printouts 2025-04-01 22:26:38 +02:00
nmi_selftest.c x86/nmi: Clean up NMI selftest 2025-04-01 22:26:32 +02:00
paravirt-spinlocks.c
paravirt.c x86/paravirt: Restrict PARAVIRT_XXL to 64-bit only 2025-05-17 10:38:29 +02:00
pci-dma.c
pcspeaker.c
perf_regs.c
platform-quirks.c
pmem.c
probe_roms.c
process.c - Make TDX and kexec work together 2025-10-04 10:01:30 -07:00
process.h
process_32.c x86/traps: Initialize DR7 by writing its architectural reset value 2025-06-24 13:15:52 -07:00
process_64.c x86/process: Clear hardware feedback history for AMD processors 2025-07-07 22:30:36 +02:00
ptrace.c x86/ptrace: Use USER_REGSET_NOTE_TYPE() to specify regset note names 2025-07-14 22:27:48 -07:00
pvclock.c
quirks.c
reboot.c
reboot_fixups_32.c x86/msr: Rename 'wrmsrl()' to 'wrmsrq()' 2025-04-10 11:58:33 +02:00
relocate_kernel_32.S x86/asm: Remove semicolon from "rep" prefixes 2025-04-18 09:33:33 +02:00
relocate_kernel_64.S x86/sme: Use percpu boolean to control WBINVD during kexec 2025-09-05 10:40:40 -07:00
resource.c
rethook.c
rtc.c
setup.c Significant patch series in this pull request: 2025-08-03 16:23:09 -07:00
setup_percpu.c
sev_verify_cbit.S
shstk.c Performance events updates for v6.18: 2025-09-30 11:11:21 -07:00
signal.c x86/fpu: Convert task_struct::thread.fpu accesses to use x86_task_fpu() 2025-04-14 08:18:29 +02:00
signal_32.c x86/fred/signal: Prevent immediate repeat of single step trap on return from SIGTRAP handler 2025-06-09 08:50:58 -07:00
signal_64.c x86/fred/signal: Prevent immediate repeat of single step trap on return from SIGTRAP handler 2025-06-09 08:50:58 -07:00
smp.c x86/smp: PM/hibernate: Split arch_resume_nosmt() 2025-06-07 14:22:56 +02:00
smpboot.c sched/fair: Get rid of sched_domains_curr_level hack for tl->cpumask() 2025-09-03 10:03:12 +02:00
stacktrace.c
static_call.c Merge commit 'its-for-linus-20250509-merge' into x86/core, to resolve conflicts 2025-05-13 10:47:10 +02:00
step.c
sys_ia32.c
sys_x86_64.c
tboot.c
time.c
tls.c
tls.h
trace.c
trace_clock.c x86/msr: Add explicit includes of <asm/msr.h> 2025-05-02 10:23:47 +02:00
traps.c x86,ibt: Use UDB instead of 0xEA 2025-09-04 21:59:09 +02:00
tsc.c x86/cpuid: Set <asm/cpuid/api.h> as the main CPUID header 2025-05-15 18:23:55 +02:00
tsc_msr.c
tsc_sync.c x86/msr: Add explicit includes of <asm/msr.h> 2025-05-02 10:23:47 +02:00
umip.c x86/umip: Fix decoding of register forms of 0F 01 (SGDT and SIDT aliases) 2025-09-19 21:34:48 +02:00
unwind_frame.c
unwind_guess.c
unwind_orc.c
uprobes.c uprobes/x86: Return error from uprobe syscall when not called from trampoline 2025-09-15 13:46:29 +02:00
verify_cpu.S
vm86_32.c
vmcore_info_32.c
vmcore_info_64.c
vmlinux.lds.S x86/boot: Get rid of the .head.text section 2025-09-03 18:06:32 +02:00
vsmp_64.c
x86_init.c