8 %include "vmm_symbol.asm"
10 SVM_ERROR equ 0xFFFFFFFF
11 SVM_SUCCESS equ 0x00000000
18 EXTERN handle_svm_exit
21 EXPORT safe_svm_launch
28 ;; These need to be kept similar with the svm return values in svm.h
29 SVM_HANDLER_SUCCESS equ 0x00
30 SVM_HANDLER_ERROR equ 0x1
31 SVM_HANDLER_HALT equ 0x2
36 ; Save and restore registers needed by SVM
37 %macro Save_SVM_Registers 1
43 mov [eax + 24], dword 0 ;; esp
50 mov [eax + 56], ebx ;; eax
57 %macro Restore_SVM_Registers 1
63 ;; mov esp, [eax + 24]
67 ;; mov eax, [eax + 56]
91 ;VMRUN equ db 0Fh, 01h, D8h
92 ;VMLOAD equ db 0x0F,0x01,0xDA
93 ;VMSAVE equ db 0x0F,0x01,0xDB
94 ;STGI equ db 0x0F,0x01,0xDC
95 ;CLGI equ db 0x0F,0x01,0xDD
117 ; I think its safe to say that there are some pretty serious register issues...
126 ; db 00fh, 001h, 0d8h
139 ;; Need to check this..
140 ;; save_svm_launch(rax, struct guest_gprs * regs)
148 pusha ;; Save Host state
151 push dword [ebp + 12] ;; pointer to the guest GPR save area
152 push dword [ebp + 8] ;; pointer to the VMCB pointer
154 ;; mov eax, [esp + 4] ;; mov guest GPR pointer to eax
156 ;; this is plus 8 because we push eax in the macro
157 Restore_SVM_Registers [esp + 8] ;; Restore Guest GPR state
158 pop eax ;; pop VMCB pointer into eax
164 ;; pop eax ;; pop Guest GPR pointer into eax
165 ;; this is plus 4 because we push eax in the macro NEED TO CHANGE
166 Save_SVM_Registers [esp+4] ;; save guest GPRs
168 add esp, 4 ;; skip past the gpr ptr
170 popa ;; Restore Host state