direct-io.hg

changeset 10506:ab0cae84cfec

[HVM] Fix virtual apic irq distribution.
But currently we inject PIT irqs to cpu0 only. Also mute some warning
messages.

Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
Signed-off-by: Xin Li <xin.b.li@intel.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Jun 27 15:38:32 2006 +0100 (2006-06-27)
parents bad506bc0c85
children 8a89c0ff3f87
files xen/arch/x86/hvm/vioapic.c xen/arch/x86/hvm/vlapic.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vioapic.c	Tue Jun 27 15:22:55 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/vioapic.c	Tue Jun 27 15:38:32 2006 +0100
     1.3 @@ -40,6 +40,9 @@
     1.4  #include <asm/hvm/support.h>
     1.5  #include <asm/current.h>
     1.6  
     1.7 +/* HACK: Route IRQ0 only to VCPU0 to prevent time jumps. */
     1.8 +#define IRQ0_SPECIAL_ROUTING 1
     1.9 +
    1.10  #if defined(__ia64__)
    1.11  #define	opt_hvm_debug_level	opt_vmx_debug_level
    1.12  #endif
    1.13 @@ -392,12 +395,12 @@ static void ioapic_deliver(hvm_vioapic_t
    1.14      uint8_t trig_mode = s->redirtbl[irqno].RedirForm.trigmod;
    1.15      uint32_t deliver_bitmask;
    1.16  
    1.17 -    HVM_DBG_LOG(DBG_LEVEL_IOAPIC, "IOAPIC deliver: "
    1.18 +    HVM_DBG_LOG(DBG_LEVEL_IOAPIC,
    1.19        "dest %x dest_mode %x delivery_mode %x vector %x trig_mode %x\n",
    1.20        dest, dest_mode, delivery_mode, vector, trig_mode);
    1.21  
    1.22 -    deliver_bitmask =
    1.23 -      ioapic_get_delivery_bitmask(s, dest, dest_mode, vector, delivery_mode);
    1.24 +    deliver_bitmask = ioapic_get_delivery_bitmask(
    1.25 +        s, dest, dest_mode, vector, delivery_mode);
    1.26  
    1.27      if (!deliver_bitmask) {
    1.28          HVM_DBG_LOG(DBG_LEVEL_IOAPIC, "ioapic deliver "
    1.29 @@ -411,15 +414,19 @@ static void ioapic_deliver(hvm_vioapic_t
    1.30      {
    1.31          struct vlapic* target;
    1.32  
    1.33 -        target = apic_round_robin(
    1.34 -                s->domain, dest_mode, vector, deliver_bitmask);
    1.35 +#ifdef IRQ0_SPECIAL_ROUTING
    1.36 +        if (irqno == 0)
    1.37 +            target = s->lapic_info[0];
    1.38 +        else
    1.39 +#endif
    1.40 +            target = apic_round_robin(s->domain, dest_mode,
    1.41 +                                      vector, deliver_bitmask);
    1.42          if (target)
    1.43              ioapic_inj_irq(s, target, vector, trig_mode, delivery_mode);
    1.44 -        else{ 
    1.45 -            HVM_DBG_LOG(DBG_LEVEL_IOAPIC, "ioapic deliver "
    1.46 +        else
    1.47 +            HVM_DBG_LOG(DBG_LEVEL_IOAPIC,
    1.48                "null round robin mask %x vector %x delivery_mode %x\n",
    1.49                deliver_bitmask, vector, deliver_bitmask);
    1.50 -        }
    1.51          break;
    1.52      }
    1.53  
    1.54 @@ -429,6 +436,13 @@ static void ioapic_deliver(hvm_vioapic_t
    1.55          uint8_t bit;
    1.56          for (bit = 0; bit < s->lapic_count; bit++) {
    1.57              if (deliver_bitmask & (1 << bit)) {
    1.58 +#ifdef IRQ0_SPECIAL_ROUTING
    1.59 +                if ( (irqno == 0) && (bit !=0) )
    1.60 +                {
    1.61 +                    printk("PIT irq to bit %x\n", bit);
    1.62 +                    domain_crash_synchronous();
    1.63 +                }
    1.64 +#endif
    1.65                  if (s->lapic_info[bit]) {
    1.66                      ioapic_inj_irq(s, s->lapic_info[bit],
    1.67                                  vector, trig_mode, delivery_mode);
     2.1 --- a/xen/arch/x86/hvm/vlapic.c	Tue Jun 27 15:22:55 2006 +0100
     2.2 +++ b/xen/arch/x86/hvm/vlapic.c	Tue Jun 27 15:38:32 2006 +0100
     2.3 @@ -212,18 +212,19 @@ static int vlapic_accept_irq(struct vcpu
     2.4  
     2.5          if ( test_and_set_bit(vector, &vlapic->irr[0]) )
     2.6          {
     2.7 -            printk("<vlapic_accept_irq>"
     2.8 -                   "level trig mode repeatedly for vector %d\n", vector);
     2.9 +            HVM_DBG_LOG(DBG_LEVEL_VLAPIC,
    2.10 +              "level trig mode repeatedly for vector %d\n", vector);
    2.11              break;
    2.12          }
    2.13  
    2.14          if ( level )
    2.15          {
    2.16 -            printk("<vlapic_accept_irq> level trig mode for vector %d\n",
    2.17 -                   vector);
    2.18 +            HVM_DBG_LOG(DBG_LEVEL_VLAPIC,
    2.19 +              "level trig mode for vector %d\n", vector);
    2.20              set_bit(vector, &vlapic->tmr[0]);
    2.21          }
    2.22          evtchn_set_pending(v, iopacket_port(v));
    2.23 +
    2.24          result = 1;
    2.25          break;
    2.26  
    2.27 @@ -308,8 +309,15 @@ struct vlapic* apic_round_robin(struct d
    2.28  
    2.29      old = next = d->arch.hvm_domain.round_info[vector];
    2.30  
    2.31 -    do {
    2.32 -        /* the vcpu array is arranged according to vcpu_id */
    2.33 +    /* the vcpu array is arranged according to vcpu_id */
    2.34 +    do
    2.35 +    {
    2.36 +        next++;
    2.37 +        if ( !d->vcpu[next] ||
    2.38 +             !test_bit(_VCPUF_initialised, &d->vcpu[next]->vcpu_flags) ||
    2.39 +             next == MAX_VIRT_CPUS )
    2.40 +            next = 0;
    2.41 +
    2.42          if ( test_bit(next, &bitmap) )
    2.43          {
    2.44              target = d->vcpu[next]->arch.hvm_vcpu.vlapic;
    2.45 @@ -321,12 +329,6 @@ struct vlapic* apic_round_robin(struct d
    2.46              }
    2.47              break;
    2.48          }
    2.49 -
    2.50 -        next ++;
    2.51 -        if ( !d->vcpu[next] ||
    2.52 -             !test_bit(_VCPUF_initialised, &d->vcpu[next]->vcpu_flags) ||
    2.53 -             next == MAX_VIRT_CPUS )
    2.54 -            next = 0;
    2.55      } while ( next != old );
    2.56  
    2.57      d->arch.hvm_domain.round_info[vector] = next;
    2.58 @@ -956,7 +958,7 @@ int cpu_has_apic_interrupt(struct vcpu* 
    2.59      }
    2.60      return 0;
    2.61  }
    2.62 - 
    2.63 +
    2.64  void vlapic_post_injection(struct vcpu *v, int vector, int deliver_mode)
    2.65  {
    2.66      struct vlapic *vlapic = VLAPIC(v);