debuggers.hg
view linux-2.4.27-xen-sparse/arch/xen/kernel/time.c @ 2651:e1abd8945ded
bitkeeper revision 1.1159.1.213 (416517f3vAbY9ISDviAe0Gjenl6dKw)
Take better care of over time consistency in XenLinux.
Avoid spinning on serial line with interrupts disabled in Xen.
Take better care of over time consistency in XenLinux.
Avoid spinning on serial line with interrupts disabled in Xen.
author | kaf24@freefall.cl.cam.ac.uk |
---|---|
date | Thu Oct 07 10:18:27 2004 +0000 (2004-10-07) |
parents | ff4e7a241335 |
children | 756c16a98f27 d7ee91c5f868 |
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
2 ****************************************************************************
3 * (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge
4 * (C) 2002-2003 - Keir Fraser - University of Cambridge
5 ****************************************************************************
6 *
7 * File: arch/xen/kernel/time.c
8 * Author: Rolf Neugebauer and Keir Fraser
9 *
10 * Description: Interface with Xen to get correct notion of time
11 */
13 /*
14 * linux/arch/i386/kernel/time.c
15 *
16 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
17 *
18 * This file contains the PC-specific time handling details:
19 * reading the RTC at bootup, etc..
20 * 1994-07-02 Alan Modra
21 * fixed set_rtc_mmss, fixed time.year for >= 2000, new mktime
22 * 1995-03-26 Markus Kuhn
23 * fixed 500 ms bug at call to set_rtc_mmss, fixed DS12887
24 * precision CMOS clock update
25 * 1996-05-03 Ingo Molnar
26 * fixed time warps in do_[slow|fast]_gettimeoffset()
27 * 1997-09-10 Updated NTP code according to technical memorandum Jan '96
28 * "A Kernel Model for Precision Timekeeping" by Dave Mills
29 * 1998-09-05 (Various)
30 * More robust do_fast_gettimeoffset() algorithm implemented
31 * (works with APM, Cyrix 6x86MX and Centaur C6),
32 * monotonic gettimeofday() with fast_get_timeoffset(),
33 * drift-proof precision TSC calibration on boot
34 * (C. Scott Ananian <cananian@alumni.princeton.edu>, Andrew D.
35 * Balsa <andrebalsa@altern.org>, Philip Gladstone <philip@raptor.com>;
36 * ported from 2.0.35 Jumbo-9 by Michael Krause <m.krause@tu-harburg.de>).
37 * 1998-12-16 Andrea Arcangeli
38 * Fixed Jumbo-9 code in 2.1.131: do_gettimeofday was missing 1 jiffy
39 * because was not accounting lost_ticks.
40 * 1998-12-24 Copyright (C) 1998 Andrea Arcangeli
41 * Fixed a xtime SMP race (we need the xtime_lock rw spinlock to
42 * serialize accesses to xtime/lost_ticks).
43 */
45 #include <asm/smp.h>
46 #include <asm/irq.h>
47 #include <asm/msr.h>
48 #include <asm/delay.h>
49 #include <asm/mpspec.h>
50 #include <asm/uaccess.h>
51 #include <asm/processor.h>
53 #include <asm/div64.h>
54 #include <asm/hypervisor.h>
55 #include <asm/hypervisor-ifs/dom0_ops.h>
57 #include <linux/mc146818rtc.h>
58 #include <linux/kernel.h>
59 #include <linux/interrupt.h>
60 #include <linux/time.h>
61 #include <linux/init.h>
62 #include <linux/smp.h>
63 #include <linux/irq.h>
64 #include <linux/sysctl.h>
65 #include <linux/sysrq.h>
67 spinlock_t rtc_lock = SPIN_LOCK_UNLOCKED;
68 extern rwlock_t xtime_lock;
69 extern unsigned long wall_jiffies;
71 unsigned long cpu_khz; /* get this from Xen, used elsewhere */
73 static unsigned int rdtsc_bitshift;
74 static u32 st_scale_f; /* convert ticks -> usecs */
75 static u32 st_scale_i; /* convert ticks -> usecs */
77 /* These are peridically updated in shared_info, and then copied here. */
78 static u32 shadow_tsc_stamp;
79 static u64 shadow_system_time;
80 static u32 shadow_time_version;
81 static struct timeval shadow_tv;
83 /*
84 * We use this to ensure that gettimeofday() is monotonically increasing. We
85 * only break this guarantee if the wall clock jumps backwards "a long way".
86 */
87 static struct timeval last_seen_tv = {0,0};
89 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
90 /* Periodically propagate synchronised time base to the RTC and to Xen. */
91 static long last_update_to_rtc, last_update_to_xen;
92 #endif
94 /* Periodically take synchronised time base from Xen, if we need it. */
95 static long last_update_from_xen; /* UTC seconds when last read Xen clock. */
97 /* Keep track of last time we did processing/updating of jiffies and xtime. */
98 static u64 processed_system_time; /* System time (ns) at last processing. */
100 #define NS_PER_TICK (1000000000ULL/HZ)
102 #define HANDLE_USEC_UNDERFLOW(_tv) \
103 do { \
104 while ( (_tv).tv_usec < 0 ) \
105 { \
106 (_tv).tv_usec += 1000000; \
107 (_tv).tv_sec--; \
108 } \
109 } while ( 0 )
110 #define HANDLE_USEC_OVERFLOW(_tv) \
111 do { \
112 while ( (_tv).tv_usec >= 1000000 ) \
113 { \
114 (_tv).tv_usec -= 1000000; \
115 (_tv).tv_sec++; \
116 } \
117 } while ( 0 )
119 /* Dynamically-mapped IRQs. */
120 static int time_irq, debug_irq;
122 /* Does this guest OS track Xen time, or set its wall clock independently? */
123 static int independent_wallclock = 0;
124 static int __init __independent_wallclock(char *str)
125 {
126 independent_wallclock = 1;
127 return 1;
128 }
129 __setup("independent_wallclock", __independent_wallclock);
130 #define INDEPENDENT_WALLCLOCK() \
131 (independent_wallclock || (xen_start_info.flags & SIF_INITDOMAIN))
133 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
134 /*
135 * In order to set the CMOS clock precisely, set_rtc_mmss has to be
136 * called 500 ms after the second nowtime has started, because when
137 * nowtime is written into the registers of the CMOS clock, it will
138 * jump to the next second precisely 500 ms later. Check the Motorola
139 * MC146818A or Dallas DS12887 data sheet for details.
140 *
141 * BUG: This routine does not handle hour overflow properly; it just
142 * sets the minutes. Usually you'll only notice that after reboot!
143 */
144 static int set_rtc_mmss(unsigned long nowtime)
145 {
146 int retval = 0;
147 int real_seconds, real_minutes, cmos_minutes;
148 unsigned char save_control, save_freq_select;
150 /* gets recalled with irq locally disabled */
151 spin_lock(&rtc_lock);
152 save_control = CMOS_READ(RTC_CONTROL);
153 CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
155 save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
156 CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
158 cmos_minutes = CMOS_READ(RTC_MINUTES);
159 if ( !(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD )
160 BCD_TO_BIN(cmos_minutes);
162 /*
163 * since we're only adjusting minutes and seconds, don't interfere with
164 * hour overflow. This avoids messing with unknown time zones but requires
165 * your RTC not to be off by more than 15 minutes
166 */
167 real_seconds = nowtime % 60;
168 real_minutes = nowtime / 60;
169 if ( ((abs(real_minutes - cmos_minutes) + 15)/30) & 1 )
170 real_minutes += 30; /* correct for half hour time zone */
171 real_minutes %= 60;
173 if ( abs(real_minutes - cmos_minutes) < 30 )
174 {
175 if ( !(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD )
176 {
177 BIN_TO_BCD(real_seconds);
178 BIN_TO_BCD(real_minutes);
179 }
180 CMOS_WRITE(real_seconds,RTC_SECONDS);
181 CMOS_WRITE(real_minutes,RTC_MINUTES);
182 }
183 else
184 {
185 printk(KERN_WARNING
186 "set_rtc_mmss: can't update from %d to %d\n",
187 cmos_minutes, real_minutes);
188 retval = -1;
189 }
191 /* The following flags have to be released exactly in this order,
192 * otherwise the DS12887 (popular MC146818A clone with integrated
193 * battery and quartz) will not reset the oscillator and will not
194 * update precisely 500 ms later. You won't find this mentioned in
195 * the Dallas Semiconductor data sheets, but who believes data
196 * sheets anyway ... -- Markus Kuhn
197 */
198 CMOS_WRITE(save_control, RTC_CONTROL);
199 CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
200 spin_unlock(&rtc_lock);
202 return retval;
203 }
204 #endif
207 /*
208 * Reads a consistent set of time-base values from Xen, into a shadow data
209 * area. Must be called with the xtime_lock held for writing.
210 */
211 static void __get_time_values_from_xen(void)
212 {
213 do {
214 shadow_time_version = HYPERVISOR_shared_info->time_version2;
215 rmb();
216 shadow_tv.tv_sec = HYPERVISOR_shared_info->wc_sec;
217 shadow_tv.tv_usec = HYPERVISOR_shared_info->wc_usec;
218 shadow_tsc_stamp =
219 (u32)(HYPERVISOR_shared_info->tsc_timestamp >> rdtsc_bitshift);
220 shadow_system_time = HYPERVISOR_shared_info->system_time;
221 rmb();
222 }
223 while ( shadow_time_version != HYPERVISOR_shared_info->time_version1 );
224 }
226 #define TIME_VALUES_UP_TO_DATE \
227 ({ rmb(); (shadow_time_version == HYPERVISOR_shared_info->time_version2); })
230 /*
231 * Returns the system time elapsed, in ns, since the current shadow_timestamp
232 * was calculated. Must be called with the xtime_lock held for reading.
233 */
234 static inline unsigned long __get_time_delta_usecs(void)
235 {
236 s32 delta_tsc;
237 u32 low;
238 u64 delta, tsc;
240 rdtscll(tsc);
241 low = (u32)(tsc >> rdtsc_bitshift);
242 delta_tsc = (s32)(low - shadow_tsc_stamp);
243 if ( unlikely(delta_tsc < 0) ) delta_tsc = 0;
244 delta = ((u64)delta_tsc * st_scale_f);
245 delta >>= 32;
246 delta += ((u64)delta_tsc * st_scale_i);
248 return (unsigned long)delta;
249 }
252 /*
253 * Returns the current time-of-day in UTC timeval format.
254 */
255 void do_gettimeofday(struct timeval *tv)
256 {
257 unsigned long flags, lost;
258 struct timeval _tv;
260 again:
261 read_lock_irqsave(&xtime_lock, flags);
263 _tv.tv_usec = __get_time_delta_usecs();
264 if ( (lost = (jiffies - wall_jiffies)) != 0 )
265 _tv.tv_usec += lost * (1000000 / HZ);
266 _tv.tv_sec = xtime.tv_sec;
267 _tv.tv_usec += xtime.tv_usec;
269 if ( unlikely(!TIME_VALUES_UP_TO_DATE) )
270 {
271 /*
272 * We may have blocked for a long time, rendering our calculations
273 * invalid (e.g. the time delta may have overflowed). Detect that
274 * and recalculate with fresh values.
275 */
276 read_unlock_irqrestore(&xtime_lock, flags);
277 write_lock_irqsave(&xtime_lock, flags);
278 __get_time_values_from_xen();
279 write_unlock_irqrestore(&xtime_lock, flags);
280 goto again;
281 }
283 HANDLE_USEC_OVERFLOW(_tv);
285 /* Ensure that time-of-day is monotonically increasing. */
286 if ( (_tv.tv_sec < last_seen_tv.tv_sec) ||
287 ((_tv.tv_sec == last_seen_tv.tv_sec) &&
288 (_tv.tv_usec < last_seen_tv.tv_usec)) )
289 _tv = last_seen_tv;
290 last_seen_tv = _tv;
292 read_unlock_irqrestore(&xtime_lock, flags);
294 *tv = _tv;
295 }
298 /*
299 * Sets the current time-of-day based on passed-in UTC timeval parameter.
300 */
301 void do_settimeofday(struct timeval *tv)
302 {
303 struct timeval newtv;
304 suseconds_t usec;
306 if ( !INDEPENDENT_WALLCLOCK() )
307 return;
309 write_lock_irq(&xtime_lock);
311 /*
312 * Ensure we don't get blocked for a long time so that our time delta
313 * overflows. If that were to happen then our shadow time values would
314 * be stale, so we can retry with fresh ones.
315 */
316 again:
317 usec = tv->tv_usec - __get_time_delta_usecs();
318 if ( unlikely(!TIME_VALUES_UP_TO_DATE) )
319 {
320 __get_time_values_from_xen();
321 goto again;
322 }
323 tv->tv_usec = usec;
325 HANDLE_USEC_UNDERFLOW(*tv);
327 newtv = *tv;
329 tv->tv_usec -= (jiffies - wall_jiffies) * (1000000 / HZ);
330 HANDLE_USEC_UNDERFLOW(*tv);
332 xtime = *tv;
333 time_adjust = 0; /* stop active adjtime() */
334 time_status |= STA_UNSYNC;
335 time_maxerror = NTP_PHASE_LIMIT;
336 time_esterror = NTP_PHASE_LIMIT;
338 /* Reset all our running time counts. They make no sense now. */
339 last_seen_tv.tv_sec = 0;
340 last_update_from_xen = 0;
342 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
343 if ( xen_start_info.flags & SIF_INITDOMAIN )
344 {
345 dom0_op_t op;
346 last_update_to_rtc = last_update_to_xen = 0;
347 op.cmd = DOM0_SETTIME;
348 op.u.settime.secs = newtv.tv_sec;
349 op.u.settime.usecs = newtv.tv_usec;
350 op.u.settime.system_time = shadow_system_time;
351 write_unlock_irq(&xtime_lock);
352 HYPERVISOR_dom0_op(&op);
353 }
354 else
355 #endif
356 {
357 write_unlock_irq(&xtime_lock);
358 }
359 }
362 asmlinkage long sys_stime(int *tptr)
363 {
364 int value;
365 struct timeval tv;
367 if ( !capable(CAP_SYS_TIME) )
368 return -EPERM;
370 if ( get_user(value, tptr) )
371 return -EFAULT;
373 tv.tv_sec = value;
374 tv.tv_usec = 0;
376 do_settimeofday(&tv);
378 return 0;
379 }
382 /* Convert jiffies to system time. Call with xtime_lock held for reading. */
383 static inline u64 __jiffies_to_st(unsigned long j)
384 {
385 return processed_system_time + ((j - jiffies) * NS_PER_TICK);
386 }
389 static inline void do_timer_interrupt(int irq, void *dev_id,
390 struct pt_regs *regs)
391 {
392 s64 delta;
393 unsigned long ticks = 0;
394 long sec_diff;
396 retry:
397 __get_time_values_from_xen();
399 if ( (delta = (s64)(shadow_system_time + __get_time_delta_usecs() * 1000 -
400 processed_system_time)) < 0 )
401 {
402 if (!TIME_VALUES_UP_TO_DATE)
403 goto retry;
404 printk("Timer ISR: Time went backwards: %lld\n", delta);
405 return;
406 }
408 /* Process elapsed jiffies since last call. */
409 while ( delta >= NS_PER_TICK )
410 {
411 ticks++;
412 delta -= NS_PER_TICK;
413 processed_system_time += NS_PER_TICK;
414 }
416 if ( ticks != 0 )
417 {
418 do_timer_ticks(ticks);
420 if ( user_mode(regs) )
421 update_process_times_us(ticks, 0);
422 else
423 update_process_times_us(0, ticks);
424 }
426 /*
427 * Take synchronised time from Xen once a minute if we're not
428 * synchronised ourselves, and we haven't chosen to keep an independent
429 * time base.
430 */
431 if ( !INDEPENDENT_WALLCLOCK() &&
432 ((time_status & STA_UNSYNC) != 0) &&
433 (xtime.tv_sec > (last_update_from_xen + 60)) )
434 {
435 /* Adjust shadow timeval for jiffies that haven't updated xtime yet. */
436 shadow_tv.tv_usec -= (jiffies - wall_jiffies) * (1000000/HZ);
437 HANDLE_USEC_UNDERFLOW(shadow_tv);
439 /*
440 * Reset our running time counts if they are invalidated by a warp
441 * backwards of more than 500ms.
442 */
443 sec_diff = xtime.tv_sec - shadow_tv.tv_sec;
444 if ( unlikely(abs(sec_diff) > 1) ||
445 unlikely(((sec_diff * 1000000) +
446 xtime.tv_usec - shadow_tv.tv_usec) > 500000) )
447 {
448 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
449 last_update_to_rtc = last_update_to_xen = 0;
450 #endif
451 last_seen_tv.tv_sec = 0;
452 }
454 /* Update our unsynchronised xtime appropriately. */
455 xtime = shadow_tv;
457 last_update_from_xen = xtime.tv_sec;
458 }
460 #ifdef CONFIG_XEN_PRIVILEGED_GUEST
461 if ( (xen_start_info.flags & SIF_INITDOMAIN) &&
462 ((time_status & STA_UNSYNC) == 0) )
463 {
464 /* Send synchronised time to Xen approximately every minute. */
465 if ( xtime.tv_sec > (last_update_to_xen + 60) )
466 {
467 dom0_op_t op;
468 struct timeval tv = xtime;
470 tv.tv_usec += (jiffies - wall_jiffies) * (1000000/HZ);
471 HANDLE_USEC_OVERFLOW(tv);
473 op.cmd = DOM0_SETTIME;
474 op.u.settime.secs = tv.tv_sec;
475 op.u.settime.usecs = tv.tv_usec;
476 op.u.settime.system_time = shadow_system_time;
477 HYPERVISOR_dom0_op(&op);
479 last_update_to_xen = xtime.tv_sec;
480 }
482 /*
483 * If we have an externally synchronized Linux clock, then update CMOS
484 * clock accordingly every ~11 minutes. Set_rtc_mmss() has to be called
485 * as close as possible to 500 ms before the new second starts.
486 */
487 if ( (xtime.tv_sec > (last_update_to_rtc + 660)) &&
488 (xtime.tv_usec >= (500000 - ((unsigned) tick) / 2)) &&
489 (xtime.tv_usec <= (500000 + ((unsigned) tick) / 2)) )
490 {
491 if ( set_rtc_mmss(xtime.tv_sec) == 0 )
492 last_update_to_rtc = xtime.tv_sec;
493 else
494 last_update_to_rtc = xtime.tv_sec - 600;
495 }
496 }
497 #endif
498 }
501 static void timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
502 {
503 write_lock(&xtime_lock);
504 do_timer_interrupt(irq, NULL, regs);
505 write_unlock(&xtime_lock);
506 }
508 static struct irqaction irq_timer = {
509 timer_interrupt,
510 SA_INTERRUPT,
511 0,
512 "timer",
513 NULL,
514 NULL
515 };
518 /*
519 * This function works out when the the next timer function has to be
520 * executed (by looking at the timer list) and sets the Xen one-shot
521 * domain timer to the appropriate value. This is typically called in
522 * cpu_idle() before the domain blocks.
523 *
524 * The function returns a non-0 value on error conditions.
525 *
526 * It must be called with interrupts disabled.
527 */
528 extern spinlock_t timerlist_lock;
529 int set_timeout_timer(void)
530 {
531 struct timer_list *timer;
532 u64 alarm = 0;
533 int ret = 0;
535 spin_lock(&timerlist_lock);
537 /*
538 * This is safe against long blocking (since calculations are not based on
539 * TSC deltas). It is also safe against warped system time since
540 * suspend-resume is cooperative and we would first get locked out. It is
541 * safe against normal updates of jiffies since interrupts are off.
542 */
543 if ( (timer = next_timer_event()) != NULL )
544 alarm = __jiffies_to_st(timer->expires);
546 /* Tasks on the timer task queue expect to be executed on the next tick. */
547 if ( TQ_ACTIVE(tq_timer) )
548 alarm = __jiffies_to_st(jiffies + 1);
550 /* Failure is pretty bad, but we'd best soldier on. */
551 if ( HYPERVISOR_set_timer_op(alarm) != 0 )
552 ret = -1;
554 spin_unlock(&timerlist_lock);
556 return ret;
557 }
560 /* Time debugging. */
561 static void dbg_time_int(int irq, void *dev_id, struct pt_regs *ptregs)
562 {
563 unsigned long flags, j;
564 u64 s_now, j_st;
565 struct timeval s_tv, tv;
567 struct timer_list *timer;
568 u64 t_st;
570 read_lock_irqsave(&xtime_lock, flags);
571 s_tv.tv_sec = shadow_tv.tv_sec;
572 s_tv.tv_usec = shadow_tv.tv_usec;
573 s_now = shadow_system_time;
574 read_unlock_irqrestore(&xtime_lock, flags);
576 do_gettimeofday(&tv);
578 j = jiffies;
579 j_st = __jiffies_to_st(j);
581 timer = next_timer_event();
582 t_st = __jiffies_to_st(timer->expires);
584 printk(KERN_ALERT "time: shadow_st=0x%X:%08X\n",
585 (u32)(s_now>>32), (u32)s_now);
586 printk(KERN_ALERT "time: wct=%lds %ldus shadow_wct=%lds %ldus\n",
587 tv.tv_sec, tv.tv_usec, s_tv.tv_sec, s_tv.tv_usec);
588 printk(KERN_ALERT "time: jiffies=%lu(0x%X:%08X) timeout=%lu(0x%X:%08X)\n",
589 jiffies,(u32)(j_st>>32), (u32)j_st,
590 timer->expires,(u32)(t_st>>32), (u32)t_st);
591 printk(KERN_ALERT "time: processed_system_time=0x%X:%08X\n",
592 (u32)(processed_system_time>>32), (u32)processed_system_time);
594 #ifdef CONFIG_MAGIC_SYSRQ
595 handle_sysrq('t',NULL,NULL,NULL);
596 #endif
597 }
599 static struct irqaction dbg_time = {
600 dbg_time_int,
601 SA_SHIRQ,
602 0,
603 "timer_dbg",
604 &dbg_time_int,
605 NULL
606 };
608 void __init time_init(void)
609 {
610 unsigned long long alarm;
611 u64 __cpu_khz, __cpu_ghz, cpu_freq, scale, scale2;
612 unsigned int cpu_ghz;
614 __cpu_khz = __cpu_ghz = cpu_freq = HYPERVISOR_shared_info->cpu_freq;
615 do_div(__cpu_khz, 1000UL);
616 cpu_khz = (u32)__cpu_khz;
617 do_div(__cpu_ghz, 1000000000UL);
618 cpu_ghz = (unsigned int)__cpu_ghz;
620 printk("Xen reported: %lu.%03lu MHz processor.\n",
621 cpu_khz / 1000, cpu_khz % 1000);
623 xtime.tv_sec = HYPERVISOR_shared_info->wc_sec;
624 xtime.tv_usec = HYPERVISOR_shared_info->wc_usec;
625 processed_system_time = shadow_system_time;
627 for ( rdtsc_bitshift = 0; cpu_ghz != 0; rdtsc_bitshift++, cpu_ghz >>= 1 )
628 continue;
630 scale = 1000000LL << (32 + rdtsc_bitshift);
631 do_div(scale, (u32)cpu_freq);
633 if ( (cpu_freq >> 32) != 0 )
634 {
635 scale2 = 1000000LL << rdtsc_bitshift;
636 do_div(scale2, (u32)(cpu_freq>>32));
637 scale += scale2;
638 }
640 st_scale_f = scale & 0xffffffff;
641 st_scale_i = scale >> 32;
643 __get_time_values_from_xen();
644 processed_system_time = shadow_system_time;
646 time_irq = bind_virq_to_irq(VIRQ_TIMER);
647 debug_irq = bind_virq_to_irq(VIRQ_DEBUG);
649 (void)setup_irq(time_irq, &irq_timer);
650 (void)setup_irq(debug_irq, &dbg_time);
652 rdtscll(alarm);
653 }
655 void time_suspend(void)
656 {
657 }
659 void time_resume(void)
660 {
661 unsigned long flags;
662 write_lock_irqsave(&xtime_lock, flags);
663 /* Get timebases for new environment. */
664 __get_time_values_from_xen();
665 /* Reset our own concept of passage of system time. */
666 processed_system_time = shadow_system_time;
667 /* Accept a warp in UTC (wall-clock) time. */
668 last_seen_tv.tv_sec = 0;
669 /* Make sure we resync UTC time with Xen on next timer interrupt. */
670 last_update_from_xen = 0;
671 write_unlock_irqrestore(&xtime_lock, flags);
672 }
674 /*
675 * /proc/sys/xen: This really belongs in another file. It can stay here for
676 * now however.
677 */
678 static ctl_table xen_subtable[] = {
679 {1, "independent_wallclock", &independent_wallclock,
680 sizeof(independent_wallclock), 0644, NULL, proc_dointvec},
681 {0}
682 };
683 static ctl_table xen_table[] = {
684 {123, "xen", NULL, 0, 0555, xen_subtable},
685 {0}
686 };
687 static int __init xen_sysctl_init(void)
688 {
689 (void)register_sysctl_table(xen_table, 0);
690 return 0;
691 }
692 __initcall(xen_sysctl_init);