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
36 EXTERN handle_svm_exit
39 EXPORT safe_svm_launch
46 ;; These need to be kept similar with the svm return values in svm.h
47 SVM_HANDLER_SUCCESS equ 0x00
48 SVM_HANDLER_ERROR equ 0x1
49 SVM_HANDLER_HALT equ 0x2
54 ; Save and restore registers needed by SVM
55 %macro Save_SVM_Registers 1
61 mov [eax + 24], dword 0 ;; esp
68 mov [eax + 56], ebx ;; eax
75 %macro Restore_SVM_Registers 1
81 ;; mov esp, [eax + 24]
85 ;; mov eax, [eax + 56]
109 ;VMRUN equ db 0Fh, 01h, D8h
110 ;VMLOAD equ db 0x0F,0x01,0xDA
111 ;VMSAVE equ db 0x0F,0x01,0xDB
112 ;STGI equ db 0x0F,0x01,0xDC
113 ;CLGI equ db 0x0F,0x01,0xDD
129 ; I think its safe to say that there are some pretty serious register issues...
138 ; db 00fh, 001h, 0d8h
151 ;; Need to check this..
152 ;; save_svm_launch(rax, struct guest_gprs * regs)
160 pusha ;; Save Host state
163 push dword [ebp + 12] ;; pointer to the guest GPR save area
164 push dword [ebp + 8] ;; pointer to the VMCB pointer
166 ;; mov eax, [esp + 4] ;; mov guest GPR pointer to eax
168 ;; this is plus 8 because we push eax in the macro
169 Restore_SVM_Registers [esp + 8] ;; Restore Guest GPR state
170 pop eax ;; pop VMCB pointer into eax
176 ;; pop eax ;; pop Guest GPR pointer into eax
177 ;; this is plus 4 because we push eax in the macro NEED TO CHANGE
178 Save_SVM_Registers [esp+4] ;; save guest GPRs
180 add esp, 4 ;; skip past the gpr ptr
182 popa ;; Restore Host state