From patchwork Tue Jul 19 17:59:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 591666 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5817:0:0:0:0 with SMTP id j23csp4212852max; Tue, 19 Jul 2022 11:08:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u5Mcj+j5wQu5hvs3EjWR6KW4TCCOsJQTZGS5Hz4md4L7LmooJB9O/orc+AKVmaovHyv5bD X-Received: by 2002:a05:620a:2544:b0:6a7:97b7:5400 with SMTP id s4-20020a05620a254400b006a797b75400mr21064230qko.628.1658254089858; Tue, 19 Jul 2022 11:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658254089; cv=none; d=google.com; s=arc-20160816; b=uc65ZT6s6hTtpG34G4xPvD9wrquZDxZtgRTVderb9B4zEQXquaWHo+4wf4l5Jz+P/r fW32iLBzNibVlMP2BamGFCAn28MLnJp6NQjKLGNXFY6zeThWU8KM5evW3H8A05bpmfPZ Pis4uJy6ZVMukQl5CNagjXnA+8k/zzf1rD0Jz4sYYeuYSk1aiobvNjO2Fbt5D/T/M7S9 q+maW1YmJpa40hKv/oEYrtkYtHtM1GQKQmBW/sLsYCeNLRE+1EJoMj3MVlou0fN2GvRd M7vErD/qgEEmVHkCtvOV3e2zIVOuR/D/WXYDBiVmX6FEjy2cYd3Yosbxg40I3Yw+6orC ZPcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2zzB5VOxoMIq4rlx0ft919864A3qEcunZls1gpJJ+3w=; b=rZP83Bq4BvccBiWCoaNrKl3LnvwoqH9rfwCPn6tjKu2LaObdYktz1wMssi1beeC5Ch LuuB1lM5yNYw2QuDkENBXFPNB2Yt9f1oEvSyfXFZNWrjsaPUSbfwI6h4ySLdSv/JWU4g XLDSrpd/R+mH/WWbugCIJi7hnOslVC4aQ/qButEEFrDyLZfDLq2fh2ONN/K/yUSjE6LP zAJOhDVS5I8LP/EoduMWNw9KPpZAdOHqQ5m061p1Y/z3KX074NThjOrVuvGa1UBnGJE9 kRufl1j0FGxS3v4OQ8BghvlDXECaehxnvTFdGndwTV8ZRAbADcB1Oan74zWEvAQRm760 /BTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LlrG4I5J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o11-20020a0562140e4b00b00473443e5d19si6848653qvc.206.2022.07.19.11.08.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Jul 2022 11:08:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LlrG4I5J; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDrdh-0001Od-0A for patch@linaro.org; Tue, 19 Jul 2022 14:08:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDrWL-0006BU-IE for qemu-devel@nongnu.org; Tue, 19 Jul 2022 14:00:33 -0400 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]:36369) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDrWJ-0006B7-Ua for qemu-devel@nongnu.org; Tue, 19 Jul 2022 14:00:33 -0400 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-10d7170b2fcso4258156fac.3 for ; Tue, 19 Jul 2022 11:00:31 -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 :mime-version:content-transfer-encoding; bh=2zzB5VOxoMIq4rlx0ft919864A3qEcunZls1gpJJ+3w=; b=LlrG4I5J4vs27gH2iF/5t3mfJRafB3uRcKiumXfBHA3mj4qpVkYFtYzIRyDompge5z eiI7+7iXb4qTf8X4GlRf9yY6A7S8RBpvN4ZIU1jtBKuaYaynlxGpqfW/60PlNgmTO1wv 9h38yHvHIrt2PdR7dP9UVi55fhmi3OpPB6OGOO/tf1mQ+FtHBeiJ23+jZg/K+3B4e/38 gnVD8LlBra0vgZ6gXNi3TUAWyPx6rCsjMtU2+OiW+VZZXeHyugzF0L2GG4KN+wwp2sUp kImw0UF+OII97opOfVvoVHabNWJdXDT8HwYHO1ESCDnwGBb5lXlF8P0/CkYYmhEo7aot aJjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2zzB5VOxoMIq4rlx0ft919864A3qEcunZls1gpJJ+3w=; b=Nl17WGQ+b3wH0wlwbI54r5RkYMyTNSnUmCThxmyo5El2zrA3FuKgwdp792StwyHue8 fSuKO7ZbINsnGV5bhuGOzwI/rKX6905cu/Ywg+gFo9NA0k/mobIbucs1Cy0fQmyfybga vj+4D+Fhjh0U+Zlbt1HHwf5XckbHmIq7klGb6qeu95N1XiG1BFMIgmSd7hz0e0tNBhXF pwKHlrKdg6w2Zr/aZ3ahGhR4J3DENa6bTTGFoLVlUADBv+Pb0ZUs33vVzmMHFeauwgwR PO7GyPjD7zgBo6g4y8dDjwkVdhfqHVUw40OMe7rZ8TXRtaetbXo4r29Aq/tcw7zmVzzB RgEA== X-Gm-Message-State: AJIora+SOPXXWBNBaXh3g0hvvJ1vLgHfG9v4iwPXqpk9X2qXpgaFoANZ yD6bvhGOFJBQTUwni1p7MLmwkFIWVJRxHNQ1 X-Received: by 2002:a05:6870:4344:b0:10b:8499:395d with SMTP id x4-20020a056870434400b0010b8499395dmr353713oah.214.1658253629324; Tue, 19 Jul 2022 11:00:29 -0700 (PDT) Received: from stoup.. ([172.58.110.182]) by smtp.gmail.com with ESMTPSA id c25-20020a4ae259000000b0035eb4e5a6cesm6286747oot.36.2022.07.19.11.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 11:00:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Xiaojuan Yang Subject: [PULL 05/21] target/loongarch/tlb_helper: Fix coverity integer overflow error Date: Tue, 19 Jul 2022 23:29:44 +0530 Message-Id: <20220719180000.378186-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220719180000.378186-1-richard.henderson@linaro.org> References: <20220719180000.378186-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::30; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x30.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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Xiaojuan Yang Replace '1 << shift' with 'MAKE_64BIT_MASK(shift, 1)' to fix unintentional integer overflow errors in tlb_helper file. Fix coverity CID: 1489759 1489762 Signed-off-by: Xiaojuan Yang Reviewed-by: Richard Henderson Message-Id: <20220715060740.1500628-5-yangxiaojuan@loongson.cn> Signed-off-by: Richard Henderson --- target/loongarch/tlb_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/loongarch/tlb_helper.c b/target/loongarch/tlb_helper.c index bab19c7e05..610b6d123c 100644 --- a/target/loongarch/tlb_helper.c +++ b/target/loongarch/tlb_helper.c @@ -298,7 +298,7 @@ static void invalidate_tlb_entry(CPULoongArchState *env, int index) } else { tlb_ps = FIELD_EX64(env->CSR_STLBPS, CSR_STLBPS, PS); } - pagesize = 1 << tlb_ps; + pagesize = MAKE_64BIT_MASK(tlb_ps, 1); mask = MAKE_64BIT_MASK(0, tlb_ps + 1); if (tlb_v0) { @@ -736,7 +736,7 @@ void helper_ldpte(CPULoongArchState *env, target_ulong base, target_ulong odd, (tmp0 & (~(1 << R_TLBENTRY_G_SHIFT))); ps = ptbase + ptwidth - 1; if (odd) { - tmp0 += (1 << ps); + tmp0 += MAKE_64BIT_MASK(ps, 1); } } else { /* 0:64bit, 1:128bit, 2:192bit, 3:256bit */