When booting on old hardware with CMOS clock set before year 2000, initial system time appears to be in the end of twenty first century. On 32-bit systems it falls beyond 2038 with interesting consequences. This regression was introduced in 2006 by r162963 (then it was sys/i386/isa/clock.c). Here is the patch to correct this problem on modern systems: --- /usr/src/sys/x86/isa/atrtc.c 2014-08-14 06:33:26.168778002 +0000 +++ atrtc.c 2014-12-04 10:50:10.597250292 +0000 @@ -354,7 +354,7 @@ #ifdef USE_RTC_CENTURY ct.year += readrtc(RTC_CENTURY) * 100; #else - ct.year += 2000; + ct.year += ( ct.year < 70 ? 2000 : 1900 ); #endif critical_exit(); /* Set dow = -1 because some clocks don't set it correctly. */
1980 would be a better pivot year: The PC didn't exist before 1985. MS DOS doesn't have a filesystem that can cope before 1980 in any meaningful way, so most BIOSs default to 1980 or later when they have no clue. They don't know anything about 1970 being magic to unix. Also, it buys us 10 years before we have to look at this again, though predicting about when the i386 port will run out of steam in FreeBSD is a bit tricky... Other than that, this change looks good to me.
A commit references this bug: Author: brueffer Date: Mon Jun 29 17:02:10 UTC 2015 New revision: 284931 URL: https://svnweb.freebsd.org/changeset/base/284931 Log: Set the initial system time to a sane (as in: not end of 21st century) value when booting on a PC with CMOS clock set to a year before 2000. This uses 1980 (instead of 1970 as in the initial patch) as pivot year as suggested by imp in the PR followup. PR: 195703 Submitted by: cs@soi.spb.ru Reviewed by: imp MFC after: 1 weeks Changes: head/sys/x86/isa/atrtc.c
Patch committed, including the adjustment suggested by Warner. Thanks for the submission!
A commit references this bug: Author: brueffer Date: Mon Jul 13 11:58:09 UTC 2015 New revision: 285446 URL: https://svnweb.freebsd.org/changeset/base/285446 Log: MFC: r284931 Set the initial system time to a sane (as in: not end of 21st century) value when booting on a PC with CMOS clock set to a year before 2000. This uses 1980 (instead of 1970 as in the initial patch) as pivot year as suggested by imp in the PR followup. PR: 195703 Submitted by: cs@soi.spb.ru Reviewed by: imp Approved by: re (gjb) Changes: _U stable/10/ stable/10/sys/x86/isa/atrtc.c
A commit references this bug: Author: brueffer Date: Mon Jul 13 11:59:29 UTC 2015 New revision: 285447 URL: https://svnweb.freebsd.org/changeset/base/285447 Log: MFC: r284931 Set the initial system time to a sane (as in: not end of 21st century) value when booting on a PC with CMOS clock set to a year before 2000. This uses 1980 (instead of 1970 as in the initial patch) as pivot year as suggested by imp in the PR followup. PR: 195703 Submitted by: cs@soi.spb.ru Reviewed by: imp Changes: _U stable/9/sys/ stable/9/sys/x86/isa/atrtc.c
Merges done, thanks again!