From nobody Sat May 18 10:48:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1686073016; cv=none; d=zohomail.com; s=zohoarc; b=Q1UcP9qh4QBs/2iCnyd4IdTQia5O1CnW/EYkGugbR6vMMtarwStL7GrlRD7C2uEETydpqvujZ3Z0E3yHrljuB4oON7uimnJ6jj+zom1aSgbrBygG3GrWj7cK98sGuNhi3YkCBiDWj4w19iJsRsMOdpEExqWOOVu6iRgu4sWif2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686073016; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=lHEChm4frbPH7coBKbTXY9kQlG4XX744+VMt8p1duic=; b=NCxfETeoTudJglkSjs1LZfGKnx/LGKXnVKBVx6SwlY2KrnLr1Pte5tiZynzpYSUAYClPi3bxneKVOCB5z9BKMpZ8FdyctDoq8tBI75moBFDVzFIgptpIoM4CU3qhqj96htTWIrQrDg7Q4mtsPXuqZ/7BfB0mPdjf9//vJut/2uo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1686073015948304.0430190055109; Tue, 6 Jun 2023 10:36:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6aIN-0006aj-Ka; Tue, 06 Jun 2023 13:16:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6aIL-0006Vz-Ri for qemu-devel@nongnu.org; Tue, 06 Jun 2023 13:16:33 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q6aIK-0008Dd-90 for qemu-devel@nongnu.org; Tue, 06 Jun 2023 13:16:33 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6537d2a8c20so2997000b3a.2 for ; Tue, 06 Jun 2023 10:16:31 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:b7fa:ce59:1445:805a]) by smtp.gmail.com with ESMTPSA id jk19-20020a170903331300b001b0aec3ed59sm8765704plb.256.2023.06.06.10.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 10:16:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686071791; x=1688663791; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lHEChm4frbPH7coBKbTXY9kQlG4XX744+VMt8p1duic=; b=s2HGw3G9qzuCc4B5BTPbYSivNP8WVCmvT+0wLQTN1SUmmAq4UBmOiqUgcXf9us2k9o M7aVEXBx64OIFvlfAGZa0GKNyMapJrYWnE+NHeBnUvSc5/i6f/3OUXfvP1MT0liomzMR hsbYMxiemAsIdBDN9dV5+swuvdTHBm21X4oggs3aibyKroGZdtMwoKEKm2msc2JJq1DB FM5D4a3BdFDFZTQ/aXiWsAVNeygE9tgx4eTmJ8KS+ei+MNZ4D/QepZQZRBORrVvjyA1j yt/MrNIqwDzq9ykMP52LxMJ2oWtY9gaFKUqSoPd6IyORGTKRQEpq+ofx9KBHRP6gIS0W 5+6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686071791; x=1688663791; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lHEChm4frbPH7coBKbTXY9kQlG4XX744+VMt8p1duic=; b=DWNhu9bpHQ9q3jri4ndXenATae7VmvjAcQ5QbCRWsSz4fbvVzGA7wkxZNNLfc2fM7q Q8YJBBF7VKOmDcCM02OkJC9PNkshv2igrcuW6N23mNRn1B0JJfoPnEzNxhIsyuDMtZzE /OF/1ODLjMeSyRZ8Xvtoo+WZergAsSTDCWIXcK1+cxyn3lmpOr0arHuq+dl5R3w5BHG7 PYVoG01qtp2tVo/eccGLEDsawrIVseB8847D2cVRpzC7lnvprgyGV5R1fKAuMDV+dM2X eG8mEND998BbgtNfmgEJxu3xUwnQXo3nwVq84TJUam4WYhV6F8k8OStsAu8EyIcb+pW5 l8FQ== X-Gm-Message-State: AC+VfDz8cEJ59whCtkky6dcBLRLNDeWCH2jpf75wjhEI8vnAGKGkNHTY B9Um330qyJQ1tcYmAlfCmp98NztkNZFRpQKl9es= X-Google-Smtp-Source: ACHHUZ71GnqKS5NDdJv/WIVn0ozDksUUS9WryEhSX16KWeYkT53nKkhd2xp52yej+2CsphEEQvrVhw== X-Received: by 2002:a05:6a20:841e:b0:10b:dca4:8a3b with SMTP id c30-20020a056a20841e00b0010bdca48a3bmr294820pzd.31.1686071790893; Tue, 06 Jun 2023 10:16:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH] accel/tcg: Fix undefined shift in store_whole_le16 Date: Tue, 6 Jun 2023 10:16:29 -0700 Message-Id: <20230606171629.98157-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1686073018452100003 Content-Type: text/plain; charset="utf-8" The computation is documented as unused in this case, but triggers an ubsan error: ../accel/tcg/ldst_atomicity.c.inc:837:33: runtime error: shift exponent -32= is negative SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../accel/tcg/ldst_a= tomicity.c.inc:837:33 in Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- Hi Peter. Found this while merge testing FEAT_LSE. Clearly my bug, which I ought to have found earlier. r~ --- accel/tcg/ldst_atomicity.c.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/accel/tcg/ldst_atomicity.c.inc b/accel/tcg/ldst_atomicity.c.inc index 2514899408..de70531a7a 100644 --- a/accel/tcg/ldst_atomicity.c.inc +++ b/accel/tcg/ldst_atomicity.c.inc @@ -833,7 +833,9 @@ static uint64_t store_whole_le16(void *pv, int size, In= t128 val_le) } store_atom_insert_al16(pv - o, v, m); =20 - /* Unused if sz <=3D 64. */ + if (sz <=3D 64) { + return 0; + } return int128_gethi(val_le) >> (sz - 64); } =20 --=20 2.34.1