]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
hvm: Remove guest-triggerable assertions from vlapic emulation.
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 14 Dec 2007 11:55:51 +0000 (11:55 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 14 Dec 2007 11:55:51 +0000 (11:55 +0000)
Currently our VLAPIC will happily deliver interrupts on vectors <
16. This could be emulated better, but probably does not matter.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen-unstable changeset:   16615:3ee37b6279b76c58f49a056c44f413bf8cc030a9
xen-unstable date:        Fri Dec 14 10:48:18 2007 +0000

xen/arch/x86/hvm/vlapic.c

index a9adc77568ca9e409ef3303496848cf66a14e62b..4ace0645c825b28f348f6012192b8232b26ed566 100644 (file)
@@ -124,12 +124,7 @@ static void vlapic_clear_irr(int vector, struct vlapic *vlapic)
 
 int vlapic_find_highest_irr(struct vlapic *vlapic)
 {
-    int result;
-
-    result = vlapic_find_highest_vector(&vlapic->regs->data[APIC_IRR]);
-    ASSERT((result == -1) || (result >= 16));
-
-    return result;
+    return vlapic_find_highest_vector(&vlapic->regs->data[APIC_IRR]);
 }
 
 int vlapic_set_irq(struct vlapic *vlapic, uint8_t vec, uint8_t trig)
@@ -144,14 +139,9 @@ int vlapic_set_irq(struct vlapic *vlapic, uint8_t vec, uint8_t trig)
     return ret;
 }
 
-int vlapic_find_highest_isr(struct vlapic *vlapic)
+static int vlapic_find_highest_isr(struct vlapic *vlapic)
 {
-    int result;
-
-    result = vlapic_find_highest_vector(&vlapic->regs->data[APIC_ISR]);
-    ASSERT((result == -1) || (result >= 16));
-
-    return result;
+    return vlapic_find_highest_vector(&vlapic->regs->data[APIC_ISR]);
 }
 
 uint32_t vlapic_get_ppr(struct vlapic *vlapic)
@@ -455,11 +445,9 @@ static void vlapic_set_tdcr(struct vlapic *vlapic, unsigned int val)
                 "timer_divisor: %d", vlapic->hw.timer_divisor);
 }
 
-static void vlapic_read_aligned(struct vlapic *vlapic, unsigned int offset,
-                         unsigned int len, unsigned int *result)
+static void vlapic_read_aligned(
+    struct vlapic *vlapic, unsigned int offset, unsigned int *result)
 {
-    ASSERT((len == 4) && (offset >= 0) && (offset <= APIC_TDCR));
-
     switch ( offset )
     {
     case APIC_PROCPRI:
@@ -488,15 +476,9 @@ static unsigned long vlapic_read(struct vcpu *v, unsigned long address,
     if ( offset > APIC_TDCR )
         return 0;
 
-    /* some bugs on kernel cause read this with byte*/
-    if ( len != 4 )
-        HVM_DBG_LOG(DBG_LEVEL_VLAPIC,
-                    "read with len=0x%lx, should be 4 instead",
-                    len);
-
     alignment = offset & 0x3;
 
-    vlapic_read_aligned(vlapic, offset & ~0x3, 4, &tmp);
+    vlapic_read_aligned(vlapic, offset & ~0x3, &tmp);
     switch ( len )
     {
     case 1:
@@ -504,12 +486,14 @@ static unsigned long vlapic_read(struct vcpu *v, unsigned long address,
         break;
 
     case 2:
-        ASSERT( alignment != 3 );
+        if ( alignment == 3 )
+            goto unaligned_exit_and_crash;
         result = *(unsigned short *)((unsigned char *)&tmp + alignment);
         break;
 
     case 4:
-        ASSERT( alignment == 0 );
+        if ( alignment != 0 )
+            goto unaligned_exit_and_crash;
         result = *(unsigned int *)((unsigned char *)&tmp + alignment);
         break;
 
@@ -524,6 +508,9 @@ static unsigned long vlapic_read(struct vcpu *v, unsigned long address,
 
     return result;
 
+ unaligned_exit_and_crash:
+    gdprintk(XENLOG_ERR, "Unaligned LAPIC read len=0x%lx at offset=0x%x.\n",
+             len, offset);
  exit_and_crash:
     domain_crash(v->domain);
     return 0;