Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


WTF??????
[palacios.git] / palacios / src / geekos / svm_lowlevel.asm
1 ;  -*- fundamental -*-
2
3
4 %ifndef SVM_ASM
5 %define SVM_ASM
6
7 %include "defs.asm"
8 %include "symbol.asm"
9
10
11 EXPORT GetGDTR
12 EXPORT GetIDTR
13
14
15
16 EXTERN handle_svm_exit
17
18 EXPORT launch_svm
19
20
21 [BITS 32]
22
23 %macro vmrun 0
24         db      00fh, 001h, 0d8h
25 %endmacro
26
27
28 ;VMRUN  equ db 0Fh, 01h, D8h
29 ;VMLOAD equ db 0x0F,0x01,0xDA
30 ;VMSAVE equ db 0x0F,0x01,0xDB
31 ;STGI   equ db 0x0F,0x01,0xDC
32 ;CLGI   equ db 0x0F,0x01,0xDD
33
34
35
36
37 GetGDTR:
38         push    ebp
39         mov     ebp, esp
40         pusha   
41         mov     ebx, [ebp + 8]
42         sgdt    [ebx]
43         
44         popa
45         pop     ebp
46         ret
47
48
49
50 GetIDTR:
51         push    ebp
52         mov     ebp, esp
53         pusha   
54         mov     ebx, [ebp + 8]
55         sgdt    [ebx]
56         
57         popa
58         pop     ebp
59         ret
60
61
62
63 ; I think its safe to say that there are some pretty serious register issues...
64 launch_svm:
65         push    ebp
66         mov     ebp, esp
67         pusha
68         
69         mov     eax, [ebp + 8]
70         vmrun
71 ;       db      00fh, 001h, 0d8h
72         popa
73         pop     ebp
74         ret
75
76
77
78 ; eventual svm_launch
79 ;   pusha
80 ;   pushf
81 ;
82 ; .vmm_loop
83 ;       vmrun
84 ;       push guest GPRs
85 ;       call handle_svm_exit
86 ;       jz .vmm_loop
87 ;  popf
88 ;  popa
89 ;  ret
90 ;
91 ;
92 ;
93
94
95
96 ;; Need to check this..
97 ;; Since RAX/EAX is saved in the VMCB, we should probably just 
98 ;;      do our own replacement for pusha/popa that excludes [e|r]ax
99 safe_svm_launch:
100         push    ebp
101         mov     ebp, esp
102         pushf
103         pusha
104
105 .vmm_loop:
106         mov     eax, [ebp + 8]
107         vmrun
108         pusha
109         call    handle_svm_exit
110         and     eax, eax
111         popa                    ;; restore the guest GPRs, (DOES THIS AFFECT E/RFLAGS?)
112         jz      .vmm_loop
113
114         ;; HOW DO WE GET THE RETURN VALUE OF HANDLE_SVM_EXIT BACK TO THE CALLER
115         popf
116         popa
117         pop     ebp
118         ret
119
120
121 %endif
122
123