From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arianna Avanzini Subject: [PATCH v10 02/12] arch/arm: unmap partially-mapped I/O-memory regions Date: Tue, 29 Jul 2014 00:11:59 +0200 Message-ID: <1406585529-32193-3-git-send-email-avanzini.arianna@gmail.com> References: <1406585529-32193-1-git-send-email-avanzini.arianna@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1406585529-32193-1-git-send-email-avanzini.arianna@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Ian.Campbell@eu.citrix.com, paolo.valente@unimore.it, keir@xen.org, stefano.stabellini@eu.citrix.com, Ian.Jackson@eu.citrix.com, dario.faggioli@citrix.com, tim@xen.org, julien.grall@citrix.com, etrudeau@broadcom.com, andrew.cooper3@citrix.com, JBeulich@suse.com, avanzini.arianna@gmail.com, viktor.kleinik@globallogic.com List-Id: xen-devel@lists.xenproject.org This commit changes the function apply_p2m_changes() to destroy changes performed while mapping an I/O-memory region, if errors are seen during the operation. The implemented behaviour is the counterpart of the x86 code, which destroys the whole range: this is useful to avoid that I/O- memory areas are partially accessible to guests. Signed-off-by: Arianna Avanzini Cc: Dario Faggioli Cc: Paolo Valente Cc: Stefano Stabellini Cc: Julien Grall Cc: Ian Campbell Cc: Jan Beulich Cc: Keir Fraser Cc: Tim Deegan Cc: Ian Jackson Cc: Andrew Cooper Cc: Eric Trudeau Cc: Viktor Kleinik --- v10: - Recursively call apply_p2m_changes() on the whole I/O-memory range when unmapping a partially-mapped I/O-memory region. v9: - Let apply_p2m_ranges() unwind its own progress instead of relying on the caller to unmap partially-mapped I/O-memory regions. - Adapt to rework of p2m-related functions for ARM. --- xen/arch/arm/p2m.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 8feb5c5..2745279 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -713,7 +713,7 @@ static int apply_p2m_changes(struct domain *d, int rc, ret; struct p2m_domain *p2m = &d->arch.p2m; lpae_t *first = NULL, *second = NULL, *third = NULL; - paddr_t addr; + paddr_t addr, orig_maddr = maddr; unsigned long cur_first_page = ~0, cur_first_offset = ~0, cur_second_offset = ~0; @@ -844,6 +844,10 @@ out: if (third) unmap_domain_page(third); if (second) unmap_domain_page(second); if (first) unmap_domain_page(first); + if ( rc < 0 && mattr == MATTR_DEV && ( op == INSERT || op == ALLOCATE ) ) + apply_p2m_changes(d, REMOVE, start_gpaddr, + end_gpaddr, orig_maddr, + MATTR_DEV, p2m_invalid); spin_unlock(&p2m->lock); -- 2.0.3