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]
Date:	Wed, 10 Mar 2010 15:47:05 +0000
From:	Stefano Stabellini <stefano.stabellini@...citrix.com>
To:	xen-devel@...ts.xensource.com, linux-kernel@...r.kernel.org
Subject: [PATCH 3 of 5] pv clocksource

Hi all,
this adds a PV clocksource that can provide a reliable clocksource for
Linux running as an HVM guest on Xen.

Signed-off-by: Stefano Stabellini <stefano.stabellini@...citrix.com>
Signed-off-by: Sheng Yang <sheng@...ux.intel.com>

---

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 42135e8..6292cc6 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1253,6 +1253,20 @@ static void __init init_shared_info(void)
 	per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0];
 }
 
+static void __init init_pv_clocksource(void)
+{
+	if (!xen_hvm_domain())
+		return;
+
+	pv_time_ops.sched_clock = xen_sched_clock;
+
+	x86_platform.calibrate_tsc = xen_tsc_khz;
+	x86_platform.get_wallclock = xen_get_wallclock;
+	x86_platform.set_wallclock = xen_set_wallclock;
+
+	xen_register_clocksource();
+}
+
 void __init xen_guest_init(void)
 {
 	int r;
@@ -1262,5 +1276,6 @@ void __init xen_guest_init(void)
 		return;
 
 	init_shared_info();
+	init_pv_clocksource();
 }
 
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index 0a5aa44..d1c1c50 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -474,11 +474,21 @@ void xen_timer_resume(void)
 	}
 }
 
+static bool xen_clocksource_enabled;
+
+void xen_register_clocksource(void)
+{
+	if (!xen_clocksource_enabled) {
+		clocksource_register(&xen_clocksource);
+		xen_clocksource_enabled = 1;
+	}
+}
+
 __init void xen_time_init(void)
 {
 	int cpu = smp_processor_id();
 
-	clocksource_register(&xen_clocksource);
+	xen_register_clocksource();
 
 	if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL) == 0) {
 		/* Successfully turned off 100Hz tick, so we have the
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 355fa6b..2aeaf51 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -46,6 +46,7 @@ cycle_t xen_clocksource_read(void);
 void xen_setup_cpu_clockevents(void);
 unsigned long xen_tsc_khz(void);
 void __init xen_time_init(void);
+void xen_register_clocksource(void);
 unsigned long xen_get_wallclock(void);
 int xen_set_wallclock(unsigned long time);
 unsigned long long xen_sched_clock(void);
--
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