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.


Modify Socket, Make V3_SOCK long
[palacios.git] / palacios / include / palacios / vmm_instr_emulator.h
index 190dcee..3e9e613 100644 (file)
@@ -1,3 +1,22 @@
+/*
+ * This file is part of the Palacios Virtual Machine Monitor developed
+ * by the V3VEE Project with funding from the United States National 
+ * Science Foundation and the Department of Energy.  
+ *
+ * The V3VEE Project is a joint project between Northwestern University
+ * and the University of New Mexico.  You can find out more at 
+ * http://www.v3vee.org
+ *
+ * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
+ * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
+ * All rights reserved.
+ *
+ * Author: Jack Lange <jarusl@cs.northwestern.edu>
+ *
+ * This is free software.  You are permitted to use,
+ * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
+ */
+
 #include <palacios/vmm_types.h>
 
 
 
 
 
+
+#define MAKE_2OP_64STR_INST(iname) static inline void iname##64(addr_t * dst, \
+                                                                addr_t * src, \
+                                                                addr_t * ecx, addr_t * flags) { \
+    /* Some of the flags values are not copied out in a pushf, we save them here */ \
+    addr_t flags_rsvd = *flags & ~0xfffe7fff;                          \
+                                                                       \
+    asm volatile (                                                     \
+        "pushfq; "                                                     \
+        "pushq %4; "                                                   \
+        "popfq; "                                                      \
+        "rep; "                                                        \
+        #iname"q; "                                                    \
+        "pushfq; "                                                     \
+        "popq %0; "                                                    \
+        "popfq; "                                                      \
+        : "=q"(*flags)                                                 \
+        : "D"(*dst),"S"(*src),"c"(*ecx),"q"(*flags)                    \
+        );                                                             \
+                                                                       \
+    /*  : "=D"(*dst),"=S"(*src),"=c"(*ecx),"=q"(*flags)*/              \
+    *flags |= flags_rsvd;                                              \
+  }
+
+
 #define MAKE_2OP_32STR_INST(iname) static inline void iname##32(addr_t * dst, \
                                                                addr_t * src, \
                                                                addr_t * ecx, addr_t * flags) { \
         "pushf; "                                                      \
         "pop %0; "                                                     \
         "popf; "                                                       \
-        : "=b"(*flags)                                                 \
-        : "D"(*dst),"S"(*src),"c"(*ecx),"b"(*flags)                    \
+        : "=q"(*flags)                                                 \
+        : "D"(*dst),"S"(*src),"c"(*ecx),"q"(*flags)                    \
         );                                                             \
                                                                        \
     /*  : "=D"(*dst),"=S"(*src),"=c"(*ecx),"=q"(*flags)*/              \
         "pushf; "                                                      \
         "pop %0; "                                                     \
         "popf; "                                                       \
-        : "=b"(*flags)                                                 \
-        : "D"(*dst),"S"(*src),"c"(*ecx),"b"(*flags)                    \
+        : "=q"(*flags)                                                 \
+        : "D"(*dst),"S"(*src),"c"(*ecx),"q"(*flags)                    \
         );                                                             \
     *flags |= flags_rsvd;                                              \
   }
         "pushf; "                                                      \
         "pop %0; "                                                     \
         "popf; "                                                       \
-        : "=b"(*flags)                                                 \
-        : "D"(*dst),"S"(*src),"c"(*ecx),"b"(*flags)                    \
+        : "=q"(*flags)                                                 \
+        : "D"(*dst),"S"(*src),"c"(*ecx),"q"(*flags)                    \
         );                                                             \
     *flags |= flags_rsvd;                                              \
   }
 
 
 
+#define MAKE_2OP_64_INST(iname) static inline void iname##64(addr_t * dst, addr_t * src) { \
+    uint64_t tmp_dst = *dst, tmp_src = *src;                           \
+                                                                       \
+    asm volatile (                                                     \
+        #iname"q %1, %0; "                                             \
+        : "=q"(tmp_dst)                                                \
+        : "q"(tmp_src), "0"(tmp_dst)                                   \
+        );                                                             \
+    *dst = tmp_dst;                                                    \
+  }
+
 #define MAKE_2OP_32_INST(iname) static inline void iname##32(addr_t * dst, addr_t * src) { \
     uint32_t tmp_dst = *dst, tmp_src = *src;                           \
                                                                        \
 
 
 
-
+/****************************/
+/* 8 Bit instruction forms  */
+/****************************/
 
 MAKE_2OP_8FLAGS_INST(adc);
 MAKE_2OP_8FLAGS_INST(add);
@@ -378,8 +435,12 @@ MAKE_1OP_8_INST(not);
 MAKE_2OP_8_INST(mov);
 MAKE_2OP_8_INST(xchg);
 
+MAKE_2OP_8STR_INST(movs);
 
 
+/****************************/
+/* 16 Bit instruction forms */
+/****************************/
 MAKE_2OP_16FLAGS_INST(adc);
 MAKE_2OP_16FLAGS_INST(add);
 MAKE_2OP_16FLAGS_INST(and);
@@ -397,10 +458,11 @@ MAKE_1OP_16_INST(not);
 MAKE_2OP_16_INST(mov);
 MAKE_2OP_16_INST(xchg);
 
+MAKE_2OP_16STR_INST(movs);
 
-
-
-
+/****************************/
+/* 32 Bit instruction forms */
+/****************************/
 MAKE_2OP_32FLAGS_INST(adc);
 MAKE_2OP_32FLAGS_INST(add);
 MAKE_2OP_32FLAGS_INST(and);
@@ -418,6 +480,32 @@ MAKE_1OP_32_INST(not);
 MAKE_2OP_32_INST(mov);
 MAKE_2OP_32_INST(xchg);
 
-MAKE_2OP_8STR_INST(movs);
-MAKE_2OP_16STR_INST(movs);
+
+
 MAKE_2OP_32STR_INST(movs);
+
+#ifdef __V3_64BIT__
+
+/****************************/
+/* 64 Bit instruction forms */
+/****************************/
+MAKE_2OP_64FLAGS_INST(adc);
+MAKE_2OP_64FLAGS_INST(add);
+MAKE_2OP_64FLAGS_INST(and);
+MAKE_2OP_64FLAGS_INST(or);
+MAKE_2OP_64FLAGS_INST(xor);
+MAKE_2OP_64FLAGS_INST(sub);
+
+MAKE_1OP_64FLAGS_INST(inc);
+MAKE_1OP_64FLAGS_INST(dec);
+MAKE_1OP_64FLAGS_INST(neg);
+
+MAKE_1OP_64_INST(not);
+
+
+MAKE_2OP_64_INST(mov);
+
+MAKE_2OP_64_INST(xchg);
+
+
+#endif