[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen stable-4.12] VT-d: prepare for per-device quarantine page tables (part II)
commit e3be966b9cc9143ca6ec6bb7df0c4cb7a6fd317a Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Tue Apr 5 15:39:43 2022 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Tue Apr 5 15:39:43 2022 +0200 VT-d: prepare for per-device quarantine page tables (part II) Replace the passing of struct domain * by domid_t in preparation of per-device quarantine page tables also requiring per-device pseudo domain IDs, which aren't going to be associated with any struct domain instances. No functional change intended (except for slightly adjusted log message text). Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Paul Durrant <paul@xxxxxxx> Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> master commit: 7131163c4806e3c7de24873164d1a003d2a27dee master date: 2022-04-05 14:18:48 +0200 --- xen/drivers/passthrough/vtd/iommu.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 47a1c9c29f..88ef84336e 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -52,8 +52,8 @@ static struct tasklet vtd_fault_tasklet; 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; @@ -61,23 +61,24 @@ static int domain_iommu_domid(struct domain *d, 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; @@ -88,7 +89,7 @@ static int context_set_domain_id(struct context_entry *context, 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; @@ -104,7 +105,7 @@ static int context_set_domain_id(struct context_entry *context, 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); @@ -131,9 +132,9 @@ static void __init free_intel_iommu(struct intel_iommu *intel) 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 ) { @@ -189,7 +190,7 @@ static void check_cleanup_domid_map(struct domain *d, if ( !found ) { clear_bit(iommu->index, &dom_iommu(d)->arch.iommu_bitmap); - cleanup_domid_map(d, iommu); + cleanup_domid_map(d->domain_id, iommu); } } @@ -670,7 +671,7 @@ static int __must_check iommu_flush_iotlb(struct domain *d, dfn_t dfn, 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; @@ -1495,7 +1496,7 @@ int domain_context_mapping_one( 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: @@ -1803,7 +1804,7 @@ int domain_context_unmap_one( 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); -- generated by git-patchbot for /home/xen/git/xen.git#stable-4.12
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |