From nobody Thu Nov 21 17:11:39 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=1724454083; cv=none; d=zohomail.com; s=zohoarc; b=CJbqZbquSn8k1m59ZcuhQS6Oa9HHqV29fnGT/ZHMI5nV0YZh07wmh7NbDCxSHJJlhKQCYAVJRbGf1mcbCR6bO66wQydUoiE40ra2d1EGEsE6FIO6jrRXKQ2w5Bcr6dgDzoOxG+scydI4q84fiaAdAwb27KbAAE9m8EwZYiVXn1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724454083; h=Content-Type: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=zF8pjt0XDyvgbiqMd5EfMePZ7QzQjeJHHv0zF/e7/x8=; b=VKihJ6I0lMhH9+G5kWqusIjQ9BgaxEzhrsUD33Kl648DtqL/jmZfNVXJF970PO6Yqzw3qV2hf2US3OXur0PIN5G4+7Zcn+teGt+v5WNc3qacFHAh5fCDPpluRdmVuklzlhbAu01ILZDywYFbehXriDEEMMzmA4orzcMVu0LiOpg= 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 1724454083921897.1579892037082; Fri, 23 Aug 2024 16:01:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.782738.1192253 (Exim 4.92) (envelope-from ) id 1shdHJ-0002AY-0L; Fri, 23 Aug 2024 23:01:09 +0000 Received: by outflank-mailman (output) from mailman id 782738.1192253; Fri, 23 Aug 2024 23:01:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1shdHI-0002AR-U8; Fri, 23 Aug 2024 23:01:08 +0000 Received: by outflank-mailman (input) for mailman id 782738; Fri, 23 Aug 2024 23:01:08 +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 1shdHI-0001rz-5B for xen-devel@lists.xenproject.org; Fri, 23 Aug 2024 23:01:08 +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 94189d40-61a3-11ef-8776-851b0ebba9a2; Sat, 24 Aug 2024 01:01:06 +0200 (CEST) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5bf0261f162so3219718a12.0 for ; Fri, 23 Aug 2024 16:01:06 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c04a3ed39fsm2619258a12.57.2024.08.23.16.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 16:01:04 -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: 94189d40-61a3-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1724454065; x=1725058865; 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=zF8pjt0XDyvgbiqMd5EfMePZ7QzQjeJHHv0zF/e7/x8=; b=MqBDW0/B4wR3ADIjwQ2TjC2NDLDy8CHiuSvFfND/ePLS7FaezWDRzr7bcy7wZzs699 /fjdbAvUvbmGkQzG4ruNqqduphY36zzJPqRuGtHikotQxUqSd758bmwLnqdm4i7Qfrxn pktqRW/C81ASSooi7dqsHo82pdUrFYH+4vgWk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724454065; x=1725058865; 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=zF8pjt0XDyvgbiqMd5EfMePZ7QzQjeJHHv0zF/e7/x8=; b=N+iEC50JoQmIpJXyj7zPtlTLyxhgGnzbgYdpqpZXecvsfInFEWfYRLIGA7sN+4mDv1 C4MkX2VJ9SctekK6zbBA3/4r7NOW/V+u4S5NdAp/mn+bC20s0aXkHAOuG7CYZU6lm3pC vmEAPgaWljABVlTqUyH94nMoJ9JAP8i5MdQQT+TYNdpQy/3ZA3NJ2RGC83tOZ7PTqGeL kCMukjqlZUbf91+O6+bxwPS0sarVN3gPD910qV/8HxEi3VfcP7TZFJwwA6syH1Q7KH11 yFQeUqvTDubjJYxBmBUID1qnDxwp03UTIvOlmClIgvdo6NTtbgD1lmXmntyRP02PSm8r XB8Q== X-Gm-Message-State: AOJu0YyygRZmYw8fNvXjNklPSVex6PGXC4QZitTtyfu+qbgEh8WojTfa Qypk1JCQpyQOFU0QVatlzKjsSZh7ws4Gb7T+GnIf1DM/UEMKHZp7ytxj8m0Oi/HsPhAAfekYEjz p X-Google-Smtp-Source: AGHT+IH2JdWSF1S4Wcp3axdJeQAz99ay+Ym31Wz/fI9epA6oB/3l14OL97aAyOaoM3sQM2+yPfGtvw== X-Received: by 2002:a05:6402:4404:b0:5c0:9814:3f94 with SMTP id 4fb4d7f45d1cf-5c098144075mr133295a12.21.1724454065157; Fri, 23 Aug 2024 16:01:05 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Jan Beulich Subject: [PATCH] ARM/vgic: Use for_each_set_bit() in vgic_to_sgi() Date: Sat, 24 Aug 2024 00:01:00 +0100 Message-Id: <20240823230100.1581448-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1724454085926116600 The existing expression is just a very complicated way of expressing a loop over all bits of target->list. Simplify the expression. While here, fix the two gprintk()'s. Because of a quotes vs line continuat= ion issue, there's a long string of spaces in the middle of the format string. $ strings xen-syms-arm32 | grep -e VGIC -e GICD_SGIR <1>%pv VGIC: write r=3D%08x target->list=3D%hx= , wrong CPUTargetList <1>%pv vGICD:unhandled GICD_SGIR write %08x with wron= g mode not to mention trailing whitespace too. Rewrite them to be more consise and more useful. Use 0x prefixes for hex, rather than ambigous, and identify the problem target vCPU / mode, rather t= han simply saying somethign was wrong. Signed-off-by: Andrew Cooper Reviewed-by: Michal Orzel --- CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Jan Beulich In a fun twist, we can't use target->list directly in the expresion, because the typeof() picks up constness from the pointer, and we get: In file included from arch/arm/vgic.c:11: arch/arm/vgic.c: In function =E2=80=98vgic_to_sgi=E2=80=99: ./include/xen/bitops.h:305:19: error: assignment of read-only variable = =E2=80=98__v=E2=80=99 305 | __v &=3D __v - 1 ) | ^~ arch/arm/vgic.c:483:9: note: in expansion of macro =E2=80=98for_each_set_= bit=E2=80=99 483 | for_each_set_bit ( i, target->list ) | ^~~~~~~~~~~~~~~~ Sadly we need -std=3Dc23 before we can use typeof_unqual() which is what we actually want here. --- xen/arch/arm/vgic.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c index 7b54ccc7cbfa..081cbb67fb52 100644 --- a/xen/arch/arm/vgic.c +++ b/xen/arch/arm/vgic.c @@ -470,8 +470,7 @@ bool vgic_to_sgi(struct vcpu *v, register_t sgir, enum = gic_sgi_mode irqmode, struct domain *d =3D v->domain; int vcpuid; int i; - unsigned int base; - unsigned long int bitmap; + unsigned int base, bitmap; =20 ASSERT( virq < 16 ); =20 @@ -481,15 +480,16 @@ bool vgic_to_sgi(struct vcpu *v, register_t sgir, enu= m gic_sgi_mode irqmode, perfc_incr(vgic_sgi_list); base =3D target->aff1 << 4; bitmap =3D target->list; - bitmap_for_each ( i, &bitmap, sizeof(target->list) * 8 ) + + for_each_set_bit ( i, bitmap ) { vcpuid =3D base + i; if ( vcpuid >=3D d->max_vcpus || d->vcpu[vcpuid] =3D=3D NULL || !is_vcpu_online(d->vcpu[vcpuid]) ) { - gprintk(XENLOG_WARNING, "VGIC: write r=3D%"PRIregister" \ - target->list=3D%hx, wrong CPUTargetList \n", - sgir, target->list); + gprintk(XENLOG_WARNING, + "vGIC: write %#"PRIregister", target->list=3D%#x, = bad target v%d\n", + sgir, target->list, vcpuid); continue; } vgic_inject_irq(d, d->vcpu[vcpuid], virq, true); @@ -510,8 +510,8 @@ bool vgic_to_sgi(struct vcpu *v, register_t sgir, enum = gic_sgi_mode irqmode, break; default: gprintk(XENLOG_WARNING, - "vGICD:unhandled GICD_SGIR write %"PRIregister" \ - with wrong mode\n", sgir); + "vGICD: GICD_SGIR write %#"PRIregister" with unhangled mod= e %d\n", + sgir, irqmode); return false; } =20 --=20 2.39.2