From: Tim Deegan Subject: Re: [PATCH 2/18 V2]: PVH xen: add XENMEM_add_to_physmap_range Date: Thu, 21 Mar 2013 14:53:13 +0000 Message-ID: <20130321145313.GJ12338@ocelot.phlegethon.org> References: <20130315172018.395bbbe3@mantra.us.oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20130315172018.395bbbe3@mantra.us.oracle.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: Mukesh Rathor Cc: "Xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org At 17:20 -0700 on 15 Mar (1363368018), Mukesh Rathor wrote: > +static noinline int xenmem_add_to_physmap_range(struct domain *d, > + struct xen_add_to_physmap_range *xatpr) > +{ > + int rc; > + > + /* Process entries in reverse order to allow continuations */ > + while ( xatpr->size > 0 ) > + { > + xen_ulong_t idx; > + xen_pfn_t gpfn; > + struct xen_add_to_physmap xatp; > + > + rc = copy_from_guest_offset(&idx, xatpr->idxs, xatpr->size-1, 1); > + if ( rc < 0 ) copy_from_guest_offset() returns the number of bytes that could not be copied, which would never be < 0. > + goto out; > + > + rc = copy_from_guest_offset(&gpfn, xatpr->gpfns, xatpr->size-1, 1); > + if ( rc < 0 ) Ditto. > + goto out; > + > + xatp.space = xatpr->space; > + xatp.idx = idx; > + xatp.gpfn = gpfn; > + rc = xenmem_add_to_physmap_once(d, &xatp, xatpr->foreign_domid); > + > + if (rc) Whitespace missing. > + goto out; > + > + xatpr->size--; > + > + /* Check for continuation if it's not the last interation */ > + if ( xatpr->size > 0 && hypercall_preempt_check() ) > + { > + rc = -EAGAIN; > + goto out; > + } > + } > + > + rc = 0; > + > +out: > + return rc; > + > } > > long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg) > @@ -4465,6 +4515,32 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg) > return rc; > } > > + case XENMEM_add_to_physmap_range: > + { > + struct xen_add_to_physmap_range xatpr; > + struct domain *d; > + > + if ( copy_from_guest(&xatpr, arg, 1) ) > + return -EFAULT; > + > + rc = rcu_lock_target_domain_by_id(xatpr.domid, &d); > + if ( rc != 0 ) > + return rc; There should be an XSM hook here somewhere. > + rc = xenmem_add_to_physmap_range(d, &xatpr); > + > + rcu_unlock_domain(d); > + > + if ( rc && copy_to_guest(arg, &xatpr, 1) ) > + rc = -EFAULT; > + > + if ( rc == -EAGAIN ) > + rc = hypercall_create_continuation( > + __HYPERVISOR_memory_op, "ih", op, arg); > + > + return rc; > + } > + > case XENMEM_set_memory_map: > { > struct xen_foreign_memory_map fmap; > -- > 1.7.2.3 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel