Subject: port-xen/37104: miss handling of rtc_offset on Xen kernel
To: None <port-xen-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: None <ryo@kitanet.ne.jp>
List: netbsd-bugs
Date: 10/10/2007 16:50:00
>Number: 37104
>Category: port-xen
>Synopsis: miss handling of rtc_offset on Xen kernel
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: port-xen-maintainer
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Oct 10 16:50:00 +0000 2007
>Originator: Ryo Tsuruta
>Release: NetBSD 4.0_RC2
>Organization:
>Environment:
NetBSD uni.home.local 4.0_RC2 NetBSD 4.0_RC2 (1709-GDJ_XEN3_DOM0) #0: Sun Oct 7 01:43:36 JST 2007 root@uni.home.local:/usr/src/netbsd-4/obj/netbsd-4/src/sys/arch/i386/compile/1709-GDJ_XEN3_DOM0 i386
>Description:
rtc_offset does not reflect the current time.
Wed Oct 10 16:19 UTC 2007
Thu Oct 11 01:19 JST 2007
% sysctl kern.rtc_offset
kern.rtc_offset = -540 (JST)
% env TZ=UTC+0 date
Thu Oct 11 01:19:30 UTC 2007
% env TZ=JST-9 date
Thu Oct 11 10:19:36 JST 2007
>How-To-Repeat:
Change rtc_offset by "sysctl -w kern.rtc_offset=XX", then just type the date command.
>Fix:
I think we should store the UTC time to shadow_ts.
It seems working fine after I applied the patch.
Wed Oct 10 16:30 UTC 2007
Thu Oct 11 01:30 JST 2007
% sysctl kern.rtc_offset
kern.rtc_offset = -540 (JST)
% env TZ=UTC+0 date
Wed Oct 10 16:30:12 UTC 2007
% env TZ=JST-9 date
Thu Oct 11 01:30:22 JST 2007
--- src/sys/arch/xen/xen/clock.c.orig 2007-10-11 00:57:35.000000000 +0900
+++ src/sys/arch/xen/xen/clock.c 2007-10-07 01:37:39.000000000 +0900
@@ -123,7 +123,8 @@
do {
tversion = HYPERVISOR_shared_info->wc_version;
x86_lfence();
- shadow_ts.tv_sec = HYPERVISOR_shared_info->wc_sec;
+ shadow_ts.tv_sec =
+ HYPERVISOR_shared_info->wc_sec + rtc_offset * 60;
shadow_ts.tv_nsec = HYPERVISOR_shared_info->wc_nsec;
x86_lfence();
} while ((HYPERVISOR_shared_info->wc_version & 1) ||
@@ -132,7 +133,8 @@
do {
shadow_time_version = HYPERVISOR_shared_info->time_version2;
x86_lfence();
- shadow_ts.tv_sec = HYPERVISOR_shared_info->wc_sec;
+ shadow_ts.tv_sec =
+ HYPERVISOR_shared_info->wc_sec + rtc_offset * 60;
shadow_ts.tv_nsec = HYPERVISOR_shared_info->wc_usec;
shadow_tsc_stamp = HYPERVISOR_shared_info->tsc_timestamp;
shadow_system_time = HYPERVISOR_shared_info->system_time;