From patchwork Thu Aug 31 13:17:35 2023 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: 719017 Delivered-To: patch@linaro.org Received: by 2002:adf:e5c2:0:b0:31d:da82:a3b4 with SMTP id a2csp467381wrn; Thu, 31 Aug 2023 06:18:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmHdx4o+lNL3ahL2gkPfVWk0SfxBHL4NEGDu5gzV/7W6wqFvCswbUxVBoigkXFh0YSMkcN X-Received: by 2002:adf:e5cf:0:b0:317:e542:80a8 with SMTP id a15-20020adfe5cf000000b00317e54280a8mr3821120wrn.15.1693487934052; Thu, 31 Aug 2023 06:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693487934; cv=none; d=google.com; s=arc-20160816; b=QG4Erp5S8IWQgiFzOKij1oTQQRN8Lp2pVriBvSMyUQwhHd55XvdG4OKR5oYmLNbJR0 Jrufgv+rTZFdh1hOMjcmi5sGAiqbBcptJBFoXaGDRo6GXKgWZyDgyiSgIgRja9x4SoOj WWCV8AEx6YwAijGNQVrkOR04bXHlLI+O6AUIIJvU5XRXtzNk+f5gBAkkDAvkyxsv+Glt 6QZLMyKifuUMvPgPhkmHDHIVdIqH4CQd9DKWXDdEnySgJaF5+K3XVKH8HMrxCGA/OCSA mWPXpwlpO/jV44o/TBNAFp/DY1UP8qf+iLsaCX6lKV2sVSb3ok0ockH1m90KXK+cDymn afiw== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=MdzPEcxzucIAuSdP8BdEgSNIDWAAi6SMHz+Cq8k3u5g=; fh=bxBG4IA4tiUG5pDYni+yATEj3+TFAU9mOTrz33B66t8=; b=l34sdJIrjImPgcOhF8uG/larriKzcsY/IUmiroCXTABtRyZjPYufj/UkHGWRlyXXUr siuLlRyVfzxVeywUdfxi6c1n/9xrJ3jHDg2Ri6M36vqTxZRm8oAeCJNzBa4hU4QKtG+o /G/vs1HkoQWQp7nqN7ya3pavzKzks3/JjtjSc2Wy2PNaZLRwuIG/6Keoeeqq+7Y66Ntn V2qUFoIUASFzZXrHSO1I8K89w/EphJaKNPeBQRYO3w+rRuMO2X5SgQPtP0mXisEcj8WJ KldsJF3JIVPiGPhV3B2NWOoM9Bmvkc4IG5/zBFXPi8viP3zktUJjI5F1QecExAC03q74 3dJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a6acD0ZY; 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 e18-20020adfe7d2000000b00317e4bf873esi664923wrn.512.2023.08.31.06.18.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 06:18:54 -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=a6acD0ZY; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbhYN-0002YC-La; Thu, 31 Aug 2023 09:17:43 -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 1qbhYM-0002Oy-Du for qemu-devel@nongnu.org; Thu, 31 Aug 2023 09:17:42 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbhYJ-0004Ff-Uu for qemu-devel@nongnu.org; Thu, 31 Aug 2023 09:17:42 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-401b5516104so7248755e9.2 for ; Thu, 31 Aug 2023 06:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693487858; x=1694092658; 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=MdzPEcxzucIAuSdP8BdEgSNIDWAAi6SMHz+Cq8k3u5g=; b=a6acD0ZY2nCQCDSJvNLPLu3UZvD3bw88RnArk65MuLbPKKCAMkKHF4OR75aja2dehe wlchUHz6rCDacYDxrAYymlJc9qUzkLJalO7Dh6Aa0gNQQFH9NfPoiGgbXVUBaGz2DMFj PFj69LdU7r0aajHUuDCY0MLpHEDuu7WhhrMjs7bPd0980HX3gR0AboFZo8yiksC14OsS QPsx36Zu7WVCHjYgMVDNJRGXxyRZcZt6Wuwp2wJMHKn8kuNEGPdQ2ICgNNgrZK4s6tT+ cI53+3SynpjfHfkVGiLjEB4e6pOBoeRpvdIYzkv2Lf02zJ5CUB8hRsxBQyvG7u4ZTHvj AHng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693487858; x=1694092658; 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=MdzPEcxzucIAuSdP8BdEgSNIDWAAi6SMHz+Cq8k3u5g=; b=E1WrxRYXhpSCEu+DV9finW/XfWruSh4gLnowqB4enXIhyjWDvGFic8LolAJPk1RriI UlqOjy+XeH64CcBaRc7oTkX9w63trkj6Kop3amwU13Bdgzvejj9JY++g0lXYrf7uRcZK /kfLA11TFPSXFFCzsU4tJhvpXDuA4BvLoPwFG7oEr59tyMrkCwNBrYOCSwA0vdKccsqV ricNKqQy2vBZnIx5PiLlf0yoh736czZdt2l8Q6HF0D7C1yOqsPElvQGjJgigFlzNcAxi cDGNmRzVHZo0J5Ur/WV9t7XmYqVwoYB/PjS7uDkd+V7gzbFzpyfqFvYj0qHlcXASj2Uv pbew== X-Gm-Message-State: AOJu0YwXPEEIa9/BQ8rvQIP63MTawdqJJaQaEwKEGFLSsadghG/l6csG Zy3U8WvHEpiXKq18MuJiRk9UZxsVGTSY2Zm2+w0= X-Received: by 2002:a7b:cb9a:0:b0:401:5956:3cdd with SMTP id m26-20020a7bcb9a000000b0040159563cddmr4272237wmi.33.1693487857862; Thu, 31 Aug 2023 06:17:37 -0700 (PDT) Received: from m1x-phil.lan ([176.187.199.245]) by smtp.gmail.com with ESMTPSA id 9-20020a05600c228900b003fc080acf68sm5129100wmf.34.2023.08.31.06.17.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 31 Aug 2023 06:17:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Max Filippov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH] target/xtensa/mmu: Avoid maybe-uninitialized error in get_phys_page() Date: Thu, 31 Aug 2023 15:17:35 +0200 Message-ID: <20230831131735.69288-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::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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 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-bounces+patch=linaro.org@nongnu.org Fix when using GCC v11.4 (Ubuntu 11.4.0-1ubuntu1~22.04) with CFLAGS=-Og: target/xtensa/mmu_helper.c: In function ‘helper_pptlb’: target/xtensa/mmu_helper.c:986:35: error: ‘bg_segment’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 986 | return env->config->mpu_bg[bg_segment].attr | segment; | ^ target/xtensa/mmu_helper.c: In function ‘xtensa_get_physical_addr’: target/xtensa/mmu_helper.c:1011:35: error: ‘segment’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 1011 | attr = env->config->mpu_bg[segment].attr; | ^ target/xtensa/mmu_helper.c:996:14: note: ‘segment’ was declared here 996 | unsigned segment; | ^~~~~~~ Signed-off-by: Philippe Mathieu-Daudé --- target/xtensa/mmu_helper.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c index fa66e8e867..93e3866217 100644 --- a/target/xtensa/mmu_helper.c +++ b/target/xtensa/mmu_helper.c @@ -980,9 +980,10 @@ uint32_t HELPER(pptlb)(CPUXtensaState *env, uint32_t v) } else if (nhits == 1 && (env->sregs[MPUENB] & (1u << segment))) { return env->mpu_fg[segment].attr | segment | XTENSA_MPU_PROBE_V; } else { - xtensa_mpu_lookup(env->config->mpu_bg, - env->config->n_mpu_bg_segments, - v, &bg_segment); + nhits = xtensa_mpu_lookup(env->config->mpu_bg, + env->config->n_mpu_bg_segments, + v, &bg_segment); + assert(nhits > 0); return env->config->mpu_bg[bg_segment].attr | segment; } } @@ -1005,9 +1006,10 @@ static int get_physical_addr_mpu(CPUXtensaState *env, } else if (nhits == 1 && (env->sregs[MPUENB] & (1u << segment))) { attr = env->mpu_fg[segment].attr; } else { - xtensa_mpu_lookup(env->config->mpu_bg, - env->config->n_mpu_bg_segments, - vaddr, &segment); + nhits = xtensa_mpu_lookup(env->config->mpu_bg, + env->config->n_mpu_bg_segments, + vaddr, &segment); + assert(nhits > 0); attr = env->config->mpu_bg[segment].attr; }