VirtualBox

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

Last change on this file since 56286 was 56286, checked in by vboxsync, 10 years ago

Cleaned up all grep hits for 'VMMGC'.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 17.8 KB
Line 
1; $Id: CPUMInternal.mac 56286 2015-06-09 11:06:39Z vboxsync $
2;; @file
3; CPUM - Internal header file (asm).
4;
5
6;
7; Copyright (C) 2006-2015 Oracle Corporation
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
18%include "VBox/asmdefs.mac"
19%include "VBox/vmm/cpum.mac"
20
21;;
22; CPU info
23struc CPUMINFO
24 .cMsrRanges resd 1 ; uint32_t
25 .fMsrMask resd 1 ; uint32_t
26 .cCpuIdLeaves resd 1 ; uint32_t
27 .iFirstExtCpuIdLeaf resd 1 ; uint32_t
28 .uPadding resd 1 ; uint32_t
29 .enmUnknownCpuIdMethod resd 1 ; CPUMUNKNOWNCPUID
30 .DefCpuId resb CPUMCPUID_size ; CPUMCPUID
31 .uScalableBusFreq resq 1 ; uint64_t
32 .paMsrRangesR0 RTR0PTR_RES 1 ; R0PTRTYPE(PCPUMMSRRANGE)
33 .paCpuIdLeavesR0 RTR0PTR_RES 1 ; R0PTRTYPE(PCPUMCPUIDLEAF)
34 .paMsrRangesR3 RTR3PTR_RES 1 ; R3PTRTYPE(PCPUMMSRRANGE)
35 .paCpuIdLeavesR3 RTR3PTR_RES 1 ; R3PTRTYPE(PCPUMCPUIDLEAF)
36 .paMsrRangesRC RTRCPTR_RES 1 ; RCPTRTYPE(PCPUMMSRRANGE)
37 .paCpuIdLeavesRC RTRCPTR_RES 1 ; RCPTRTYPE(PCPUMCPUIDLEAF)
38endstruc
39
40
41%define CPUM_USED_FPU RT_BIT(0)
42%define CPUM_USED_FPU_SINCE_REM RT_BIT(1)
43%define CPUM_USED_MANUAL_XMM_RESTORE RT_BIT(2)
44%define CPUM_USE_SYSENTER RT_BIT(3)
45%define CPUM_USE_SYSCALL RT_BIT(4)
46%define CPUM_USE_DEBUG_REGS_HOST RT_BIT(5)
47%define CPUM_USED_DEBUG_REGS_HOST RT_BIT(6)
48%define CPUM_USE_DEBUG_REGS_HYPER RT_BIT(7)
49%define CPUM_USED_DEBUG_REGS_HYPER RT_BIT(8)
50%define CPUM_USED_DEBUG_REGS_GUEST RT_BIT(9)
51%define CPUM_SYNC_FPU_STATE RT_BIT(16)
52%define CPUM_SYNC_DEBUG_REGS_GUEST RT_BIT(17)
53%define CPUM_SYNC_DEBUG_REGS_HYPER RT_BIT(18)
54%define CPUM_USE_FFXSR_LEAKY RT_BIT(19)
55%define CPUM_USE_SUPPORTS_LONGMODE RT_BIT(20)
56
57%define CPUM_HANDLER_DS 1
58%define CPUM_HANDLER_ES 2
59%define CPUM_HANDLER_FS 3
60%define CPUM_HANDLER_GS 4
61%define CPUM_HANDLER_IRET 5
62%define CPUM_HANDLER_TYPEMASK 0ffh
63%define CPUM_HANDLER_CTXCORE_IN_EBP RT_BIT(31)
64
65
66;; if anyone figures how to do %if HC_ARCH_BITS == 64 || defined(VBOX_WITH_HYBRID_32BIT_KERNEL) in
67; nasm please tell / fix this hack.
68%ifdef VBOX_WITH_HYBRID_32BIT_KERNEL
69 %define fVBOX_WITH_HYBRID_32BIT_KERNEL 1
70%else
71 %define fVBOX_WITH_HYBRID_32BIT_KERNEL 0
72%endif
73
74struc CPUM
75 ;...
76 .offCPUMCPU0 resd 1
77 .fHostUseFlags resd 1
78
79 ; CR4 masks
80 .CR4.AndMask resd 1
81 .CR4.OrMask resd 1
82 ; entered rawmode?
83 .u8PortableCpuIdLevel resb 1
84 .fPendingRestore resb 1
85
86 alignb 8
87 .fXStateGuestMask resq 1
88 .fXStateHostMask resq 1
89
90 alignb 64
91 .HostFeatures resb 32
92 .GuestFeatures resb 32
93 .GuestInfo resb RTHCPTR_CB*4 + RTRCPTR_CB*2 + 4*12
94
95 ; Patch manager saved state compatability CPUID leaf arrays
96 .aGuestCpuIdPatmStd resb 16*6
97 .aGuestCpuIdPatmExt resb 16*10
98 .aGuestCpuIdPatmCentaur resb 16*4
99
100 alignb 8
101 .cMsrWrites resq 1
102 .cMsrWritesToIgnoredBits resq 1
103 .cMsrWritesRaiseGp resq 1
104 .cMsrWritesUnknown resq 1
105 .cMsrReads resq 1
106 .cMsrReadsRaiseGp resq 1
107 .cMsrReadsUnknown resq 1
108endstruc
109
110struc CPUMCPU
111 ;
112 ; Guest context state
113 ; (Identical to the .Hyper chunk below.)
114 ;
115 .Guest resq 0
116 .Guest.eax resq 1
117 .Guest.ecx resq 1
118 .Guest.edx resq 1
119 .Guest.ebx resq 1
120 .Guest.esp resq 1
121 .Guest.ebp resq 1
122 .Guest.esi resq 1
123 .Guest.edi resq 1
124 .Guest.r8 resq 1
125 .Guest.r9 resq 1
126 .Guest.r10 resq 1
127 .Guest.r11 resq 1
128 .Guest.r12 resq 1
129 .Guest.r13 resq 1
130 .Guest.r14 resq 1
131 .Guest.r15 resq 1
132 .Guest.es.Sel resw 1
133 .Guest.es.PaddingSel resw 1
134 .Guest.es.ValidSel resw 1
135 .Guest.es.fFlags resw 1
136 .Guest.es.u64Base resq 1
137 .Guest.es.u32Limit resd 1
138 .Guest.es.Attr resd 1
139 .Guest.cs.Sel resw 1
140 .Guest.cs.PaddingSel resw 1
141 .Guest.cs.ValidSel resw 1
142 .Guest.cs.fFlags resw 1
143 .Guest.cs.u64Base resq 1
144 .Guest.cs.u32Limit resd 1
145 .Guest.cs.Attr resd 1
146 .Guest.ss.Sel resw 1
147 .Guest.ss.PaddingSel resw 1
148 .Guest.ss.ValidSel resw 1
149 .Guest.ss.fFlags resw 1
150 .Guest.ss.u64Base resq 1
151 .Guest.ss.u32Limit resd 1
152 .Guest.ss.Attr resd 1
153 .Guest.ds.Sel resw 1
154 .Guest.ds.PaddingSel resw 1
155 .Guest.ds.ValidSel resw 1
156 .Guest.ds.fFlags resw 1
157 .Guest.ds.u64Base resq 1
158 .Guest.ds.u32Limit resd 1
159 .Guest.ds.Attr resd 1
160 .Guest.fs.Sel resw 1
161 .Guest.fs.PaddingSel resw 1
162 .Guest.fs.ValidSel resw 1
163 .Guest.fs.fFlags resw 1
164 .Guest.fs.u64Base resq 1
165 .Guest.fs.u32Limit resd 1
166 .Guest.fs.Attr resd 1
167 .Guest.gs.Sel resw 1
168 .Guest.gs.PaddingSel resw 1
169 .Guest.gs.ValidSel resw 1
170 .Guest.gs.fFlags resw 1
171 .Guest.gs.u64Base resq 1
172 .Guest.gs.u32Limit resd 1
173 .Guest.gs.Attr resd 1
174 .Guest.eip resq 1
175 .Guest.eflags resq 1
176 .Guest.cr0 resq 1
177 .Guest.cr2 resq 1
178 .Guest.cr3 resq 1
179 .Guest.cr4 resq 1
180 .Guest.dr resq 8
181 .Guest.gdtrPadding resw 3
182 .Guest.gdtr resw 0
183 .Guest.gdtr.cbGdt resw 1
184 .Guest.gdtr.pGdt resq 1
185 .Guest.idtrPadding resw 3
186 .Guest.idtr resw 0
187 .Guest.idtr.cbIdt resw 1
188 .Guest.idtr.pIdt resq 1
189 .Guest.ldtr.Sel resw 1
190 .Guest.ldtr.PaddingSel resw 1
191 .Guest.ldtr.ValidSel resw 1
192 .Guest.ldtr.fFlags resw 1
193 .Guest.ldtr.u64Base resq 1
194 .Guest.ldtr.u32Limit resd 1
195 .Guest.ldtr.Attr resd 1
196 .Guest.tr.Sel resw 1
197 .Guest.tr.PaddingSel resw 1
198 .Guest.tr.ValidSel resw 1
199 .Guest.tr.fFlags resw 1
200 .Guest.tr.u64Base resq 1
201 .Guest.tr.u32Limit resd 1
202 .Guest.tr.Attr resd 1
203 .Guest.SysEnter.cs resb 8
204 .Guest.SysEnter.eip resb 8
205 .Guest.SysEnter.esp resb 8
206 .Guest.msrEFER resb 8
207 .Guest.msrSTAR resb 8
208 .Guest.msrPAT resb 8
209 .Guest.msrLSTAR resb 8
210 .Guest.msrCSTAR resb 8
211 .Guest.msrSFMASK resb 8
212 .Guest.msrKERNELGSBASE resb 8
213 .Guest.msrApicBase resb 8
214 .Guest.aXcr resq 2
215 .Guest.fXStateMask resq 1
216 .Guest.pXStateR0 RTR0PTR_RES 1
217 .Guest.pXStateR3 RTR3PTR_RES 1
218 .Guest.pXStateRC RTRCPTR_RES 1
219 .Guest.aoffXState resw 64
220
221 alignb 64
222 .GuestMsrs resq 0
223 .GuestMsrs.au64 resq 64
224
225 ;
226 ; Other stuff.
227 ;
228 .fUseFlags resd 1
229 .fChanged resd 1
230 .offCPUM resd 1
231 .u32RetCode resd 1
232
233%ifdef VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI
234 .pvApicBase RTR0PTR_RES 1
235 .fApicDisVectors resd 1
236 .fX2Apic resb 1
237%else
238 .abPadding3 resb (RTR0PTR_CB + 4 + 1)
239%endif
240
241 .fRawEntered resb 1
242 .fRemEntered resb 1
243
244 .abPadding2 resb (64 - 16 - RTR0PTR_CB - 4 - 1 - 2)
245
246 ;
247 ; Host context state
248 ;
249 alignb 64
250 .Host resb 0
251%if HC_ARCH_BITS == 64 || fVBOX_WITH_HYBRID_32BIT_KERNEL
252 ;.Host.rax resq 1 - scratch
253 .Host.rbx resq 1
254 ;.Host.rcx resq 1 - scratch
255 ;.Host.rdx resq 1 - scratch
256 .Host.rdi resq 1
257 .Host.rsi resq 1
258 .Host.rbp resq 1
259 .Host.rsp resq 1
260 ;.Host.r8 resq 1 - scratch
261 ;.Host.r9 resq 1 - scratch
262 .Host.r10 resq 1
263 .Host.r11 resq 1
264 .Host.r12 resq 1
265 .Host.r13 resq 1
266 .Host.r14 resq 1
267 .Host.r15 resq 1
268 ;.Host.rip resd 1 - scratch
269 .Host.rflags resq 1
270%endif
271%if HC_ARCH_BITS == 32
272 ;.Host.eax resd 1 - scratch
273 .Host.ebx resd 1
274 ;.Host.edx resd 1 - scratch
275 ;.Host.ecx resd 1 - scratch
276 .Host.edi resd 1
277 .Host.esi resd 1
278 .Host.ebp resd 1
279 .Host.eflags resd 1
280 ;.Host.eip resd 1 - scratch
281 ; lss pair!
282 .Host.esp resd 1
283%endif
284 .Host.ss resw 1
285 .Host.ssPadding resw 1
286 .Host.gs resw 1
287 .Host.gsPadding resw 1
288 .Host.fs resw 1
289 .Host.fsPadding resw 1
290 .Host.es resw 1
291 .Host.esPadding resw 1
292 .Host.ds resw 1
293 .Host.dsPadding resw 1
294 .Host.cs resw 1
295 .Host.csPadding resw 1
296
297%if HC_ARCH_BITS == 32 && fVBOX_WITH_HYBRID_32BIT_KERNEL == 0
298 .Host.cr0 resd 1
299 ;.Host.cr2 resd 1 - scratch
300 .Host.cr3 resd 1
301 .Host.cr4 resd 1
302
303 .Host.dr0 resd 1
304 .Host.dr1 resd 1
305 .Host.dr2 resd 1
306 .Host.dr3 resd 1
307 .Host.dr6 resd 1
308 .Host.dr7 resd 1
309
310 .Host.gdtr resb 6 ; GDT limit + linear address
311 .Host.gdtrPadding resw 1
312 .Host.idtr resb 6 ; IDT limit + linear address
313 .Host.idtrPadding resw 1
314 .Host.ldtr resw 1
315 .Host.ldtrPadding resw 1
316 .Host.tr resw 1
317 .Host.trPadding resw 1
318
319 .Host.SysEnterPadding resd 1
320 .Host.SysEnter.cs resq 1
321 .Host.SysEnter.eip resq 1
322 .Host.SysEnter.esp resq 1
323 .Host.efer resq 1
324 .Host.auPadding resb (20)
325
326%else ; 64-bit
327
328 .Host.cr0 resq 1
329 ;.Host.cr2 resq 1 - scratch
330 .Host.cr3 resq 1
331 .Host.cr4 resq 1
332 .Host.cr8 resq 1
333
334 .Host.dr0 resq 1
335 .Host.dr1 resq 1
336 .Host.dr2 resq 1
337 .Host.dr3 resq 1
338 .Host.dr6 resq 1
339 .Host.dr7 resq 1
340
341 .Host.gdtr resb 10 ; GDT limit + linear address
342 .Host.gdtrPadding resw 1
343 .Host.idtr resb 10 ; IDT limit + linear address
344 .Host.idtrPadding resw 1
345 .Host.ldtr resw 1
346 .Host.ldtrPadding resw 1
347 .Host.tr resw 1
348 .Host.trPadding resw 1
349
350 .Host.SysEnter.cs resq 1
351 .Host.SysEnter.eip resq 1
352 .Host.SysEnter.esp resq 1
353 .Host.FSbase resq 1
354 .Host.GSbase resq 1
355 .Host.efer resq 1
356 %if fVBOX_WITH_HYBRID_32BIT_KERNEL
357 .Host.auPadding resb 54
358 %else
359 .Host.auPadding resb 4
360 %endif
361%endif ; 64-bit
362 .Host.pXStateRC RTRCPTR_RES 1
363 alignb RTR0PTR_CB
364 .Host.pXStateR0 RTR0PTR_RES 1
365 .Host.pXStateR3 RTR3PTR_RES 1
366 alignb 8
367 .Host.xcr0 resq 1
368 .Host.fXStateMask resq 1
369
370 ;
371 ; Hypervisor Context (same as .Guest above).
372 ;
373 alignb 64
374 .Hyper resq 0
375 .Hyper.eax resq 1
376 .Hyper.ecx resq 1
377 .Hyper.edx resq 1
378 .Hyper.ebx resq 1
379 .Hyper.esp resq 1
380 .Hyper.ebp resq 1
381 .Hyper.esi resq 1
382 .Hyper.edi resq 1
383 .Hyper.r8 resq 1
384 .Hyper.r9 resq 1
385 .Hyper.r10 resq 1
386 .Hyper.r11 resq 1
387 .Hyper.r12 resq 1
388 .Hyper.r13 resq 1
389 .Hyper.r14 resq 1
390 .Hyper.r15 resq 1
391 .Hyper.es.Sel resw 1
392 .Hyper.es.PaddingSel resw 1
393 .Hyper.es.ValidSel resw 1
394 .Hyper.es.fFlags resw 1
395 .Hyper.es.u64Base resq 1
396 .Hyper.es.u32Limit resd 1
397 .Hyper.es.Attr resd 1
398 .Hyper.cs.Sel resw 1
399 .Hyper.cs.PaddingSel resw 1
400 .Hyper.cs.ValidSel resw 1
401 .Hyper.cs.fFlags resw 1
402 .Hyper.cs.u64Base resq 1
403 .Hyper.cs.u32Limit resd 1
404 .Hyper.cs.Attr resd 1
405 .Hyper.ss.Sel resw 1
406 .Hyper.ss.PaddingSel resw 1
407 .Hyper.ss.ValidSel resw 1
408 .Hyper.ss.fFlags resw 1
409 .Hyper.ss.u64Base resq 1
410 .Hyper.ss.u32Limit resd 1
411 .Hyper.ss.Attr resd 1
412 .Hyper.ds.Sel resw 1
413 .Hyper.ds.PaddingSel resw 1
414 .Hyper.ds.ValidSel resw 1
415 .Hyper.ds.fFlags resw 1
416 .Hyper.ds.u64Base resq 1
417 .Hyper.ds.u32Limit resd 1
418 .Hyper.ds.Attr resd 1
419 .Hyper.fs.Sel resw 1
420 .Hyper.fs.PaddingSel resw 1
421 .Hyper.fs.ValidSel resw 1
422 .Hyper.fs.fFlags resw 1
423 .Hyper.fs.u64Base resq 1
424 .Hyper.fs.u32Limit resd 1
425 .Hyper.fs.Attr resd 1
426 .Hyper.gs.Sel resw 1
427 .Hyper.gs.PaddingSel resw 1
428 .Hyper.gs.ValidSel resw 1
429 .Hyper.gs.fFlags resw 1
430 .Hyper.gs.u64Base resq 1
431 .Hyper.gs.u32Limit resd 1
432 .Hyper.gs.Attr resd 1
433 .Hyper.eip resq 1
434 .Hyper.eflags resq 1
435 .Hyper.cr0 resq 1
436 .Hyper.cr2 resq 1
437 .Hyper.cr3 resq 1
438 .Hyper.cr4 resq 1
439 .Hyper.dr resq 8
440 .Hyper.gdtrPadding resw 3
441 .Hyper.gdtr resw 0
442 .Hyper.gdtr.cbGdt resw 1
443 .Hyper.gdtr.pGdt resq 1
444 .Hyper.idtrPadding resw 3
445 .Hyper.idtr resw 0
446 .Hyper.idtr.cbIdt resw 1
447 .Hyper.idtr.pIdt resq 1
448 .Hyper.ldtr.Sel resw 1
449 .Hyper.ldtr.PaddingSel resw 1
450 .Hyper.ldtr.ValidSel resw 1
451 .Hyper.ldtr.fFlags resw 1
452 .Hyper.ldtr.u64Base resq 1
453 .Hyper.ldtr.u32Limit resd 1
454 .Hyper.ldtr.Attr resd 1
455 .Hyper.tr.Sel resw 1
456 .Hyper.tr.PaddingSel resw 1
457 .Hyper.tr.ValidSel resw 1
458 .Hyper.tr.fFlags resw 1
459 .Hyper.tr.u64Base resq 1
460 .Hyper.tr.u32Limit resd 1
461 .Hyper.tr.Attr resd 1
462 .Hyper.SysEnter.cs resb 8
463 .Hyper.SysEnter.eip resb 8
464 .Hyper.SysEnter.esp resb 8
465 .Hyper.msrEFER resb 8
466 .Hyper.msrSTAR resb 8
467 .Hyper.msrPAT resb 8
468 .Hyper.msrLSTAR resb 8
469 .Hyper.msrCSTAR resb 8
470 .Hyper.msrSFMASK resb 8
471 .Hyper.msrKERNELGSBASE resb 8
472 .Hyper.msrApicBase resb 8
473 .Hyper.aXcr resq 2
474 .Hyper.fXStateMask resq 1
475 .Hyper.pXStateR0 RTR0PTR_RES 1
476 .Hyper.pXStateR3 RTR3PTR_RES 1
477 .Hyper.pXStateRC RTRCPTR_RES 1
478 .Hyper.aoffXState resw 64
479 alignb 64
480
481%ifdef VBOX_WITH_CRASHDUMP_MAGIC
482 .aMagic resb 56
483 .uMagic resq 1
484%endif
485endstruc
486
487
488;;
489; Converts the CPUM pointer to CPUMCPU
490; @param %1 register name
491%macro CPUMCPU_FROM_CPUM 1
492 add %1, dword [%1 + CPUM.offCPUMCPU0]
493%endmacro
494
495;;
496; Converts the CPUM pointer to CPUMCPU
497; @param %1 register name (CPUM)
498; @param %2 register name (CPUMCPU offset)
499%macro CPUMCPU_FROM_CPUM_WITH_OFFSET 2
500 add %1, %2
501%endmacro
502
503;;
504; Converts the CPUMCPU pointer to CPUM
505; @param %1 register name
506%macro CPUM_FROM_CPUMCPU 1
507 sub %1, dword [%1 + CPUMCPU.offCPUM]
508%endmacro
509
510;;
511; Converts the CPUMCPU pointer to CPUM
512; @param %1 register name (CPUM)
513; @param %2 register name (CPUMCPU offset)
514%macro CPUM_FROM_CPUMCPU_WITH_OFFSET 2
515 sub %1, %2
516%endmacro
517
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