Skip to content

Commit 7d06af2

Browse files
yghannamgregkh
authored andcommitted
x86/CPU/AMD: Ignore invalid reset reason value
commit e9576e0 upstream. The reset reason value may be "all bits set", e.g. 0xFFFFFFFF. This is a commonly used error response from hardware. This may occur due to a real hardware issue or when running in a VM. The user will see all reset reasons reported in this case. Check for an error response value and return early to avoid decoding invalid data. Also, adjust the data variable type to match the hardware register size. Fixes: ab81310 ("x86/CPU/AMD: Print the reason for the last reset") Reported-by: Libing He <libhe@redhat.com> Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/20250721181155.3536023-1-yazen.ghannam@amd.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 29c0ce3 commit 7d06af2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/x86/kernel/cpu/amd.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,8 +1324,8 @@ static const char * const s5_reset_reason_txt[] = {
13241324

13251325
static __init int print_s5_reset_status_mmio(void)
13261326
{
1327-
unsigned long value;
13281327
void __iomem *addr;
1328+
u32 value;
13291329
int i;
13301330

13311331
if (!cpu_feature_enabled(X86_FEATURE_ZEN))
@@ -1338,12 +1338,16 @@ static __init int print_s5_reset_status_mmio(void)
13381338
value = ioread32(addr);
13391339
iounmap(addr);
13401340

1341+
/* Value with "all bits set" is an error response and should be ignored. */
1342+
if (value == U32_MAX)
1343+
return 0;
1344+
13411345
for (i = 0; i < ARRAY_SIZE(s5_reset_reason_txt); i++) {
13421346
if (!(value & BIT(i)))
13431347
continue;
13441348

13451349
if (s5_reset_reason_txt[i]) {
1346-
pr_info("x86/amd: Previous system reset reason [0x%08lx]: %s\n",
1350+
pr_info("x86/amd: Previous system reset reason [0x%08x]: %s\n",
13471351
value, s5_reset_reason_txt[i]);
13481352
}
13491353
}

0 commit comments

Comments
 (0)