mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: Yazen Ghannam <yazen.ghannam@amd.com>, x86@kernel.org
Cc: linux-kernel@vger.kernel.org, Libing He <libhe@redhat.com>,
	David Arcari <darcari@redhat.com>
Subject: Re: [PATCH] x86/CPU/AMD: Ignore invalid reset reason value
Date: Mon, 21 Jul 2025 13:13:27 -0500	[thread overview]
Message-ID: <c7f895b1-4f48-4d41-91ed-26ca857e3665@kernel.org> (raw)
In-Reply-To: <20250721181155.3536023-1-yazen.ghannam@amd.com>

On 7/21/25 1:11 PM, Yazen Ghannam wrote:
> 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: ab8131028710 ("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>
> Cc: David Arcari <darcari@redhat.com>
> Cc: Mario Limonciello <mario.limonciello@amd.com>
> Cc: stable@vger.kernel.org
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>

> ---
>   arch/x86/kernel/cpu/amd.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
> index 50f88fe51816..db0f9e0d181a 100644
> --- a/arch/x86/kernel/cpu/amd.c
> +++ b/arch/x86/kernel/cpu/amd.c
> @@ -1274,8 +1274,8 @@ static const char * const s5_reset_reason_txt[] = {
>   
>   static __init int print_s5_reset_status_mmio(void)
>   {
> -	unsigned long value;
>   	void __iomem *addr;
> +	u32 value;
>   	int i;
>   
>   	if (!cpu_feature_enabled(X86_FEATURE_ZEN))
> @@ -1288,12 +1288,16 @@ static __init int print_s5_reset_status_mmio(void)
>   	value = ioread32(addr);
>   	iounmap(addr);
>   
> +	/* Value with "all bits set" is an error response and should be ignored. */
> +	if (value == U32_MAX)
> +		return 0;
> +
>   	for (i = 0; i < ARRAY_SIZE(s5_reset_reason_txt); i++) {
>   		if (!(value & BIT(i)))
>   			continue;
>   
>   		if (s5_reset_reason_txt[i]) {
> -			pr_info("x86/amd: Previous system reset reason [0x%08lx]: %s\n",
> +			pr_info("x86/amd: Previous system reset reason [0x%08x]: %s\n",
>   				value, s5_reset_reason_txt[i]);
>   		}
>   	}
> 
> base-commit: 65f55a30176662ee37fe18b47430ee30b57bfc98


  parent reply	other threads:[~2025-07-21 18:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-21 18:11 Yazen Ghannam
2025-07-21 18:11 ` Yazen Ghannam
2025-07-21 18:13 ` Mario Limonciello [this message]
2025-07-22 16:56 ` Borislav Petkov
2025-07-23 18:34   ` Yazen Ghannam
2025-07-23 19:35     ` Borislav Petkov
2025-07-23 19:46       ` Yazen Ghannam
2025-07-24 20:58       ` Sean Christopherson
2025-07-24 21:02         ` Mario Limonciello
2025-07-24 21:32           ` Sean Christopherson
2025-07-25  6:50             ` Borislav Petkov
2025-08-15 21:39               ` Sean Christopherson
2025-08-15 22:04                 ` Borislav Petkov
2025-08-15 22:49                   ` Sean Christopherson
2025-08-16  8:42                     ` Borislav Petkov
2025-08-18 14:24                       ` Sean Christopherson
2025-08-18 14:31                         ` Borislav Petkov
2025-08-18 15:35                           ` Sean Christopherson
2025-08-18 14:52 ` [tip: x86/urgent] " tip-bot2 for Yazen Ghannam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c7f895b1-4f48-4d41-91ed-26ca857e3665@kernel.org \
    --to=superm1@kernel.org \
    --cc=darcari@redhat.com \
    --cc=libhe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    --cc=yazen.ghannam@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®