1 | ; $Id: VMMGCA.asm 8155 2008-04-18 15:16:47Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; VMMGC - Guest Context Virtual Machine Monitor assembly routines.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ; Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
7 | ;
|
---|
8 | ; This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | ; available from http://www.virtualbox.org. This file is free software;
|
---|
10 | ; you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | ; General Public License (GPL) as published by the Free Software
|
---|
12 | ; Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | ;
|
---|
16 | ; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
17 | ; Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
18 | ; additional information or have any questions.
|
---|
19 | ;
|
---|
20 |
|
---|
21 | ;*******************************************************************************
|
---|
22 | ;* Header Files *
|
---|
23 | ;*******************************************************************************
|
---|
24 | %include "VBox/asmdefs.mac"
|
---|
25 | %include "VBox/x86.mac"
|
---|
26 |
|
---|
27 |
|
---|
28 | ;*******************************************************************************
|
---|
29 | ;* Defined Constants And Macros *
|
---|
30 | ;*******************************************************************************
|
---|
31 | ;; save all registers before loading special values for the faulting.
|
---|
32 | %macro SaveAndLoadAll 0
|
---|
33 | pushad
|
---|
34 | push ds
|
---|
35 | push es
|
---|
36 | push fs
|
---|
37 | push gs
|
---|
38 | call NAME(vmmGCTestLoadRegs)
|
---|
39 | %endmacro
|
---|
40 |
|
---|
41 | ;; restore all registers after faulting.
|
---|
42 | %macro RestoreAll 0
|
---|
43 | pop gs
|
---|
44 | pop fs
|
---|
45 | pop es
|
---|
46 | pop ds
|
---|
47 | popad
|
---|
48 | %endmacro
|
---|
49 |
|
---|
50 |
|
---|
51 | ;*******************************************************************************
|
---|
52 | ;* External Symbols *
|
---|
53 | ;*******************************************************************************
|
---|
54 | extern IMPNAME(g_Logger)
|
---|
55 | extern IMPNAME(g_RelLogger)
|
---|
56 | extern NAME(RTLogLogger)
|
---|
57 |
|
---|
58 |
|
---|
59 | BEGINCODE
|
---|
60 |
|
---|
61 | ;/**
|
---|
62 | ; * Internal GC logger worker: Logger wrapper.
|
---|
63 | ; */
|
---|
64 | ;VMMGCDECL(void) vmmGCLoggerWrapper(const char *pszFormat, ...);
|
---|
65 | EXPORTEDNAME vmmGCLoggerWrapper
|
---|
66 | %ifdef __YASM__
|
---|
67 | %ifdef ASM_FORMAT_ELF
|
---|
68 | push dword IMP(g_Logger) ; YASM BUG #67! YASMCHECK!
|
---|
69 | %else
|
---|
70 | push IMP(g_Logger)
|
---|
71 | %endif
|
---|
72 | %else
|
---|
73 | push IMP(g_Logger)
|
---|
74 | %endif
|
---|
75 | call NAME(RTLogLogger)
|
---|
76 | add esp, byte 4
|
---|
77 | ret
|
---|
78 | ENDPROC vmmGCLoggerWrapper
|
---|
79 |
|
---|
80 |
|
---|
81 | ;/**
|
---|
82 | ; * Internal GC logger worker: Logger (release) wrapper.
|
---|
83 | ; */
|
---|
84 | ;VMMGCDECL(void) vmmGCRelLoggerWrapper(const char *pszFormat, ...);
|
---|
85 | EXPORTEDNAME vmmGCRelLoggerWrapper
|
---|
86 | %ifdef __YASM__
|
---|
87 | %ifdef ASM_FORMAT_ELF
|
---|
88 | push dword IMP(g_RelLogger) ; YASM BUG #67! YASMCHECK!
|
---|
89 | %else
|
---|
90 | push IMP(g_RelLogger)
|
---|
91 | %endif
|
---|
92 | %else
|
---|
93 | push IMP(g_RelLogger)
|
---|
94 | %endif
|
---|
95 | call NAME(RTLogLogger)
|
---|
96 | add esp, byte 4
|
---|
97 | ret
|
---|
98 | ENDPROC vmmGCRelLoggerWrapper
|
---|
99 |
|
---|
100 |
|
---|
101 | ;;
|
---|
102 | ; Enables write protection.
|
---|
103 | BEGINPROC vmmGCEnableWP
|
---|
104 | push eax
|
---|
105 | mov eax, cr0
|
---|
106 | or eax, X86_CR0_WRITE_PROTECT
|
---|
107 | mov cr0, eax
|
---|
108 | pop eax
|
---|
109 | ret
|
---|
110 | ENDPROC vmmGCEnableWP
|
---|
111 |
|
---|
112 |
|
---|
113 | ;;
|
---|
114 | ; Disables write protection.
|
---|
115 | BEGINPROC vmmGCDisableWP
|
---|
116 | push eax
|
---|
117 | mov eax, cr0
|
---|
118 | and eax, ~X86_CR0_WRITE_PROTECT
|
---|
119 | mov cr0, eax
|
---|
120 | pop eax
|
---|
121 | ret
|
---|
122 | ENDPROC vmmGCDisableWP
|
---|
123 |
|
---|
124 |
|
---|
125 | ;;
|
---|
126 | ; Load special register set expected upon faults.
|
---|
127 | ; All registers are changed.
|
---|
128 | BEGINPROC vmmGCTestLoadRegs
|
---|
129 | mov eax, ss
|
---|
130 | mov ds, eax
|
---|
131 | mov es, eax
|
---|
132 | mov fs, eax
|
---|
133 | mov gs, eax
|
---|
134 | mov edi, 001234567h
|
---|
135 | mov esi, 042000042h
|
---|
136 | mov ebp, 0ffeeddcch
|
---|
137 | mov ebx, 089abcdefh
|
---|
138 | mov ecx, 0ffffaaaah
|
---|
139 | mov edx, 077778888h
|
---|
140 | mov eax, 0f0f0f0f0h
|
---|
141 | ret
|
---|
142 | ENDPROC vmmGCTestLoadRegs
|
---|
143 |
|
---|
144 |
|
---|
145 | ;;
|
---|
146 | ; A Trap 3 testcase.
|
---|
147 | GLOBALNAME vmmGCTestTrap3
|
---|
148 | SaveAndLoadAll
|
---|
149 |
|
---|
150 | int 3
|
---|
151 | EXPORTEDNAME vmmGCTestTrap3_FaultEIP
|
---|
152 |
|
---|
153 | RestoreAll
|
---|
154 | mov eax, 0ffffffffh
|
---|
155 | ret
|
---|
156 | ENDPROC vmmGCTestTrap3
|
---|
157 |
|
---|
158 |
|
---|
159 | ;;
|
---|
160 | ; A Trap 8 testcase.
|
---|
161 | GLOBALNAME vmmGCTestTrap8
|
---|
162 | SaveAndLoadAll
|
---|
163 |
|
---|
164 | sub esp, byte 8
|
---|
165 | sidt [esp]
|
---|
166 | mov word [esp], 111 ; make any #PF double fault.
|
---|
167 | lidt [esp]
|
---|
168 | add esp, byte 8
|
---|
169 |
|
---|
170 | COM_S_CHAR '!'
|
---|
171 |
|
---|
172 | xor eax, eax
|
---|
173 | EXPORTEDNAME vmmGCTestTrap8_FaultEIP
|
---|
174 | mov eax, [eax]
|
---|
175 |
|
---|
176 |
|
---|
177 | COM_S_CHAR '2'
|
---|
178 |
|
---|
179 | RestoreAll
|
---|
180 | mov eax, 0ffffffffh
|
---|
181 | ret
|
---|
182 | ENDPROC vmmGCTestTrap8
|
---|
183 |
|
---|
184 |
|
---|
185 | ;;
|
---|
186 | ; A simple Trap 0d testcase.
|
---|
187 | GLOBALNAME vmmGCTestTrap0d
|
---|
188 | SaveAndLoadAll
|
---|
189 |
|
---|
190 | push ds
|
---|
191 | EXPORTEDNAME vmmGCTestTrap0d_FaultEIP
|
---|
192 | ltr [esp]
|
---|
193 | pop eax
|
---|
194 |
|
---|
195 | RestoreAll
|
---|
196 | mov eax, 0ffffffffh
|
---|
197 | ret
|
---|
198 | ENDPROC vmmGCTestTrap0d
|
---|
199 |
|
---|
200 |
|
---|
201 | ;;
|
---|
202 | ; A simple Trap 0e testcase.
|
---|
203 | GLOBALNAME vmmGCTestTrap0e
|
---|
204 | SaveAndLoadAll
|
---|
205 |
|
---|
206 | xor eax, eax
|
---|
207 | EXPORTEDNAME vmmGCTestTrap0e_FaultEIP
|
---|
208 | mov eax, [eax]
|
---|
209 |
|
---|
210 | RestoreAll
|
---|
211 | mov eax, 0ffffffffh
|
---|
212 | ret
|
---|
213 |
|
---|
214 | EXPORTEDNAME vmmGCTestTrap0e_ResumeEIP
|
---|
215 | RestoreAll
|
---|
216 | xor eax, eax
|
---|
217 | ret
|
---|
218 | ENDPROC vmmGCTestTrap0e
|
---|
219 |
|
---|