[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v8 05/14] arch/arm: unmap partially-mapped I/O-memory regions
This commit changes the interface of apply_p2m_changes() to accept optionally the pointer to a counter of successfully performed mappings; such a counter is used only in case of INSERT operation. If an error is encountered during the operation, and therefore the mapping is only partially performed, such a counter is useful to let the caller be able to undo what has just been done. Signed-off-by: Arianna Avanzini <avanzini.arianna@xxxxxxxxx> Cc: Dario Faggioli <dario.faggioli@xxxxxxxxxx> Cc: Paolo Valente <paolo.valente@xxxxxxxxxx> Cc: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> Cc: Julien Grall <julien.grall@xxxxxxxxxx> Cc: Ian Campbell <Ian.Campbell@xxxxxxxxxxxxx> Cc: Jan Beulich <JBeulich@xxxxxxxx> Cc: Keir Fraser <keir@xxxxxxx> Cc: Tim Deegan <tim@xxxxxxx> Cc: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Cc: Eric Trudeau <etrudeau@xxxxxxxxxxxx> Cc: Viktor Kleinik <viktor.kleinik@xxxxxxxxxxxxxxx> --- v8: - Use correct count in unmap_mmio_regions(). v6: - Pass p2m_invalid as last parameter to unmap_mmio_regions() for ARM as it is not (and currently must not be) used. --- xen/arch/arm/p2m.c | 42 +++++++++++++++++++++++++++++++++--------- xen/include/asm-arm/p2m.h | 4 ++++ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 2d8b78f..cf01736 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -294,6 +294,7 @@ static int apply_p2m_changes(struct domain *d, paddr_t start_gpaddr, paddr_t end_gpaddr, paddr_t maddr, + unsigned long *nr_inserted, int mattr, p2m_type_t t) { @@ -304,7 +305,7 @@ static int apply_p2m_changes(struct domain *d, unsigned long cur_first_page = ~0, cur_first_offset = ~0, cur_second_offset = ~0; - unsigned long count = 0; + unsigned long count = 0, inserted = 0; unsigned int flush = 0; bool_t populate = (op == INSERT || op == ALLOCATE); lpae_t pte; @@ -420,6 +421,7 @@ static int apply_p2m_changes(struct domain *d, { pte = mfn_to_p2m_entry(maddr >> PAGE_SHIFT, mattr, t); write_pte(&third[third_table_offset(addr)], pte); + inserted++; } break; case REMOVE: @@ -519,6 +521,8 @@ out: if (second) unmap_domain_page(second); if (first) unmap_domain_page(first); + if ( nr_inserted != NULL ) *nr_inserted = inserted; + spin_unlock(&p2m->lock); return rc; @@ -529,7 +533,7 @@ int p2m_populate_ram(struct domain *d, paddr_t end) { return apply_p2m_changes(d, ALLOCATE, start, end, - 0, MATTR_MEM, p2m_ram_rw); + 0, NULL, MATTR_MEM, p2m_ram_rw); } int map_mmio_regions(struct domain *d, @@ -537,11 +541,31 @@ int map_mmio_regions(struct domain *d, unsigned long nr_mfns, unsigned long mfn) { - return apply_p2m_changes(d, INSERT, + unsigned long nr_inserted; + int ret; + + ret = apply_p2m_changes(d, INSERT, + pfn_to_paddr(start_gfn), + pfn_to_paddr(start_gfn + nr_mfns), + pfn_to_paddr(mfn), + &nr_inserted, + MATTR_DEV, p2m_mmio_direct); + if ( ret && nr_inserted != 0 ) + unmap_mmio_regions(d, start_gfn, nr_inserted, mfn); + + return ret; +} + +int unmap_mmio_regions(struct domain *d, + unsigned long start_gfn, + unsigned long nr_mfns, + unsigned long mfn) +{ + return apply_p2m_changes(d, REMOVE, pfn_to_paddr(start_gfn), pfn_to_paddr(start_gfn + nr_mfns), - pfn_to_paddr(mfn), - MATTR_DEV, p2m_mmio_direct); + pfn_to_paddr(mfn), NULL, + MATTR_DEV, p2m_invalid); } int guest_physmap_add_entry(struct domain *d, @@ -553,7 +577,7 @@ int guest_physmap_add_entry(struct domain *d, return apply_p2m_changes(d, INSERT, pfn_to_paddr(gpfn), pfn_to_paddr(gpfn + (1 << page_order)), - pfn_to_paddr(mfn), MATTR_MEM, t); + pfn_to_paddr(mfn), NULL, MATTR_MEM, t); } void guest_physmap_remove_page(struct domain *d, @@ -563,7 +587,7 @@ void guest_physmap_remove_page(struct domain *d, apply_p2m_changes(d, REMOVE, pfn_to_paddr(gpfn), pfn_to_paddr(gpfn + (1<<page_order)), - pfn_to_paddr(mfn), MATTR_MEM, p2m_invalid); + pfn_to_paddr(mfn), NULL, MATTR_MEM, p2m_invalid); } int p2m_alloc_table(struct domain *d) @@ -710,7 +734,7 @@ int relinquish_p2m_mapping(struct domain *d) return apply_p2m_changes(d, RELINQUISH, pfn_to_paddr(p2m->lowest_mapped_gfn), pfn_to_paddr(p2m->max_mapped_gfn), - pfn_to_paddr(INVALID_MFN), + pfn_to_paddr(INVALID_MFN), NULL, MATTR_MEM, p2m_invalid); } @@ -725,7 +749,7 @@ int p2m_cache_flush(struct domain *d, xen_pfn_t start_mfn, xen_pfn_t end_mfn) pfn_to_paddr(start_mfn), pfn_to_paddr(end_mfn), pfn_to_paddr(INVALID_MFN), - MATTR_MEM, p2m_invalid); + NULL, MATTR_MEM, p2m_invalid); } unsigned long gmfn_to_mfn(struct domain *d, unsigned long gpfn) diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 6d56daa..71665f3 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -91,6 +91,10 @@ int map_mmio_regions(struct domain *d, unsigned long start_gfn, unsigned long nr_mfns, unsigned long mfn); +int unmap_mmio_regions(struct domain *d, + unsigned long start_gfn, + unsigned long nr_mfns, + unsigned long mfn); int guest_physmap_add_entry(struct domain *d, unsigned long gfn, -- 1.9.2 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |