Skip to content

Commit e9576e0

Browse files
yghannambp3tk0v
authored andcommitted
x86/CPU/AMD: Ignore invalid reset reason value
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 <[email protected]> Signed-off-by: Yazen Ghannam <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/[email protected]
1 parent d8df126 commit e9576e0

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
@@ -1326,8 +1326,8 @@ static const char * const s5_reset_reason_txt[] = {
13261326

13271327
static __init int print_s5_reset_status_mmio(void)
13281328
{
1329-
unsigned long value;
13301329
void __iomem *addr;
1330+
u32 value;
13311331
int i;
13321332

13331333
if (!cpu_feature_enabled(X86_FEATURE_ZEN))
@@ -1340,12 +1340,16 @@ static __init int print_s5_reset_status_mmio(void)
13401340
value = ioread32(addr);
13411341
iounmap(addr);
13421342

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

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

0 commit comments

Comments
 (0)