static int setup_hwdom_device(u8 devfn, struct pci_dev *);
static void setup_hwdom_rmrr(struct domain *d);
-static int domain_iommu_domid(struct domain *d,
- struct iommu *iommu)
+static int get_iommu_did(domid_t domid, const struct iommu *iommu,
+ bool warn)
{
unsigned long nr_dom, i;
i = find_first_bit(iommu->domid_bitmap, nr_dom);
while ( i < nr_dom )
{
- if ( iommu->domid_map[i] == d->domain_id )
+ if ( iommu->domid_map[i] == domid )
return i;
i = find_next_bit(iommu->domid_bitmap, nr_dom, i+1);
}
- dprintk(XENLOG_ERR VTDPREFIX,
- "Cannot get valid iommu domid: domid=%d iommu->index=%d\n",
- d->domain_id, iommu->index);
+ if ( warn )
+ dprintk(XENLOG_ERR VTDPREFIX,
+ "No valid iommu %u domid for Dom%d\n",
+ iommu->index, domid);
+
return -1;
}
#define DID_FIELD_WIDTH 16
#define DID_HIGH_OFFSET 8
static int context_set_domain_id(struct context_entry *context,
- struct domain *d,
- struct iommu *iommu)
+ domid_t domid, struct iommu *iommu)
{
unsigned long nr_dom, i;
int found = 0;
i = find_first_bit(iommu->domid_bitmap, nr_dom);
while ( i < nr_dom )
{
- if ( iommu->domid_map[i] == d->domain_id )
+ if ( iommu->domid_map[i] == domid )
{
found = 1;
break;
dprintk(XENLOG_ERR VTDPREFIX, "IOMMU: no free domain ids\n");
return -EFAULT;
}
- iommu->domid_map[i] = d->domain_id;
+ iommu->domid_map[i] = domid;
}
set_bit(i, iommu->domid_bitmap);
xfree(intel);
}
-static void cleanup_domid_map(struct domain *domain, struct iommu *iommu)
+static void cleanup_domid_map(domid_t domid, struct iommu *iommu)
{
- int iommu_domid = domain_iommu_domid(domain, iommu);
+ int iommu_domid = get_iommu_did(domid, iommu, false);
if ( iommu_domid >= 0 )
{
if ( !found )
{
clear_bit(iommu->index, &dom_iommu(d)->arch.iommu_bitmap);
- cleanup_domid_map(d, iommu);
+ cleanup_domid_map(d->domain_id, iommu);
}
}
continue;
flush_dev_iotlb = !!find_ats_dev_drhd(iommu);
- iommu_domid= domain_iommu_domid(d, iommu);
+ iommu_domid = get_iommu_did(d->domain_id, iommu, !d->is_dying);
if ( iommu_domid == -1 )
continue;
spin_unlock(&hd->arch.mapping_lock);
}
- rc = context_set_domain_id(&lctxt, domain, iommu);
+ rc = context_set_domain_id(&lctxt, domid, iommu);
if ( rc )
{
unlock:
context_clear_entry(*context);
iommu_sync_cache(context, sizeof(struct context_entry));
- iommu_domid= domain_iommu_domid(domain, iommu);
+ iommu_domid = get_iommu_did(domid, iommu, !domain->is_dying);
if ( iommu_domid == -1 )
{
spin_unlock(&iommu->lock);