aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'xen/arch/x86/time.c')
-rw-r--r--xen/arch/x86/time.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 06b0acf44a..208945ca33 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1,5 +1,4 @@
-/* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
- ****************************************************************************
+/****************************************************************************
* (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge
* (C) 2002-2003 University of Cambridge
****************************************************************************
@@ -52,7 +51,7 @@ static s_time_t stime_irq; /* System time at last 'time update' */
static unsigned long wc_sec, wc_usec; /* UTC time at last 'time update'. */
static rwlock_t time_lock = RW_LOCK_UNLOCKED;
-static void timer_interrupt(int irq, void *dev_id, struct xen_regs *regs)
+void timer_interrupt(int irq, void *dev_id, struct xen_regs *regs)
{
write_lock_irq(&time_lock);
@@ -275,19 +274,13 @@ s_time_t get_s_time(void)
return now;
}
-
-int update_dom_time(struct domain *d)
+static inline void __update_dom_time(struct exec_domain *ed)
{
+ struct domain *d = ed->domain;
shared_info_t *si = d->shared_info;
- unsigned long flags;
- if ( d->last_propagated_timestamp == full_tsc_irq )
- return 0;
-
- read_lock_irqsave(&time_lock, flags);
+ spin_lock(&d->time_lock);
- d->last_propagated_timestamp = full_tsc_irq;
-
si->time_version1++;
wmb();
@@ -300,12 +293,23 @@ int update_dom_time(struct domain *d)
wmb();
si->time_version2++;
+ spin_unlock(&d->time_lock);
+}
+
+int update_dom_time(struct exec_domain *ed)
+{
+ unsigned long flags;
+
+ if ( ed->domain->shared_info->tsc_timestamp == full_tsc_irq )
+ return 0;
+
+ read_lock_irqsave(&time_lock, flags);
+ __update_dom_time(ed);
read_unlock_irqrestore(&time_lock, flags);
return 1;
}
-
/* Set clock to <secs,usecs> after 00:00:00 UTC, 1 January, 1970. */
void do_settime(unsigned long secs, unsigned long usecs, u64 system_time_base)
{
@@ -326,12 +330,11 @@ void do_settime(unsigned long secs, unsigned long usecs, u64 system_time_base)
wc_sec = secs;
wc_usec = _usecs;
- write_unlock_irq(&time_lock);
-
/* Others will pick up the change at the next tick. */
- current->last_propagated_timestamp = 0; /* force propagation */
- (void)update_dom_time(current);
+ __update_dom_time(current);
send_guest_virq(current, VIRQ_TIMER);
+
+ write_unlock_irq(&time_lock);
}
@@ -386,3 +389,13 @@ void __init time_init(void)
setup_irq(0, &irq0);
}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */