From owner-svn-src-all@freebsd.org Tue Dec 29 14:10:00 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27830A55BFB; Tue, 29 Dec 2015 14:10:00 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail110.syd.optusnet.com.au (mail110.syd.optusnet.com.au [211.29.132.97]) by mx1.freebsd.org (Postfix) with ESMTP id E377C1A13; Tue, 29 Dec 2015 14:09:59 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c211-30-166-197.carlnfd1.nsw.optusnet.com.au (c211-30-166-197.carlnfd1.nsw.optusnet.com.au [211.30.166.197]) by mail110.syd.optusnet.com.au (Postfix) with ESMTPS id 9F661781843; Wed, 30 Dec 2015 01:09:47 +1100 (AEDT) Date: Wed, 30 Dec 2015 01:09:47 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Dmitry Chagin cc: Bruce Evans , Konstantin Belousov , Ian Lepore , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r292777 - in head: lib/libc/sys sys/kern In-Reply-To: Message-ID: <20151229235754.T3714@besplex.bde.org> References: MIME-Version: 1.0 X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=cK4dyQqN c=1 sm=1 tr=0 a=KA6XNC2GZCFrdESI5ZmdjQ==:117 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=nlC_4_pT8q9DhB4Ho9EA:9 a=1ux614oztSyDE4AEBDIA:9 a=45ClL6m2LaAA:10 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Dec 2015 14:10:00 -0000 On Tue, 29 Dec 2015, Dmitry Chagin wrote: > So, my point was: > a) for a long time we have broken settimeofday() which does not allow us > to set the system time before the Epoch We still have a broken settimeofday that doesn't allow us to set the system time to the Epoch in the Western hemisphere if the clock is on local time, and doesn't allow as to set the system time to a year > 9999. More precise= ly it does allow us to set these and usually panics on x86 before completing. > b) as you already mentioned POSIX doesn't require times before the Epoch = to > work In fact, the representation of times is undefined for times before the Epoch in general. The specification of clock_settime() is interesting. At least in an old POSIX-2001 draft, It is required to set to the specified time and is not limited to the current time, whatever that is. It is only required to work for CLOCK_REALTIME. It is required to fail if the specified time is outside of the "legal range" for the clock id. "legal range" is bad wording and is unspecified. > =D1=81) Linux does not allows negative seconds also Old (~2004) versions of Linux seem to have less error checking for i386 settimeofday() FreeBSD then, so they seem to allow it. The implementation seems to be: - copy the requested value to the kernel software time without much error checking. Don't touch the hardware yet - update the RTC every 11 minutes if the clock is externally synchronized. So with 64-bit time_t anyone could easily set the time to year +-292g, or just to year +-10k. The AT RTC cannot represent this, and it is difficult to make it try since it is difficult to find external servers running that far off the current time. With 32-bit time_t the range is 1906-2037. Linux seems to have no range checking for the conversion to BCD, but it doesn't panic because the BCD macros are expressions. These macros of course don't work for arbitrary inputs. They just convert valid but unusual years to garbage. Before that, negative times are converted to garbage using a type pun: set_rtc_mmss(xtime.tv_sec) starts with a time_t, but the function takes an unsigned long. So 1 second before the Epoch becomes year +584g. The usual divisions by 60 are used to reduce the type-punned time. Since it is unsigned, these now give garbage in-range values. > d) we have settimeofsay(2) that consistent with POSIX and in my > understanding phrase "The time is expressed in seconds and microseconds > since midnight (0 hour), January 1, 1970." is a strict definition, which > prohibits time before the Epoch TImes before the Epoch give undefined behaviour, so they are allowed to work. They are even allowed to work better than times after the Epoch, since they can have any representation and are not require to be missing support for leap seconds. > I do not understand why we should have our own (separate from the rest > world) behavior. It would be good to not have such broken bounds checkng as the rest of the world. Updating the AT RTC synchronously in settimeofday() is already more significantly different than limiting the range of accepted times. One reason that Linux updates asynchronously is that a correct synchronous update (which FreeBSD doesn't do) requires waiting for a second or two. The asynchronous update gives the usual problems handling errors -- even if the interrupt handler detected representation errors, it wouldn't be able to return them to settimeofday(). So errors of a measly 292g years go unreported. Bruce From owner-svn-src-all@freebsd.org Tue Dec 29 15:23:04 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CB024A555A8; Tue, 29 Dec 2015 15:23:04 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9BC34118A; Tue, 29 Dec 2015 15:23:04 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tBTFN3QH074515; Tue, 29 Dec 2015 15:23:03 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tBTFN3og074514; Tue, 29 Dec 2015 15:23:03 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201512291523.tBTFN3og074514@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Tue, 29 Dec 2015 15:23:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r292870 - head/contrib/binutils/bfd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Dec 2015 15:23:04 -0000 Author: ian Date: Tue Dec 29 15:23:03 2015 New Revision: 292870 URL: https://svnweb.freebsd.org/changeset/base/292870 Log: Correct the code for sign-extending a 16 bit value. As near as I can tell this is effectively a no-op -- the addend term in MOVT/MOVW relocations always seems to be zero. But this is correct and the old code wasn't. Modified: head/contrib/binutils/bfd/elf32-arm.c Modified: head/contrib/binutils/bfd/elf32-arm.c ============================================================================== --- head/contrib/binutils/bfd/elf32-arm.c Tue Dec 29 12:38:04 2015 (r292869) +++ head/contrib/binutils/bfd/elf32-arm.c Tue Dec 29 15:23:03 2015 (r292870) @@ -5800,7 +5800,7 @@ elf32_arm_final_link_relocate (reloc_how if (globals->use_rel) { addend = ((insn >> 4) & 0xf000) | (insn & 0xfff); - signed_addend = (addend ^ 0x10000) - 0x10000; + signed_addend = (addend ^ 0x8000) - 0x8000; } value += signed_addend;