[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 05/13] iommu: don't domain_crash() inside iommu_map/unmap_page()
Turn iommu_map/unmap_page() into straightforward wrappers that check the existence of the relevant iommu_op and call through to it. This makes them usable by PV IOMMU code to be delivered in future patches. Leave the decision on whether to invoke domain_crash() up to the caller. This has the added benefit that the (module/line number) message that domain_crash() spits out will be more indicative of where the problem lies. NOTE: This patch includes one bit of clean-up in set_identity_p2m_entry() replacing use of p2m->domain with the domain pointer passed into the function. Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx> --- Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> Cc: Julien Grall <julien.grall@xxxxxxx> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Jan Beulich <jbeulich@xxxxxxxx> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> Cc: Tim Deegan <tim@xxxxxxx> Cc: Wei Liu <wei.liu2@xxxxxxxxxx> Cc: Jun Nakajima <jun.nakajima@xxxxxxxxx> Cc: Kevin Tian <kevin.tian@xxxxxxxxx> Cc: George Dunlap <george.dunlap@xxxxxxxxxxxxx> v2: - New in v2. --- xen/arch/arm/p2m.c | 2 ++ xen/arch/x86/mm.c | 3 +++ xen/arch/x86/mm/p2m-ept.c | 3 +++ xen/arch/x86/mm/p2m-pt.c | 3 +++ xen/arch/x86/mm/p2m.c | 20 ++++++++++++++++++-- xen/common/grant_table.c | 8 ++++++++ xen/common/memory.c | 3 +++ xen/drivers/passthrough/iommu.c | 12 ------------ xen/drivers/passthrough/x86/iommu.c | 5 +++++ 9 files changed, 45 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 42c16da4dd..b99f4ff913 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -955,6 +955,8 @@ static int __p2m_set_entry(struct p2m_domain *p2m, unsigned long frame = gfn_x(sgfn); rc = iommu_iotlb_flush(p2m->domain, _bfn(frame), 1UL << page_order); + if ( unlikely(rc) && !is_hardware_domain(p2m->domain) ) + domain_crash(p2m->domain); } else rc = 0; diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 4e66c6742d..32f09bac0a 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -2738,6 +2738,9 @@ static int _get_page_type(struct page_info *page, unsigned long type, iommu_ret = iommu_map_page(d, _bfn(frame), mfn, IOMMUF_readable | IOMMUF_writable); + + if ( unlikely(iommu_ret) && !is_hardware_domain(d) ) + domain_crash(d); } } diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 4951234197..5fc1e1a838 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -898,6 +898,9 @@ out: if ( !rc ) rc = ret; } + + if ( unlikely(rc) && !is_hardware_domain(d) ) + domain_crash(d); } } diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index 467ac8cb76..4e04525195 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -719,6 +719,9 @@ p2m_pt_set_entry(struct p2m_domain *p2m, gfn_t gfn_, mfn_t mfn, rc = ret; } } + + if ( unlikely(rc) && !is_hardware_domain(p2m->domain) ) + domain_crash(p2m->domain); } /* diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index ce12bcff42..5ff1d51a0e 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -724,6 +724,9 @@ p2m_remove_page(struct p2m_domain *p2m, unsigned long gfn_l, unsigned long mfn, if ( !rc ) rc = ret; } + + if ( unlikely(rc) && !is_hardware_domain(p2m->domain) ) + domain_crash(p2m->domain); } return rc; @@ -790,6 +793,9 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, if ( iommu_unmap_page(d, bfn_add(bfn, i)) ) continue; + if ( !is_hardware_domain(d) ) + domain_crash(d); + return rc; } } @@ -1158,7 +1164,7 @@ int set_identity_p2m_entry(struct domain *d, unsigned long gfn_l, struct p2m_domain *p2m = p2m_get_hostp2m(d); int ret; - if ( !paging_mode_translate(p2m->domain) ) + if ( !paging_mode_translate(d) ) { unsigned long frame = gfn_l; @@ -1167,6 +1173,11 @@ int set_identity_p2m_entry(struct domain *d, unsigned long gfn_l, return iommu_map_page(d, _bfn(frame), _mfn(frame), IOMMUF_readable | IOMMUF_writable); + + if ( unlikely(ret) && !is_hardware_domain(d) ) + domain_crash(d); + + return ret; } gfn_lock(p2m, gfn, 0); @@ -1259,7 +1270,12 @@ int clear_identity_p2m_entry(struct domain *d, unsigned long gfn_l) if ( !need_iommu(d) ) return 0; - return iommu_unmap_page(d, _bfn(frame)); + ret = iommu_unmap_page(d, _bfn(frame)); + + if ( unlikely(ret) && !is_hardware_domain(d) ) + domain_crash(d); + + return ret; } gfn_lock(p2m, gfn, 0); diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index d0926d13e0..c6b99c4116 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -1156,6 +1156,9 @@ map_grant_ref( } if ( err ) { + if ( !is_hardware_domain(ld) ) + domain_crash(ld); + double_gt_unlock(lgt, rgt); rc = GNTST_general_error; goto undo_out; @@ -1423,7 +1426,12 @@ unmap_common( double_gt_unlock(lgt, rgt); if ( err ) + { + if ( !is_hardware_domain(ld) ) + domain_crash(ld); + rc = GNTST_general_error; + } } /* If just unmapped a writable mapping, mark as dirtied */ diff --git a/xen/common/memory.c b/xen/common/memory.c index e42da275c3..35da9ca80e 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -843,6 +843,9 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, ret = iommu_iotlb_flush(d, _bfn(frame), done); if ( unlikely(ret) && rc >= 0 ) rc = ret; + + if ( unlikely(rc < 0) && !is_hardware_domain(d) ) + domain_crash(d); } #endif diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index 67a90a314f..7e59211a59 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -273,9 +273,6 @@ int iommu_map_page(struct domain *d, bfn_t bfn, mfn_t mfn, printk(XENLOG_ERR "d%d: IOMMU mapping bfn %"PRI_bfn" to mfn %"PRI_mfn" failed: %d\n", d->domain_id, bfn_x(bfn), mfn_x(mfn), rc); - - if ( !is_hardware_domain(d) ) - domain_crash(d); } return rc; @@ -296,9 +293,6 @@ int iommu_unmap_page(struct domain *d, bfn_t bfn) printk(XENLOG_ERR "d%d: IOMMU unmapping bfn %"PRI_bfn" failed: %d\n", d->domain_id, bfn_x(bfn), rc); - - if ( !is_hardware_domain(d) ) - domain_crash(d); } return rc; @@ -336,9 +330,6 @@ int iommu_iotlb_flush(struct domain *d, bfn_t bfn, unsigned int page_count) printk(XENLOG_ERR "d%d: IOMMU IOTLB flush failed: %d, bfn %"PRI_bfn", page count %u\n", d->domain_id, rc, bfn_x(bfn), page_count); - - if ( !is_hardware_domain(d) ) - domain_crash(d); } return rc; @@ -359,9 +350,6 @@ int iommu_iotlb_flush_all(struct domain *d) printk(XENLOG_ERR "d%d: IOMMU IOTLB flush all failed: %d\n", d->domain_id, rc); - - if ( !is_hardware_domain(d) ) - domain_crash(d); } return rc; diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c index 379882c690..9cd05d42d0 100644 --- a/xen/drivers/passthrough/x86/iommu.c +++ b/xen/drivers/passthrough/x86/iommu.c @@ -104,8 +104,13 @@ int arch_iommu_populate_page_table(struct domain *d) this_cpu(iommu_dont_flush_iotlb) = 0; if ( !rc ) + { rc = iommu_iotlb_flush_all(d); + if ( unlikely(rc) ) + domain_crash(d); + } + if ( rc && rc != -ERESTART ) iommu_teardown(d); -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |