Skip to contentSkip to conversation

minios: fix port selection shifts

PATCH New Samuel Thibault 1 participant 1 message May 8, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 minios: fix port selection shifts

minios: fix port selection shifts

Event selectors span unsigned longs, whose size is not always 32 bits.

extras/mini-os/hypervisor.c +3 -2
diff -r 4965e711fee8 extras/mini-os/hypervisor.c
@@ -58,7 +58,7 @@
             l2i = __ffs(l2);
             l2 &= ~(1 << l2i);
 
-            port = (l1i << 5) + l2i;
+            port = (l1i * (sizeof(unsigned long) * 8)) + l2i;
 			do_event(port, regs);
         }
     }
@@ -100,7 +100,8 @@
      * a real IO-APIC we 'lose the interrupt edge' if the channel is masked.
      */
     if (  synch_test_bit        (port,    &s->evtchn_pending[0]) && 
-         !synch_test_and_set_bit(port>>5, &vcpu_info->evtchn_pending_sel) )
+         !synch_test_and_set_bit(port / (sizeof(unsigned long) * 8),
+              &vcpu_info->evtchn_pending_sel) )
     {
         vcpu_info->evtchn_upcall_pending = 1;
         if ( !vcpu_info->evtchn_upcall_mask )