From nobody Sat Apr 27 09:08:37 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1658325523; cv=none; d=zohomail.com; s=zohoarc; b=CQTEx/G3ZpDa8Q8Z3aXW2wxp+nngeqt0a+OW74D2nUn0ZafRnYPtWEgXyDLkpYF3lHWkQw9Q8ZkMYKDQLOspXmmOEIAqU34ED14brYqP92JLAZ2tSX/PXjCsyNTLLgS24x0SNpl2rsinnMlIEIzvmfrWUNdNex2fX1d1CrJeAls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658325523; 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=/p2k6r1VXhMALlnOhZRObhIjNw1QHNMYkzSVAkcLXy4=; b=CYP7kI4FyIQAHoftCqiVYf4Rm9hIukXNh7qZ+NjlFwTlhcGlZVBxAybt9ziY70WCwf16HHtlMTDXebW3tIyGkE25PQPcIMd5C1Wc5PDi414eAsKMSj7FTI0JmR10++rBhxhtafTdmL5dvBcNhYHrgPyCJHBrA09LWzkyFSGci0U= 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 1658325522999642.2837843621387; Wed, 20 Jul 2022 06:58:42 -0700 (PDT) Received: from localhost ([::1]:60796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEADo-0007lc-OA for importer@patchew.org; Wed, 20 Jul 2022 09:58:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEACm-0006p0-S7; Wed, 20 Jul 2022 09:57:36 -0400 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]:40943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEACl-0007GR-Ev; Wed, 20 Jul 2022 09:57:36 -0400 Received: by mail-oo1-xc2b.google.com with SMTP id t11-20020a4ad0ab000000b004356ab59d3bso3491021oor.7; Wed, 20 Jul 2022 06:57:34 -0700 (PDT) Received: from balboa.ibmuc.com (200-232-202-163.dsl.telesp.net.br. [200.232.202.163]) by smtp.gmail.com with ESMTPSA id c21-20020a056808105500b003263cf0f282sm6504885oih.26.2022.07.20.06.57.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 06:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=/p2k6r1VXhMALlnOhZRObhIjNw1QHNMYkzSVAkcLXy4=; b=ZfZNZ+C4iXea4fFmejZq47y+iwkQpZHddQZBprDdYyjHoC1Gg3v4vBPDfT3rcZqNJL CsJrEGQUdJaLnRsNIHGA+hhOB+71Oes1fTIfoy0Y1JUh/Gg0ActgWgy0aA2IXvg40oIn 2mLpqNlC6Zo8L+bvbijM43fZ2/+nA1H1mgYw2cFYk/kNmGedQW16ibYLS/KdBX9Ei2ef v+qsRw5DXTWMIA/XBPMzWIqQ/e77bFOGmTyXMEiNpT0P1BYNPDQjzgXz3n7aRbT5VNEk 8aQAiy7PzPiT5oXLbrq1Zh1mJd6fvjek9KU5smKChD1L0jv7Pzwvm5o92/JaJzGUxtcK 3aPw== 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:mime-version :content-transfer-encoding; bh=/p2k6r1VXhMALlnOhZRObhIjNw1QHNMYkzSVAkcLXy4=; b=kZE2hsNCqeUysKr6xs6YHxsOF6d3W6NX74fJmweE2YlcET0dqP7fU8xWVe8HsbKx2w aml4dNTLoRlu2JWJczp4sBwpNv1b0raImrRuk9coLsrLxIie4tEaFolE3ne2GB5bRIpA QmaIdoY8YMDMQKQaxfTD/wB1cWAq78SvzHfN69p2XCy6RG4TWnhzDolXbVAi4gqPqHVI zhx9nrfGCYR6oDxpv10ju+i5oltzfF5/gjEYoBDIes1YcAcRNK8pX6yzMvjjmKs0RAKK iBlYHGjce33s9XDrEaMxM3fzRH94O+Ia3OBqHdeX4RI45i/Q4kkFk9I6Ezc7ffunG4vL r7kg== X-Gm-Message-State: AJIora9bLcZqAREbs7QG0GA3GQlgQs1kfg04RcwJwqdryyKlE5PltlZ3 e8Teu/kwdarEvQWbYAHADD2tfXaARCs= X-Google-Smtp-Source: AGRyM1tpVRPaL6di4gtlaAZ/tH1HwwlM9hv4EsoDovTrYL69FLfG9K8JHdhj8Nm2xPckhx2kZMdQtQ== X-Received: by 2002:a05:6820:514:b0:435:9b97:b818 with SMTP id m20-20020a056820051400b004359b97b818mr5785790ooj.32.1658325453263; Wed, 20 Jul 2022 06:57:33 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, Daniel Henrique Barboza , Matheus Ferst Subject: [PATCH] target/ppc: fix unreachable code in do_ldst_quad() Date: Wed, 20 Jul 2022 10:57:23 -0300 Message-Id: <20220720135723.1391598-1-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.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::c2b; envelope-from=danielhb413@gmail.com; helo=mail-oo1-xc2b.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1658325524263100001 Content-Type: text/plain; charset="utf-8" Coverity reports that commit fc34e81acd51 ("target/ppc: add macros to check privilege level") turned the following code unreachable: if (!prefixed && !(ctx->insns_flags2 & PPC2_LSQ_ISA207)) { /* lq and stq were privileged prior to V. 2.07 */ REQUIRE_SV(ctx); >>> CID 1490757: Control flow issues (UNREACHABLE) >>> This code cannot be reached: "if (ctx->le_mode) { if (ctx->le_mode) { gen_align_no_le(ctx); return true; } } This happens because the macro REQUIRE_SV(), in CONFIG_USER_MODE, will always result in a 'return true' statement. Fix it by using "#if !defined(CONFIG_USER_ONLY)" to fold the code that shouldn't be there if we're running in a non-privileged state. This is also how the REQUIRE_SV() macro is being used in storage-ctrl-impl.c.inc. Fixes: Coverity CID 1490757 Fixes: fc34e81acd51 ("target/ppc: add macros to check privilege level") Cc: Matheus Ferst Signed-off-by: Daniel Henrique Barboza Reviewed-by: V=C3=ADctor Colombo --- target/ppc/translate/fixedpoint-impl.c.inc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/ppc/translate/fixedpoint-impl.c.inc b/target/ppc/transl= ate/fixedpoint-impl.c.inc index db14d3bebc..4a32fac4f3 100644 --- a/target/ppc/translate/fixedpoint-impl.c.inc +++ b/target/ppc/translate/fixedpoint-impl.c.inc @@ -82,10 +82,14 @@ static bool do_ldst_quad(DisasContext *ctx, arg_D *a, b= ool store, bool prefixed) /* lq and stq were privileged prior to V. 2.07 */ REQUIRE_SV(ctx); =20 +#if !defined(CONFIG_USER_ONLY) if (ctx->le_mode) { gen_align_no_le(ctx); return true; } +#else + qemu_build_not_reached(); +#endif } =20 if (!store && unlikely(a->ra =3D=3D a->rt)) { --=20 2.36.1