[Xen-devel,for-next,05/16] xen/arm: guest_copy: Extend the prototype to pass the vCPU

Message ID 20171123183210.12045-6-julien.grall@linaro.org
State New
Headers show
Series
  • xen/arm: Stage-2 handling cleanup
Related show

Commit Message

Julien Grall Nov. 23, 2017, 6:31 p.m.
Currently, guest_copy assumes the copy will only be done for the current
vCPU. A follow-up patch will require to use a different vCPU.

So extend the prototype to pass the vCPU.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
---
 xen/arch/arm/guestcopy.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Stefano Stabellini Dec. 6, 2017, 1:11 a.m. | #1
On Thu, 23 Nov 2017, Julien Grall wrote:
> Currently, guest_copy assumes the copy will only be done for the current
> vCPU. A follow-up patch will require to use a different vCPU.
> 
> So extend the prototype to pass the vCPU.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  xen/arch/arm/guestcopy.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c
> index 3aaa80859e..487f5ab82d 100644
> --- a/xen/arch/arm/guestcopy.c
> +++ b/xen/arch/arm/guestcopy.c
> @@ -10,7 +10,7 @@
>  #define COPY_to_guest       (1U << 1)
>  
>  static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len,
> -                                unsigned int flags)
> +                                struct vcpu *v, unsigned int flags)
>  {
>      /* XXX needs to handle faults */
>      unsigned offset = addr & ~PAGE_MASK;
> @@ -21,7 +21,7 @@ static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len,
>          unsigned size = min(len, (unsigned)PAGE_SIZE - offset);
>          struct page_info *page;
>  
> -        page = get_page_from_gva(current, addr,
> +        page = get_page_from_gva(v, addr,
>                                   (flags & COPY_to_guest) ? GV2M_WRITE : GV2M_READ);
>          if ( page == NULL )
>              return len;
> @@ -62,24 +62,25 @@ static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len,
>  
>  unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len)
>  {
> -    return copy_guest((void *)from, (unsigned long)to, len, COPY_to_guest);
> +    return copy_guest((void *)from, (unsigned long)to, len,
> +                      current, COPY_to_guest);
>  }
>  
>  unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from,
>                                               unsigned len)
>  {
>      return copy_guest((void *)from, (unsigned long)to, len,
> -                      COPY_to_guest | COPY_flush_dcache);
> +                      current, COPY_to_guest | COPY_flush_dcache);
>  }
>  
>  unsigned long raw_clear_guest(void *to, unsigned len)
>  {
> -    return copy_guest(NULL, (unsigned long)to, len, COPY_to_guest);
> +    return copy_guest(NULL, (unsigned long)to, len, current, COPY_to_guest);
>  }
>  
>  unsigned long raw_copy_from_guest(void *to, const void __user *from, unsigned len)
>  {
> -    return copy_guest(to, (unsigned long)from, len, COPY_from_guest);
> +    return copy_guest(to, (unsigned long)from, len, current, COPY_from_guest);
>  }
>  
>  /*
> -- 
> 2.11.0
>

Patch

diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c
index 3aaa80859e..487f5ab82d 100644
--- a/xen/arch/arm/guestcopy.c
+++ b/xen/arch/arm/guestcopy.c
@@ -10,7 +10,7 @@ 
 #define COPY_to_guest       (1U << 1)
 
 static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len,
-                                unsigned int flags)
+                                struct vcpu *v, unsigned int flags)
 {
     /* XXX needs to handle faults */
     unsigned offset = addr & ~PAGE_MASK;
@@ -21,7 +21,7 @@  static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len,
         unsigned size = min(len, (unsigned)PAGE_SIZE - offset);
         struct page_info *page;
 
-        page = get_page_from_gva(current, addr,
+        page = get_page_from_gva(v, addr,
                                  (flags & COPY_to_guest) ? GV2M_WRITE : GV2M_READ);
         if ( page == NULL )
             return len;
@@ -62,24 +62,25 @@  static unsigned long copy_guest(void *buf, paddr_t addr, unsigned int len,
 
 unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len)
 {
-    return copy_guest((void *)from, (unsigned long)to, len, COPY_to_guest);
+    return copy_guest((void *)from, (unsigned long)to, len,
+                      current, COPY_to_guest);
 }
 
 unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from,
                                              unsigned len)
 {
     return copy_guest((void *)from, (unsigned long)to, len,
-                      COPY_to_guest | COPY_flush_dcache);
+                      current, COPY_to_guest | COPY_flush_dcache);
 }
 
 unsigned long raw_clear_guest(void *to, unsigned len)
 {
-    return copy_guest(NULL, (unsigned long)to, len, COPY_to_guest);
+    return copy_guest(NULL, (unsigned long)to, len, current, COPY_to_guest);
 }
 
 unsigned long raw_copy_from_guest(void *to, const void __user *from, unsigned len)
 {
-    return copy_guest(to, (unsigned long)from, len, COPY_from_guest);
+    return copy_guest(to, (unsigned long)from, len, current, COPY_from_guest);
 }
 
 /*