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.


a0c5e1a8311926e54013bd53864d4b7155b6dafc
[palacios.git] / palacios / src / geekos / svm_ctrl_regs.c
1 #include <geekos/svm_ctrl_regs.h>
2 #include <geekos/vmm_mem.h>
3 #include <geekos/vmm.h>
4 #include <geekos/vmcb.h>
5 #include <geekos/vmm_emulate.h>
6 #include <geekos/vm_guest_mem.h>
7
8 int handle_cr0_write(struct guest_info * info, ullong_t * new_cr0) {
9   //vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA((vmcb_t *)(info->vmm_data));
10   vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
11   char instr[15];
12   
13   
14
15
16   if (info->cpu_mode == REAL) {
17     read_guest_pa_memory(info, (addr_t)guest_state->rip, 15, instr);
18     int index = 0;
19
20     while (is_prefix_byte(instr[index])) {
21       PrintDebug("instr(%d): 0x%x\n", index, instr[index]);
22       index++; 
23     }
24     PrintDebug("instr(%d): 0x%x\n", index, instr[index]);
25     PrintDebug("instr(%d): 0x%x\n", index+1, instr[index + 1]);
26
27     if ((instr[index] == cr_access_byte) && 
28         (instr[index + 1] == lmsw_byte) && 
29         (MODRM_REG(instr[index + 2]) == lmsw_reg_byte)) {
30  
31       addr_t first_operand;
32       addr_t second_operand;
33      
34       // LMSW
35       // decode mod/RM
36       index += 2;
37  
38
39       if (decode_operands16(&(info->vm_regs), instr + index, &first_operand, &second_operand, REG16) != 0) {
40         // error... don't know what to do
41         return -1;
42       }
43
44       PrintDebug("FirstOperand addr: %x, RAX addr: %x\n", first_operand, &(info->vm_regs.rax));
45       
46
47       
48
49     } else if ((instr[index] == cr_access_byte) && 
50                (instr[index + 1] == clts_byte)) {
51       // CLTS
52     } else {
53       // unsupported instruction, GPF the guest
54       return -1;
55     }
56
57
58   }
59
60
61   return 0;
62 }
63
64