[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v9 04/14] arch/arm: unmap partially-mapped I/O-memory regions
This commit changes the function apply_p2m_changes() to unwind changes performed while mapping an I/O-memory region, if errors are seen during the operation. This is useful to avoid that I/O-memory areas are partially accessible to guests. 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> --- v9: - Let apply_p2m_ranges() unwind its own progress instead of relying on the caller to unmap partially-mapped I/O-memory regions. --- xen/arch/arm/p2m.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 22646e9..92fc4ec 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -314,7 +314,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; @@ -328,6 +328,7 @@ static int apply_p2m_changes(struct domain *d, spin_lock(&p2m->lock); +unwind: addr = start_gpaddr; while ( addr < end_gpaddr ) { @@ -338,7 +339,9 @@ static int apply_p2m_changes(struct domain *d, if ( !first ) { rc = -EINVAL; - goto out; + end_gpaddr = start_gpaddr + inserted * PAGE_SIZE; + op = REMOVE; + goto unwind; } cur_first_page = p2m_first_level_index(addr); } @@ -357,7 +360,9 @@ static int apply_p2m_changes(struct domain *d, if ( rc < 0 ) { printk("p2m_populate_ram: L1 failed\n"); - goto out; + end_gpaddr = start_gpaddr + inserted * PAGE_SIZE; + op = REMOVE; + goto unwind; } } @@ -384,7 +389,9 @@ static int apply_p2m_changes(struct domain *d, flush_pt); if ( rc < 0 ) { printk("p2m_populate_ram: L2 failed\n"); - goto out; + end_gpaddr = start_gpaddr + inserted * PAGE_SIZE; + op = REMOVE; + goto unwind; } } @@ -441,6 +448,7 @@ static int apply_p2m_changes(struct domain *d, pte = mfn_to_p2m_entry(maddr >> PAGE_SHIFT, mattr, t); p2m_write_pte(&third[third_table_offset(addr)], pte, flush_pt); + inserted++; } break; case REMOVE: -- 1.9.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |