diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2019-08-21 20:44:10 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2019-08-21 20:44:10 +0000 |
commit | 88189cd37e490ab9c99c014fc44132efceaa8868 (patch) | |
tree | b20b7feea2832be528f34e5bcec9cbb6cdc8bf26 /sys/arch/amd64/isa | |
parent | 5e13514aef36d7e3e10f623e4512aab59b10e521 (diff) |
sysctl(2): add kern.utc_offset: successor to the DST/TIMEZONE options(4)
The DST and TIMEZONE options(4) are incompatible with KARL, so we need
some other way to compensate for an RTC running with a known offset.
Enter kern.utc_offset, an offset in minutes East of UTC. TIMEZONE has
always been minutes West, but this is inconsistent with how everyone
else talks about timezones, hence the flip.
TIMEZONE has the advantage of being compiled into the binary. Our new
sysctl(2) has no such luck, so it needs to be set as early as possible
in boot, from sysctl.conf(5), so we can correct the kernel clock from
the RTC's local time to UTC before daemons like ntpd(8) and cron(8)
start. To encourage this, kern.utc_offset is made immutable after the
securelevel(7) is raised to 1.
Prompted by yasuoka@. Discussed with deraadt@, kettenis@, yasuoka@.
Additional testing by yasuoka@.
ok deraadt@, yasuoka@
Diffstat (limited to 'sys/arch/amd64/isa')
-rw-r--r-- | sys/arch/amd64/isa/clock.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/sys/arch/amd64/isa/clock.c b/sys/arch/amd64/isa/clock.c index 203882d5e1d..b80bcf7c647 100644 --- a/sys/arch/amd64/isa/clock.c +++ b/sys/arch/amd64/isa/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.30 2019/07/19 14:50:43 cheloha Exp $ */ +/* $OpenBSD: clock.c,v 1.31 2019/08/21 20:44:09 cheloha Exp $ */ /* $NetBSD: clock.c,v 1.1 2003/04/26 18:39:50 fvdl Exp $ */ /*- @@ -475,9 +475,7 @@ inittodr(time_t base) dt.dt_mon = bcdtobin(rtclk[MC_MONTH]); dt.dt_year = clock_expandyear(bcdtobin(rtclk[MC_YEAR])); - ts.tv_sec = clock_ymdhms_to_secs(&dt) + tz.tz_minuteswest * 60; - if (tz.tz_dsttime) - ts.tv_sec -= 3600; + ts.tv_sec = clock_ymdhms_to_secs(&dt) - utc_offset; if (base != 0 && base < ts.tv_sec - 5*SECYR) printf("WARNING: file system time much less than clock time\n"); @@ -506,7 +504,7 @@ resettodr(void) { mc_todregs rtclk; struct clock_ymdhms dt; - int century, diff, s; + int century, s; /* * We might have been called by boot() due to a crash early @@ -520,10 +518,7 @@ resettodr(void) memset(&rtclk, 0, sizeof(rtclk)); splx(s); - diff = tz.tz_minuteswest * 60; - if (tz.tz_dsttime) - diff -= 3600; - clock_secs_to_ymdhms(time_second - diff, &dt); + clock_secs_to_ymdhms(time_second + utc_offset, &dt); rtclk[MC_SEC] = bintobcd(dt.dt_sec); rtclk[MC_MIN] = bintobcd(dt.dt_min); |