[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] simplify xenmem_add_to_physmap_batch()
commit d287c90369d870f15cc3b3cf113287093e7118b9 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Wed Jan 3 11:05:05 2018 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Wed Jan 3 11:05:05 2018 +0100 simplify xenmem_add_to_physmap_batch() There's no need for - advancing the handles and at the same time using __copy_{from,to}_guest_offset(), - an "out" label, - local variables "done" and (function scope) "rc". To better reflect its resulting use also rename the function's "start" parameter to "extent". Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/common/memory.c | 60 +++++++++++++++-------------------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/xen/common/memory.c b/xen/common/memory.c index a6ba33f..5a1508a 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -810,67 +810,41 @@ static int xenmem_add_to_physmap(struct domain *d, static int xenmem_add_to_physmap_batch(struct domain *d, struct xen_add_to_physmap_batch *xatpb, - unsigned int start) + unsigned int extent) { - unsigned int done = 0; - int rc; - - if ( xatpb->size < start ) + if ( xatpb->size < extent ) return -EILSEQ; - guest_handle_add_offset(xatpb->idxs, start); - guest_handle_add_offset(xatpb->gpfns, start); - guest_handle_add_offset(xatpb->errs, start); - xatpb->size -= start; - - if ( !guest_handle_okay(xatpb->idxs, xatpb->size) || - !guest_handle_okay(xatpb->gpfns, xatpb->size) || - !guest_handle_okay(xatpb->errs, xatpb->size) ) + if ( !guest_handle_subrange_okay(xatpb->idxs, extent, xatpb->size - 1) || + !guest_handle_subrange_okay(xatpb->gpfns, extent, xatpb->size - 1) || + !guest_handle_subrange_okay(xatpb->errs, extent, xatpb->size - 1) ) return -EFAULT; - while ( xatpb->size > done ) + while ( xatpb->size > extent ) { xen_ulong_t idx; xen_pfn_t gpfn; + int rc; - if ( unlikely(__copy_from_guest_offset(&idx, xatpb->idxs, 0, 1)) ) - { - rc = -EFAULT; - goto out; - } - - if ( unlikely(__copy_from_guest_offset(&gpfn, xatpb->gpfns, 0, 1)) ) - { - rc = -EFAULT; - goto out; - } + if ( unlikely(__copy_from_guest_offset(&idx, xatpb->idxs, + extent, 1)) || + unlikely(__copy_from_guest_offset(&gpfn, xatpb->gpfns, + extent, 1)) ) + return -EFAULT; rc = xenmem_add_to_physmap_one(d, xatpb->space, xatpb->u, idx, _gfn(gpfn)); - if ( unlikely(__copy_to_guest_offset(xatpb->errs, 0, &rc, 1)) ) - { - rc = -EFAULT; - goto out; - } - - guest_handle_add_offset(xatpb->idxs, 1); - guest_handle_add_offset(xatpb->gpfns, 1); - guest_handle_add_offset(xatpb->errs, 1); + if ( unlikely(__copy_to_guest_offset(xatpb->errs, extent, &rc, 1)) ) + return -EFAULT; /* Check for continuation if it's not the last iteration. */ - if ( xatpb->size > ++done && hypercall_preempt_check() ) - { - rc = start + done; - goto out; - } + if ( xatpb->size > ++extent && hypercall_preempt_check() ) + return extent; } - rc = 0; - -out: - return rc; + return 0; } static int construct_memop_from_reservation( -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |