]> xenbits.xensource.com Git - xen.git/commitdiff
ARM/vgic: Use for_each_set_bit() in vgic_to_sgi()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 23 Aug 2024 22:25:28 +0000 (23:25 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 27 Aug 2024 17:08:19 +0000 (18:08 +0100)
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 continuation
issue, there's a line of spaces in the middle of the format string.

  $ strings xen-syms-arm32 | grep -e VGIC -e GICD_SGIR
  <G><1>%pv VGIC: write r=%08x                         target->list=%hx, wrong CPUTargetList
  <G><1>%pv vGICD:unhandled GICD_SGIR write %08x                  with wrong mode

not to mention trailing whitespace too.

Rewrite them to be more concise and useful.  Use 0x prefixes for hex, rather
than being ambiguous, and identify the problem target vCPU / mode, rather than
simply saying something was wrong.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
xen/arch/arm/vgic.c

index 7b54ccc7cbfa01bcad828b054393837985736ba2..8ffe099bcb5f2fdc3b56a2d5389b875addb926c6 100644 (file)
@@ -470,8 +470,7 @@ bool vgic_to_sgi(struct vcpu *v, register_t sgir, enum gic_sgi_mode irqmode,
     struct domain *d = v->domain;
     int vcpuid;
     int i;
-    unsigned int base;
-    unsigned long int bitmap;
+    unsigned int base, bitmap;
 
     ASSERT( virq < 16 );
 
@@ -481,15 +480,16 @@ bool vgic_to_sgi(struct vcpu *v, register_t sgir, enum gic_sgi_mode irqmode,
         perfc_incr(vgic_sgi_list);
         base = target->aff1 << 4;
         bitmap = target->list;
-        bitmap_for_each ( i, &bitmap, sizeof(target->list) * 8 )
+
+        for_each_set_bit ( i, bitmap )
         {
             vcpuid = base + i;
             if ( vcpuid >= d->max_vcpus || d->vcpu[vcpuid] == NULL ||
                  !is_vcpu_online(d->vcpu[vcpuid]) )
             {
-                gprintk(XENLOG_WARNING, "VGIC: write r=%"PRIregister" \
-                        target->list=%hx, wrong CPUTargetList \n",
-                        sgir, target->list);
+                gprintk(XENLOG_WARNING,
+                        "vGIC: write %#"PRIregister", target->list=%#x, bad target vcpu%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 unhandled mode %d\n",
+                sgir, irqmode);
         return false;
     }