VirtualBox

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

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

VMM: Fix restoring 32-bit guest FPU state on 64-bit capable VMs.

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