From nobody Sun Nov 24 13:37: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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1722446598; cv=none; d=zohomail.com; s=zohoarc; b=CjDVzRdJGOLSctIvEDRzA7qY1+cGx9g68H3LMvQCAygc9e6XiwjcLdMOz5B5A8iCs/rkZoeD7f3gbnH+uodQbdhoekLPXEIiEIC0bMsNIUPOGuMeSEyzbiki7uDIybRW0j+MH7iqyBj281QuboKTbYeNymL6FFCpP8ADmaAyO8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722446598; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=krq/DVBMGIf3UCTnG4Govxc+YjVtitrTOmfpG0clA+g=; b=m+AgjJVUIUTO8adVwoBW4qXMeo4kgupeWzNGx6Q5VZf9VOmQMXjFa0JaaO8VAY4LmM/U2SgV3r0z/j51NZi7kxTxuPdWz3P7W7o3EZH6PY8KvTxvFAKx4X0ehXU8pG88odgcTkD9TwSPMH8fwnMbJ9NzdG3d3hmXnataUv0rdlU= 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 1722446598493713.4024207970812; Wed, 31 Jul 2024 10:23:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZD2N-0000NQ-Es; Wed, 31 Jul 2024 13:22:55 -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 1sZD2J-0000Mj-1r for qemu-devel@nongnu.org; Wed, 31 Jul 2024 13:22:52 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZD2H-0005ds-Ih for qemu-devel@nongnu.org; Wed, 31 Jul 2024 13:22:50 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-367963ea053so3734842f8f.2 for ; Wed, 31 Jul 2024 10:22:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367e51f0sm17545140f8f.46.2024.07.31.10.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jul 2024 10:22:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722446567; x=1723051367; 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=krq/DVBMGIf3UCTnG4Govxc+YjVtitrTOmfpG0clA+g=; b=B+OkF8R3MU3mfyP/hClSK8caTHzqdqQ2fbIX3lOyA0vZgeMeBbwyI6BhEvJ89RrCCx ZSEw2zB9k4yAe6ox0gkyaoSpvjngJUnPSyoQ6H7/vHUUYEPn3DPHEFWJkiiO00nvpTc8 zbkZ8uurFCmo7b8HO/gJxnOHIpMEZD2qRniCEwDuYWVXfTLmuYMrKviEhFlvp8feZdRx FhGLIJnl/yfSyA5w6VRZkym5m33yAOGnC7l0fhh76WulWk/jsS8SsyClNAHTOc3sjHZl JA8evvvnbPgcaU4do/IKZq0WQWd1hD0luTeI+ZpMWxJloswtGtr7WgMNvgcSZB39CcKS +cNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722446567; x=1723051367; 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=krq/DVBMGIf3UCTnG4Govxc+YjVtitrTOmfpG0clA+g=; b=m7F5g5O8bVeWlsxolA4uGDXGc0BuuVSQq1cZKDXUAxHzjMNGXpXb15RMJjLah0y/9e SOfLCc/9scBOSP6UiU2fyoC8KEvASzFD6mSdeuBJxfyAxFCt4/WT+iZYENLmV3LB74HQ 2i24q7S6nLdVFIwI9f/SJmkkT7RdD4czfdb0Babm4JpGQL7Q4JANCBT8dSRhAeqKnL7F nUkPzULXPK2Mvq8WiBg77Iq49R+yuC/jKAW8MNtRkmrGofSs8OwLLRQ71p/kx1flYAk5 KlNUW8B6mQUSV0/67k1tcjGCXw6LSQroQYh3X1AWMC6SkA6hJTJu/ZCKGCjnP945Ko9n O2SA== X-Gm-Message-State: AOJu0YxNyQSV+nTg3U064yuad0oQ+Nv52J2ims3OrXiFA60TUDv6Wisd HX8hAHCJSvHBcINwT/BrGt2fxkvWpOcOupyBAwt71HGtxwAqf6DNjAvF5S6ZO+mIOL3Uu570TRv e X-Google-Smtp-Source: AGHT+IF3VIuzY4sZRhm2IyCP2I6uw4EW0NRqXNwuciEkXUbsHr9TawBA9fsA5Vidi5fccf5orWZNcg== X-Received: by 2002:a05:6000:b09:b0:368:5042:25f3 with SMTP id ffacd0b85a97d-36b5d092d74mr11872685f8f.34.1722446567545; Wed, 31 Jul 2024 10:22:47 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Max Filippov Subject: [PATCH] target/xtensa: Correct assert condition in handle_interrupt() Date: Wed, 31 Jul 2024 18:22:46 +0100 Message-Id: <20240731172246.3682311-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.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=2a00:1450:4864:20::434; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x434.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1722446598913116600 Content-Type: text/plain; charset="utf-8" In commit ad18376b90c8101 we added an assert that the level value was in-bounds for the array we're about to index into. However, the assert condition is wrong -- env->config->interrupt_vector is an array of uint32_t, so we should bounds check the index against ARRAY_SIZE(...), not against sizeof(). Resolves: Coverity CID 1507131 Fixes: ad18376b90c8101 ("target/xtensa: Assert that interrupt level is with= in bounds") Signed-off-by: Peter Maydell Acked-by: Max Filippov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- Spotted because Coverity (correctly) thought the issue was still outstanding. --- target/xtensa/exc_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c index 0514c2c1f32..ca629f071d1 100644 --- a/target/xtensa/exc_helper.c +++ b/target/xtensa/exc_helper.c @@ -171,7 +171,7 @@ static void handle_interrupt(CPUXtensaState *env) =20 if (level > 1) { /* env->config->nlevel check should have ensured this */ - assert(level < sizeof(env->config->interrupt_vector)); + assert(level < ARRAY_SIZE(env->config->interrupt_vector)); =20 env->sregs[EPC1 + level - 1] =3D env->pc; env->sregs[EPS2 + level - 2] =3D env->sregs[PS]; --=20 2.34.1