From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arianna Avanzini Subject: [PATCH v11 02/14] arch/arm: unmap partially-mapped memory regions Date: Sun, 24 Aug 2014 22:29:55 +0200 Message-ID: <1408912207-28146-3-git-send-email-avanzini.arianna@gmail.com> References: <1408912207-28146-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: <1408912207-28146-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, andrii.tseglytskyi@globallogic.com List-Id: xen-devel@lists.xenproject.org This commit changes the function apply_p2m_changes() to destroy changes performed while mapping a 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 memory areas remain 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 Cc: Andrii Tseglytskyi --- v11: - Handle partially-mapped memory regions regardless of their being I/O-memory regions or not. 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 b9129a0..0520f84 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 && ( op == INSERT || op == ALLOCATE ) ) + apply_p2m_changes(d, REMOVE, start_gpaddr, + end_gpaddr, orig_maddr, + MATTR_DEV, p2m_invalid); spin_unlock(&p2m->lock); -- 2.1.0