x86/hvm: provide XEN_DMOP_pin_memory_cacheattr
authorRoss Lagerwall <ross.lagerwall@citrix.com>
Thu, 25 Jan 2018 11:25:22 +0000 (12:25 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 25 Jan 2018 11:25:22 +0000 (12:25 +0100)
Provide XEN_DMOP_pin_memory_cacheattr to allow a deprivileged QEMU to
pin the caching type of RAM after moving the VRAM. It is equivalent to
XEN_DOMCTL_pin_memory_cacheattr.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/dm.c
xen/include/public/hvm/dm_op.h
xen/include/xlat.lst

index a5773e35f4462cfb60fd42832bdddd92db02bcc1..8083ded467f2a5543f47228b6116aaca48353928 100644 (file)
@@ -20,6 +20,7 @@
 #include <xen/sched.h>
 
 #include <asm/hap.h>
+#include <asm/hvm/cacheattr.h>
 #include <asm/hvm/ioreq.h>
 #include <asm/shadow.h>
 
@@ -671,6 +672,22 @@ static int dm_op(const struct dmop_args *op_args)
         break;
     }
 
+    case XEN_DMOP_pin_memory_cacheattr:
+    {
+        const struct xen_dm_op_pin_memory_cacheattr *data =
+            &op.u.pin_memory_cacheattr;
+
+        if ( data->pad )
+        {
+            rc = -EINVAL;
+            break;
+        }
+
+        rc = hvm_set_mem_pinned_cacheattr(d, data->start, data->end,
+                                          data->type);
+        break;
+    }
+
     default:
         rc = -EOPNOTSUPP;
         break;
@@ -701,6 +718,7 @@ CHECK_dm_op_inject_event;
 CHECK_dm_op_inject_msi;
 CHECK_dm_op_remote_shutdown;
 CHECK_dm_op_relocate_memory;
+CHECK_dm_op_pin_memory_cacheattr;
 
 int compat_dm_op(domid_t domid,
                  unsigned int nr_bufs,
index 837c53f1b59d0d3fb17f2a226fe68f0907e43034..bfbd3a6141b7dc9b65d37b1d55d23fc0a0de85c9 100644 (file)
@@ -386,6 +386,19 @@ struct xen_dm_op_relocate_memory {
     uint64_aligned_t dst_gfn;
 };
 
+/*
+ * XEN_DMOP_pin_memory_cacheattr : Pin caching type of RAM space.
+ *                                 Identical to XEN_DOMCTL_pin_mem_cacheattr.
+ */
+#define XEN_DMOP_pin_memory_cacheattr 18
+
+struct xen_dm_op_pin_memory_cacheattr {
+    uint64_aligned_t start; /* Start gfn. */
+    uint64_aligned_t end;   /* End gfn. */
+    uint32_t type;          /* XEN_DOMCTL_MEM_CACHEATTR_* */
+    uint32_t pad;
+};
+
 struct xen_dm_op {
     uint32_t op;
     uint32_t pad;
@@ -408,6 +421,7 @@ struct xen_dm_op {
                 map_mem_type_to_ioreq_server;
         struct xen_dm_op_remote_shutdown remote_shutdown;
         struct xen_dm_op_relocate_memory relocate_memory;
+        struct xen_dm_op_pin_memory_cacheattr pin_memory_cacheattr;
     } u;
 };
 
index b3d00b7f46896e81a30a8ab25b67cce77ba6b653..3690b97d5d615de0ab057ed4cad74c77fcbffb50 100644 (file)
@@ -65,6 +65,7 @@
 ?      dm_op_inject_msi                hvm/dm_op.h
 ?      dm_op_ioreq_server_range        hvm/dm_op.h
 ?      dm_op_modified_memory           hvm/dm_op.h
+?      dm_op_pin_memory_cacheattr      hvm/dm_op.h
 ?      dm_op_remote_shutdown           hvm/dm_op.h
 ?      dm_op_set_ioreq_server_state    hvm/dm_op.h
 ?      dm_op_set_isa_irq_level         hvm/dm_op.h