x86/HVM: add more checks verifying that PIT/PIC/IOAPIC are emulated
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>
Thu, 11 Aug 2016 11:18:24 +0000 (13:18 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 11 Aug 2016 11:18:24 +0000 (13:18 +0200)
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/vlapic.c
xen/arch/x86/hvm/vpt.c

index ba9b29337672342f24e01476e4905413390da222..1d5d2879502ffaa6c652f26bde87591e8caa2cfc 100644 (file)
@@ -1114,7 +1114,14 @@ static int __vlapic_accept_pic_intr(struct vcpu *v)
     struct domain *d = v->domain;
     struct vlapic *vlapic = vcpu_vlapic(v);
     uint32_t lvt0 = vlapic_get_reg(vlapic, APIC_LVT0);
-    union vioapic_redir_entry redir0 = domain_vioapic(d)->redirtbl[0];
+    union vioapic_redir_entry redir0;
+
+    ASSERT(has_vpic(d));
+
+    if ( !has_vioapic(d) )
+        return 0;
+
+    redir0 = domain_vioapic(d)->redirtbl[0];
 
     /* We deliver 8259 interrupts to the appropriate CPU as follows. */
     return ((/* IOAPIC pin0 is unmasked and routing to this LAPIC? */
@@ -1130,7 +1137,7 @@ static int __vlapic_accept_pic_intr(struct vcpu *v)
 
 int vlapic_accept_pic_intr(struct vcpu *v)
 {
-    if ( vlapic_hw_disabled(vcpu_vlapic(v)) )
+    if ( vlapic_hw_disabled(vcpu_vlapic(v)) || !has_vpic(v->domain) )
         return 0;
 
     TRACE_2D(TRC_HVM_EMUL_LAPIC_PIC_INTR,
@@ -1145,6 +1152,9 @@ void vlapic_adjust_i8259_target(struct domain *d)
 {
     struct vcpu *v;
 
+    if ( !has_vpic(d) )
+        return;
+
     for_each_vcpu ( d, v )
         if ( __vlapic_accept_pic_intr(v) )
             goto found;
index 358ec576fedbe8df5c4e3a6b7b26ae1178f25dcc..5c48fdb4b5bd0e2bd2a6b62631f9ec16d1062de1 100644 (file)
@@ -496,7 +496,7 @@ void pt_adjust_global_vcpu_target(struct vcpu *v)
     struct pl_time *pl_time;
     int i;
 
-    if ( v == NULL )
+    if ( !v || !has_vpit(v->domain) )
         return;
 
     vpit = &v->domain->arch.vpit;