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>] [day] [month] [year] [list]
Message-ID: <20250226132733.58327-1-gpiccoli@igalia.com>
Date: Wed, 26 Feb 2025 10:27:13 -0300
From: "Guilherme G. Piccoli" <gpiccoli@...lia.com>
To: x86@...nel.org,
	linux-kernel@...r.kernel.org
Cc: tglx@...utronix.de,
	mingo@...hat.com,
	bp@...en8.de,
	dave.hansen@...ux.intel.com,
	hpa@...or.com,
	kernel@...ccoli.net,
	kernel-dev@...lia.com,
	"Guilherme G. Piccoli" <gpiccoli@...lia.com>
Subject: [PATCH] x86/tsc: Add debugfs entry to mark TSC as unstable after boot

Right now, we can force the TSC to be marked as unstable through
boot parameter. There are debug / test cases though in which would
be preferable to simulate the clocksource watchdog behavior, i.e.,
marking TSC as unstable during the system run. Some paths might
change, for example: the tracing clock is auto switched to global
if TSC is marked as unstable on boot, but it could remain local if
TSC gets marked as unstable after tracing initialization.

Hence, the proposal here is to have a simple debugfs file that
gets TSC marked as unstable when written.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@...lia.com>
---
 arch/x86/kernel/tsc.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 88e5a4ed9db3..6bce5f3a2848 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -9,6 +9,7 @@
 #include <linux/timer.h>
 #include <linux/acpi_pmtmr.h>
 #include <linux/cpufreq.h>
+#include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/clocksource.h>
 #include <linux/percpu.h>
@@ -1602,3 +1603,24 @@ unsigned long calibrate_delay_is_known(void)
 	return 0;
 }
 #endif
+
+#ifdef CONFIG_DEBUG_FS
+static ssize_t tsc_debugfs_write(struct file *f, const char __user *ubuf,
+				 size_t count, loff_t *ppos)
+{
+	mark_tsc_unstable("debugfs write");
+	return count;
+}
+
+static const struct file_operations tsc_debugfs_fops = {
+	.write	= tsc_debugfs_write,
+};
+
+static __init int tsc_debugfs_init(void)
+{
+	debugfs_create_file("mark_tsc_unstable", 0200, /* write only */
+			    arch_debugfs_dir, NULL, &tsc_debugfs_fops);
+	return 0;
+}
+late_initcall(tsc_debugfs_init);
+#endif /* CONFIG_DEBUG_FS */
-- 
2.48.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ