[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] xen/arm: guest_copy: Extend the prototype to pass the vCPU



commit 2986481b3d9e6d382f0ed9ef3d0be365ccbc309e
Author:     Julien Grall <julien.grall@xxxxxxxxxx>
AuthorDate: Tue Dec 12 19:02:01 2017 +0000
Commit:     Stefano Stabellini <sstabellini@xxxxxxxxxx>
CommitDate: Tue Dec 12 11:58:10 2017 -0800

    xen/arm: guest_copy: Extend the prototype to pass the vCPU
    
    Currently, guest_copy assumes the copy will only be done for the current
    vCPU. copy_guest is meant to be vCPU agnostic, so extend the prototype
    to pass the vCPU.
    
    At the same time, encapsulate the vCPU in an union to allow extension
    for copying from a guest domain (ipa case) in the future.
    
    Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx>
    Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
 xen/arch/arm/guestcopy.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c
index ff7d153..7e92e27 100644
--- a/xen/arch/arm/guestcopy.c
+++ b/xen/arch/arm/guestcopy.c
@@ -9,8 +9,18 @@
 #define COPY_from_guest     (0U << 1)
 #define COPY_to_guest       (1U << 1)
 
+typedef union
+{
+    struct
+    {
+        struct vcpu *v;
+    } gva;
+} copy_info_t;
+
+#define GVA_INFO(vcpu) ((copy_info_t) { .gva = { vcpu } })
+
 static unsigned long copy_guest(void *buf, uint64_t addr, unsigned int len,
-                                unsigned int flags)
+                                copy_info_t info, unsigned int flags)
 {
     /* XXX needs to handle faults */
     unsigned offset = addr & ~PAGE_MASK;
@@ -23,7 +33,7 @@ static unsigned long copy_guest(void *buf, uint64_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(info.gva.v, addr,
                                  (flags & COPY_to_guest) ? GV2M_WRITE : 
GV2M_READ);
         if ( page == NULL )
             return len;
@@ -64,24 +74,27 @@ static unsigned long copy_guest(void *buf, uint64_t addr, 
unsigned int len,
 
 unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len)
 {
-    return copy_guest((void *)from, (vaddr_t)to, len, COPY_to_guest);
+    return copy_guest((void *)from, (vaddr_t)to, len,
+                      GVA_INFO(current), COPY_to_guest);
 }
 
 unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from,
                                              unsigned len)
 {
-    return copy_guest((void *)from, (vaddr_t)to, len,
+    return copy_guest((void *)from, (vaddr_t)to, len, GVA_INFO(current),
                       COPY_to_guest | COPY_flush_dcache);
 }
 
 unsigned long raw_clear_guest(void *to, unsigned len)
 {
-    return copy_guest(NULL, (vaddr_t)to, len, COPY_to_guest);
+    return copy_guest(NULL, (vaddr_t)to, len, GVA_INFO(current),
+                      COPY_to_guest);
 }
 
 unsigned long raw_copy_from_guest(void *to, const void __user *from, unsigned 
len)
 {
-    return copy_guest(to, (vaddr_t)from, len, COPY_from_guest);
+    return copy_guest(to, (vaddr_t)from, len, GVA_INFO(current),
+                      COPY_from_guest);
 }
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.