VirtualBox

source: vbox/trunk/src/VBox/VMM/CPUMInternal.mac@ 15962

Last change on this file since 15962 was 15962, checked in by vboxsync, 16 years ago

Added debugging code (inactive) for tracking the state of the 32/64 switcher in crash dumps

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.3 KB
Line 
1; $Id: CPUMInternal.mac 15962 2009-01-15 12:33:49Z vboxsync $
2;; @file
3; CPUM - Internal header file (asm).
4;
5
6;
7; Copyright (C) 2006-2007 Sun Microsystems, Inc.
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18; Clara, CA 95054 USA or visit http://www.sun.com if you need
19; additional information or have any questions.
20;
21
22%include "VBox/asmdefs.mac"
23
24%define CPUM_USED_FPU RT_BIT(0)
25%define CPUM_USED_FPU_SINCE_REM RT_BIT(1)
26%define CPUM_USE_SYSENTER RT_BIT(2)
27%define CPUM_USE_SYSCALL RT_BIT(3)
28%define CPUM_USE_DEBUG_REGS_HOST RT_BIT(4)
29%define CPUM_USE_DEBUG_REGS RT_BIT(5)
30%define CPUM_SYNC_FPU_STATE RT_BIT(7)
31%define CPUM_SYNC_DEBUG_STATE RT_BIT(8)
32
33%define CPUM_HANDLER_DS 1
34%define CPUM_HANDLER_ES 2
35%define CPUM_HANDLER_FS 3
36%define CPUM_HANDLER_GS 4
37%define CPUM_HANDLER_IRET 5
38%define CPUM_HANDLER_TYPEMASK 0ffh
39%define CPUM_HANDLER_CTXCORE_IN_EBP RT_BIT(31)
40
41%define VMMGCRET_USED_FPU 040000000h
42
43%define FPUSTATE_SIZE 512
44
45;; if anyone figures how to do %if HC_ARCH_BITS == 64 || defined(VBOX_WITH_HYBRID_32BIT_KERNEL) in
46; nasm please tell / fix this hack.
47%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
48 %define fVBOX_WITH_HYBRID_32BIT_KERNEL 1
49%else
50 %define fVBOX_WITH_HYBRID_32BIT_KERNEL 0
51%endif
52
53struc CPUM
54 ;
55 ; Hypervisor Context.
56 ;
57 alignb 64 ; the padding
58 .Hyper.fpu resb FPUSTATE_SIZE
59
60 .Hyper.edi resq 1
61 .Hyper.esi resq 1
62 .Hyper.ebp resq 1
63 .Hyper.eax resq 1
64 .Hyper.ebx resq 1
65 .Hyper.edx resq 1
66 .Hyper.ecx resq 1
67 .Hyper.esp resq 1
68 .Hyper.lss_esp resd 1
69 .Hyper.ss resw 1
70 .Hyper.ssPadding resw 1
71 .Hyper.gs resw 1
72 .Hyper.gsPadding resw 1
73 .Hyper.fs resw 1
74 .Hyper.fsPadding resw 1
75 .Hyper.es resw 1
76 .Hyper.esPadding resw 1
77 .Hyper.ds resw 1
78 .Hyper.dsPadding resw 1
79 .Hyper.cs resw 1
80 .Hyper.csPadding resw 3
81 .Hyper.eflags resq 1
82 .Hyper.eip resq 1
83 .Hyper.r8 resq 1
84 .Hyper.r9 resq 1
85 .Hyper.r10 resq 1
86 .Hyper.r11 resq 1
87 .Hyper.r12 resq 1
88 .Hyper.r13 resq 1
89 .Hyper.r14 resq 1
90 .Hyper.r15 resq 1
91
92 .Hyper.esHid.u64Base resq 1
93 .Hyper.esHid.u32Limit resd 1
94 .Hyper.esHid.Attr resd 1
95
96 .Hyper.csHid.u64Base resq 1
97 .Hyper.csHid.u32Limit resd 1
98 .Hyper.csHid.Attr resd 1
99
100 .Hyper.ssHid.u64Base resq 1
101 .Hyper.ssHid.u32Limit resd 1
102 .Hyper.ssHid.Attr resd 1
103
104 .Hyper.dsHid.u64Base resq 1
105 .Hyper.dsHid.u32Limit resd 1
106 .Hyper.dsHid.Attr resd 1
107
108 .Hyper.fsHid.u64Base resq 1
109 .Hyper.fsHid.u32Limit resd 1
110 .Hyper.fsHid.Attr resd 1
111
112 .Hyper.gsHid.u64Base resq 1
113 .Hyper.gsHid.u32Limit resd 1
114 .Hyper.gsHid.Attr resd 1
115
116 .Hyper.cr0 resq 1
117 .Hyper.cr2 resq 1
118 .Hyper.cr3 resq 1
119 .Hyper.cr4 resq 1
120
121 .Hyper.dr resq 8
122
123 .Hyper.gdtr resb 10 ; GDT limit + linear address
124 .Hyper.gdtrPadding resw 1
125 .Hyper.idtr resb 10 ; IDT limit + linear address
126 .Hyper.idtrPadding resw 1
127 .Hyper.ldtr resw 1
128 .Hyper.ldtrPadding resw 1
129 .Hyper.tr resw 1
130 .Hyper.trPadding resw 1
131
132 .Hyper.SysEnter.cs resb 8
133 .Hyper.SysEnter.eip resb 8
134 .Hyper.SysEnter.esp resb 8
135
136 .Hyper.msrEFER resb 8
137 .Hyper.msrSTAR resb 8
138 .Hyper.msrPAT resb 8
139 .Hyper.msrLSTAR resb 8
140 .Hyper.msrCSTAR resb 8
141 .Hyper.msrSFMASK resb 8
142 .Hyper.msrKERNELGSBASE resb 8
143
144 .Hyper.ldtrHid.u64Base resq 1
145 .Hyper.ldtrHid.u32Limit resd 1
146 .Hyper.ldtrHid.Attr resd 1
147
148 .Hyper.trHid.u64Base resq 1
149 .Hyper.trHid.u32Limit resd 1
150 .Hyper.trHid.Attr resd 1
151
152 ;
153 ; Other stuff.
154 ;
155 alignb 64
156 ; hypervisor core context.
157 .pHyperCoreR3 RTR3PTR_RES 1
158 .pHyperCoreR0 RTR0PTR_RES 1
159 .pHyperCoreRC RTRCPTR_RES 1
160 ;...
161 .ulOffCPUMCPU resd 1
162 .fValidHiddenSelRegs resd 1
163
164 ; CPUID eax=1
165 .CPUFeatures.edx resd 1
166 .CPUFeatures.ecx resd 1
167
168 ; CPUID eax=0x80000001
169 .CPUFeaturesExt.edx resd 1
170 .CPUFeaturesExt.ecx resd 1
171
172 .enmCPUVendor resd 1
173
174 ; CR4 masks
175 .CR4.AndMask resd 1
176 .CR4.OrMask resd 1
177 ; entered rawmode?
178 .fRawEntered resb 1
179%if RTHCPTR_CB == 8
180 .abPadding resb 7
181%else
182 .abPadding resb 3
183%endif
184
185 ; CPUID leafs
186 .aGuestCpuIdStd resb 16*6
187 .aGuestCpuIdExt resb 16*10
188 .aGuestCpuIdCentaur resb 16*4
189 .GuestCpuIdDef resb 16
190
191 alignb 64
192 ; CPUMCTX debug stuff...
193 .GuestEntry resb 1024
194endstruc
195
196struc CPUMCPU
197 ;
198 ; Host context state
199 ;
200 .Host.fpu resb FPUSTATE_SIZE
201
202%if HC_ARCH_BITS == 64 || fVBOX_WITH_HYBRID_32BIT_KERNEL
203 ;.Host.rax resq 1 - scratch
204 .Host.rbx resq 1
205 ;.Host.rcx resq 1 - scratch
206 ;.Host.rdx resq 1 - scratch
207 .Host.rdi resq 1
208 .Host.rsi resq 1
209 .Host.rbp resq 1
210 .Host.rsp resq 1
211 ;.Host.r8 resq 1 - scratch
212 ;.Host.r9 resq 1 - scratch
213 .Host.r10 resq 1
214 .Host.r11 resq 1
215 .Host.r12 resq 1
216 .Host.r13 resq 1
217 .Host.r14 resq 1
218 .Host.r15 resq 1
219 ;.Host.rip resd 1 - scratch
220 .Host.rflags resq 1
221%endif
222%if HC_ARCH_BITS == 32
223 ;.Host.eax resd 1 - scratch
224 .Host.ebx resd 1
225 ;.Host.edx resd 1 - scratch
226 ;.Host.ecx resd 1 - scratch
227 .Host.edi resd 1
228 .Host.esi resd 1
229 .Host.ebp resd 1
230 .Host.eflags resd 1
231 ;.Host.eip resd 1 - scratch
232 ; lss pair!
233 .Host.esp resd 1
234%endif
235 .Host.ss resw 1
236 .Host.ssPadding resw 1
237 .Host.gs resw 1
238 .Host.gsPadding resw 1
239 .Host.fs resw 1
240 .Host.fsPadding resw 1
241 .Host.es resw 1
242 .Host.esPadding resw 1
243 .Host.ds resw 1
244 .Host.dsPadding resw 1
245 .Host.cs resw 1
246 .Host.csPadding resw 1
247
248%if HC_ARCH_BITS == 32 && fVBOX_WITH_HYBRID_32BIT_KERNEL == 0
249 .Host.cr0 resd 1
250 ;.Host.cr2 resd 1 - scratch
251 .Host.cr3 resd 1
252 .Host.cr4 resd 1
253
254 .Host.dr0 resd 1
255 .Host.dr1 resd 1
256 .Host.dr2 resd 1
257 .Host.dr3 resd 1
258 .Host.dr6 resd 1
259 .Host.dr7 resd 1
260
261 .Host.gdtr resb 6 ; GDT limit + linear address
262 .Host.gdtrPadding resw 1
263 .Host.idtr resb 6 ; IDT limit + linear address
264 .Host.idtrPadding resw 1
265 .Host.ldtr resw 1
266 .Host.ldtrPadding resw 1
267 .Host.tr resw 1
268 .Host.trPadding resw 1
269
270 .Host.SysEnterPadding resd 1
271 .Host.SysEnter.cs resq 1
272 .Host.SysEnter.eip resq 1
273 .Host.SysEnter.esp resq 1
274 .Host.efer resq 1
275
276%else ; 64-bit
277
278 .Host.cr0 resq 1
279 ;.Host.cr2 resq 1 - scratch
280 .Host.cr3 resq 1
281 .Host.cr4 resq 1
282 .Host.cr8 resq 1
283
284 .Host.dr0 resq 1
285 .Host.dr1 resq 1
286 .Host.dr2 resq 1
287 .Host.dr3 resq 1
288 .Host.dr6 resq 1
289 .Host.dr7 resq 1
290
291 .Host.gdtr resb 10 ; GDT limit + linear address
292 .Host.gdtrPadding resw 1
293 .Host.idtr resb 10 ; IDT limit + linear address
294 .Host.idtrPadding resw 1
295 .Host.ldtr resw 1
296 .Host.ldtrPadding resw 1
297 .Host.tr resw 1
298 .Host.trPadding resw 1
299
300 .Host.SysEnter.cs resq 1
301 .Host.SysEnter.eip resq 1
302 .Host.SysEnter.esp resq 1
303 .Host.FSbase resq 1
304 .Host.GSbase resq 1
305 .Host.efer resq 1
306%endif ; 64-bit
307
308%ifdef VBOX_WITH_CRASHDUMP_MAGIC
309 .aMagic resb 56
310 .uMagic resq 1
311%endif
312 ;
313 ; Guest context state
314 ; (Identical to the .Hyper chunk above.)
315 ;
316 alignb 64
317 .Guest.fpu resb FPUSTATE_SIZE
318
319 .Guest.edi resq 1
320 .Guest.esi resq 1
321 .Guest.ebp resq 1
322 .Guest.eax resq 1
323 .Guest.ebx resq 1
324 .Guest.edx resq 1
325 .Guest.ecx resq 1
326 .Guest.esp resq 1
327 .Guest.lss_esp resd 1
328 .Guest.ss resw 1
329 .Guest.ssPadding resw 1
330 .Guest.gs resw 1
331 .Guest.gsPadding resw 1
332 .Guest.fs resw 1
333 .Guest.fsPadding resw 1
334 .Guest.es resw 1
335 .Guest.esPadding resw 1
336 .Guest.ds resw 1
337 .Guest.dsPadding resw 1
338 .Guest.cs resw 1
339 .Guest.csPadding resw 3
340 .Guest.eflags resq 1
341 .Guest.eip resq 1
342 .Guest.r8 resq 1
343 .Guest.r9 resq 1
344 .Guest.r10 resq 1
345 .Guest.r11 resq 1
346 .Guest.r12 resq 1
347 .Guest.r13 resq 1
348 .Guest.r14 resq 1
349 .Guest.r15 resq 1
350
351 .Guest.esHid.u64Base resq 1
352 .Guest.esHid.u32Limit resd 1
353 .Guest.esHid.Attr resd 1
354
355 .Guest.csHid.u64Base resq 1
356 .Guest.csHid.u32Limit resd 1
357 .Guest.csHid.Attr resd 1
358
359 .Guest.ssHid.u64Base resq 1
360 .Guest.ssHid.u32Limit resd 1
361 .Guest.ssHid.Attr resd 1
362
363 .Guest.dsHid.u64Base resq 1
364 .Guest.dsHid.u32Limit resd 1
365 .Guest.dsHid.Attr resd 1
366
367 .Guest.fsHid.u64Base resq 1
368 .Guest.fsHid.u32Limit resd 1
369 .Guest.fsHid.Attr resd 1
370
371 .Guest.gsHid.u64Base resq 1
372 .Guest.gsHid.u32Limit resd 1
373 .Guest.gsHid.Attr resd 1
374
375 .Guest.cr0 resq 1
376 .Guest.cr2 resq 1
377 .Guest.cr3 resq 1
378 .Guest.cr4 resq 1
379
380 .Guest.dr resq 8
381
382 .Guest.gdtr.cbGdt resw 1
383 .Guest.gdtr.pGdt resq 1
384 .Guest.gdtrPadding resw 1
385 .Guest.idtr.cbIdt resw 1
386 .Guest.idtr.pIdt resq 1
387 .Guest.idtrPadding resw 1
388 .Guest.ldtr resw 1
389 .Guest.ldtrPadding resw 1
390 .Guest.tr resw 1
391 .Guest.trPadding resw 1
392
393 .Guest.SysEnter.cs resb 8
394 .Guest.SysEnter.eip resb 8
395 .Guest.SysEnter.esp resb 8
396
397 .Guest.msrEFER resb 8
398 .Guest.msrSTAR resb 8
399 .Guest.msrPAT resb 8
400 .Guest.msrLSTAR resb 8
401 .Guest.msrCSTAR resb 8
402 .Guest.msrSFMASK resb 8
403 .Guest.msrKERNELGSBASE resb 8
404
405 .Guest.ldtrHid.u64Base resq 1
406 .Guest.ldtrHid.u32Limit resd 1
407 .Guest.ldtrHid.Attr resd 1
408
409 .Guest.trHid.u64Base resq 1
410 .Guest.trHid.u32Limit resd 1
411 .Guest.trHid.Attr resd 1
412
413 .GuestMsr.au64 resq 64
414
415 .fUseFlags resd 1
416 .fChanged resd 1
417 .ulOffCPUM resd 1
418 .u32RetCode resd 1
419endstruc
420
421
422;;
423; Converts the CPUM pointer to CPUMCPU (for the first VMCPU)
424; @param %1 register name
425%macro CPUMCPU_FROM_CPUM 1
426 add %1, dword [%1 + CPUM.ulOffCPUMCPU]
427%endmacro
428
429;;
430; Converts the CPUMCPU pointer to CPUM (for the first VMCPU)
431; @param %1 register name
432%macro CPUM_FROM_CPUMCPU 1
433 sub %1, dword [%1 + CPUMCPU.ulOffCPUM]
434%endmacro
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette