3 ;; (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
4 ;; (c) 2008, The V3VEE Project <http://www.v3vee.org>
10 %include "vmm_symbol.asm"
12 SVM_ERROR equ 0xFFFFFFFF
13 SVM_SUCCESS equ 0x00000000
21 EXTERN handle_svm_exit
24 EXPORT safe_svm_launch
31 ;; These need to be kept similar with the svm return values in svm.h
32 SVM_HANDLER_SUCCESS equ 0x00
33 SVM_HANDLER_ERROR equ 0x1
34 SVM_HANDLER_HALT equ 0x2
39 ; Save and restore registers needed by SVM
40 %macro Save_SVM_Registers 1
46 mov [eax + 24], dword 0 ;; esp
53 mov [eax + 56], ebx ;; eax
60 %macro Restore_SVM_Registers 1
66 ;; mov esp, [eax + 24]
70 ;; mov eax, [eax + 56]
94 ;VMRUN equ db 0Fh, 01h, D8h
95 ;VMLOAD equ db 0x0F,0x01,0xDA
96 ;VMSAVE equ db 0x0F,0x01,0xDB
97 ;STGI equ db 0x0F,0x01,0xDC
98 ;CLGI equ db 0x0F,0x01,0xDD
124 ; I think its safe to say that there are some pretty serious register issues...
133 ; db 00fh, 001h, 0d8h
146 ;; Need to check this..
147 ;; save_svm_launch(rax, struct guest_gprs * regs)
155 pusha ;; Save Host state
158 push dword [ebp + 12] ;; pointer to the guest GPR save area
159 push dword [ebp + 8] ;; pointer to the VMCB pointer
161 ;; mov eax, [esp + 4] ;; mov guest GPR pointer to eax
163 ;; this is plus 8 because we push eax in the macro
164 Restore_SVM_Registers [esp + 8] ;; Restore Guest GPR state
165 pop eax ;; pop VMCB pointer into eax
171 ;; pop eax ;; pop Guest GPR pointer into eax
172 ;; this is plus 4 because we push eax in the macro NEED TO CHANGE
173 Save_SVM_Registers [esp+4] ;; save guest GPRs
175 add esp, 4 ;; skip past the gpr ptr
177 popa ;; Restore Host state