31
31
/* Xen may fire a timer up to this many ns early */
32
32
#define TIMER_SLOP 100000
33
33
34
+ static u64 xen_sched_clock_offset __read_mostly ;
35
+
34
36
/* Get the TSC speed from Xen */
35
37
static unsigned long xen_tsc_khz (void )
36
38
{
@@ -57,6 +59,11 @@ static u64 xen_clocksource_get_cycles(struct clocksource *cs)
57
59
return xen_clocksource_read ();
58
60
}
59
61
62
+ static u64 xen_sched_clock (void )
63
+ {
64
+ return xen_clocksource_read () - xen_sched_clock_offset ;
65
+ }
66
+
60
67
static void xen_read_wallclock (struct timespec64 * ts )
61
68
{
62
69
struct shared_info * s = HYPERVISOR_shared_info ;
@@ -367,7 +374,7 @@ void xen_timer_resume(void)
367
374
}
368
375
369
376
static const struct pv_time_ops xen_time_ops __initconst = {
370
- .sched_clock = xen_clocksource_read ,
377
+ .sched_clock = xen_sched_clock ,
371
378
.steal_clock = xen_steal_clock ,
372
379
};
373
380
@@ -505,6 +512,7 @@ static void __init xen_time_init(void)
505
512
506
513
void __init xen_init_time_ops (void )
507
514
{
515
+ xen_sched_clock_offset = xen_clocksource_read ();
508
516
pv_time_ops = xen_time_ops ;
509
517
510
518
x86_init .timers .timer_init = xen_time_init ;
@@ -546,6 +554,7 @@ void __init xen_hvm_init_time_ops(void)
546
554
return ;
547
555
}
548
556
557
+ xen_sched_clock_offset = xen_clocksource_read ();
549
558
pv_time_ops = xen_time_ops ;
550
559
x86_init .timers .setup_percpu_clockev = xen_time_init ;
551
560
x86_cpuinit .setup_percpu_clockev = xen_hvm_setup_cpu_clockevents ;
0 commit comments