From: ANNIE LI <annie.li@oracle.com>
To: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Cc: Kurt Hackel <Kurt.Hackel@oracle.com>,
Dan Magenheimer <dan.magenheimer@oracle.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH] hvm: Correct RTC time offset update error due to tm->tm_year
Date: Mon, 20 Feb 2012 15:19:59 +0800 [thread overview]
Message-ID: <4F41F41F.9060601@oracle.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 567 bytes --]
Hi
In rtc_set_time, mktime is called to calculate seconds since 1970/01/01,
input parameters of mktime are required to be in normal date format.
Such as: year=1980, mon=12, day=31, hour=23, min=59, sec=59. However,
the current input parameter of mktime is tm->tm_year, and it is the
number of years since 1900. (For example, if current time is 2012/12/31,
and tm->tm_year is 112). This is not suitable for requirement of mktime.
So I think tm->tm_year should be changed to tm->tm_year+1900 when
calling mktime. Please check the patch attached.
Thanks,
Annie
[-- Attachment #2: rtc-timeoffset.patch --]
[-- Type: text/plain, Size: 1329 bytes --]
# HG changeset patch
# Parent f2543f449a49b8979becbf6888e009973427089a
hvm: correct RTC time offset update error due to tm->tm_year
mktime requires input year in normal date format, i.e. 1980. So it is necessary
to change tm->tm_year to tm->tm_year+1900. Otherwise, the calculation result
of mktime is incorrect.
Signed-off-by: Annie Li <annie.li@oracle.com>
diff -r f2543f449a49 xen/arch/x86/hvm/rtc.c
--- a/xen/arch/x86/hvm/rtc.c Mon Feb 13 17:57:47 2012 +0000
+++ b/xen/arch/x86/hvm/rtc.c Mon Feb 20 14:39:00 2012 +0800
@@ -165,7 +165,7 @@ static void rtc_set_time(RTCState *s)
ASSERT(spin_is_locked(&s->lock));
- before = mktime(tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
+ before = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
tm->tm_sec = from_bcd(s, s->hw.cmos_data[RTC_SECONDS]);
@@ -179,7 +179,7 @@ static void rtc_set_time(RTCState *s)
tm->tm_mon = from_bcd(s, s->hw.cmos_data[RTC_MONTH]) - 1;
tm->tm_year = from_bcd(s, s->hw.cmos_data[RTC_YEAR]) + 100;
- after = mktime(tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
+ after = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
/* We use the guest's setting of the RTC to define the local-time
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2012-02-20 7:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 7:19 ANNIE LI [this message]
2012-02-20 14:53 ` [PATCH] hvm: Correct RTC time offset update error due to tm->tm_year Zhang, Yang Z
2012-02-20 15:04 ` young zhang
2012-02-20 23:54 ` Zhang, Yang Z
2012-02-21 2:31 ` ANNIE LI
2012-02-22 11:05 ` Ian Campbell
2012-02-22 13:10 ` annie li
2012-02-22 13:58 ` Ian Campbell
2012-02-22 14:35 ` annie li
2012-02-23 14:52 ` annie li
2012-02-23 15:17 ` annie li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F41F41F.9060601@oracle.com \
--to=annie.li@oracle.com \
--cc=Kurt.Hackel@oracle.com \
--cc=dan.magenheimer@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).