Re: Remove timezone support from the kernel
I got a few reports from Windows dual-booters that things still work as expected for them, so it seems like it shouldn't cause any issues or break any existing use cases now. ok to commit? On Tue, Apr 24, 2012 at 03:06:42PM -0700, Matthew Dempsky wrote: > On Tue, Apr 24, 2012 at 04:27:00PM +0400, Vadim Zhukov wrote: > > This will somewhat break dual-booting machines with Windblows as > > second OS. :( > > Okay, here's an alternative diff that only affects gettimeofday() and > settimeofday(). Users can still set the kernel timezone through > config(8) or boot_config(8), and it will still be used to compensate > for a non-UTC clock, but that's all the kernel timezone will be used > for. As far as userland will see, the kernel will appear hard > configured for UTC: gettimeofday() will always return a UTC timezone > and settimeofday() will return EINVAL if you try to set a non-UTC > timezone. > > In base, this should only affect users of date(1)'s -d and -t options, > but I plan to remove those anyway if this diff goes in. > > I'm very interested in hearing from Windows dual-booters who use local > time RTCs whether this has any negative consequences for them. > > > Index: kern_time.c > === > RCS file: /home/mdempsky/anoncvs/cvs/src/sys/kern/kern_time.c,v > retrieving revision 1.74 > diff -u -p -r1.74 kern_time.c > --- kern_time.c 23 Mar 2012 15:51:26 - 1.74 > +++ kern_time.c 24 Apr 2012 16:17:44 - > @@ -391,8 +458,10 @@ sys_gettimeofday(struct proc *p, void *v > } > #endif > } > - if (tzp) > - error = copyout(&tz, tzp, sizeof (tz)); > + if (tzp) { > + const struct timezone tz0 = { 0 }; > + error = copyout(&tz0, tzp, sizeof(tz0)); > + } > return (error); > } > > @@ -415,20 +484,22 @@ sys_settimeofday(struct proc *p, void *v > > if ((error = suser(p, 0))) > return (error); > - /* Verify all parameters before changing time. */ > - if (tv && (error = copyin(tv, &atv, sizeof(atv > - return (error); > - if (tzp && (error = copyin(tzp, &atz, sizeof(atz > - return (error); > + if (tzp) { > + if ((error = copyin(tzp, &atz, sizeof(atz))) != 0) > + return (error); > + if (atz.tz_minuteswest != 0 || atz.tz_dsttime != 0) > + return (EINVAL); > + } > if (tv) { > struct timespec ts; > > + if ((error = copyin(tv, &atv, sizeof(atv))) != 0) > + return (error); > + > TIMEVAL_TO_TIMESPEC(&atv, &ts); > if ((error = settime(&ts)) != 0) > return (error); > } > - if (tzp) > - tz = atz; > return (0); > }
Re: Remove timezone support from the kernel
On Tue, 24 Apr 2012 15:06:42 -0700 Matthew Dempsky wrote: > On Tue, Apr 24, 2012 at 04:27:00PM +0400, Vadim Zhukov wrote: > > This will somewhat break dual-booting machines with Windblows as > > second OS. :( > > Okay, here's an alternative diff that only affects gettimeofday() and > settimeofday(). Users can still set the kernel timezone through > config(8) or boot_config(8), and it will still be used to compensate > for a non-UTC clock, but that's all the kernel timezone will be used > for. As far as userland will see, the kernel will appear hard > configured for UTC: gettimeofday() will always return a UTC timezone > and settimeofday() will return EINVAL if you try to set a non-UTC > timezone. > > In base, this should only affect users of date(1)'s -d and -t options, > but I plan to remove those anyway if this diff goes in. > > I'm very interested in hearing from Windows dual-booters who use local > time RTCs whether this has any negative consequences for them. No problems on amd64, with ntpd_flags=" -s" in /etc/rc.conf.local thanks > Index: kern_time.c > === > RCS file: /home/mdempsky/anoncvs/cvs/src/sys/kern/kern_time.c,v > retrieving revision 1.74 > diff -u -p -r1.74 kern_time.c > --- kern_time.c 23 Mar 2012 15:51:26 - 1.74 > +++ kern_time.c 24 Apr 2012 16:17:44 - > @@ -391,8 +458,10 @@ sys_gettimeofday(struct proc *p, void *v > } > #endif > } > - if (tzp) > - error = copyout(&tz, tzp, sizeof (tz)); > + if (tzp) { > + const struct timezone tz0 = { 0 }; > + error = copyout(&tz0, tzp, sizeof(tz0)); > + } > return (error); > } > > @@ -415,20 +484,22 @@ sys_settimeofday(struct proc *p, void *v > > if ((error = suser(p, 0))) > return (error); > - /* Verify all parameters before changing time. */ > - if (tv && (error = copyin(tv, &atv, sizeof(atv > - return (error); > - if (tzp && (error = copyin(tzp, &atz, sizeof(atz > - return (error); > + if (tzp) { > + if ((error = copyin(tzp, &atz, sizeof(atz))) != 0) > + return (error); > + if (atz.tz_minuteswest != 0 || atz.tz_dsttime != 0) > + return (EINVAL); > + } > if (tv) { > struct timespec ts; > > + if ((error = copyin(tv, &atv, sizeof(atv))) != 0) > + return (error); > + > TIMEVAL_TO_TIMESPEC(&atv, &ts); > if ((error = settime(&ts)) != 0) > return (error); > } > - if (tzp) > - tz = atz; > return (0); > } > -- Amit Kulkarni
Re: Remove timezone support from the kernel
On Tue, Apr 24, 2012 at 04:27:00PM +0400, Vadim Zhukov wrote: > This will somewhat break dual-booting machines with Windblows as > second OS. :( Okay, here's an alternative diff that only affects gettimeofday() and settimeofday(). Users can still set the kernel timezone through config(8) or boot_config(8), and it will still be used to compensate for a non-UTC clock, but that's all the kernel timezone will be used for. As far as userland will see, the kernel will appear hard configured for UTC: gettimeofday() will always return a UTC timezone and settimeofday() will return EINVAL if you try to set a non-UTC timezone. In base, this should only affect users of date(1)'s -d and -t options, but I plan to remove those anyway if this diff goes in. I'm very interested in hearing from Windows dual-booters who use local time RTCs whether this has any negative consequences for them. Index: kern_time.c === RCS file: /home/mdempsky/anoncvs/cvs/src/sys/kern/kern_time.c,v retrieving revision 1.74 diff -u -p -r1.74 kern_time.c --- kern_time.c 23 Mar 2012 15:51:26 - 1.74 +++ kern_time.c 24 Apr 2012 16:17:44 - @@ -391,8 +458,10 @@ sys_gettimeofday(struct proc *p, void *v } #endif } - if (tzp) - error = copyout(&tz, tzp, sizeof (tz)); + if (tzp) { + const struct timezone tz0 = { 0 }; + error = copyout(&tz0, tzp, sizeof(tz0)); + } return (error); } @@ -415,20 +484,22 @@ sys_settimeofday(struct proc *p, void *v if ((error = suser(p, 0))) return (error); - /* Verify all parameters before changing time. */ - if (tv && (error = copyin(tv, &atv, sizeof(atv - return (error); - if (tzp && (error = copyin(tzp, &atz, sizeof(atz - return (error); + if (tzp) { + if ((error = copyin(tzp, &atz, sizeof(atz))) != 0) + return (error); + if (atz.tz_minuteswest != 0 || atz.tz_dsttime != 0) + return (EINVAL); + } if (tv) { struct timespec ts; + if ((error = copyin(tv, &atv, sizeof(atv))) != 0) + return (error); + TIMEVAL_TO_TIMESPEC(&atv, &ts); if ((error = settime(&ts)) != 0) return (error); } - if (tzp) - tz = atz; return (0); }
Re: Remove timezone support from the kernel
24 P0P?QP5P;Q 2012B P3. 20:05 P?P>P;QP7P>P2P0QP5P;Q Matthew Dempsky P=P0P?P8QP0P;: > On Tue, Apr 24, 2012 at 4:11 PM, Peter Hessler wrote: >> On 2012 Apr 24 (Tue) at 16:27:00 +0400 (+0400), Vadim Zhukov wrote: >> :This will somewhat break dual-booting machines with Windblows as >> :second OS. :( But I'm not a developer and do not have any vote, of >> :course. :) > > Ugh. I didn't realize Windows still expects the RTC to be local time by default. > >> Windows 7 does not have that limitation, you can configure it to use UTC >> as the BIOS clock. > > It looks like Markus Kuhn has a FAQ about Windows, the RTC, and UTC: > http://www.cl.cam.ac.uk/~mgk25/mswish/ut-rtc.html > > TL;DR: Windows Vista SP2 and Windows 7 support setting the RTC to UTC, > but your system might become unresponsive during DST changes... > idiots. > > > I'm inclined to say our FAQ > (http://www.openbsd.org/faq/faq8.html#TimeZone) should instruct > Windows users to just set RealTimeIsUniversal and bring any issues to > Microsoft to fix rather than working around the issue with kernel > timezone support. It doesn't make sense for us to continue > complicating things just to workaround their broken design. Microsoft > has had 10+ years to make this setting work. Agree. :) Thanks for all the info and your work! -- WBR, Vadim Zhukov
Re: Remove timezone support from the kernel
On Tue, Apr 24, 2012 at 4:11 PM, Peter Hessler wrote: > On 2012 Apr 24 (Tue) at 16:27:00 +0400 (+0400), Vadim Zhukov wrote: > :This will somewhat break dual-booting machines with Windblows as > :second OS. :( But I'm not a developer and do not have any vote, of > :course. :) Ugh. I didn't realize Windows still expects the RTC to be local time by default. > Windows 7 does not have that limitation, you can configure it to use UTC > as the BIOS clock. It looks like Markus Kuhn has a FAQ about Windows, the RTC, and UTC: http://www.cl.cam.ac.uk/~mgk25/mswish/ut-rtc.html TL;DR: Windows Vista SP2 and Windows 7 support setting the RTC to UTC, but your system might become unresponsive during DST changes... idiots. I'm inclined to say our FAQ (http://www.openbsd.org/faq/faq8.html#TimeZone) should instruct Windows users to just set RealTimeIsUniversal and bring any issues to Microsoft to fix rather than working around the issue with kernel timezone support. It doesn't make sense for us to continue complicating things just to workaround their broken design. Microsoft has had 10+ years to make this setting work.
Re: Remove timezone support from the kernel
On 2012 Apr 24 (Tue) at 16:27:00 +0400 (+0400), Vadim Zhukov wrote: :23 P0P?QP5P;Q 2012B P3. 21:37 P?P>P;QP7P>P2P0QP5P;Q Matthew Dempsky : P=P0P?P8QP0P;: :> There's no reason for the kernel to track the system's timezone :> anymore. B This is handled in userspace by the TZ environment variable, :> and POSIX doesn't even define what happens if you pass a non-NULL :> pointer as the 'struct timezone *' argument to gettimeofday() (and :> settimeofday() has never been in POSIX). :> :> The diff below: :> B - eliminates tz :> B - adds a compile-time check to detect configs with non-0 timezone :> B - changes settimeofday() to return EINVAL when given a non-0 timezone :> B - eliminates the userconf code for changing/printing the timezone :> B - removes clock and msdosfs code that looks at the kernel timezone :> :> After this, we'll be able to move gettimeofday() and settimeofday() :> into libc as user-space wrappers around clock_gettime() and :> clock_settime(), respectively. :> :> Any objections? : :This will somewhat break dual-booting machines with Windblows as :second OS. :( But I'm not a developer and do not have any vote, of :course. :) :-- : WBR, : Vadim Zhukov : Windows 7 does not have that limitation, you can configure it to use UTC as the BIOS clock. -- The [Ford Foundation] is a large body of money completely surrounded by people who want some. -- Dwight MacDonald
Re: Remove timezone support from the kernel
On Tue, Apr 24, 2012 at 7:35 AM, Stuart Henderson wrote: > On 2012/04/24 16:27, Vadim Zhukov wrote: >> 23 P0P?QP5P;Q 2012B P3. 21:37 P?P>P;Q P7P>P2P0Q P5P;Q Matthew Dempsky >> P=P0P?P8Q P0P;: >> > There's no reason for the kernel to track the system's timezone >> > anymore. B This is handled in userspace by the TZ environment variable, >> > and POSIX doesn't even define what happens if you pass a non-NULL >> > pointer as the 'struct timezone *' argument to gettimeofday() (and >> > settimeofday() has never been in POSIX). >> > >> > The diff below: >> > B - eliminates tz >> > B - adds a compile-time check to detect configs with non-0 timezone >> > B - changes settimeofday() to return EINVAL when given a non-0 timezone >> > B - eliminates the userconf code for changing/printing the timezone >> > B - removes clock and msdosfs code that looks at the kernel timezone >> > >> > After this, we'll be able to move gettimeofday() and settimeofday() >> > into libc as user-space wrappers around clock_gettime() and >> > clock_settime(), respectively. >> > >> > Any objections? >> >> This will somewhat break dual-booting machines with Windblows as >> second OS. :( But I'm not a developer and do not have any vote, of >> course. :) > > It seems simpler to use NTP to fetch a correct time, than to build a custom > kernel. I hope to find a way to keep Windows time unmodified while OpenBSD adjusts. i.e its currently documented in the FAQ http://www.openbsd.org/faq/faq8.html#TimeZone The installer asks for the TZ and adjusts /etc/localtime but until I changed the option "TIMEZONE=value" in kernel the clock was off thanks
Re: Remove timezone support from the kernel
24 P0P?QP5P;Q 2012B P3. 16:35 P?P>P;QP7P>P2P0QP5P;Q Stuart Henderson P=P0P?P8QP0P;: > On 2012/04/24 16:27, Vadim Zhukov wrote: >> 23 P0P?QP5P;Q B 2012B P3. 21:37 P?P>P;Q P7P>P2P0Q P5P;Q Matthew Dempsky >> P=P0P?P8Q P0P;: >> > There's no reason for the kernel to track the system's timezone >> > anymore. B This is handled in userspace by the TZ environment variable, >> > and POSIX doesn't even define what happens if you pass a non-NULL >> > pointer as the 'struct timezone *' argument to gettimeofday() (and >> > settimeofday() has never been in POSIX). >> > >> > The diff below: >> > B - eliminates tz >> > B - adds a compile-time check to detect configs with non-0 timezone >> > B - changes settimeofday() to return EINVAL when given a non-0 timezone >> > B - eliminates the userconf code for changing/printing the timezone >> > B - removes clock and msdosfs code that looks at the kernel timezone >> > >> > After this, we'll be able to move gettimeofday() and settimeofday() >> > into libc as user-space wrappers around clock_gettime() and >> > clock_settime(), respectively. >> > >> > Any objections? >> >> This will somewhat break dual-booting machines with Windblows as >> second OS. :( But I'm not a developer and do not have any vote, of >> course. :) > > It seems simpler to use NTP to fetch a correct time, than to build a custom kernel. Yes, if your laptop is always online when you boot in OpenBSD. :-\ And this was not about building custom kernel, single config(8) call at the end of OS upgrade process works just fine ATM. Oh, and I don't want to attack or stop anyone hacking OpenBSD. :) -- WBR, Vadim Zhukov
Re: Remove timezone support from the kernel
On 2012/04/24 16:27, Vadim Zhukov wrote: > 23 P0P?QP5P;Q 2012B P3. 21:37 P?P>P;QP7P>P2P0QP5P;Q Matthew Dempsky > P=P0P?P8QP0P;: > > There's no reason for the kernel to track the system's timezone > > anymore. B This is handled in userspace by the TZ environment variable, > > and POSIX doesn't even define what happens if you pass a non-NULL > > pointer as the 'struct timezone *' argument to gettimeofday() (and > > settimeofday() has never been in POSIX). > > > > The diff below: > > B - eliminates tz > > B - adds a compile-time check to detect configs with non-0 timezone > > B - changes settimeofday() to return EINVAL when given a non-0 timezone > > B - eliminates the userconf code for changing/printing the timezone > > B - removes clock and msdosfs code that looks at the kernel timezone > > > > After this, we'll be able to move gettimeofday() and settimeofday() > > into libc as user-space wrappers around clock_gettime() and > > clock_settime(), respectively. > > > > Any objections? > > This will somewhat break dual-booting machines with Windblows as > second OS. :( But I'm not a developer and do not have any vote, of > course. :) It seems simpler to use NTP to fetch a correct time, than to build a custom kernel.
Re: Remove timezone support from the kernel
23 P0P?QP5P;Q 2012B P3. 21:37 P?P>P;QP7P>P2P0QP5P;Q Matthew Dempsky P=P0P?P8QP0P;: > There's no reason for the kernel to track the system's timezone > anymore. B This is handled in userspace by the TZ environment variable, > and POSIX doesn't even define what happens if you pass a non-NULL > pointer as the 'struct timezone *' argument to gettimeofday() (and > settimeofday() has never been in POSIX). > > The diff below: > B - eliminates tz > B - adds a compile-time check to detect configs with non-0 timezone > B - changes settimeofday() to return EINVAL when given a non-0 timezone > B - eliminates the userconf code for changing/printing the timezone > B - removes clock and msdosfs code that looks at the kernel timezone > > After this, we'll be able to move gettimeofday() and settimeofday() > into libc as user-space wrappers around clock_gettime() and > clock_settime(), respectively. > > Any objections? This will somewhat break dual-booting machines with Windblows as second OS. :( But I'm not a developer and do not have any vote, of course. :) -- WBR, Vadim Zhukov
Re: Remove timezone support from the kernel
On Mon, Apr 23, 2012 at 8:37 PM, Matthew Dempsky wrote: > There's no reason for the kernel to track the system's timezone > anymore. B This is handled in userspace by the TZ environment variable, > and POSIX doesn't even define what happens if you pass a non-NULL > pointer as the 'struct timezone *' argument to gettimeofday() (and > settimeofday() has never been in POSIX). > > The diff below: > B - eliminates tz > B - adds a compile-time check to detect configs with non-0 timezone > B - changes settimeofday() to return EINVAL when given a non-0 timezone > B - eliminates the userconf code for changing/printing the timezone > B - removes clock and msdosfs code that looks at the kernel timezone > > After this, we'll be able to move gettimeofday() and settimeofday() > into libc as user-space wrappers around clock_gettime() and > clock_settime(), respectively. > > Any objections? > I think it's a good idea. Should have been done long ago. -- ### Coonardoo - PQP8P=P8QP:P0 Q QQP=Q / The Well In The Shadow / Le Puits Dans L'Ombre ###