diff --git a/arch/x86/time.c b/arch/x86/time.c index 2c8d033..26750d5 100644 --- a/arch/x86/time.c +++ b/arch/x86/time.c @@ -79,6 +79,13 @@ static inline int time_values_up_to_date(void) return (shadow.version == src->version); } +static inline int wc_values_up_to_date(void) +{ + shared_info_t *s= HYPERVISOR_shared_info; + + return (shadow_ts_version == s->version); +} + /* * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction, @@ -160,7 +167,7 @@ uint64_t monotonic_clock(void) local_time_version = shadow.version; rmb(); time = shadow.system_timestamp + get_nsec_offset(); - if (!time_values_up_to_date()) + if (!time_values_up_to_date()) get_time_values_from_xen(); rmb(); } while (local_time_version != shadow.version); @@ -186,9 +193,12 @@ static void update_wallclock(void) int gettimeofday(struct timeval *tv, void *tz) { uint64_t nsec = monotonic_clock(); + + if (!wc_values_up_to_date()) + update_wallclock(); + nsec += shadow_ts.tv_nsec; - - + tv->tv_sec = shadow_ts.tv_sec; tv->tv_sec += NSEC_TO_SEC(nsec); tv->tv_usec = NSEC_TO_USEC(nsec % 1000000000UL); @@ -199,8 +209,6 @@ int gettimeofday(struct timeval *tv, void *tz) void block_domain(s_time_t until) { - struct timeval tv; - gettimeofday(&tv, NULL); ASSERT(irqs_disabled()); if(monotonic_clock() < until) { @@ -216,8 +224,6 @@ void block_domain(s_time_t until) */ static void timer_handler(evtchn_port_t ev, struct pt_regs *regs, void *ign) { - get_time_values_from_xen(); - update_wallclock(); }