From: Samuel Thibault Subject: [PATCH] Re: Who uses xc_gnttab_map_grant_refs? Date: Mon, 21 Jul 2008 11:48:11 +0100 Message-ID: <20080721104811.GO4501@implementation.uk.xensource.com> References: <20080716144039.GA14133@implementation.uk.xensource.com> <617dbaa80807160751w5d6b0097p821d0f0281b04608@mail.gmail.com> <20080716150842.GB14133@implementation.uk.xensource.com> <18560.42753.839101.911894@mariner.uk.xensource.com> <20080718144701.GW4456@implementation.uk.xensource.com> <18560.44798.347872.311788@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="OgqxwSJOaUobr8KG" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <18560.44798.347872.311788@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Jackson Cc: Derek Murray , xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --OgqxwSJOaUobr8KG Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Ian Jackson, le Fri 18 Jul 2008 15:55:58 +0100, a =E9crit : > Samuel Thibault writes ("Re: [Xen-devel] Who uses xc_gnttab_map_grant_r= efs?"): > > But still kill the old function at least? >=20 > Is that a change we want to make at this stage of the release ? I > don't necessarily have an opinion but it's a question we should be > asking. Ok, well, here is a patch that keeps the old function, just making its implementation an internal with an additional domids_stride parameter in order to also both efficiency. Samuel libxc: add xc_gnttab_map_domain_grant_refs. xc_gnttab_map_domain_grant_refs permits to simply map several pages from the same domain. Signed-off-by: Samuel Thibault diff -r 3139383b36a0 tools/libxc/xc_linux.c --- a/tools/libxc/xc_linux.c Fri Jul 18 18:13:53 2008 +0100 +++ b/tools/libxc/xc_linux.c Mon Jul 21 11:44:43 2008 +0100 @@ -418,9 +418,10 @@ return addr; } =20 -void *xc_gnttab_map_grant_refs(int xcg_handle, +static void *do_gnttab_map_grant_refs(int xcg_handle, uint32_t count, uint32_t *domids, + int domids_stride, uint32_t *refs, int prot) { @@ -435,7 +436,7 @@ =20 for ( i =3D 0; i < count; i++ ) { - map->refs[i].domid =3D domids[i]; + map->refs[i].domid =3D domids[i * domids_stride]; map->refs[i].ref =3D refs[i]; } =20 @@ -462,6 +463,24 @@ out: free(map); return addr; +} + +void *xc_gnttab_map_grant_refs(int xcg_handle, + uint32_t count, + uint32_t *domids, + uint32_t *refs, + int prot) +{ + return do_gnttab_map_grant_refs(xcg_handle, count, domids, 1, refs, = prot); +} + +void *xc_gnttab_map_domain_grant_refs(int xcg_handle, + uint32_t count, + uint32_t domid, + uint32_t *refs, + int prot) +{ + return do_gnttab_map_grant_refs(xcg_handle, count, &domid, 0, refs, = prot); } =20 int xc_gnttab_munmap(int xcg_handle, diff -r 3139383b36a0 tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h Fri Jul 18 18:13:53 2008 +0100 +++ b/tools/libxc/xenctrl.h Mon Jul 21 11:44:43 2008 +0100 @@ -865,6 +865,23 @@ uint32_t *refs, int prot); =20 +/** + * Memory maps one or more grant references from one domain to a + * contiguous local address range. Mappings should be unmapped with + * xc_gnttab_munmap. Returns NULL on failure. + * + * @parm xcg_handle a handle on an open grant table interface + * @parm count the number of grant references to be mapped + * @parm domid the domain to map memory from + * @parm refs an array of @count grant references to be mapped + * @parm prot same flag as in mmap() + */ +void *xc_gnttab_map_domain_grant_refs(int xcg_handle, + uint32_t count, + uint32_t domid, + uint32_t *refs, + int prot); + /* * Unmaps the @count pages starting at @start_address, which were mapped= by a * call to xc_gnttab_map_grant_ref or xc_gnttab_map_grant_refs. Returns = zero --OgqxwSJOaUobr8KG Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch diff -r 3139383b36a0 tools/libxc/xc_linux.c --- a/tools/libxc/xc_linux.c Fri Jul 18 18:13:53 2008 +0100 +++ b/tools/libxc/xc_linux.c Mon Jul 21 11:44:43 2008 +0100 @@ -418,9 +418,10 @@ return addr; } -void *xc_gnttab_map_grant_refs(int xcg_handle, +static void *do_gnttab_map_grant_refs(int xcg_handle, uint32_t count, uint32_t *domids, + int domids_stride, uint32_t *refs, int prot) { @@ -435,7 +436,7 @@ for ( i = 0; i < count; i++ ) { - map->refs[i].domid = domids[i]; + map->refs[i].domid = domids[i * domids_stride]; map->refs[i].ref = refs[i]; } @@ -462,6 +463,24 @@ out: free(map); return addr; +} + +void *xc_gnttab_map_grant_refs(int xcg_handle, + uint32_t count, + uint32_t *domids, + uint32_t *refs, + int prot) +{ + return do_gnttab_map_grant_refs(xcg_handle, count, domids, 1, refs, prot); +} + +void *xc_gnttab_map_domain_grant_refs(int xcg_handle, + uint32_t count, + uint32_t domid, + uint32_t *refs, + int prot) +{ + return do_gnttab_map_grant_refs(xcg_handle, count, &domid, 0, refs, prot); } int xc_gnttab_munmap(int xcg_handle, diff -r 3139383b36a0 tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h Fri Jul 18 18:13:53 2008 +0100 +++ b/tools/libxc/xenctrl.h Mon Jul 21 11:44:43 2008 +0100 @@ -865,6 +865,23 @@ uint32_t *refs, int prot); +/** + * Memory maps one or more grant references from one domain to a + * contiguous local address range. Mappings should be unmapped with + * xc_gnttab_munmap. Returns NULL on failure. + * + * @parm xcg_handle a handle on an open grant table interface + * @parm count the number of grant references to be mapped + * @parm domid the domain to map memory from + * @parm refs an array of @count grant references to be mapped + * @parm prot same flag as in mmap() + */ +void *xc_gnttab_map_domain_grant_refs(int xcg_handle, + uint32_t count, + uint32_t domid, + uint32_t *refs, + int prot); + /* * Unmaps the @count pages starting at @start_address, which were mapped by a * call to xc_gnttab_map_grant_ref or xc_gnttab_map_grant_refs. Returns zero --OgqxwSJOaUobr8KG Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --OgqxwSJOaUobr8KG--