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.


code restructuring
[palacios.git] / palacios / src / palacios / svm_handler.c
1 #include <palacios/svm_handler.h>
2 #include <palacios/vmm.h>
3 #include <palacios/svm_ctrl_regs.h>
4 #include <palacios/svm_io.h>
5
6 extern struct vmm_os_hooks * os_hooks;
7
8
9 int handle_svm_exit(struct guest_info * info) {
10   vmcb_ctrl_t * guest_ctrl = 0;
11   vmcb_saved_state_t * guest_state = 0;
12   ulong_t exit_code = 0;
13   
14   guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data));
15   guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
16   
17
18   // Update the high level state 
19   info->rip = guest_state->rip;
20   info->vm_regs.rsp = guest_state->rsp;
21   info->vm_regs.rax = guest_state->rax;
22   info->vm_regs.rsp = guest_state->rsp;
23
24
25   PrintDebug("SVM Returned:(VMCB=%x)\n", info->vmm_data); 
26   PrintDebug("RIP: %x\n", guest_state->rip);
27   
28
29
30   exit_code = guest_ctrl->exit_code;
31   
32   // PrintDebugVMCB((vmcb_t*)(info->vmm_data));
33   PrintDebug("SVM Returned: Exit Code: %x\n",exit_code); 
34
35   PrintDebug("io_info1 low = 0x%.8x\n", *(uint_t*)&(guest_ctrl->exit_info1));
36   PrintDebug("io_info1 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info1)) + 4));
37
38   PrintDebug("io_info2 low = 0x%.8x\n", *(uint_t*)&(guest_ctrl->exit_info2));
39   PrintDebug("io_info2 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info2)) + 4));
40
41   
42   if (exit_code == VMEXIT_IOIO) {
43     struct svm_io_info * io_info = (struct svm_io_info *)&(guest_ctrl->exit_info1);
44     
45     if (io_info->type == 0) {
46       if (io_info->str) {
47         handle_svm_io_outs(info);
48       } else {
49         handle_svm_io_out(info);
50       }
51     } else {
52       if (io_info->str) {
53         handle_svm_io_ins(info);
54       } else {
55         handle_svm_io_in(info);
56       }
57     }
58   } else if (exit_code == VMEXIT_CR0_WRITE) {
59     PrintDebug("CR0 Write\n");
60
61     if (handle_cr0_write(info) == -1) {
62       return -1;
63     }
64
65   } else if (( (exit_code == VMEXIT_CR3_READ)  ||
66                (exit_code == VMEXIT_CR3_WRITE) ||
67                (exit_code == VMEXIT_INVLPG)    ||
68                (exit_code == VMEXIT_INVLPGA)   || 
69                (exit_code == VMEXIT_EXCP14)) && 
70              (info->page_mode == SHADOW_PAGING)) {
71     handle_shadow_paging(info);
72   }
73
74
75   // Update the low level state
76   guest_state->rax = info->vm_regs.rax;
77   guest_state->rip = info->rip;
78   guest_state->rsp = info->vm_regs.rsp;
79
80   return 0;
81 }
82
83
84
85
86 int handle_shadow_paging(struct guest_info * info) {
87   vmcb_ctrl_t * guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data));
88   //  vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
89
90   if (guest_ctrl->exit_code == VMEXIT_CR3_READ) {
91
92   }
93
94   return 0;
95 }
96
97
98