From patchwork Sun Sep 26 21:39:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1533018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=TusnAc1o; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HHfLh5styz9t6g for ; Mon, 27 Sep 2021 07:39:55 +1000 (AEST) Received: from localhost ([::1]:50772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUbsF-0008Aa-5n for incoming@patchwork.ozlabs.org; Sun, 26 Sep 2021 17:39:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUbrc-0008AN-DD; Sun, 26 Sep 2021 17:39:12 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:41730) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mUbrX-00076x-5x; Sun, 26 Sep 2021 17:39:12 -0400 Received: by mail-wr1-x432.google.com with SMTP id w29so46110441wra.8; Sun, 26 Sep 2021 14:39:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Zn/EeFiHzDUyaGhXtsd/E2eXxlWN4jO4U2XJ3ypuRU8=; b=TusnAc1oGYHvPlvcSQLjOn/YShIM3N+QvWAZlUMwNDBu1uvHUYutfOjrPDO4kfj8sX b+9+ls89Fi0fRVdtyFsqDEK0fgaD3gOMV5P0CEpsQ1K//tjLEdXsUYStw9o3B+zyrDi1 0K0sOZlegd0Ge98hiFS3UxXweYTR14ZI+7lKO83GETPK579ITIPV2Hx+dNQPk3WvlOaX 7So0iMatCiCDWBrFq3ATQ3YPTSRbRqgBIFWWO0eB3hNDcMktRGezL05YpoJ8auklCPQp KigcmDpFCnwRbFMXrhGSMjsnVeUsGu3QFjO99BNJIU9g3TqZ5vcfpZ3dkx9VG3rQrR1H XlMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=Zn/EeFiHzDUyaGhXtsd/E2eXxlWN4jO4U2XJ3ypuRU8=; b=4eXgtdgwWvlTnn68LJ4zMtnmFxDo8yc6KEtmx+1BJ2jHY7mRkjjEZ97KF4qJrdDpiS OuzYKLVKXIbfoKMEfa2cdf8aFO4G/AN9AKD7zfTyoapPG+8u6Xu+4bBddfXAdSDfW+rE T1gYF7kGycyzUHsqQLwuyWAh2dRaRamxJ2Dq5O513UcuCLc8XA3aYJyjRE0JikR9tdV1 kn5aUyOiwAHXLvv8+bLPRkyBKXIM8v5wWne9SVheyS/mxNjnTwj0/12AWtJGP/r/f0Ml FHpqZZLcRfv7o9isTNE5tUlRYfpcyM/qCONsdvu51rGeKCsS5GQeB0pcBNBSbEprtscn p/ug== X-Gm-Message-State: AOAM533zhO47khku1OiiGC9xE8Af4w5iwW/X2gOy1j/+nWJiaGvJXwOQ bk0D4r2Hq8sT/RjI63y2O44Qdyg7PfA= X-Google-Smtp-Source: ABdhPJxiVb52ouDAu7b9pG6QN8xK6OND6x6i7sqCdqaARk4Tph92KlBMWliKcuKPocFbggL8vNiDqg== X-Received: by 2002:adf:a31a:: with SMTP id c26mr25367673wrb.307.1632692344935; Sun, 26 Sep 2021 14:39:04 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id 4sm13854324wmv.42.2021.09.26.14.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 14:39:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH] tcg/riscv: Fix potential bug in clobbered call register set Date: Sun, 26 Sep 2021 23:39:02 +0200 Message-Id: <20210926213902.1713506-1-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x432.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-riscv@nongnu.org, Richard Henderson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Palmer Dabbelt , Joelle van Dyne , Alistair Francis Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The tcg_target_call_clobber_regs variable is of type TCGRegSet, which is unsigned and might be 64-bit wide. By initializing it as unsigned type, only 32-bit are set. Currently the RISCV TCG backend only uses 32 registers, so this is not a problem. However if more register were to be implemented (such vectors) then it would become problematic. Since we are better safe than sorry, properly initialize the value as 64-bit. Fixes: 7a5549f2aea ("tcg/riscv: Add the target init code") Signed-off-by: Philippe Mathieu-Daudé --- tcg/riscv/tcg-target.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index dc8d8f1de23..5bd95633b0d 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1734,7 +1734,7 @@ static void tcg_target_init(TCGContext *s) tcg_target_available_regs[TCG_TYPE_I64] = 0xffffffff; } - tcg_target_call_clobber_regs = -1u; + tcg_target_call_clobber_regs = -1ull; tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S0); tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S1); tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S2);