diff mbox

[v1,15/20] x86: Add more checks verifying that PIT/PIC/IOAPIC are emulated

Message ID 1467745519-9868-16-git-send-email-boris.ostrovsky@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Boris Ostrovsky July 5, 2016, 7:05 p.m. UTC
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
Changes in v1:
* More checks, in more approriate places

 xen/arch/x86/hvm/vlapic.c |   12 ++++++++++--
 xen/arch/x86/hvm/vpt.c    |    2 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

Comments

Jan Beulich Aug. 3, 2016, 4:04 p.m. UTC | #1
>>> On 05.07.16 at 21:05, <boris.ostrovsky@oracle.com> wrote:
> --- a/xen/arch/x86/hvm/vlapic.c
> +++ b/xen/arch/x86/hvm/vlapic.c
> @@ -1115,7 +1115,12 @@ 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;
> +
> +    if ( !has_vioapic(d) || !has_vpic(d) )

The has_vpic() part should really be an ASSERT(), as both callers
already do that check afaics. With that adjusted
Reviewed-by: Jan Beulich <jbeulich@suse.com>
diff mbox

Patch

diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
index e2f4450..a3855c8 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -1115,7 +1115,12 @@  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;
+
+    if ( !has_vioapic(d) || !has_vpic(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? */
@@ -1131,7 +1136,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,
@@ -1146,6 +1151,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;
diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c
index 358ec57..c90aa95 100644
--- a/xen/arch/x86/hvm/vpt.c
+++ b/xen/arch/x86/hvm/vpt.c
@@ -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 == NULL || !has_vpit(v->domain) )
         return;
 
     vpit = &v->domain->arch.vpit;