1 | ; $Id: VMMRCA.asm 35335 2010-12-27 12:34:40Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; VMMGC - Raw-mode Context Virtual Machine Monitor assembly routines.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ; Copyright (C) 2006-2007 Oracle Corporation
|
---|
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 |
|
---|
17 | ;*******************************************************************************
|
---|
18 | ;* Header Files *
|
---|
19 | ;*******************************************************************************
|
---|
20 | %include "VBox/asmdefs.mac"
|
---|
21 | %include "VBox/x86.mac"
|
---|
22 |
|
---|
23 |
|
---|
24 | ;*******************************************************************************
|
---|
25 | ;* Defined Constants And Macros *
|
---|
26 | ;*******************************************************************************
|
---|
27 | ;; save all registers before loading special values for the faulting.
|
---|
28 | %macro SaveAndLoadAll 0
|
---|
29 | pushad
|
---|
30 | push ds
|
---|
31 | push es
|
---|
32 | push fs
|
---|
33 | push gs
|
---|
34 | call NAME(vmmGCTestLoadRegs)
|
---|
35 | %endmacro
|
---|
36 |
|
---|
37 | ;; restore all registers after faulting.
|
---|
38 | %macro RestoreAll 0
|
---|
39 | pop gs
|
---|
40 | pop fs
|
---|
41 | pop es
|
---|
42 | pop ds
|
---|
43 | popad
|
---|
44 | %endmacro
|
---|
45 |
|
---|
46 |
|
---|
47 | ;*******************************************************************************
|
---|
48 | ;* External Symbols *
|
---|
49 | ;*******************************************************************************
|
---|
50 | extern IMPNAME(g_Logger)
|
---|
51 | extern IMPNAME(g_RelLogger)
|
---|
52 | extern NAME(RTLogLogger)
|
---|
53 |
|
---|
54 |
|
---|
55 | BEGINCODE
|
---|
56 |
|
---|
57 | ;/**
|
---|
58 | ; * Internal GC logger worker: Logger wrapper.
|
---|
59 | ; */
|
---|
60 | ;VMMRCDECL(void) vmmGCLoggerWrapper(const char *pszFormat, ...);
|
---|
61 | EXPORTEDNAME vmmGCLoggerWrapper
|
---|
62 | %ifdef __YASM__
|
---|
63 | %ifdef ASM_FORMAT_ELF
|
---|
64 | push dword IMP(g_Logger) ; YASM BUG #67! YASMCHECK!
|
---|
65 | %else
|
---|
66 | push IMP(g_Logger)
|
---|
67 | %endif
|
---|
68 | %else
|
---|
69 | push IMP(g_Logger)
|
---|
70 | %endif
|
---|
71 | call NAME(RTLogLogger)
|
---|
72 | add esp, byte 4
|
---|
73 | ret
|
---|
74 | ENDPROC vmmGCLoggerWrapper
|
---|
75 |
|
---|
76 |
|
---|
77 | ;/**
|
---|
78 | ; * Internal GC logger worker: Logger (release) wrapper.
|
---|
79 | ; */
|
---|
80 | ;VMMRCDECL(void) vmmGCRelLoggerWrapper(const char *pszFormat, ...);
|
---|
81 | EXPORTEDNAME vmmGCRelLoggerWrapper
|
---|
82 | %ifdef __YASM__
|
---|
83 | %ifdef ASM_FORMAT_ELF
|
---|
84 | push dword IMP(g_RelLogger) ; YASM BUG #67! YASMCHECK!
|
---|
85 | %else
|
---|
86 | push IMP(g_RelLogger)
|
---|
87 | %endif
|
---|
88 | %else
|
---|
89 | push IMP(g_RelLogger)
|
---|
90 | %endif
|
---|
91 | call NAME(RTLogLogger)
|
---|
92 | add esp, byte 4
|
---|
93 | ret
|
---|
94 | ENDPROC vmmGCRelLoggerWrapper
|
---|
95 |
|
---|
96 |
|
---|
97 | ;;
|
---|
98 | ; Enables write protection.
|
---|
99 | BEGINPROC vmmGCEnableWP
|
---|
100 | push eax
|
---|
101 | mov eax, cr0
|
---|
102 | or eax, X86_CR0_WRITE_PROTECT
|
---|
103 | mov cr0, eax
|
---|
104 | pop eax
|
---|
105 | ret
|
---|
106 | ENDPROC vmmGCEnableWP
|
---|
107 |
|
---|
108 |
|
---|
109 | ;;
|
---|
110 | ; Disables write protection.
|
---|
111 | BEGINPROC vmmGCDisableWP
|
---|
112 | push eax
|
---|
113 | mov eax, cr0
|
---|
114 | and eax, ~X86_CR0_WRITE_PROTECT
|
---|
115 | mov cr0, eax
|
---|
116 | pop eax
|
---|
117 | ret
|
---|
118 | ENDPROC vmmGCDisableWP
|
---|
119 |
|
---|
120 |
|
---|
121 | ;;
|
---|
122 | ; Load special register set expected upon faults.
|
---|
123 | ; All registers are changed.
|
---|
124 | BEGINPROC vmmGCTestLoadRegs
|
---|
125 | mov eax, ss
|
---|
126 | mov ds, eax
|
---|
127 | mov es, eax
|
---|
128 | mov fs, eax
|
---|
129 | mov gs, eax
|
---|
130 | mov edi, 001234567h
|
---|
131 | mov esi, 042000042h
|
---|
132 | mov ebp, 0ffeeddcch
|
---|
133 | mov ebx, 089abcdefh
|
---|
134 | mov ecx, 0ffffaaaah
|
---|
135 | mov edx, 077778888h
|
---|
136 | mov eax, 0f0f0f0f0h
|
---|
137 | ret
|
---|
138 | ENDPROC vmmGCTestLoadRegs
|
---|
139 |
|
---|
140 |
|
---|
141 | ;;
|
---|
142 | ; A Trap 3 testcase.
|
---|
143 | GLOBALNAME vmmGCTestTrap3
|
---|
144 | SaveAndLoadAll
|
---|
145 |
|
---|
146 | int 3
|
---|
147 | EXPORTEDNAME vmmGCTestTrap3_FaultEIP
|
---|
148 |
|
---|
149 | RestoreAll
|
---|
150 | mov eax, 0ffffffffh
|
---|
151 | ret
|
---|
152 | ENDPROC vmmGCTestTrap3
|
---|
153 |
|
---|
154 |
|
---|
155 | ;;
|
---|
156 | ; A Trap 8 testcase.
|
---|
157 | GLOBALNAME vmmGCTestTrap8
|
---|
158 | SaveAndLoadAll
|
---|
159 |
|
---|
160 | sub esp, byte 8
|
---|
161 | sidt [esp]
|
---|
162 | mov word [esp], 111 ; make any #PF double fault.
|
---|
163 | lidt [esp]
|
---|
164 | add esp, byte 8
|
---|
165 |
|
---|
166 | COM_S_CHAR '!'
|
---|
167 |
|
---|
168 | xor eax, eax
|
---|
169 | EXPORTEDNAME vmmGCTestTrap8_FaultEIP
|
---|
170 | mov eax, [eax]
|
---|
171 |
|
---|
172 |
|
---|
173 | COM_S_CHAR '2'
|
---|
174 |
|
---|
175 | RestoreAll
|
---|
176 | mov eax, 0ffffffffh
|
---|
177 | ret
|
---|
178 | ENDPROC vmmGCTestTrap8
|
---|
179 |
|
---|
180 |
|
---|
181 | ;;
|
---|
182 | ; A simple Trap 0d testcase.
|
---|
183 | GLOBALNAME vmmGCTestTrap0d
|
---|
184 | SaveAndLoadAll
|
---|
185 |
|
---|
186 | push ds
|
---|
187 | EXPORTEDNAME vmmGCTestTrap0d_FaultEIP
|
---|
188 | ltr [esp]
|
---|
189 | pop eax
|
---|
190 |
|
---|
191 | RestoreAll
|
---|
192 | mov eax, 0ffffffffh
|
---|
193 | ret
|
---|
194 | ENDPROC vmmGCTestTrap0d
|
---|
195 |
|
---|
196 |
|
---|
197 | ;;
|
---|
198 | ; A simple Trap 0e testcase.
|
---|
199 | GLOBALNAME vmmGCTestTrap0e
|
---|
200 | SaveAndLoadAll
|
---|
201 |
|
---|
202 | xor eax, eax
|
---|
203 | EXPORTEDNAME vmmGCTestTrap0e_FaultEIP
|
---|
204 | mov eax, [eax]
|
---|
205 |
|
---|
206 | RestoreAll
|
---|
207 | mov eax, 0ffffffffh
|
---|
208 | ret
|
---|
209 |
|
---|
210 | EXPORTEDNAME vmmGCTestTrap0e_ResumeEIP
|
---|
211 | RestoreAll
|
---|
212 | xor eax, eax
|
---|
213 | ret
|
---|
214 | ENDPROC vmmGCTestTrap0e
|
---|
215 |
|
---|