From patchwork Fri Feb 23 08:32:45 2024 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: 1903151 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=l0NqPI6/; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Th3Dy6r0Dz23l1 for ; Fri, 23 Feb 2024 19:33:22 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdQzS-0003MT-LR; Fri, 23 Feb 2024 03:33:06 -0500 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 1rdQzR-0003M3-1X for qemu-devel@nongnu.org; Fri, 23 Feb 2024 03:33:05 -0500 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdQzD-0006uZ-5z for qemu-devel@nongnu.org; Fri, 23 Feb 2024 03:33:04 -0500 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-563bb51c36eso82102a12.2 for ; Fri, 23 Feb 2024 00:32:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708677169; x=1709281969; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Uq2awk8nJO2BrLl428ae84YlkT7Ql/QRWd4SAtS9N7o=; b=l0NqPI6/rMIH3/9WQgbHOT2bO6yQkvh4aI6UVN4604XuEyTbWVdrdzNEyAXKbIRm+9 6T4Z8oWcNEzarh+6VV0qXW8VRjdL2f3sVELyB0vZkqgh0ZrvAZmiBDoWDX/QwSBDjeY9 N14na4NnbiMtm/Kh6rWg/HtaqLFQrbWVHru8lgPZ2RpMBG4GhFczoZ/4HPHC+l61Bj+r QyK5/cmBMv8TqQWrz1pbmXY8wGbRMvDbeybQm/g9M9njtjl2Ue4TrW0dhu0WKbXfF0sg axlhGfZRq77kJihH9kb5CZeueRw2zsWjkt4njY+VFFO9WGd6wYfOZ9oiOVjHaPhCvTkK sPWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708677169; x=1709281969; 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=Uq2awk8nJO2BrLl428ae84YlkT7Ql/QRWd4SAtS9N7o=; b=OcP8fKftkp3G9Hr6u3G1eKaE1J/OfxGXl5Bn9XSf8igIG2/0Sr3qrWRTzv1+bTItqR PmwvAIyUzTdDDE7LT6NM6WEPmsFYMRwpFxLxH5GAjMdA54mtIIik1lc7lcp5LDKUfnkY rS7WzSHV7nhUNktt58nPp/Uus35Y5RMW9LEmlBfg7OahEW7RFYqiVvXBf+mABiwfTvDC YM2y8IQqW7+en8zProe+Ctc9CXkiMp+0dru84FqY0FKoj0VO8Sl9LarVdrOE5sqnha28 wYwtgFIWhWG0EZuHlJ+CmjXf7+fo/Rv6GqqV0hFG4SXplG59SftHPqjNuPZGKkISOIHJ 6nmA== X-Gm-Message-State: AOJu0YzlYznq93Qc2UhrN4eomNBAxP8l6LljEtJGASN1Rpp3RHgwW/I5 tE1xmhroywvzBaCRWH0FEF6DL8R5PGsOhNDTCBVFrqQ9JDwISH3lcFWGjKnbvAv8xDHHyyFM1oK uxww= X-Google-Smtp-Source: AGHT+IHvWa2zlzbP1Yi4jmgq9IZrsMcgkXaIsuKhBDVifB4CmqgzuWhbdRtrWveRIyjDPssIj190Rg== X-Received: by 2002:a17:906:4813:b0:a3f:a3bc:1444 with SMTP id w19-20020a170906481300b00a3fa3bc1444mr716138ejq.54.1708677168956; Fri, 23 Feb 2024 00:32:48 -0800 (PST) Received: from m1x-phil.lan (sto95-h01-176-184-18-96.dsl.sta.abo.bbox.fr. [176.184.18.96]) by smtp.gmail.com with ESMTPSA id wn2-20020a170907068200b00a3e6f22f21dsm5294894ejb.54.2024.02.23.00.32.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 23 Feb 2024 00:32:48 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Nicholas Piggin , Thomas Huth , Daniel Henrique Barboza , qemu-ppc@nongnu.org, =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= , =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= Subject: [RFC PATCH] target/ppc/mmu: Silent maybe-uninitialized error in ppc_hash64_xlate() Date: Fri, 23 Feb 2024 09:32:45 +0100 Message-ID: <20240223083245.80175-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=philmd@linaro.org; helo=mail-ed1-x52f.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=unavailable 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Initialize apshift to avoid a maybe-uninitialized error: C compiler for the host machine: cc -m64 -mbig-endian (gcc 13.2.0 "cc (Debian 13.2.0-10) 13.2.0") C linker for the host machine: cc -m64 -mbig-endian ld.bfd 2.41.90.20240115 Host machine cpu family: ppc64 Host machine cpu: ppc64 ... target/ppc/mmu-hash64.c: In function 'ppc_hash64_xlate': target/ppc/mmu-hash64.c:1154:15: error: 'apshift' may be used uninitialized [-Werror=maybe-uninitialized] 1154 | *raddrp = deposit64(pte.pte1 & HPTE64_R_RPN, 0, apshift, eaddr); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ target/ppc/mmu-hash64.c:947:14: note: 'apshift' was declared here 947 | unsigned apshift; | ^~~~~~~ The call chain is: ppc_hash64_xlate -> ppc_hash64_htab_lookup -> ppc_hash64_pteg_search ppc_hash64_pteg_search() either sets *pshift or returns -1, ppc_hash64_htab_lookup() returns if ppc_hash64_pteg_search() returned -1: 1068: ptex = ppc_hash64_htab_lookup(cpu, slb, eaddr, &pte, &apshift); 1069: if (ptex == -1) { 1070: if (!guest_visible) { 1071: return false; 1072: } ... 1087: return false; So IIUC this "uninitialized use" can not happens. Signed-off-by: Philippe Mathieu-Daudé --- I had this in an old branch (2 months old) I just rebased, and don't get why nobody else got this error yet. --- target/ppc/mmu-hash64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c index d645c0bb94..cd1e0c13c8 100644 --- a/target/ppc/mmu-hash64.c +++ b/target/ppc/mmu-hash64.c @@ -944,7 +944,7 @@ bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, CPUPPCState *env = &cpu->env; ppc_slb_t vrma_slbe; ppc_slb_t *slb; - unsigned apshift; + unsigned apshift = 0; hwaddr ptex; ppc_hash_pte64_t pte; int exec_prot, pp_prot, amr_prot, prot;