From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52475) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXBNp-0000ts-ND for qemu-devel@nongnu.org; Mon, 07 Apr 2014 11:22:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WXBNi-0007aN-IZ for qemu-devel@nongnu.org; Mon, 07 Apr 2014 11:22:49 -0400 Received: from mail-ee0-f43.google.com ([74.125.83.43]:42488) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXBNi-0007aA-Bz for qemu-devel@nongnu.org; Mon, 07 Apr 2014 11:22:42 -0400 Received: by mail-ee0-f43.google.com with SMTP id e53so768178eek.30 for ; Mon, 07 Apr 2014 08:22:41 -0700 (PDT) Message-ID: <5342C2BE.4020805@cloudius-systems.com> Date: Mon, 07 Apr 2014 18:22:38 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1396019577-2013-1-git-send-email-peter.maydell@linaro.org> <1396019577-2013-3-git-send-email-peter.maydell@linaro.org> <5340FDA3.1080902@msgid.tls.msk.ru> <5342BC96.6010204@cloudius-systems.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH 2/3] int128.h: Avoid undefined behaviours involving signed arithmetic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Trivial , Patch Tracking , Michael Tokarev , QEMU Developers , Richard Henderson On 04/07/2014 06:17 PM, Peter Maydell wrote: > On 7 April 2014 15:56, Avi Kivity wrote: >> On 04/06/2014 01:18 PM, Peter Maydell wrote: >>> The alternative would be to say that Int128 should have >>> undefined behaviour on underflow/overflow and the test >>> code is wrong, but that doesn't seem very useful to me. >> Isn't the test broken here? It is trying to add (or shift) -2^127 and >> something else, and the result truly overflows. > Well, the test code is assuming "semantics as per 2s > complement arithmetic" and checking various corner cases. > As I say, we could define that this is invalid and > rewrite the test cases. It is invalid. The test thinks that -2^127 * 2 == 0, but if a guest could trigger it, it would probably be a security issue.