Skip to content

Commit

Permalink
x86/ioapic: Fix signed shifts in io_apic.c
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Jan Beulich <[email protected]>
Reviewed-by: Andrew Cooper <[email protected]>
Release-Acked-By: Oleksii Kurochko <[email protected]>
  • Loading branch information
Matthew Barnes authored and andyhhp committed Jun 21, 2024
1 parent 62071a1 commit c5746b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions xen/arch/x86/io_apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c5746b0

Please sign in to comment.