Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


linux userspace hypercall addition utility + Makefile updates
Peter Dinda [Fri, 13 Apr 2012 22:00:18 +0000 (17:00 -0500)]
linux_usr/Makefile
linux_usr/v3_hypercall.c [new file with mode: 0644]

index 4f2aa2c..6b60433 100644 (file)
@@ -24,6 +24,7 @@ BASE_EXECS =  v3_mem \
                v3_cons_sc \
                v3_stream \
                v3_monitor \
+                v3_hypercall 
 
 #
 # Examples
@@ -31,13 +32,18 @@ BASE_EXECS =        v3_mem \
 EXAMPLE_EXECS = v3_user_host_dev_example \
                v3_os_debug \
                v3_user_keyed_stream_example \
-               v3_user_keyed_stream_file \
+               v3_user_keyed_stream_file 
 
 #
 # Currently experimental things
 #
 EXPERIMENTAL_EXECS =   v3_simulate  \
-                       v3_inject_ecc_scrubber_mce
+                       v3_inject_ecc_scrubber_mce  \
+                        v3_top_inject \
+                        v3_env_inject 
+
+
+
 
 #
 # Things that have been built elsewhere - just for reference here
@@ -61,6 +67,8 @@ ifeq ($(STATIC),1)
   CFLAGS += -static 
 endif
 
+CFLAGS += -I../linux_module
+
 CC = gcc
 AR = ar
 
diff --git a/linux_usr/v3_hypercall.c b/linux_usr/v3_hypercall.c
new file mode 100644 (file)
index 0000000..1cc53b4
--- /dev/null
@@ -0,0 +1,85 @@
+/* 
+ * V3 Hypercall Add Utility
+ * Allows hypercalls to be added to Palacios at run-time
+ *
+ * (c) Kyle C. Hale, 2011
+ */
+
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <malloc.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include "../linux_module/iface-host-hypercall.h"
+
+static void usage (char * bin) {
+       fprintf(stderr, "%s /dev/v3-vm<N> add|remove <nr> [function]\n", bin);
+       fprintf(stderr, "<nr> = hypercall number\n"
+               "[function] = kernel symbol to bind to\n"
+               "             (defaults to a nop if not given)\n");
+}
+
+int main (int argc, char ** argv) {
+  char * vm_dev = NULL;
+  int vm_fd, err;
+  struct hcall_data hd;
+  enum {ADD,REMOVE} task;
+
+  
+  if (argc < 4 || argc>5) {
+    usage(argv[0]);
+    return -1;
+  }
+
+  vm_dev = argv[1];
+
+  hd.hcall_nr = strtol(argv[3], NULL, 0);
+  
+  if (!strcasecmp(argv[2],"add")) { 
+    task=ADD;
+    if (argc==4) { 
+      hd.fn[0]=0;  // blank
+    } else {
+      strcpy(hd.fn,argv[4]);
+    }
+  } else if (!strcasecmp(argv[2],"remove")) { 
+    task=REMOVE;
+  } else {
+    usage(argv[0]);
+    return -1;
+  }
+
+  printf("%s hypercall %d (0x%x) -> '%s' on %s\n",
+        task==ADD ? "Adding" : "Removing",
+        hd.hcall_nr, hd.hcall_nr,
+        task==REMOVE ? "(unimportant)" 
+        : strcmp(hd.fn,"") ? hd.fn : "(default nop)", vm_dev);
+
+  vm_fd = open(vm_dev, O_RDONLY);
+  if (vm_fd == -1) {
+    perror("Cannot open VM device");
+    return -1;
+  }
+
+  if (ioctl(vm_fd, 
+           task==ADD ? V3_VM_HYPERCALL_ADD : V3_VM_HYPERCALL_REMOVE,
+           &hd) < 0) { 
+    perror("Cannot complete task due ioctl failure");
+    close(vm_fd);
+    return -1;
+  }
+  
+  close(vm_fd);
+
+  printf("Done.\n");
+
+  return 0;
+}
+
+