|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH for-next 02/16] xen/arm: raw_copy_to_guest_helper: Rework the prototype and rename it
On Thu, 23 Nov 2017, Julien Grall wrote:
> All the helpers within arch/arm/guestcopy.c are doing the same things:
> copy data from/to the guest.
>
> At the moment, the logic is duplicated in each helpers making more
> difficult to implement new variant.
>
> The first step for the consolidation is to get a common prototype and a
> base. For convenience (it is at the beginning of the file!),
> raw_copy_to_guest_helper is chosen.
>
> The function is now renamed copy_guest to show it will be a
> generic function to copy data from/to the guest. Note that for now, only
> copying to guest virtual address is supported. Follow-up patches will
> extend the support.
>
> Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx>
> ---
> xen/arch/arm/guestcopy.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c
> index 2620e659b4..d1cfbe922c 100644
> --- a/xen/arch/arm/guestcopy.c
> +++ b/xen/arch/arm/guestcopy.c
> @@ -7,11 +7,11 @@
>
> #define COPY_flush_dcache (1U << 0)
>
> -static unsigned long raw_copy_to_guest_helper(void *to, const void *from,
> - unsigned len, int flags)
> +static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len,
> + unsigned int flags)
Why not use vaddr_t ?
> {
> /* XXX needs to handle faults */
> - unsigned offset = (vaddr_t)to & ~PAGE_MASK;
> + unsigned offset = addr & ~PAGE_MASK;
>
> while ( len )
> {
> @@ -19,21 +19,21 @@ static unsigned long raw_copy_to_guest_helper(void *to,
> const void *from,
> unsigned size = min(len, (unsigned)PAGE_SIZE - offset);
> struct page_info *page;
>
> - page = get_page_from_gva(current, (vaddr_t) to, GV2M_WRITE);
> + page = get_page_from_gva(current, addr, GV2M_WRITE);
> if ( page == NULL )
> return len;
>
> p = __map_domain_page(page);
> p += offset;
> - memcpy(p, from, size);
> + memcpy(p, buf, size);
> if ( flags & COPY_flush_dcache )
> clean_dcache_va_range(p, size);
>
> unmap_domain_page(p - offset);
> put_page(page);
> len -= size;
> - from += size;
> - to += size;
> + buf += size;
> + addr += size;
> /*
> * After the first iteration, guest virtual address is correctly
> * aligned to PAGE_SIZE.
> @@ -46,13 +46,13 @@ static unsigned long raw_copy_to_guest_helper(void *to,
> const void *from,
>
> unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len)
> {
> - return raw_copy_to_guest_helper(to, from, len, 0);
> + return copy_guest((void *)from, (unsigned long)to, len, 0);
> }
>
> unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from,
> unsigned len)
> {
> - return raw_copy_to_guest_helper(to, from, len, COPY_flush_dcache);
> + return copy_guest((void *)from, (unsigned long)to, len,
> COPY_flush_dcache);
> }
>
> unsigned long raw_clear_guest(void *to, unsigned len)
> --
> 2.11.0
>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |