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.


internal decoders works enough to boot a 32 bit linux guest
Jack Lange [Wed, 9 Mar 2011 01:10:53 +0000 (19:10 -0600)]
palacios/include/palacios/vmm_instr_decoder.h
palacios/src/palacios/vmm_v3dec.c

index 15d6271..1c292a3 100644 (file)
@@ -135,8 +135,7 @@ typedef enum {
 } op_form_t;
 
 
-static int get_addr_width(struct guest_info * info, struct x86_instr * instr,
-                         op_form_t form) {
+static int get_addr_width(struct guest_info * info, struct x86_instr * instr) {
 
     switch (v3_get_vm_cpu_mode(info)) {
        case REAL:
@@ -453,6 +452,25 @@ static inline int decode_cr(struct guest_info * core,
            val;                                                        \
        })
 
+
+#define ADDR_MASK(val, length) ({                            \
+            ullong_t mask = 0x0LL;                           \
+            switch (length) {                                \
+                case 2:                                              \
+                    mask = 0x00000000000fffffLL;             \
+                    break;                                   \
+                case 4:                                              \
+                    mask = 0x00000000ffffffffLL;             \
+                    break;                                   \
+                case 8:                                              \
+                    mask = 0xffffffffffffffffLL;              \
+                    break;                                   \
+            }                                                \
+            val & mask;                                              \
+        })
+
+
+
 static  int decode_rm_operand16(struct guest_info * core,
                                uint8_t * modrm_instr, 
                                struct x86_instr * instr,
@@ -548,7 +566,8 @@ static  int decode_rm_operand16(struct guest_info * core,
            seg = &(core->segments.ds);
        }
        
-       operand->operand = get_addr_linear(core, base_addr, seg);
+       operand->operand = ADDR_MASK(get_addr_linear(core, base_addr, seg), 
+                                    get_addr_width(core, instr));
     }
 
 
@@ -718,7 +737,8 @@ static int decode_rm_operand32(struct guest_info * core,
            seg = &(core->segments.ds);
        }
        
-       operand->operand = get_addr_linear(core, base_addr, seg);
+       operand->operand = ADDR_MASK(get_addr_linear(core, base_addr, seg), 
+                               get_addr_width(core, instr));
     }
 
 
index f02d04b..7dd716e 100644 (file)
 #include <palacios/vmm_instr_decoder.h>
 
 
-/* Disgusting mask hack...
-   I can't think right now, so we'll do it this way...
-*/
-static const ullong_t mask_1 = 0x00000000000000ffLL;
-static const ullong_t mask_2 = 0x000000000000ffffLL;
-static const ullong_t mask_4 = 0x00000000ffffffffLL;
-static const ullong_t mask_8 = 0xffffffffffffffffLL;
-
-
-#define MASK(val, length) ({                   \
-           ullong_t mask = 0x0LL;              \
-           switch (length) {                   \
-               case 1:                         \
-                   mask = mask_1;              \
-                   break;                      \
-               case 2:                         \
-                   mask = mask_2;              \
-                   break;                      \
-               case 4:                         \
-                   mask = mask_4;              \
-                   break;                      \
-               case 8:                         \
-                   mask = mask_8;              \
-                   break;                      \
-           }                                   \
-           val & mask;                         \
-       })
+#define MASK(val, length) ({                                           \
+            ullong_t mask = 0x0LL;                                     \
+            switch (length) {                                          \
+               case 1:                                                 \
+                   mask = 0x00000000000000ffLL;                        \
+                    break;                                             \
+                case 2:                                                        \
+                    mask = 0x000000000000ffffLL;                       \
+                    break;                                             \
+                case 4:                                                        \
+                    mask = 0x00000000ffffffffLL;                       \
+                    break;                                             \
+                case 8:                                                        \
+                    mask = 0xffffffffffffffffLL;                       \
+                    break;                                             \
+            }                                                          \
+            val & mask;                                                        \
+        })
 
 static v3_op_type_t op_form_to_type(op_form_t form);
 static int parse_operands(struct guest_info * core, uint8_t * instr_ptr, struct x86_instr * instr, op_form_t form);
@@ -124,7 +115,7 @@ static int parse_operands(struct guest_info * core, uint8_t * instr_ptr,
                          struct x86_instr * instr, op_form_t form) {
     // get operational mode of the guest for operand width
     uint8_t operand_width = get_operand_width(core, instr, form);
-    uint8_t addr_width = get_addr_width(core, instr, form);
+    uint8_t addr_width = get_addr_width(core, instr);
     int ret = 0;
     uint8_t * instr_start = instr_ptr;