return pos;
}
-static int device_in_domain(const struct iommu *iommu,
- const struct pci_dev *pdev, u16 did)
+static bool device_in_domain(const struct iommu *iommu,
+ const struct pci_dev *pdev, uint16_t did)
{
- struct root_entry *root_entry = NULL;
+ struct root_entry *root_entry;
struct context_entry *ctxt_entry = NULL;
- int tt, found = 0;
+ unsigned int tt;
+ bool found = false;
- root_entry = (struct root_entry *) map_vtd_domain_page(iommu->root_maddr);
- if ( !root_entry || !root_present(root_entry[pdev->bus]) )
- goto out;
-
- ctxt_entry = (struct context_entry *)
- map_vtd_domain_page(root_entry[pdev->bus].val);
+ if ( unlikely(!iommu->root_maddr) )
+ {
+ ASSERT_UNREACHABLE();
+ return false;
+ }
- if ( ctxt_entry == NULL )
+ root_entry = map_vtd_domain_page(iommu->root_maddr);
+ if ( !root_present(root_entry[pdev->bus]) )
goto out;
+ ctxt_entry = map_vtd_domain_page(root_entry[pdev->bus].val);
if ( context_domain_id(ctxt_entry[pdev->devfn]) != did )
goto out;
if ( tt != CONTEXT_TT_DEV_IOTLB )
goto out;
- found = 1;
+ found = true;
out:
if ( root_entry )
unmap_vtd_domain_page(root_entry);