3 ;; This file is part of the Palacios Virtual Machine Monitor developed
4 ;; by the V3VEE Project with funding from the United States National
5 ;; Science Foundation and the Department of Energy.
7 ;; The V3VEE Project is a joint project between Northwestern University
8 ;; and the University of New Mexico. You can find out more at
9 ;; http://www.v3vee.org
11 ;; Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
12 ;; Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
13 ;; All rights reserved.
15 ;; Author: Jack Lange <jarusl@cs.northwestern.edu>
17 ;; This is free software. You are permitted to use,
18 ;; redistribute, and modify it as specified in the file "V3VEE_LICENSE".
27 %include "vmm_symbol.asm"
29 SVM_ERROR equ 0xFFFFFFFF
30 SVM_SUCCESS equ 0x00000000
38 EXTERN handle_svm_exit
41 EXPORT safe_svm_launch
48 ;; These need to be kept similar with the svm return values in svm.h
49 SVM_HANDLER_SUCCESS equ 0x00
50 SVM_HANDLER_ERROR equ 0x1
51 SVM_HANDLER_HALT equ 0x2
56 ; Save and restore registers needed by SVM
57 %macro Save_SVM_Registers 1
63 mov [eax + 24], dword 0 ;; esp
70 mov [eax + 56], ebx ;; eax
77 %macro Restore_SVM_Registers 1
83 ;; mov esp, [eax + 24]
87 ;; mov eax, [eax + 56]
111 ;VMRUN equ db 0Fh, 01h, D8h
112 ;VMLOAD equ db 0x0F,0x01,0xDA
113 ;VMSAVE equ db 0x0F,0x01,0xDB
114 ;STGI equ db 0x0F,0x01,0xDC
115 ;CLGI equ db 0x0F,0x01,0xDD
141 ; I think its safe to say that there are some pretty serious register issues...
150 ; db 00fh, 001h, 0d8h
163 ;; Need to check this..
164 ;; save_svm_launch(rax, struct guest_gprs * regs)
172 pusha ;; Save Host state
175 push dword [ebp + 12] ;; pointer to the guest GPR save area
176 push dword [ebp + 8] ;; pointer to the VMCB pointer
178 ;; mov eax, [esp + 4] ;; mov guest GPR pointer to eax
180 ;; this is plus 8 because we push eax in the macro
181 Restore_SVM_Registers [esp + 8] ;; Restore Guest GPR state
182 pop eax ;; pop VMCB pointer into eax
188 ;; pop eax ;; pop Guest GPR pointer into eax
189 ;; this is plus 4 because we push eax in the macro NEED TO CHANGE
190 Save_SVM_Registers [esp+4] ;; save guest GPRs
192 add esp, 4 ;; skip past the gpr ptr
194 popa ;; Restore Host state