add NULL checks in code added by 24492:6c104b46ef89
authorJan Beulich <jbeulich@suse.com>
Thu, 19 Jan 2012 09:08:12 +0000 (10:08 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 19 Jan 2012 09:08:12 +0000 (10:08 +0100)
Also a couple of missing is_hvm_domain() checks.

Further properly pass the PCI segment in a call to pci_get_pdev().

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen/drivers/passthrough/amd/iommu_guest.c
xen/drivers/passthrough/amd/iommu_init.c

index d1e0e4ab89027e40d7c5406e0530aef904820aeb..b88056ec60f5a4a76ddb2a82d59662d332df6e80 100644 (file)
@@ -182,7 +182,13 @@ void guest_iommu_add_ppr_log(struct domain *d, u32 entry[])
     ppr_entry_t *log, *log_base;
     struct guest_iommu *iommu;
 
+    if ( !is_hvm_domain(d) )
+        return;
+
     iommu = domain_iommu(d);
+    if ( !iommu )
+        return;
+
     tail = iommu_get_rb_pointer(iommu->ppr_log.reg_tail.lo);
     head = iommu_get_rb_pointer(iommu->ppr_log.reg_head.lo);
 
@@ -225,7 +231,13 @@ void guest_iommu_add_event_log(struct domain *d, u32 entry[])
     event_entry_t *log, *log_base;
     struct guest_iommu *iommu;
 
+    if ( !is_hvm_domain(d) )
+        return;
+
     iommu = domain_iommu(d);
+    if ( !iommu )
+        return;
+
     tail = iommu_get_rb_pointer(iommu->event_log.reg_tail.lo);
     head = iommu_get_rb_pointer(iommu->event_log.reg_head.lo);
 
@@ -793,6 +805,9 @@ int guest_iommu_set_base(struct domain *d, uint64_t base)
     p2m_type_t t;
     struct guest_iommu *iommu = domain_iommu(d);
 
+    if ( !iommu )
+        return -EACCES;
+
     iommu->mmio_base = base;
     base >>= PAGE_SHIFT;
 
@@ -882,6 +897,8 @@ void guest_iommu_destroy(struct domain *d)
         return;
 
     iommu = domain_iommu(d);
+    if ( !iommu )
+        return;
 
     tasklet_kill(&iommu->cmd_buffer_tasklet);
     xfree(iommu);
@@ -893,7 +910,7 @@ static int guest_iommu_mmio_range(struct vcpu *v, unsigned long addr)
 {
     struct guest_iommu *iommu = vcpu_iommu(v);
 
-    return addr >= iommu->mmio_base &&
+    return iommu && addr >= iommu->mmio_base &&
            addr < iommu->mmio_base + IOMMU_MMIO_SIZE;
 }
 
index 7770e22d13d46a08282343c92c52ae18ae0518cd..024dac97210f164ea884fe844997989e3dcd4483 100644 (file)
@@ -651,7 +651,7 @@ void parse_ppr_log_entry(struct amd_iommu *iommu, u32 entry[])
     local_irq_enable();
 
     spin_lock(&pcidevs_lock);
-    pdev = pci_get_pdev(0, bus, devfn);
+    pdev = pci_get_pdev(iommu->seg, bus, devfn);
     spin_unlock(&pcidevs_lock);
 
     local_irq_disable();