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.


35914631b5976add2fe6290c8a8e713791d07a7a
[palacios.git] / palacios / src / palacios / vmx_lowlevel.S
1
2 #define VMX_SUCCESS         0
3 #define VMX_FAIL_INVALID    1
4 #define VMX_FAIL_VALID      2
5
6 #define VMCS_HOST_RSP       0x00006C14
7
8 #if defined(__V3_64BIT__)
9
10 #define r(reg) %r##reg
11
12 #define PUSHA    \
13     push %rax;   \
14     push %rbx;   \
15     push %rcx;   \
16     push %rdx;   \
17     push %rbp;   \
18     push %rdi;   \
19     push %rsi;   \
20     push %r8 ;   \
21     push %r9 ;   \
22     push %r10;   \
23     push %r11;   \
24     push %r12;   \
25     push %r13;   \
26     push %r14;   \
27     push %r15;   
28
29 #define POPA     \
30     pop %r15;    \
31     pop %r14;    \
32     pop %r13;    \
33     pop %r12;    \
34     pop %r11;    \
35     pop %r10;    \
36     pop %r9 ;    \
37     pop %r8 ;    \
38     pop %rsi;    \
39     pop %rdi;    \
40     pop %rbp;    \
41     pop %rdx;    \
42     pop %rcx;    \
43     pop %rbx;    \
44     pop %rax;    
45 #else
46
47 #define r(reg) %e##reg
48   
49 #define PUSHA    \
50     push %eax;   \
51     push %ebx;   \
52     push %ecx;   \
53     push %edx;   \
54     push %ebp;   \
55     push %edi;   \
56     push %esi;
57
58 #define POPA     \
59     pop %esi;    \
60     pop %edi;    \
61     pop %ebp;    \
62     pop %edx;    \
63     pop %ecx;    \
64     pop %ebx;    \
65     pop %eax;
66
67 #endif
68
69 .align 8
70 .globl v3_vmx_exit_handler
71 v3_vmx_exit_handler:
72     PUSHA
73     call v3_vmx_handle_exit
74     POPA
75
76 v3_vmx_vmresume:
77     vmresume
78     sti
79     jz .Lfail_valid
80     jc .Lfail_invalid
81     jmp .Lreturn
82
83 .globl v3_vmx_vmlaunch
84 v3_vmx_vmlaunch:
85     cli 
86     pushf
87     PUSHA
88
89     mov r(sp), r(ax)
90     mov $VMCS_HOST_RSP, r(bx)
91     vmwrite r(bx), r(ax)
92     jz .Lfail_valid
93     jc .Lfail_invalid
94
95     vmlaunch
96     sti
97     jz .Lfail_valid
98     jc .Lfail_invalid
99     jmp .Lreturn
100
101 .Lfail_valid:
102     mov $VMX_FAIL_VALID, r(ax)
103     jmp .Lreturn
104
105 .Lfail_invalid:
106     mov $VMX_FAIL_INVALID, r(ax)
107     jmp .Lreturn
108
109 .Lreturn:
110     POPA
111     popf
112     ret
113
114
115
116