From patchwork Thu Aug 1 14:23:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 816038 Delivered-To: patch@linaro.org Received: by 2002:a5d:4acf:0:b0:367:895a:4699 with SMTP id y15csp1212135wrs; Thu, 1 Aug 2024 07:24:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1kWnlsJBPNUkx68eBMQPeR3rVKK4g8aPj88e6eCELCKuYrkoF08YVG4JB48nPzGC0M6JwwRexgjKqflmiGtiN X-Google-Smtp-Source: AGHT+IEA7vOW0u+dbMCcvOTpqmb0x5T8+tw4EstnD834UWxcI9/+EQPfjj7X4wJcoGLwsDhHIXEm X-Received: by 2002:a05:6808:2110:b0:3db:42b2:ee28 with SMTP id 5614622812f47-3db5584dbc0mr229746b6e.51.1722522257940; Thu, 01 Aug 2024 07:24:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722522257; cv=none; d=google.com; s=arc-20160816; b=GSqJOaEvVr8aT8oB/UsZbPZBkmkOzcduQnAl/ddduzYTDkCceY5BzgpvBUn8OZ7t2Q +gq2jHIxgU4rReqs3Epf2qStdIiei6bG9SoiOVbomWj1sKcP78GPUPVZGGE9n3LcHerS jCnbr8pngK6bYosogsVrGLJjGTbSZJCJFQlvfoXfDBtXDe8HdvnWrn7YoUzWR4ovGfhU FT64qLM2vBTo+sEuHlZrimWE+JXLTJFbSBmLsNMSvAu6juuY6gu5IeXRUXBKXgn7i+Tn rq+lJguwY796DfGSou+G+q413EIm5BJpiV5Y9d5noBOIQol3edwEH5uu3lcqtqX9vMNx tRFg== 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:to:from :dkim-signature; bh=Bek6kRqgfRzW+L/s2A9z/Tq60M2bck1dCjbLVYSP28w=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=xG6Op1EuuCJGy0VwtEUgCdPFwIMGmpHMoOGXDrWJwYDBM99zZNsAFSUUfSWvIEOM2m +rgytZGMUf9+1wsLg76hMio2rm5bkkthOsA6pQrvSNB1gSZiYvrCSI55lYYQxSXMs917 9sYtovMWmsH5IQvte8vepaBIN4FmdgzSLDG+LvLDHdnaEjqv4dFQn9ZMP/ULRZrdRxcv EI7Pc5aUB0LjKWpTKv6NTL7DyJGodnTI3elM+2x1muLmu/XDXOQpkXdNcK4OMMXvo5Lp WxKRCCmZtl2J9BqsBsyz5Wt+//rTZIHnm3K0tvhE21dnoiyfOlE41RiRCT83QDMxoPbX IQwA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s8uVYjeP; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-4f6c88ae7ccsi2638252e0c.240.2024.08.01.07.24.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Aug 2024 07:24:17 -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=s8uVYjeP; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZWiL-0004w9-4u; Thu, 01 Aug 2024 10:23:33 -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 1sZWiH-0004iD-Ux for qemu-devel@nongnu.org; Thu, 01 Aug 2024 10:23:30 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZWiG-0002eN-7y for qemu-devel@nongnu.org; Thu, 01 Aug 2024 10:23:29 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-52efd530a4eso10870635e87.0 for ; Thu, 01 Aug 2024 07:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722522206; x=1723127006; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Bek6kRqgfRzW+L/s2A9z/Tq60M2bck1dCjbLVYSP28w=; b=s8uVYjeP227e5wmxqTO5buNKKkseicQxqxXI23OVFVgTJwG6ZQEMgo829KidsiD3a9 w02D2gdpJiZ9r8xrBZoD+n7OTCAvXOnXrOvX1AiR3quDv7nZOJ9IIIbu7aJHfLzBkOgn Q5pWFjkW1qiCKEMkCpnsMBjeFPZrLyaXg46Q03nt8DJ88FsYRyjkNnDmEelJ8WIxTFRd kLWstTYLNkN/Z2LtK+JIIQtyT2FkqOF/IM1lgvd5SVd9iJWf8tpinSEka34wYnSI8cna MRbT/9sFt2IWK2dk8fc8nmRjFYSwDSN72b02n9PCU5H97tNO4wMh/QZ2YbPqio6xaDT/ sr+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722522206; x=1723127006; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bek6kRqgfRzW+L/s2A9z/Tq60M2bck1dCjbLVYSP28w=; b=PhXj1l3m8Jlt6+eoOCcVdDDDxDf6FKnooy+XtkZYx02GjSJ0NbbwLZYvGvrG2UWHaR Bkg+s7UnIFXJRF+pDZL2/XW9F+h2EXC6xcgu1Ll9Fvr0Fblow/6Cf4Ps/XbQ+UMhKeER w4ULaARds3irtfQKo/c54JP/Ae9stWK449mtE2cEt/JgFIBFml7MBcvnRkkB9J10f8vf SMnLPOHHRin8WryzP583EKJyBC53uX+XiC9oN0yfGjyroeACHpj5twihf4RVAMiMHZfz 0XVvRF0dA8A+dHV1kN4qrbdUAANaigvMluys4hyJFZ58uzC+n/lSuYoCc70uIcA2CPo2 DilQ== X-Gm-Message-State: AOJu0YwJ4xxAS4OLDClsyI8BvD8J4sWYEiMIFtq2DANkpUqKf8efHX+d Wl/BAMWhs14Vs98/tkMMqOsFpLXqCsPo34QAly4o2wR3bsFwlCUcK2uzMmJGnvPPFapXgSTBEdA e X-Received: by 2002:a05:6512:3f0d:b0:530:b871:eb90 with SMTP id 2adb3069b0e04-530bb39b860mr20663e87.40.1722522206167; Thu, 01 Aug 2024 07:23:26 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-428e08012d7sm29657435e9.22.2024.08.01.07.23.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:23:25 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 4/4] target/xtensa: Correct assert condition in handle_interrupt() Date: Thu, 1 Aug 2024 15:23:22 +0100 Message-Id: <20240801142322.3948866-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240801142322.3948866-1-peter.maydell@linaro.org> References: <20240801142322.3948866-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=peter.maydell@linaro.org; helo=mail-lf1-x129.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 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 within bounds") Signed-off-by: Peter Maydell Acked-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé Message-id: 20240731172246.3682311-1-peter.maydell@linaro.org --- 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) 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)); env->sregs[EPC1 + level - 1] = env->pc; env->sregs[EPS2 + level - 2] = env->sregs[PS];