VirtualBox

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

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

Big step to separate VMM data structures for guest SMP. (pgm, em)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.4 KB
Line 
1; $Id: CPUMInternal.mac 18927 2009-04-16 11:41:38Z 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 .ulOffCPUMCPU resd 1
56 .fHostUseFlags resd 1
57
58 ; CPUID eax=1
59 .CPUFeatures.edx resd 1
60 .CPUFeatures.ecx resd 1
61
62 ; CPUID eax=0x80000001
63 .CPUFeaturesExt.edx resd 1
64 .CPUFeaturesExt.ecx resd 1
65
66 .enmCPUVendor resd 1
67
68 ; CR4 masks
69 .CR4.AndMask resd 1
70 .CR4.OrMask resd 1
71 ; entered rawmode?
72 .fRawEntered resb 1
73%if RTHCPTR_CB == 8
74 .abPadding resb 7
75%else
76 .abPadding resb 3
77%endif
78
79 ; CPUID leafs
80 .aGuestCpuIdStd resb 16*6
81 .aGuestCpuIdExt resb 16*10
82 .aGuestCpuIdCentaur resb 16*4
83 .GuestCpuIdDef resb 16
84
85 alignb 64
86 ; CPUMCTX debug stuff...
87 .GuestEntry resb 1024
88endstruc
89
90struc CPUMCPU
91 ;
92 ; Hypervisor Context.
93 ;
94 alignb 64 ; the padding
95 .Hyper.fpu resb FPUSTATE_SIZE
96
97 .Hyper.edi resq 1
98 .Hyper.esi resq 1
99 .Hyper.ebp resq 1
100 .Hyper.eax resq 1
101 .Hyper.ebx resq 1
102 .Hyper.edx resq 1
103 .Hyper.ecx resq 1
104 .Hyper.esp resq 1
105 .Hyper.lss_esp resd 1
106 .Hyper.ss resw 1
107 .Hyper.ssPadding resw 1
108 .Hyper.gs resw 1
109 .Hyper.gsPadding resw 1
110 .Hyper.fs resw 1
111 .Hyper.fsPadding resw 1
112 .Hyper.es resw 1
113 .Hyper.esPadding resw 1
114 .Hyper.ds resw 1
115 .Hyper.dsPadding resw 1
116 .Hyper.cs resw 1
117 .Hyper.csPadding resw 3
118 .Hyper.eflags resq 1
119 .Hyper.eip resq 1
120 .Hyper.r8 resq 1
121 .Hyper.r9 resq 1
122 .Hyper.r10 resq 1
123 .Hyper.r11 resq 1
124 .Hyper.r12 resq 1
125 .Hyper.r13 resq 1
126 .Hyper.r14 resq 1
127 .Hyper.r15 resq 1
128
129 .Hyper.esHid.u64Base resq 1
130 .Hyper.esHid.u32Limit resd 1
131 .Hyper.esHid.Attr resd 1
132
133 .Hyper.csHid.u64Base resq 1
134 .Hyper.csHid.u32Limit resd 1
135 .Hyper.csHid.Attr resd 1
136
137 .Hyper.ssHid.u64Base resq 1
138 .Hyper.ssHid.u32Limit resd 1
139 .Hyper.ssHid.Attr resd 1
140
141 .Hyper.dsHid.u64Base resq 1
142 .Hyper.dsHid.u32Limit resd 1
143 .Hyper.dsHid.Attr resd 1
144
145 .Hyper.fsHid.u64Base resq 1
146 .Hyper.fsHid.u32Limit resd 1
147 .Hyper.fsHid.Attr resd 1
148
149 .Hyper.gsHid.u64Base resq 1
150 .Hyper.gsHid.u32Limit resd 1
151 .Hyper.gsHid.Attr resd 1
152
153 .Hyper.cr0 resq 1
154 .Hyper.cr2 resq 1
155 .Hyper.cr3 resq 1
156 .Hyper.cr4 resq 1
157
158 .Hyper.dr resq 8
159
160 .Hyper.gdtr resb 10 ; GDT limit + linear address
161 .Hyper.gdtrPadding resw 1
162 .Hyper.idtr resb 10 ; IDT limit + linear address
163 .Hyper.idtrPadding resw 1
164 .Hyper.ldtr resw 1
165 .Hyper.ldtrPadding resw 1
166 .Hyper.tr resw 1
167 .Hyper.trPadding resw 1
168
169 .Hyper.SysEnter.cs resb 8
170 .Hyper.SysEnter.eip resb 8
171 .Hyper.SysEnter.esp resb 8
172
173 .Hyper.msrEFER resb 8
174 .Hyper.msrSTAR resb 8
175 .Hyper.msrPAT resb 8
176 .Hyper.msrLSTAR resb 8
177 .Hyper.msrCSTAR resb 8
178 .Hyper.msrSFMASK resb 8
179 .Hyper.msrKERNELGSBASE resb 8
180
181 .Hyper.ldtrHid.u64Base resq 1
182 .Hyper.ldtrHid.u32Limit resd 1
183 .Hyper.ldtrHid.Attr resd 1
184
185 .Hyper.trHid.u64Base resq 1
186 .Hyper.trHid.u32Limit resd 1
187 .Hyper.trHid.Attr resd 1
188
189 ;
190 ; Host context state
191 ;
192 .Host.fpu resb FPUSTATE_SIZE
193
194%if HC_ARCH_BITS == 64 || fVBOX_WITH_HYBRID_32BIT_KERNEL
195 ;.Host.rax resq 1 - scratch
196 .Host.rbx resq 1
197 ;.Host.rcx resq 1 - scratch
198 ;.Host.rdx resq 1 - scratch
199 .Host.rdi resq 1
200 .Host.rsi resq 1
201 .Host.rbp resq 1
202 .Host.rsp resq 1
203 ;.Host.r8 resq 1 - scratch
204 ;.Host.r9 resq 1 - scratch
205 .Host.r10 resq 1
206 .Host.r11 resq 1
207 .Host.r12 resq 1
208 .Host.r13 resq 1
209 .Host.r14 resq 1
210 .Host.r15 resq 1
211 ;.Host.rip resd 1 - scratch
212 .Host.rflags resq 1
213%endif
214%if HC_ARCH_BITS == 32
215 ;.Host.eax resd 1 - scratch
216 .Host.ebx resd 1
217 ;.Host.edx resd 1 - scratch
218 ;.Host.ecx resd 1 - scratch
219 .Host.edi resd 1
220 .Host.esi resd 1
221 .Host.ebp resd 1
222 .Host.eflags resd 1
223 ;.Host.eip resd 1 - scratch
224 ; lss pair!
225 .Host.esp resd 1
226%endif
227 .Host.ss resw 1
228 .Host.ssPadding resw 1
229 .Host.gs resw 1
230 .Host.gsPadding resw 1
231 .Host.fs resw 1
232 .Host.fsPadding resw 1
233 .Host.es resw 1
234 .Host.esPadding resw 1
235 .Host.ds resw 1
236 .Host.dsPadding resw 1
237 .Host.cs resw 1
238 .Host.csPadding resw 1
239
240%if HC_ARCH_BITS == 32 && fVBOX_WITH_HYBRID_32BIT_KERNEL == 0
241 .Host.cr0 resd 1
242 ;.Host.cr2 resd 1 - scratch
243 .Host.cr3 resd 1
244 .Host.cr4 resd 1
245
246 .Host.dr0 resd 1
247 .Host.dr1 resd 1
248 .Host.dr2 resd 1
249 .Host.dr3 resd 1
250 .Host.dr6 resd 1
251 .Host.dr7 resd 1
252
253 .Host.gdtr resb 6 ; GDT limit + linear address
254 .Host.gdtrPadding resw 1
255 .Host.idtr resb 6 ; IDT limit + linear address
256 .Host.idtrPadding resw 1
257 .Host.ldtr resw 1
258 .Host.ldtrPadding resw 1
259 .Host.tr resw 1
260 .Host.trPadding resw 1
261
262 .Host.SysEnterPadding resd 1
263 .Host.SysEnter.cs resq 1
264 .Host.SysEnter.eip resq 1
265 .Host.SysEnter.esp resq 1
266 .Host.efer resq 1
267
268%else ; 64-bit
269
270 .Host.cr0 resq 1
271 ;.Host.cr2 resq 1 - scratch
272 .Host.cr3 resq 1
273 .Host.cr4 resq 1
274 .Host.cr8 resq 1
275
276 .Host.dr0 resq 1
277 .Host.dr1 resq 1
278 .Host.dr2 resq 1
279 .Host.dr3 resq 1
280 .Host.dr6 resq 1
281 .Host.dr7 resq 1
282
283 .Host.gdtr resb 10 ; GDT limit + linear address
284 .Host.gdtrPadding resw 1
285 .Host.idtr resb 10 ; IDT limit + linear address
286 .Host.idtrPadding resw 1
287 .Host.ldtr resw 1
288 .Host.ldtrPadding resw 1
289 .Host.tr resw 1
290 .Host.trPadding resw 1
291
292 .Host.SysEnter.cs resq 1
293 .Host.SysEnter.eip resq 1
294 .Host.SysEnter.esp resq 1
295 .Host.FSbase resq 1
296 .Host.GSbase resq 1
297 .Host.efer resq 1
298%endif ; 64-bit
299
300%ifdef VBOX_WITH_CRASHDUMP_MAGIC
301 .aMagic resb 56
302 .uMagic resq 1
303%endif
304 ;
305 ; Guest context state
306 ; (Identical to the .Hyper chunk above.)
307 ;
308 alignb 64
309 .Guest.fpu resb FPUSTATE_SIZE
310
311 .Guest.edi resq 1
312 .Guest.esi resq 1
313 .Guest.ebp resq 1
314 .Guest.eax resq 1
315 .Guest.ebx resq 1
316 .Guest.edx resq 1
317 .Guest.ecx resq 1
318 .Guest.esp resq 1
319 .Guest.lss_esp resd 1
320 .Guest.ss resw 1
321 .Guest.ssPadding resw 1
322 .Guest.gs resw 1
323 .Guest.gsPadding resw 1
324 .Guest.fs resw 1
325 .Guest.fsPadding resw 1
326 .Guest.es resw 1
327 .Guest.esPadding resw 1
328 .Guest.ds resw 1
329 .Guest.dsPadding resw 1
330 .Guest.cs resw 1
331 .Guest.csPadding resw 3
332 .Guest.eflags resq 1
333 .Guest.eip resq 1
334 .Guest.r8 resq 1
335 .Guest.r9 resq 1
336 .Guest.r10 resq 1
337 .Guest.r11 resq 1
338 .Guest.r12 resq 1
339 .Guest.r13 resq 1
340 .Guest.r14 resq 1
341 .Guest.r15 resq 1
342
343 .Guest.esHid.u64Base resq 1
344 .Guest.esHid.u32Limit resd 1
345 .Guest.esHid.Attr resd 1
346
347 .Guest.csHid.u64Base resq 1
348 .Guest.csHid.u32Limit resd 1
349 .Guest.csHid.Attr resd 1
350
351 .Guest.ssHid.u64Base resq 1
352 .Guest.ssHid.u32Limit resd 1
353 .Guest.ssHid.Attr resd 1
354
355 .Guest.dsHid.u64Base resq 1
356 .Guest.dsHid.u32Limit resd 1
357 .Guest.dsHid.Attr resd 1
358
359 .Guest.fsHid.u64Base resq 1
360 .Guest.fsHid.u32Limit resd 1
361 .Guest.fsHid.Attr resd 1
362
363 .Guest.gsHid.u64Base resq 1
364 .Guest.gsHid.u32Limit resd 1
365 .Guest.gsHid.Attr resd 1
366
367 .Guest.cr0 resq 1
368 .Guest.cr2 resq 1
369 .Guest.cr3 resq 1
370 .Guest.cr4 resq 1
371
372 .Guest.dr resq 8
373
374 .Guest.gdtr.cbGdt resw 1
375 .Guest.gdtr.pGdt resq 1
376 .Guest.gdtrPadding resw 1
377 .Guest.idtr.cbIdt resw 1
378 .Guest.idtr.pIdt resq 1
379 .Guest.idtrPadding resw 1
380 .Guest.ldtr resw 1
381 .Guest.ldtrPadding resw 1
382 .Guest.tr resw 1
383 .Guest.trPadding resw 1
384
385 .Guest.SysEnter.cs resb 8
386 .Guest.SysEnter.eip resb 8
387 .Guest.SysEnter.esp resb 8
388
389 .Guest.msrEFER resb 8
390 .Guest.msrSTAR resb 8
391 .Guest.msrPAT resb 8
392 .Guest.msrLSTAR resb 8
393 .Guest.msrCSTAR resb 8
394 .Guest.msrSFMASK resb 8
395 .Guest.msrKERNELGSBASE resb 8
396
397 .Guest.ldtrHid.u64Base resq 1
398 .Guest.ldtrHid.u32Limit resd 1
399 .Guest.ldtrHid.Attr resd 1
400
401 .Guest.trHid.u64Base resq 1
402 .Guest.trHid.u32Limit resd 1
403 .Guest.trHid.Attr resd 1
404
405 .GuestMsr.au64 resq 64
406
407 ;
408 ; Other stuff.
409 ;
410 alignb 64
411 ; hypervisor core context.
412 .pHyperCoreR3 RTR3PTR_RES 1
413 .pHyperCoreR0 RTR0PTR_RES 1
414 .pHyperCoreRC RTRCPTR_RES 1
415
416 .fUseFlags resd 1
417 .fChanged resd 1
418 .ulOffCPUM resd 1
419 .u32RetCode resd 1
420
421%if RTHCPTR_CB == 8
422 .abPadding2 resb 28
423%else
424 .abPadding2 resb 36
425%endif
426
427endstruc
428
429
430;;
431; Converts the CPUM pointer to CPUMCPU (for the first VMCPU)
432; @param %1 register name
433%macro CPUMCPU_FROM_CPUM 1
434 add %1, dword [%1 + CPUM.ulOffCPUMCPU]
435%endmacro
436
437;;
438; Converts the CPUMCPU pointer to CPUM (for the first VMCPU)
439; @param %1 register name
440%macro CPUM_FROM_CPUMCPU 1
441 sub %1, dword [%1 + CPUMCPU.ulOffCPUM]
442%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