VirtualBox

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

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

CPUM,IEM: Expose GuestFeatures and HostFeatures (exploded CPUID), making IEM use it. Early XSAVE/AVX guest support preps.

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