]> xenbits.xensource.com Git - xen.git/commitdiff
x86/ioapic: Fix signed shifts in io_apic.c
authorMatthew Barnes <matthew.barnes@cloud.com>
Thu, 20 Jun 2024 15:36:46 +0000 (16:36 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 21 Jun 2024 14:09:26 +0000 (15:09 +0100)
There exists bitshifts in the IOAPIC code where signed integers are
shifted to the left by up to 31 bits, which is undefined behaviour.

This patch fixes this by changing the integers from signed to unsigned.

Signed-off-by: Matthew Barnes <matthew.barnes@cloud.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-Acked-By: Oleksii Kurochko <oleksii.kurochko@gmail.com>
xen/arch/x86/io_apic.c

index b48a64246548119fc54e2dfaee31205624792c81..d73108558e09424e8cc3c1051b53b4c24016edb4 100644 (file)
@@ -1692,7 +1692,8 @@ static void cf_check mask_and_ack_level_ioapic_irq(struct irq_desc *desc)
        !io_apic_level_ack_pending(desc->irq))
         move_masked_irq(desc);
 
-    if ( !(v & (1 << (i & 0x1f))) ) {
+    if ( !(v & (1U << (i & 0x1f))) )
+    {
         spin_lock(&ioapic_lock);
         __edge_IO_APIC_irq(desc->irq);
         __level_IO_APIC_irq(desc->irq);
@@ -1756,7 +1757,8 @@ static void cf_check end_level_ioapic_irq_new(struct irq_desc *desc, u8 vector)
          !io_apic_level_ack_pending(desc->irq) )
         move_native_irq(desc);
 
-    if (!(v & (1 << (i & 0x1f)))) {
+    if ( !(v & (1U << (i & 0x1f))) )
+    {
         spin_lock(&ioapic_lock);
         __mask_IO_APIC_irq(desc->irq);
         __edge_IO_APIC_irq(desc->irq);