From 28e312a8b710d2208ee9ce2c25e5dfc11bc1c1b0 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Sat, 19 Nov 2011 22:13:51 +0000 Subject: [PATCH] x86: Fix RCU locking in XENMEM_add_to_physmap. Signed-off-by: Keir Fraser --- xen/arch/x86/mm.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 23afda9088..f9db1a6d91 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4677,8 +4677,9 @@ static int handle_iomem_range(unsigned long s, unsigned long e, void *p) return 0; } -static int xenmem_add_to_physmap_once(struct domain *d, - const struct xen_add_to_physmap *xatp) +static int xenmem_add_to_physmap_once( + struct domain *d, + const struct xen_add_to_physmap *xatp) { struct page_info *page = NULL; unsigned long gfn = 0; /* gcc ... */ @@ -4728,7 +4729,6 @@ static int xenmem_add_to_physmap_once(struct domain *d, if ( p2m_is_shared(p2mt) ) { put_gfn(d, gfn); - rcu_unlock_domain(d); return -ENOMEM; } if ( !get_page_from_pagenr(idx, d) ) @@ -4748,7 +4748,6 @@ static int xenmem_add_to_physmap_once(struct domain *d, if ( xatp->space == XENMAPSPACE_gmfn || xatp->space == XENMAPSPACE_gmfn_range ) put_gfn(d, gfn); - rcu_unlock_domain(d); return -EINVAL; } @@ -4786,8 +4785,6 @@ static int xenmem_add_to_physmap_once(struct domain *d, put_gfn(d, gfn); domain_unlock(d); - rcu_unlock_domain(d); - return rc; } @@ -4864,11 +4861,8 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) if ( xatp.space == XENMAPSPACE_gmfn_range ) { - if ( rc ) - { - if ( copy_to_guest(arg, &xatp, 1) ) - return -EFAULT; - } + if ( rc && copy_to_guest(arg, &xatp, 1) ) + rc = -EFAULT; if ( rc == -EAGAIN ) rc = hypercall_create_continuation( -- 2.30.2