From nobody Tue Feb 10 15:28:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523933733747563.2940955385847; Mon, 16 Apr 2018 19:55:33 -0700 (PDT) Received: from localhost ([::1]:34593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8GmC-0005Sx-9p for importer@patchew.org; Mon, 16 Apr 2018 22:55:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8GkU-0004RR-V4 for qemu-devel@nongnu.org; Mon, 16 Apr 2018 22:53:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8GkU-0007eC-8a for qemu-devel@nongnu.org; Mon, 16 Apr 2018 22:53:39 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:38657) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f8GkU-0007cr-2H for qemu-devel@nongnu.org; Mon, 16 Apr 2018 22:53:38 -0400 Received: by mail-pl0-x242.google.com with SMTP id c7-v6so11156769plr.5 for ; Mon, 16 Apr 2018 19:53:37 -0700 (PDT) Received: from cloudburst.ASUS (cpe-66-75-76-48.hawaii.res.rr.com. [66.75.76.48]) by smtp.gmail.com with ESMTPSA id v63sm31759876pfk.8.2018.04.16.19.53.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Apr 2018 19:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t5V/IQAptYx23oK2IFpQU6J5Ud1YBq6Pkr09Y/TjDyg=; b=hGo8kSMRa0rVAqpDDW5WCTIblTmdQDWfyVGo9XgOEpm+Sp/ftgZ55x9mNdjnaPIS7l y/MQbebyfrUMGyal5juzCdEKdwpIfQWLUjyx2HJy1YpBpUrDOTimYxWZGX2f3dpN7kAX 7KGjfNcAZUlmAY3FZwUjB/xnPt8ewSxIE7wqI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t5V/IQAptYx23oK2IFpQU6J5Ud1YBq6Pkr09Y/TjDyg=; b=mZul+sHIrXlHAT12g8atj9jPzter/gCg/L5bLiTROwI7TMIpi90tx++q9vP/n3ZLOl tJ+oJ7bzPlxbY4AMSnC8BDieJlt9G2APRHD8Yr0EL0CPs0J2qxQ134h7S5hpH1F4XprI 21ha1ro6MpGkpt4IPv9tZUDtxcm5450Y9K/S2IM9eoAwKMJqhxKWjQ+YIURbYVQJcMLI RR/L2mTtnovMNgCci4/OqpnfYtPBf8jPpM/K5zS5QYRV6oGFwPYns/bvS2d65njCJCaM /yT2XHdWLIKMC/bLY/29voGY/mHgomhoG3VvAsHPCO5w632/EW5JoSLUxsg7wqJz2eBc /lLw== X-Gm-Message-State: ALQs6tBq8itWw8DA4NVqGLMnWCbtk6y3unO+RRuwYGJax3ktz7HqFf7q BCRWBFN2cL/6DcQHWJnWXGLiRZpw8Ns= X-Google-Smtp-Source: AIpwx49HGYhCQGId9Vw9uHPbJ0GlEa9QvwSjLVVCZ5ePdAcEnGk2Ln21ktJ1gDi/un0MVzIUB1c3kA== X-Received: by 2002:a17:902:9303:: with SMTP id bc3-v6mr348900plb.18.1523933616779; Mon, 16 Apr 2018 19:53:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Apr 2018 16:53:28 -1000 Message-Id: <20180417025328.25431-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180417025328.25431-1-richard.henderson@linaro.org> References: <20180417025328.25431-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH 2/2] fpu: Bound increment for scalbn X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Without bounding the increment, we can overflow exp either here in scalbn_decomposed or when adding the bias in round_canonical. This can result in e.g. underflowing to 0 instead of overflowing to infinity. The old softfloat code did bound the increment. Signed-off-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Peter Maydell Tested-by: Alex Benn=C3=A9e --- fpu/softfloat.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index ba6e654050..a589f328c9 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1883,6 +1883,12 @@ static FloatParts scalbn_decomposed(FloatParts a, in= t n, float_status *s) return return_nan(a, s); } if (a.cls =3D=3D float_class_normal) { + /* The largest float type (even though not supported by FloatParts) + * is float128, which has a 15 bit exponent. Bounding N to 16 bits + * still allows rounding to infinity, without allowing overflow + * within the int32_t that backs FloatParts.exp. + */ + n =3D MIN(MAX(n, -0x10000), 0x10000); a.exp +=3D n; } return a; --=20 2.14.3