From nobody Sun Nov 24 02:22:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1724802345; cv=none; d=zohomail.com; s=zohoarc; b=U+2Tj9N16ddvoacPCB3c3zoex7IWFPHAzKlTGND4q++Prl3enovgC4m6YCUyLQrSXCrLKEGybJQKJ3DzDvv0YM9x0SO1p2NKbCVmnvksDMh/+gVe/tSlPrjZxY+4A7CAoyPunftN45N3h9vdjDzwJ7tdDv4mkCkorg2q0jcyiLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724802345; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WgiybHYeK3pm1QvF6orArHL/oTUQSxNbFe0CWEQYQ/I=; b=aIbi5tma3sBKb9Ggp+s9cqakX1aoa6+1cy9s0LQUyZJY4Nmq5QzH36OZF2voG1iGTHJ25JKX2rjifsYNQaEUt1KOlM+iu1WZIcOHdhmWNL/w12aySSHGUT2SX7Fxg7jiVwHeJyD+o0ZOhvkPTUYJ1qvpvgzWzk+4G60OfDGiKyM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1724802345258991.2591958391448; Tue, 27 Aug 2024 16:45:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.784423.1193778 (Exim 4.92) (envelope-from ) id 1sj5sP-0003Iz-Br; Tue, 27 Aug 2024 23:45:29 +0000 Received: by outflank-mailman (output) from mailman id 784423.1193778; Tue, 27 Aug 2024 23:45:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sj5sP-0003Iq-99; Tue, 27 Aug 2024 23:45:29 +0000 Received: by outflank-mailman (input) for mailman id 784423; Tue, 27 Aug 2024 23:45:28 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sj5sO-0003Ib-Oh for xen-devel@lists.xenproject.org; Tue, 27 Aug 2024 23:45:28 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6f5fd6d3-64ce-11ef-99a0-01e77a169b0f; Wed, 28 Aug 2024 01:45:26 +0200 (CEST) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5becfd14353so6700085a12.1 for ; Tue, 27 Aug 2024 16:45:26 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c0bb20b35asm1524316a12.45.2024.08.27.16.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Aug 2024 16:45:24 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6f5fd6d3-64ce-11ef-99a0-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1724802326; x=1725407126; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=WgiybHYeK3pm1QvF6orArHL/oTUQSxNbFe0CWEQYQ/I=; b=QTxE4SMJ60LztIYsjGjQkQHhBdQ0BdbiAzDRHYFpDSNG1uREZaMeFXhRv+/ME09sdb ZxCfgKObvGWSpJ6GiezKO+RSZkBMaYXMxmZ6gpeXWOvgpmb1kXjM2k4ilEkkcxcRq3T1 DgPgmmwuJO3kj+L325JnE9BhEPX76CMS/PmFQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724802326; x=1725407126; 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=WgiybHYeK3pm1QvF6orArHL/oTUQSxNbFe0CWEQYQ/I=; b=ntqbCEe4pIcRgUv3BdsXCh2PIbfh5Xhupve7YmX6MDWaOJpOEjo/A8vZG2B5LbRxJV EZSMfb2odtacrXZdM27Nz2I0/I14vDmozsBuZZroWvYI8uHH6sCjEZSEDcbJdScthTns W2XYaLWaTSrD2sCk32pfHxrMLYQ1trNJBk/ZPyvUNb60CpMHiUjdTG+5CNmmfPO5TCJJ rGlzmp0cFzY2xNudO3PPw4Jl81rDOI/zQ3duFIFOQRASz9y5rzxJXKmY/gOTdWliTKqS lWG8phlaJJAjkwdXoK8Pro/y1CCf+kHLiC/hsk7V31smtnA8MMHY7ueu85ak/lYk3oLx M5wg== X-Gm-Message-State: AOJu0YxuW3swEjn/33ogw09r73yA6jdGrpNDVDxZc5rJ8EURfAniFaSb sfq9vQ+1MHwJBa0+XSd9Fsog4lFNMLYcmsPJueB8o47PDi11Qp2wnK/CZpEgWBYnXFH3BH0ubNp X X-Google-Smtp-Source: AGHT+IE7w59NXZwFzuqnzDMQE+2TnhAN3acSGhTBtdr2LqhMBkoL1fqlpK6jqGD/DJLAUxs1JNgd5w== X-Received: by 2002:a05:6402:35c1:b0:5be:e1b6:aaef with SMTP id 4fb4d7f45d1cf-5c08919e805mr10266788a12.28.1724802325378; Tue, 27 Aug 2024 16:45:25 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel Subject: [PATCH] ARM/vgic: Fix variable shadowing in vgic_to_sgi() Date: Wed, 28 Aug 2024 00:45:22 +0100 Message-Id: <20240827234522.2237355-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1724802345832116600 Content-Type: text/plain; charset="utf-8" for_each_set_bit() allocates its own variable intentionally as loop-scope only. Unfortunately, this causes the inner 'i' to shadow the outer 'i'. Drop the outermost 'i' and 'vcpuid' variables, moving them into a more narr= ow scope and correcting them to be unsigned which they should have been all along. Fixes: 9429f1a6c475 ("ARM/vgic: Use for_each_set_bit() in vgic_to_sgi()") Signed-off-by: Andrew Cooper Reviewed-by: Michal Orzel --- CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel --- xen/arch/arm/vgic.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 8ffe099bcb5f..6ecd9146511c 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -468,8 +468,6 @@ bool vgic_to_sgi(struct vcpu *v, register_t sgir, enum = gic_sgi_mode irqmode, int virq, const struct sgi_target *target) { struct domain *d =3D v->domain; - int vcpuid; - int i; unsigned int base, bitmap; =20 ASSERT( virq < 16 ); @@ -483,7 +481,8 @@ bool vgic_to_sgi(struct vcpu *v, register_t sgir, enum = gic_sgi_mode irqmode, =20 for_each_set_bit ( i, bitmap ) { - vcpuid =3D base + i; + unsigned int vcpuid =3D base + i; + if ( vcpuid >=3D d->max_vcpus || d->vcpu[vcpuid] =3D=3D NULL || !is_vcpu_online(d->vcpu[vcpuid]) ) { @@ -497,7 +496,7 @@ bool vgic_to_sgi(struct vcpu *v, register_t sgir, enum = gic_sgi_mode irqmode, break; case SGI_TARGET_OTHERS: perfc_incr(vgic_sgi_others); - for ( i =3D 0; i < d->max_vcpus; i++ ) + for ( unsigned int i =3D 0; i < d->max_vcpus; i++ ) { if ( i !=3D current->vcpu_id && d->vcpu[i] !=3D NULL && is_vcpu_online(d->vcpu[i]) ) base-commit: b8cdfac2be38c98dd3ad0e911a3f7f787f5bcf6b prerequisite-patch-id: 87415b68ed015b8f36405b2554f2abd6c02f28aa prerequisite-patch-id: d87fe52c264dc5a33883a04b615043fbefd94f92 prerequisite-patch-id: abb68a851297bbf63c16093c6362c0d4b9c39334 --=20 2.39.2