mem_access: added trap injection to libxc
authorJoe Epstein <jepstein98@gmail.com>
Fri, 7 Jan 2011 11:54:50 +0000 (11:54 +0000)
committerJoe Epstein <jepstein98@gmail.com>
Fri, 7 Jan 2011 11:54:50 +0000 (11:54 +0000)
* Carries forward the trap injection hypercall into libxc

Signed-off-by: Joe Epstein <jepstein98@gmail.com>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
tools/libxc/xc_misc.c
tools/libxc/xenctrl.h

index f4004b1d82364636c9c672da1b21fd0fe967d2a5..b87bbc0cf91a1fd509b13c5c922f5f0191aa6447 100644 (file)
@@ -572,6 +572,38 @@ int xc_hvm_get_mem_access(
     return rc;
 }
 
+int xc_hvm_inject_trap(
+    xc_interface *xch, domid_t dom, int vcpu, uint32_t trap, uint32_t error_code, 
+    uint64_t cr2)
+{
+    DECLARE_HYPERCALL;
+    DECLARE_HYPERCALL_BUFFER(struct xen_hvm_inject_trap, arg);
+    int rc;
+
+    arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));
+    if ( arg == NULL )
+    {
+        PERROR("Could not allocate memory for xc_hvm_inject_trap hypercall");
+        return -1;
+    }
+
+    arg->domid       = dom;
+    arg->vcpuid      = vcpu;
+    arg->trap        = trap;
+    arg->error_code  = error_code;
+    arg->cr2         = cr2;
+
+    hypercall.op     = __HYPERVISOR_hvm_op;
+    hypercall.arg[0] = HVMOP_inject_trap;
+    hypercall.arg[1] = HYPERCALL_BUFFER_AS_ARG(arg);
+
+    rc = do_xen_hypercall(xch, &hypercall);
+
+    xc_hypercall_buffer_free(xch, arg);
+
+    return rc;
+}
+
 /*
  * Local variables:
  * mode: C
index aec258662f97e91102c8f71811b6375989c41b77..00c6f4425ec3ba5b683506e17cb232809c52f764 100644 (file)
@@ -1425,6 +1425,14 @@ int xc_hvm_set_mem_access(
 int xc_hvm_get_mem_access(
     xc_interface *xch, domid_t dom, uint64_t pfn, hvmmem_access_t* memaccess);
 
+/*
+ * Injects a hardware/software CPU trap, to take effect the next time the HVM 
+ * resumes. 
+ */
+int xc_hvm_inject_trap(
+    xc_interface *xch, domid_t dom, int vcpu, uint32_t trap, uint32_t error_code, 
+    uint64_t cr2);
+
 /*
  *  LOGGING AND ERROR REPORTING
  */