Fix the wrong wall clock of Dom0 after it resumes from S3. - In the GMT+08:00 time zone, if disable UTC, when Dom0 resumes from S3, its wallclock will increase by 8 hours wrongly; this is because: time_resume() treats the CMOS time as UTC time, and assigns it to the global variable wc_sec; this patch fixes the issue by remembering the difference between them before S3, and making adjustment accordingly after S3. Signed-off-by: Xu Dongxiao diff -r 2491691e3e69 xen/arch/x86/time.c --- a/xen/arch/x86/time.c Sat Dec 29 17:57:47 2007 +0000 +++ b/xen/arch/x86/time.c Fri Jan 04 16:16:11 2008 +0800 @@ -971,8 +971,13 @@ unsigned long get_localtime(struct domai + d->time_offset_seconds; } +/* "clock_cmos_diff" means the difference between UTC time and CMOS time. */ +static long clock_cmos_diff; + int time_suspend(void) { + clock_cmos_diff = (wc_sec + (wc_nsec + NOW()) / 1000000000ULL) + - get_cmos_time(); /* Better to cancel calibration timer for accuracy. */ kill_timer(&this_cpu(cpu_time).calibration_timer); @@ -986,7 +991,8 @@ int time_resume(void) set_time_scale(&this_cpu(cpu_time).tsc_scale, tmp); resume_platform_timer(); - do_settime(get_cmos_time(), 0, read_platform_stime()); + + do_settime(get_cmos_time() + clock_cmos_diff, 0, read_platform_stime()); init_percpu_time();