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

[Xen-devel] [PATCH RFC 10/18] xen: arm: add batch support to the XENMEM_p2m_lookup operation



From: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@xxxxxxxxxxxxxxx>

Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@xxxxxxxxxxxxxxx>
Signed-off-by: Iurii Konovalenko <iurii.konovalenko@xxxxxxxxxxxxxxx>
---
 xen/arch/arm/mm.c           | 33 +++++++++++++++++++++++++++++++++
 xen/include/public/memory.h | 12 +++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index b5d8c85..04fb813 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -1150,10 +1150,43 @@ int xenmem_add_to_physmap_one(
     return rc;
 }
 
+#define MAX_P2M_ENTRIES_CNT             10000
+
+static long arch_paddr_to_maddr_batch(XEN_GUEST_HANDLE_PARAM(void) arg)
+{
+    struct xen_p2m_lookup p2mr;
+    xen_pfn_t paddr, maddr;
+    unsigned int i;
+
+    if ( copy_from_guest(&p2mr, arg, 1) )
+        return -EFAULT;
+
+    if (p2mr.count < 1 || p2mr.count > MAX_P2M_ENTRIES_CNT)
+        return -EINVAL;
+
+    if ( guest_handle_is_null(p2mr.paddrs) ||
+         guest_handle_is_null(p2mr.maddrs))
+        return -EINVAL;
+
+    for ( i = 0; i < p2mr.count; i++ )
+    {
+        if ( unlikely(__copy_from_guest_offset(&paddr, p2mr.paddrs, i, 1)) )
+            return -EFAULT;
+
+        maddr = p2m_lookup(current->domain, paddr, NULL);
+
+        if ( unlikely(__copy_to_guest_offset(p2mr.maddrs, i, &maddr, 1)) )
+            return -EFAULT;
+    }
+    return 0;
+}
+
 long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
     switch ( op )
     {
+    case XENMEM_p2m_lookup:
+        return arch_paddr_to_maddr_batch(arg);
     /* XXX: memsharing not working yet */
     case XENMEM_get_sharing_shared_pages:
     case XENMEM_get_sharing_freed_pages:
diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h
index 320de91..dfc5171 100644
--- a/xen/include/public/memory.h
+++ b/xen/include/public/memory.h
@@ -608,7 +608,17 @@ struct xen_vnuma_topology_info {
 typedef struct xen_vnuma_topology_info xen_vnuma_topology_info_t;
 DEFINE_XEN_GUEST_HANDLE(xen_vnuma_topology_info_t);
 
-/* Next available subop number is 28 */
+struct xen_p2m_lookup {
+    uint32_t count;
+    XEN_GUEST_HANDLE(xen_pfn_t) paddrs; /* IN:  physical addresses */
+    XEN_GUEST_HANDLE(xen_pfn_t) maddrs; /* OUT: machine addresses */
+};
+typedef struct xen_p2m_lookup xen_p2m_lookup_t;
+DEFINE_XEN_GUEST_HANDLE(xen_p2m_lookup_t);
+
+#define XENMEM_p2m_lookup 28
+
+/* Next available subop number is 29 */
 
 #endif /* __XEN_PUBLIC_MEMORY_H__ */
 
-- 
2.8.2


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

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