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
34 EXPORT safe_svm_launch
41 ;; These need to be kept similar with the svm return values in svm.h
42 SVM_HANDLER_SUCCESS equ 0x00
43 SVM_HANDLER_ERROR equ 0x1
44 SVM_HANDLER_HALT equ 0x2
49 ; Save and restore registers needed by SVM
50 %macro Save_SVM_Registers 1
56 mov [eax + 24], dword 0 ;; esp
63 mov [eax + 56], ebx ;; eax
70 %macro Restore_SVM_Registers 1
76 ;; mov esp, [eax + 24]
80 ;; mov eax, [eax + 56]
104 ;VMRUN equ db 0Fh, 01h, D8h
105 ;VMLOAD equ db 0x0F,0x01,0xDA
106 ;VMSAVE equ db 0x0F,0x01,0xDB
107 ;STGI equ db 0x0F,0x01,0xDC
108 ;CLGI equ db 0x0F,0x01,0xDD
125 ;; Need to check this..
126 ;; save_svm_launch(rax, struct guest_gprs * regs)
134 pusha ;; Save Host state
137 push dword [ebp + 12] ;; pointer to the guest GPR save area
138 push dword [ebp + 8] ;; pointer to the VMCB pointer
140 ;; mov eax, [esp + 4] ;; mov guest GPR pointer to eax
142 ;; this is plus 8 because we push eax in the macro
143 Restore_SVM_Registers [esp + 8] ;; Restore Guest GPR state
144 pop eax ;; pop VMCB pointer into eax
150 ;; pop eax ;; pop Guest GPR pointer into eax
151 ;; this is plus 4 because we push eax in the macro NEED TO CHANGE
152 Save_SVM_Registers [esp+4] ;; save guest GPRs
154 add esp, 4 ;; skip past the gpr ptr
156 popa ;; Restore Host state