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.


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