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] [thread-next>] [day] [month] [year] [list]
Message-Id: <1379188081-15613-7-git-send-email-mathieu.desnoyers@efficios.com>
Date:	Sat, 14 Sep 2013 12:48:00 -0700
From:	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
To:	John Stultz <john.stultz@...aro.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Peter Zijlstra <peterz@...radead.org>,
	linux-kernel@...r.kernel.org
Cc:	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Subject: [PATCH 6/7] x86 tsc clock: implement clock latch

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: John Stultz <john.stultz@...aro.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Peter Zijlstra <peterz@...radead.org>
---
 arch/x86/kernel/tsc.c |   22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 6ff4924..c75e9f9 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -766,10 +766,28 @@ static cycle_t read_tsc(struct clocksource *cs)
 		ret : clocksource_tsc.cycle_last;
 }
 
+static cycle_t read_tsc_latch(struct clocksource *cs, int index)
+{
+	cycle_t ret = (cycle_t)get_cycles();
+
+	return ret >= clocksource_tsc.cycle_last_latch[index] ?
+		ret : clocksource_tsc.cycle_last_latch[index];
+}
+
+static void update_tsc_latch(struct clocksource *cs, int oldindex,
+		int newindex)
+{
+	clocksource_tsc.cycle_last_latch[newindex] =
+		clocksource_tsc.cycle_last_latch[oldindex];
+}
+
 static void resume_tsc(struct clocksource *cs)
 {
-	if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC_S3))
+	if (!boot_cpu_has(X86_FEATURE_NONSTOP_TSC_S3)) {
 		clocksource_tsc.cycle_last = 0;
+		clocksource_tsc.cycle_last_latch[0] = 0;
+		clocksource_tsc.cycle_last_latch[1] = 0;
+	}
 }
 
 static struct clocksource clocksource_tsc = {
@@ -783,6 +801,8 @@ static struct clocksource clocksource_tsc = {
 #ifdef CONFIG_X86_64
 	.archdata               = { .vclock_mode = VCLOCK_TSC },
 #endif
+	.read_latch		= read_tsc_latch,
+	.update_latch		= update_tsc_latch,
 };
 
 void mark_tsc_unstable(char *reason)
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ