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

Re: [Xen-devel] [v7][RFC][PATCH 01/13] introduce XENMEM_reserved_device_memory_map



On 2014/10/28 18:36, Jan Beulich wrote:
On 28.10.14 at 03:35, <tiejun.chen@xxxxxxxxx> wrote:
On 2014/10/27 21:35, Julien Grall wrote:
Hi,

On 10/24/2014 08:34 AM, Tiejun Chen wrote:
diff --git a/xen/common/memory.c b/xen/common/memory.c
index cc36e39..51a32a8 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -692,6 +692,32 @@ out:
       return rc;
   }

+struct get_reserved_device_memory {
+    struct xen_mem_reserved_device_memory_map map;
+    unsigned int used_entries;
+};
+
+static int get_reserved_device_memory(xen_pfn_t start,
+                                      xen_ulong_t nr, void *ctxt)

This function is only used when HAS_PASSTHROUGH is defined. You have to
protected by an #ifdef HAS_PASSTHROUGH.


I guess you mean we need to do this,

diff --git a/xen/common/memory.c b/xen/common/memory.c
index 1449c10..2177c56 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -692,6 +692,7 @@ out:
       return rc;
   }

+#ifdef HAS_PASSTHROUGH
   struct get_reserved_device_memory {
       struct xen_reserved_device_memory_map map;
       unsigned int used_entries;
@@ -717,6 +718,7 @@ static int get_reserved_device_memory(xen_pfn_t start,

       return 0;
   }
+#endif

   long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
   {

Jan,

With this above change, is the following working for you?

I already fixed this in my version (which I view to be the canonical
one).


Are you point that attached patch? Are you sure? Here I pick some code fragments from your latest patch,

--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -692,6 +692,32 @@ out:
     return rc;
 }

+struct get_reserved_device_memory {
+    struct xen_reserved_device_memory_map map;
+    unsigned int used_entries;
+};
+
+static int get_reserved_device_memory(xen_pfn_t start,
+                                      xen_ulong_t nr, void *ctxt)
+{
+    struct get_reserved_device_memory *grdm = ctxt;
+
+    if ( grdm->used_entries < grdm->map.nr_entries )
+    {
+        struct xen_reserved_device_memory rdm = {
+            .start_pfn = start, .nr_pages = nr
+        };
+
+        if ( __copy_to_guest_offset(grdm->map.buffer, grdm->used_entries,
+                                    &rdm, 1) )
+            return -EFAULT;
+    }
+
+    ++grdm->used_entries;
+
+    return 0;
+}
+
 long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
     struct domain *d;
@@ -1101,6 +1127,29 @@ long do_memory_op(unsigned long cmd, XEN
         break;
     }

+#ifdef HAS_PASSTHROUGH
+    case XENMEM_reserved_device_memory_map:
+    {
+        struct get_reserved_device_memory grdm;
+
+        if ( copy_from_guest(&grdm.map, arg, 1) ||
+             !guest_handle_okay(grdm.map.buffer, grdm.map.nr_entries) )
+            return -EFAULT;
+
+        grdm.used_entries = 0;
+        rc = iommu_get_reserved_device_memory(get_reserved_device_memory,
+                                              &grdm);
+
+        if ( !rc && grdm.map.nr_entries < grdm.used_entries )
+            rc = -ENOBUFS;
+        grdm.map.nr_entries = grdm.used_entries;
+        if ( __copy_to_guest(arg, &grdm.map, 1) )
+            rc = -EFAULT;
+
+        break;
+    }
+#endif
+
     default:
         rc = arch_memory_op(cmd, arg);
         break;
--- a/xen/drivers/passthrough/iommu.c

Thanks
Tiejun

Jan



_______________________________________________
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®.