lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250501083151.GBaBMxdyrtpcVlQaei@fat_crate.local>
Date: Thu, 1 May 2025 10:31:51 +0200
From: Borislav Petkov <bp@...en8.de>
To: Mario Limonciello <superm1@...nel.org>
Cc: Jean Delvare <jdelvare@...e.com>, Andi Shyti <andi.shyti@...nel.org>,
	Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
	Jonathan Corbet <corbet@....net>,
	Mario Limonciello <mario.limonciello@....com>,
	Yazen Ghannam <yazen.ghannam@....com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
	"H . Peter Anvin" <hpa@...or.com>,
	Shyam Sundar S K <Shyam-sundar.S-k@....com>,
	Hans de Goede <hdegoede@...hat.com>,
	"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
	open list <linux-kernel@...r.kernel.org>,
	"open list:I2C/SMBUS CONTROLLER DRIVERS FOR PC" <linux-i2c@...r.kernel.org>,
	"open list:AMD PMC DRIVER" <platform-driver-x86@...r.kernel.org>
Subject: Re: [PATCH v5 5/5] x86/CPU/AMD: Print the reason for the last reset

On Wed, Apr 30, 2025 at 02:32:44PM -0500, Mario Limonciello wrote:
> This would work, but would still need to track if "no" known bits were set
> to emit an "unknown" message.

No, when no bits are set, you don't emit anything. Because the information
content of "oh, your system rebooted due to an unknown reason" is minimal and
even actively confusing at best.

Let sleeping dogs lie.

---
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index bef871adbf84..9a8c590456d0 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -1264,10 +1264,9 @@ static const char * const s5_reset_reason_txt[] = {
 
 static __init int print_s5_reset_status_mmio(void)
 {
-	void __iomem *addr;
 	unsigned long value;
-	int nr_reasons = 0;
-	int bit = -1;
+	void __iomem *addr;
+	int i;
 
 	if (!cpu_feature_enabled(X86_FEATURE_ZEN))
 		return 0;
@@ -1279,23 +1278,13 @@ static __init int print_s5_reset_status_mmio(void)
 	value = ioread32(addr);
 	iounmap(addr);
 
-	/* Iterate on each bit in the 'value' mask: */
-	while (true) {
-		bit = find_next_bit(&value, BITS_PER_LONG, bit + 1);
-
-		/* Reached the end of the word, no more bits: */
-		if (bit >= BITS_PER_LONG) {
-			if (!nr_reasons)
-				pr_info("x86/amd: Previous system reset reason [0x%08lx]: Unknown\n", value);
-			break;
-		}
-
-		if (!s5_reset_reason_txt[bit])
+	for (i = 0; i <= ARRAY_SIZE(s5_reset_reason_txt); i++) {
+		if (!(value & BIT(i)))
 			continue;
 
-		nr_reasons++;
-		pr_info("x86/amd: Previous system reset reason [0x%08lx]: %s\n",
-			value, s5_reset_reason_txt[bit]);
+		if (s5_reset_reason_txt[i])
+			pr_info("x86/amd: Previous system reset reason [0x%08lx]: %s\n",
+				value, s5_reset_reason_txt[i]);
 	}
 
 	return 0;

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ