VirtualBox

source: vbox/trunk/include/VBox/vmm/cpumctx.h@ 89363

Last change on this file since 89363 was 87522, checked in by vboxsync, 4 years ago

VMM/HM: Moved CPUMCTX::fWorldSwitcher to HMR0PERVCPU::fWorldSwitcher. bugref:9453 bugref:9087

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 55.8 KB
Line 
1/** @file
2 * CPUM - CPU Monitor(/ Manager), Context Structures.
3 */
4
5/*
6 * Copyright (C) 2006-2020 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef VBOX_INCLUDED_vmm_cpumctx_h
27#define VBOX_INCLUDED_vmm_cpumctx_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#ifndef VBOX_FOR_DTRACE_LIB
33# include <iprt/x86.h>
34# include <VBox/types.h>
35# include <VBox/vmm/hm_svm.h>
36# include <VBox/vmm/hm_vmx.h>
37#else
38# pragma D depends_on library x86.d
39#endif
40
41
42RT_C_DECLS_BEGIN
43
44/** @defgroup grp_cpum_ctx The CPUM Context Structures
45 * @ingroup grp_cpum
46 * @{
47 */
48
49/**
50 * Selector hidden registers.
51 */
52typedef struct CPUMSELREG
53{
54 /** The selector register. */
55 RTSEL Sel;
56 /** Padding, don't use. */
57 RTSEL PaddingSel;
58 /** The selector which info resides in u64Base, u32Limit and Attr, provided
59 * that CPUMSELREG_FLAGS_VALID is set. */
60 RTSEL ValidSel;
61 /** Flags, see CPUMSELREG_FLAGS_XXX. */
62 uint16_t fFlags;
63
64 /** Base register.
65 *
66 * Long mode remarks:
67 * - Unused in long mode for CS, DS, ES, SS
68 * - 32 bits for FS & GS; FS(GS)_BASE msr used for the base address
69 * - 64 bits for TR & LDTR
70 */
71 uint64_t u64Base;
72 /** Limit (expanded). */
73 uint32_t u32Limit;
74 /** Flags.
75 * This is the high 32-bit word of the descriptor entry.
76 * Only the flags, dpl and type are used. */
77 X86DESCATTR Attr;
78} CPUMSELREG;
79#ifndef VBOX_FOR_DTRACE_LIB
80AssertCompileSize(CPUMSELREG, 24);
81#endif
82
83/** @name CPUMSELREG_FLAGS_XXX - CPUMSELREG::fFlags values.
84 * @{ */
85#define CPUMSELREG_FLAGS_VALID UINT16_C(0x0001)
86#define CPUMSELREG_FLAGS_STALE UINT16_C(0x0002)
87#define CPUMSELREG_FLAGS_VALID_MASK UINT16_C(0x0003)
88/** @} */
89
90/** Checks if the hidden parts of the selector register are valid. */
91#define CPUMSELREG_ARE_HIDDEN_PARTS_VALID(a_pVCpu, a_pSelReg) \
92 ( ((a_pSelReg)->fFlags & CPUMSELREG_FLAGS_VALID) \
93 && (a_pSelReg)->ValidSel == (a_pSelReg)->Sel )
94
95/** Old type used for the hidden register part.
96 * @deprecated */
97typedef CPUMSELREG CPUMSELREGHID;
98
99/**
100 * The sysenter register set.
101 */
102typedef struct CPUMSYSENTER
103{
104 /** Ring 0 cs.
105 * This value + 8 is the Ring 0 ss.
106 * This value + 16 is the Ring 3 cs.
107 * This value + 24 is the Ring 3 ss.
108 */
109 uint64_t cs;
110 /** Ring 0 eip. */
111 uint64_t eip;
112 /** Ring 0 esp. */
113 uint64_t esp;
114} CPUMSYSENTER;
115
116/** @def CPUM_UNION_NM
117 * For compilers (like DTrace) that does not grok nameless unions, we have a
118 * little hack to make them palatable.
119 */
120/** @def CPUM_STRUCT_NM
121 * For compilers (like DTrace) that does not grok nameless structs (it is
122 * non-standard C++), we have a little hack to make them palatable.
123 */
124#ifdef VBOX_FOR_DTRACE_LIB
125# define CPUM_UNION_NM(a_Nm) a_Nm
126# define CPUM_STRUCT_NM(a_Nm) a_Nm
127#elif defined(IPRT_WITHOUT_NAMED_UNIONS_AND_STRUCTS)
128# define CPUM_UNION_NM(a_Nm) a_Nm
129# define CPUM_STRUCT_NM(a_Nm) a_Nm
130#else
131# define CPUM_UNION_NM(a_Nm)
132# define CPUM_STRUCT_NM(a_Nm)
133#endif
134/** @def CPUM_UNION_STRUCT_NM
135 * Combines CPUM_UNION_NM and CPUM_STRUCT_NM to avoid hitting the right side of
136 * the screen in the compile time assertions.
137 */
138#define CPUM_UNION_STRUCT_NM(a_UnionNm, a_StructNm) CPUM_UNION_NM(a_UnionNm .) CPUM_STRUCT_NM(a_StructNm)
139
140/** A general register (union). */
141typedef union CPUMCTXGREG
142{
143 /** Natural unsigned integer view. */
144 uint64_t u;
145 /** 64-bit view. */
146 uint64_t u64;
147 /** 32-bit view. */
148 uint32_t u32;
149 /** 16-bit view. */
150 uint16_t u16;
151 /** 8-bit view. */
152 uint8_t u8;
153 /** 8-bit low/high view. */
154 RT_GCC_EXTENSION struct
155 {
156 /** Low byte (al, cl, dl, bl, ++). */
157 uint8_t bLo;
158 /** High byte in the first word - ah, ch, dh, bh. */
159 uint8_t bHi;
160 } CPUM_STRUCT_NM(s);
161} CPUMCTXGREG;
162#ifndef VBOX_FOR_DTRACE_LIB
163AssertCompileSize(CPUMCTXGREG, 8);
164AssertCompileMemberOffset(CPUMCTXGREG, CPUM_STRUCT_NM(s.) bLo, 0);
165AssertCompileMemberOffset(CPUMCTXGREG, CPUM_STRUCT_NM(s.) bHi, 1);
166#endif
167
168
169
170/**
171 * CPU context core.
172 *
173 * @todo Eliminate this structure!
174 * @deprecated We don't push any context cores any more in TRPM.
175 */
176#pragma pack(1)
177typedef struct CPUMCTXCORE
178{
179 /** @name General Register.
180 * @note These follow the encoding order (X86_GREG_XXX) and can be accessed as
181 * an array starting a rax.
182 * @{ */
183 union
184 {
185 uint8_t al;
186 uint16_t ax;
187 uint32_t eax;
188 uint64_t rax;
189 } CPUM_UNION_NM(rax);
190 union
191 {
192 uint8_t cl;
193 uint16_t cx;
194 uint32_t ecx;
195 uint64_t rcx;
196 } CPUM_UNION_NM(rcx);
197 union
198 {
199 uint8_t dl;
200 uint16_t dx;
201 uint32_t edx;
202 uint64_t rdx;
203 } CPUM_UNION_NM(rdx);
204 union
205 {
206 uint8_t bl;
207 uint16_t bx;
208 uint32_t ebx;
209 uint64_t rbx;
210 } CPUM_UNION_NM(rbx);
211 union
212 {
213 uint16_t sp;
214 uint32_t esp;
215 uint64_t rsp;
216 } CPUM_UNION_NM(rsp);
217 union
218 {
219 uint16_t bp;
220 uint32_t ebp;
221 uint64_t rbp;
222 } CPUM_UNION_NM(rbp);
223 union
224 {
225 uint8_t sil;
226 uint16_t si;
227 uint32_t esi;
228 uint64_t rsi;
229 } CPUM_UNION_NM(rsi);
230 union
231 {
232 uint8_t dil;
233 uint16_t di;
234 uint32_t edi;
235 uint64_t rdi;
236 } CPUM_UNION_NM(rdi);
237 uint64_t r8;
238 uint64_t r9;
239 uint64_t r10;
240 uint64_t r11;
241 uint64_t r12;
242 uint64_t r13;
243 uint64_t r14;
244 uint64_t r15;
245 /** @} */
246
247 /** @name Segment registers.
248 * @note These follow the encoding order (X86_SREG_XXX) and can be accessed as
249 * an array starting a es.
250 * @{ */
251 CPUMSELREG es;
252 CPUMSELREG cs;
253 CPUMSELREG ss;
254 CPUMSELREG ds;
255 CPUMSELREG fs;
256 CPUMSELREG gs;
257 /** @} */
258
259 /** The program counter. */
260 union
261 {
262 uint16_t ip;
263 uint32_t eip;
264 uint64_t rip;
265 } CPUM_UNION_NM(rip);
266
267 /** The flags register. */
268 union
269 {
270 X86EFLAGS eflags;
271 X86RFLAGS rflags;
272 } CPUM_UNION_NM(rflags);
273
274} CPUMCTXCORE;
275#pragma pack()
276
277
278/**
279 * SVM Host-state area (Nested Hw.virt - VirtualBox's layout).
280 *
281 * @warning Exercise caution while modifying the layout of this struct. It's
282 * part of VM saved states.
283 */
284#pragma pack(1)
285typedef struct SVMHOSTSTATE
286{
287 uint64_t uEferMsr;
288 uint64_t uCr0;
289 uint64_t uCr4;
290 uint64_t uCr3;
291 uint64_t uRip;
292 uint64_t uRsp;
293 uint64_t uRax;
294 X86RFLAGS rflags;
295 CPUMSELREG es;
296 CPUMSELREG cs;
297 CPUMSELREG ss;
298 CPUMSELREG ds;
299 VBOXGDTR gdtr;
300 VBOXIDTR idtr;
301 uint8_t abPadding[4];
302} SVMHOSTSTATE;
303#pragma pack()
304/** Pointer to the SVMHOSTSTATE structure. */
305typedef SVMHOSTSTATE *PSVMHOSTSTATE;
306/** Pointer to a const SVMHOSTSTATE structure. */
307typedef const SVMHOSTSTATE *PCSVMHOSTSTATE;
308#ifndef VBOX_FOR_DTRACE_LIB
309AssertCompileSizeAlignment(SVMHOSTSTATE, 8);
310AssertCompileSize(SVMHOSTSTATE, 184);
311#endif
312
313
314/**
315 * CPU hardware virtualization types.
316 */
317typedef enum
318{
319 CPUMHWVIRT_NONE = 0,
320 CPUMHWVIRT_VMX,
321 CPUMHWVIRT_SVM,
322 CPUMHWVIRT_32BIT_HACK = 0x7fffffff
323} CPUMHWVIRT;
324#ifndef VBOX_FOR_DTRACE_LIB
325AssertCompileSize(CPUMHWVIRT, 4);
326#endif
327
328
329/**
330 * CPU context.
331 */
332#pragma pack(1) /* for VBOXIDTR / VBOXGDTR. */
333typedef struct CPUMCTX
334{
335 /** CPUMCTXCORE Part.
336 * @{ */
337
338 /** General purpose registers. */
339 union /* no tag! */
340 {
341 /** The general purpose register array view, indexed by X86_GREG_XXX. */
342 CPUMCTXGREG aGRegs[16];
343
344 /** 64-bit general purpose register view. */
345 RT_GCC_EXTENSION struct /* no tag! */
346 {
347 uint64_t rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, r15;
348 } CPUM_STRUCT_NM(qw);
349 /** 64-bit general purpose register view. */
350 RT_GCC_EXTENSION struct /* no tag! */
351 {
352 uint64_t r0, r1, r2, r3, r4, r5, r6, r7;
353 } CPUM_STRUCT_NM(qw2);
354 /** 32-bit general purpose register view. */
355 RT_GCC_EXTENSION struct /* no tag! */
356 {
357 uint32_t eax, u32Pad00, ecx, u32Pad01, edx, u32Pad02, ebx, u32Pad03,
358 esp, u32Pad04, ebp, u32Pad05, esi, u32Pad06, edi, u32Pad07,
359 r8d, u32Pad08, r9d, u32Pad09, r10d, u32Pad10, r11d, u32Pad11,
360 r12d, u32Pad12, r13d, u32Pad13, r14d, u32Pad14, r15d, u32Pad15;
361 } CPUM_STRUCT_NM(dw);
362 /** 16-bit general purpose register view. */
363 RT_GCC_EXTENSION struct /* no tag! */
364 {
365 uint16_t ax, au16Pad00[3], cx, au16Pad01[3], dx, au16Pad02[3], bx, au16Pad03[3],
366 sp, au16Pad04[3], bp, au16Pad05[3], si, au16Pad06[3], di, au16Pad07[3],
367 r8w, au16Pad08[3], r9w, au16Pad09[3], r10w, au16Pad10[3], r11w, au16Pad11[3],
368 r12w, au16Pad12[3], r13w, au16Pad13[3], r14w, au16Pad14[3], r15w, au16Pad15[3];
369 } CPUM_STRUCT_NM(w);
370 RT_GCC_EXTENSION struct /* no tag! */
371 {
372 uint8_t al, ah, abPad00[6], cl, ch, abPad01[6], dl, dh, abPad02[6], bl, bh, abPad03[6],
373 spl, abPad04[7], bpl, abPad05[7], sil, abPad06[7], dil, abPad07[7],
374 r8l, abPad08[7], r9l, abPad09[7], r10l, abPad10[7], r11l, abPad11[7],
375 r12l, abPad12[7], r13l, abPad13[7], r14l, abPad14[7], r15l, abPad15[7];
376 } CPUM_STRUCT_NM(b);
377 } CPUM_UNION_NM(g);
378
379 /** Segment registers. */
380 union /* no tag! */
381 {
382 /** The segment register array view, indexed by X86_SREG_XXX. */
383 CPUMSELREG aSRegs[6];
384 /** The named segment register view. */
385 RT_GCC_EXTENSION struct /* no tag! */
386 {
387 CPUMSELREG es, cs, ss, ds, fs, gs;
388 } CPUM_STRUCT_NM(n);
389 } CPUM_UNION_NM(s);
390
391 /** The program counter. */
392 union
393 {
394 uint16_t ip;
395 uint32_t eip;
396 uint64_t rip;
397 } CPUM_UNION_NM(rip);
398
399 /** The flags register. */
400 union
401 {
402 X86EFLAGS eflags;
403 X86RFLAGS rflags;
404 } CPUM_UNION_NM(rflags);
405
406 /** @} */ /*(CPUMCTXCORE)*/
407
408
409 /** @name Control registers.
410 * @{ */
411 uint64_t cr0;
412 uint64_t cr2;
413 uint64_t cr3;
414 /** @todo the 4 PAE PDPE registers. See PGMCPU::aGstPaePdpeRegs. */
415 uint64_t cr4;
416 /** @} */
417
418 /** Debug registers.
419 * @remarks DR4 and DR5 should not be used since they are aliases for
420 * DR6 and DR7 respectively on both AMD and Intel CPUs.
421 * @remarks DR8-15 are currently not supported by AMD or Intel, so
422 * neither do we.
423 */
424 uint64_t dr[8];
425
426 /** Padding before the structure so the 64-bit member is correctly aligned.
427 * @todo fix this structure! */
428 uint16_t gdtrPadding[3];
429 /** Global Descriptor Table register. */
430 VBOXGDTR gdtr;
431
432 /** Padding before the structure so the 64-bit member is correctly aligned.
433 * @todo fix this structure! */
434 uint16_t idtrPadding[3];
435 /** Interrupt Descriptor Table register. */
436 VBOXIDTR idtr;
437
438 /** The task register.
439 * Only the guest context uses all the members. */
440 CPUMSELREG ldtr;
441 /** The task register.
442 * Only the guest context uses all the members. */
443 CPUMSELREG tr;
444
445 /** The sysenter msr registers.
446 * This member is not used by the hypervisor context. */
447 CPUMSYSENTER SysEnter;
448
449 /** @name System MSRs.
450 * @{ */
451 uint64_t msrEFER;
452 uint64_t msrSTAR; /**< Legacy syscall eip, cs & ss. */
453 uint64_t msrPAT; /**< Page attribute table. */
454 uint64_t msrLSTAR; /**< 64 bits mode syscall rip. */
455 uint64_t msrCSTAR; /**< Compatibility mode syscall rip. */
456 uint64_t msrSFMASK; /**< syscall flag mask. */
457 uint64_t msrKERNELGSBASE; /**< swapgs exchange value. */
458 uint64_t uMsrPadding0; /**< no longer used (used to hold a copy of APIC base MSR). */
459 /** @} */
460
461 /** The XCR0..XCR1 registers. */
462 uint64_t aXcr[2];
463 /** The mask to pass to XSAVE/XRSTOR in EDX:EAX. If zero we use
464 * FXSAVE/FXRSTOR (since bit 0 will always be set, we only need to test it). */
465 uint64_t fXStateMask;
466
467 /** Pointer to the FPU/SSE/AVX/XXXX state ring-0 mapping. */
468 R0PTRTYPE(PX86XSAVEAREA) pXStateR0;
469 /** Pointer to the FPU/SSE/AVX/XXXX state ring-3 mapping. */
470 R3PTRTYPE(PX86XSAVEAREA) pXStateR3;
471 /** State component offsets into pXState, UINT16_MAX if not present. */
472 uint16_t aoffXState[64];
473
474 /** 0x2d4 - Mirror of CPUMCPU::fUseFlags[CPUM_USED_FPU_GUEST]. */
475 bool fUsedFpuGuest;
476 uint8_t afUnused[7];
477 /** 0x2d8 - Externalized state tracker, CPUMCTX_EXTRN_XXX.
478 * Currently only used internally in NEM/win. */
479 uint64_t fExtrn;
480
481 /** 0x2e0 - Hardware virtualization state. */
482 struct
483 {
484 union /* no tag! */
485 {
486 struct
487 {
488 /** 0x2e0 - MSR holding physical address of the Guest's Host-state. */
489 uint64_t uMsrHSavePa;
490 /** 0x2e8 - Guest physical address of the nested-guest VMCB. */
491 RTGCPHYS GCPhysVmcb;
492 /** 0x2f0 - Cache of the nested-guest VMCB - R0 ptr. */
493 R0PTRTYPE(PSVMVMCB) pVmcbR0;
494 /** 0x2f8 - Cache of the nested-guest VMCB - R3 ptr. */
495 R3PTRTYPE(PSVMVMCB) pVmcbR3;
496 /** 0x300 - Guest's host-state save area. */
497 SVMHOSTSTATE HostState;
498 /** 0x3b8 - Guest TSC time-stamp of when the previous PAUSE instr. was executed. */
499 uint64_t uPrevPauseTick;
500 /** 0x3c0 - Pause filter count. */
501 uint16_t cPauseFilter;
502 /** 0x3c2 - Pause filter threshold. */
503 uint16_t cPauseFilterThreshold;
504 /** 0x3c4 - Whether the injected event is subject to event intercepts. */
505 bool fInterceptEvents;
506 /** 0x3c5 - Padding. */
507 bool afPadding[3];
508 /** 0x3c8 - MSR permission bitmap - R0 ptr. */
509 R0PTRTYPE(void *) pvMsrBitmapR0;
510 /** 0x3d0 - MSR permission bitmap - R3 ptr. */
511 R3PTRTYPE(void *) pvMsrBitmapR3;
512 /** 0x3d8 - IO permission bitmap - R0 ptr. */
513 R0PTRTYPE(void *) pvIoBitmapR0;
514 /** 0x3e0 - IO permission bitmap - R3 ptr. */
515 R3PTRTYPE(void *) pvIoBitmapR3;
516 /** 0x3e8 - Host physical address of the nested-guest VMCB. */
517 RTHCPHYS HCPhysVmcb;
518 /** 0x3f0 - Padding. */
519 uint8_t abPadding0[272];
520 } svm;
521
522 struct
523 {
524 /** 0x2e4 - Guest physical address of the VMXON region. */
525 RTGCPHYS GCPhysVmxon;
526 /** 0x2e8 - Guest physical address of the current VMCS pointer. */
527 RTGCPHYS GCPhysVmcs;
528 /** 0x2f0 - Guest physical address of the shadow VMCS pointer. */
529 RTGCPHYS GCPhysShadowVmcs;
530 /** 0x2f8 - Last emulated VMX instruction/VM-exit diagnostic. */
531 VMXVDIAG enmDiag;
532 /** 0x2fc - VMX abort reason. */
533 VMXABORT enmAbort;
534 /** 0x300 - Last emulated VMX instruction/VM-exit diagnostic auxiliary info. (mainly
535 * used for info. that's not part of the VMCS). */
536 uint64_t uDiagAux;
537 /** 0x308 - VMX abort auxiliary info. */
538 uint32_t uAbortAux;
539 /** 0x30c - Whether the guest is in VMX root mode. */
540 bool fInVmxRootMode;
541 /** 0x30d - Whether the guest is in VMX non-root mode. */
542 bool fInVmxNonRootMode;
543 /** 0x30e - Whether the injected events are subjected to event intercepts. */
544 bool fInterceptEvents;
545 /** 0x30f - Whether blocking of NMI (or virtual-NMIs) was in effect in VMX non-root
546 * mode before execution of IRET. */
547 bool fNmiUnblockingIret;
548 /** 0x310 - The current VMCS - R0 ptr. */
549 R0PTRTYPE(PVMXVVMCS) pVmcsR0;
550 /** 0x318 - The curent VMCS - R3 ptr. */
551 R3PTRTYPE(PVMXVVMCS) pVmcsR3;
552 /** 0X320 - The shadow VMCS - R0 ptr. */
553 R0PTRTYPE(PVMXVVMCS) pShadowVmcsR0;
554 /** 0x328 - The shadow VMCS - R3 ptr. */
555 R3PTRTYPE(PVMXVVMCS) pShadowVmcsR3;
556 /** 0x330 - The virtual-APIC page - R0 ptr. */
557 R0PTRTYPE(void *) pvVirtApicPageR0;
558 /** 0x338 - The virtual-APIC page - R3 ptr. */
559 R3PTRTYPE(void *) pvVirtApicPageR3;
560 /** 0x340 - The VMREAD bitmap - R0 ptr. */
561 R0PTRTYPE(void *) pvVmreadBitmapR0;
562 /** 0x348 - The VMREAD bitmap - R3 ptr. */
563 R3PTRTYPE(void *) pvVmreadBitmapR3;
564 /** 0x350 - The VMWRITE bitmap - R0 ptr. */
565 R0PTRTYPE(void *) pvVmwriteBitmapR0;
566 /** 0x358 - The VMWRITE bitmap - R3 ptr. */
567 R3PTRTYPE(void *) pvVmwriteBitmapR3;
568 /** 0x360 - The VM-entry MSR-load area - R0 ptr. */
569 R0PTRTYPE(PVMXAUTOMSR) pEntryMsrLoadAreaR0;
570 /** 0x368 - The VM-entry MSR-load area - R3 ptr. */
571 R3PTRTYPE(PVMXAUTOMSR) pEntryMsrLoadAreaR3;
572 /** 0x370 - The VM-exit MSR-store area - R0 ptr. */
573 R0PTRTYPE(PVMXAUTOMSR) pExitMsrStoreAreaR0;
574 /** 0x378 - The VM-exit MSR-store area - R3 ptr. */
575 R3PTRTYPE(PVMXAUTOMSR) pExitMsrStoreAreaR3;
576 /** 0x380 - The VM-exit MSR-load area - R0 ptr. */
577 R0PTRTYPE(PVMXAUTOMSR) pExitMsrLoadAreaR0;
578 /** 0x388 - The VM-exit MSR-load area - R3 ptr. */
579 R3PTRTYPE(PVMXAUTOMSR) pExitMsrLoadAreaR3;
580 /** 0x390 - MSR bitmap - R0 ptr. */
581 R0PTRTYPE(void *) pvMsrBitmapR0;
582 /** 0x398 - The MSR bitmap - R3 ptr. */
583 R3PTRTYPE(void *) pvMsrBitmapR3;
584 /** 0x3a0 - The I/O bitmap - R0 ptr. */
585 R0PTRTYPE(void *) pvIoBitmapR0;
586 /** 0x3a8 - The I/O bitmap - R3 ptr. */
587 R3PTRTYPE(void *) pvIoBitmapR3;
588 /** 0x3b0 - Guest TSC timestamp of the first PAUSE instruction that is considered to
589 * be the first in a loop. */
590 uint64_t uFirstPauseLoopTick;
591 /** 0x3b8 - Guest TSC timestamp of the previous PAUSE instruction. */
592 uint64_t uPrevPauseTick;
593 /** 0x3c0 - Guest TSC timestamp of VM-entry (used for VMX-preemption timer). */
594 uint64_t uEntryTick;
595 /** 0x3c8 - Virtual-APIC write offset (until trap-like VM-exit). */
596 uint16_t offVirtApicWrite;
597 /** 0x3ca - Whether virtual-NMI blocking is in effect. */
598 bool fVirtNmiBlocking;
599 /** 0x3cc - Padding. */
600 uint8_t abPadding0[5];
601 /** 0x3d0 - Guest VMX MSRs. */
602 VMXMSRS Msrs;
603 /** 0x4b0 - Host physical address of the VMCS. */
604 RTHCPHYS HCPhysVmcs;
605 /** 0x4b8 - Host physical address of the shadow VMCS. */
606 RTHCPHYS HCPhysShadowVmcs;
607 /** 0x4c0 - Host physical address of the virtual-APIC page. */
608 RTHCPHYS HCPhysVirtApicPage;
609 /** 0x4c8 - Host physical address of the VMREAD bitmap. */
610 RTHCPHYS HCPhysVmreadBitmap;
611 /** 0x4d0 - Host physical address of the VMWRITE bitmap. */
612 RTHCPHYS HCPhysVmwriteBitmap;
613 /** 0x4d8 - Host physical address of the VM-entry MSR-load area. */
614 RTHCPHYS HCPhysEntryMsrLoadArea;
615 /** 0x4e0 - Host physical address of the VM-exit MSR-store area. */
616 RTHCPHYS HCPhysExitMsrStoreArea;
617 /** 0x4e8 - Host physical address of the VM-exit MSR-load area. */
618 RTHCPHYS HCPhysExitMsrLoadArea;
619 /** 0x4f0 - Host physical address of the MSR bitmap. */
620 RTHCPHYS HCPhysMsrBitmap;
621 /** 0x4f8 - Host physical address of the I/O bitmap. */
622 RTHCPHYS HCPhysIoBitmap;
623 } vmx;
624 } CPUM_UNION_NM(s);
625
626 /** 0x500 - Hardware virtualization type currently in use. */
627 CPUMHWVIRT enmHwvirt;
628 /** 0x504 - Global interrupt flag - AMD only (always true on Intel). */
629 bool fGif;
630 bool afPadding1[3];
631 /** 0x508 - A subset of guest force flags that are saved while running the
632 * nested-guest. */
633#ifdef VMCPU_WITH_64_BIT_FFS
634 uint64_t fLocalForcedActions;
635#else
636 uint32_t fLocalForcedActions;
637 uint32_t fPadding;
638#endif
639 /** 0x510 - Pad to 64 byte boundary. */
640 uint8_t abPadding0[48];
641 } hwvirt;
642} CPUMCTX;
643#pragma pack()
644
645#ifndef VBOX_FOR_DTRACE_LIB
646AssertCompileSizeAlignment(CPUMCTX, 64);
647AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) rax, 0);
648AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) rcx, 8);
649AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) rdx, 16);
650AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) rbx, 24);
651AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) rsp, 32);
652AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) rbp, 40);
653AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) rsi, 48);
654AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) rdi, 56);
655AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) r8, 64);
656AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) r9, 72);
657AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) r10, 80);
658AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) r11, 88);
659AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) r12, 96);
660AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) r13, 104);
661AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) r14, 112);
662AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(g.) CPUM_STRUCT_NM(qw.) r15, 120);
663AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(s.) CPUM_STRUCT_NM(n.) es, 128);
664AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(s.) CPUM_STRUCT_NM(n.) cs, 152);
665AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(s.) CPUM_STRUCT_NM(n.) ss, 176);
666AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(s.) CPUM_STRUCT_NM(n.) ds, 200);
667AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(s.) CPUM_STRUCT_NM(n.) fs, 224);
668AssertCompileMemberOffset(CPUMCTX, CPUM_UNION_NM(s.) CPUM_STRUCT_NM(n.) gs, 248);
669AssertCompileMemberOffset(CPUMCTX, rip, 272);
670AssertCompileMemberOffset(CPUMCTX, rflags, 280);
671AssertCompileMemberOffset(CPUMCTX, cr0, 288);
672AssertCompileMemberOffset(CPUMCTX, cr2, 296);
673AssertCompileMemberOffset(CPUMCTX, cr3, 304);
674AssertCompileMemberOffset(CPUMCTX, cr4, 312);
675AssertCompileMemberOffset(CPUMCTX, dr, 320);
676AssertCompileMemberOffset(CPUMCTX, gdtr, 384+6);
677AssertCompileMemberOffset(CPUMCTX, idtr, 400+6);
678AssertCompileMemberOffset(CPUMCTX, ldtr, 416);
679AssertCompileMemberOffset(CPUMCTX, tr, 440);
680AssertCompileMemberOffset(CPUMCTX, SysEnter, 464);
681AssertCompileMemberOffset(CPUMCTX, msrEFER, 488);
682AssertCompileMemberOffset(CPUMCTX, msrSTAR, 496);
683AssertCompileMemberOffset(CPUMCTX, msrPAT, 504);
684AssertCompileMemberOffset(CPUMCTX, msrLSTAR, 512);
685AssertCompileMemberOffset(CPUMCTX, msrCSTAR, 520);
686AssertCompileMemberOffset(CPUMCTX, msrSFMASK, 528);
687AssertCompileMemberOffset(CPUMCTX, msrKERNELGSBASE, 536);
688AssertCompileMemberOffset(CPUMCTX, aXcr, 552);
689AssertCompileMemberOffset(CPUMCTX, fXStateMask, 568);
690AssertCompileMemberOffset(CPUMCTX, pXStateR0, 576);
691AssertCompileMemberOffset(CPUMCTX, pXStateR3, 584);
692AssertCompileMemberOffset(CPUMCTX, aoffXState, 592);
693AssertCompileMemberOffset(CPUMCTX, hwvirt, 0x2e0);
694AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.uMsrHSavePa, 0x2e0);
695AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.pVmcbR0, 0x2f0);
696AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.pVmcbR3, 0x2f8);
697AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.HostState, 0x300);
698AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.cPauseFilter, 0x3c0);
699AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.pvMsrBitmapR0, 0x3c8);
700AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.pvIoBitmapR3, 0x3e0);
701AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.HCPhysVmcb, 0x3e8);
702AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.pVmcbR0, 8);
703AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.pvMsrBitmapR0, 8);
704AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) svm.pvIoBitmapR0, 8);
705AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.GCPhysVmxon, 0x2e0);
706AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.GCPhysVmcs, 0x2e8);
707AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.GCPhysShadowVmcs, 0x2f0);
708AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.enmDiag, 0x2f8);
709AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.enmAbort, 0x2fc);
710AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.uDiagAux, 0x300);
711AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.uAbortAux, 0x308);
712AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.fInVmxRootMode, 0x30c);
713AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.fInVmxNonRootMode, 0x30d);
714AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.fInterceptEvents, 0x30e);
715AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.fNmiUnblockingIret, 0x30f);
716AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pVmcsR0, 0x310);
717AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pVmcsR3, 0x318);
718AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pShadowVmcsR0, 0x320);
719AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pShadowVmcsR3, 0x328);
720AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvVirtApicPageR0, 0x330);
721AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvVirtApicPageR3, 0x338);
722AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvVmreadBitmapR0, 0x340);
723AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvVmreadBitmapR3, 0x348);
724AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvVmwriteBitmapR0, 0x350);
725AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvVmwriteBitmapR3, 0x358);
726AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pEntryMsrLoadAreaR0, 0x360);
727AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pEntryMsrLoadAreaR3, 0x368);
728AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pExitMsrStoreAreaR0, 0x370);
729AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pExitMsrStoreAreaR3, 0x378);
730AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pExitMsrLoadAreaR0, 0x380);
731AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pExitMsrLoadAreaR3, 0x388);
732AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvMsrBitmapR0, 0x390);
733AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvMsrBitmapR3, 0x398);
734AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvIoBitmapR0, 0x3a0);
735AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvIoBitmapR3, 0x3a8);
736AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.uFirstPauseLoopTick, 0x3b0);
737AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.uPrevPauseTick, 0x3b8);
738AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.uEntryTick, 0x3c0);
739AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.offVirtApicWrite, 0x3c8);
740AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.fVirtNmiBlocking, 0x3ca);
741AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.Msrs, 0x3d0);
742AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.HCPhysVmcs, 0x4b0);
743AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.HCPhysShadowVmcs, 0x4b8);
744AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.HCPhysVirtApicPage, 0x4c0);
745AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.HCPhysVmreadBitmap, 0x4c8);
746AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.HCPhysVmwriteBitmap, 0x4d0);
747AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.HCPhysEntryMsrLoadArea, 0x4d8);
748AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.HCPhysExitMsrStoreArea, 0x4e0);
749AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.HCPhysExitMsrLoadArea, 0x4e8);
750AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.HCPhysMsrBitmap, 0x4f0);
751AssertCompileMemberOffset(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.HCPhysIoBitmap, 0x4f8);
752AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pVmcsR0, 8);
753AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pShadowVmcsR0, 8);
754AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvVmreadBitmapR0, 8);
755AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvVmwriteBitmapR0, 8);
756AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pEntryMsrLoadAreaR0, 8);
757AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pExitMsrStoreAreaR0, 8);
758AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pExitMsrLoadAreaR0, 8);
759AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvMsrBitmapR0, 8);
760AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.pvIoBitmapR0, 8);
761AssertCompileMemberAlignment(CPUMCTX, hwvirt.CPUM_UNION_NM(s.) vmx.Msrs, 8);
762AssertCompileMemberOffset(CPUMCTX, hwvirt.enmHwvirt, 0x500);
763AssertCompileMemberOffset(CPUMCTX, hwvirt.fGif, 0x504);
764AssertCompileMemberOffset(CPUMCTX, hwvirt.fLocalForcedActions, 0x508);
765AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rax, CPUMCTX, CPUM_UNION_NM(g.) aGRegs);
766AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rax, CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw2.) r0);
767AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rcx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw2.) r1);
768AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rdx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw2.) r2);
769AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rbx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw2.) r3);
770AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rsp, CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw2.) r4);
771AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rbp, CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw2.) r5);
772AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rsi, CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw2.) r6);
773AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rdi, CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw2.) r7);
774AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rax, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) eax);
775AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rcx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) ecx);
776AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rdx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) edx);
777AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rbx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) ebx);
778AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rsp, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) esp);
779AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rbp, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) ebp);
780AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rsi, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) esi);
781AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rdi, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) edi);
782AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r8, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) r8d);
783AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r9, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) r9d);
784AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r10, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) r10d);
785AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r11, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) r11d);
786AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r12, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) r12d);
787AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r13, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) r13d);
788AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r14, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) r14d);
789AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r15, CPUMCTX, CPUM_UNION_STRUCT_NM(g,dw.) r15d);
790AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rax, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) ax);
791AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rcx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) cx);
792AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rdx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) dx);
793AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rbx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) bx);
794AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rsp, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) sp);
795AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rbp, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) bp);
796AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rsi, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) si);
797AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rdi, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) di);
798AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r8, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) r8w);
799AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r9, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) r9w);
800AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r10, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) r10w);
801AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r11, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) r11w);
802AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r12, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) r12w);
803AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r13, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) r13w);
804AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r14, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) r14w);
805AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r15, CPUMCTX, CPUM_UNION_STRUCT_NM(g,w.) r15w);
806AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rax, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) al);
807AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rcx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) cl);
808AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rdx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) dl);
809AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rbx, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) bl);
810AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rsp, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) spl);
811AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rbp, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) bpl);
812AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rsi, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) sil);
813AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rdi, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) dil);
814AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r8, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) r8l);
815AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r9, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) r9l);
816AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r10, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) r10l);
817AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r11, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) r11l);
818AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r12, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) r12l);
819AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r13, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) r13l);
820AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r14, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) r14l);
821AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r15, CPUMCTX, CPUM_UNION_STRUCT_NM(g,b.) r15l);
822AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_NM(s.) CPUM_STRUCT_NM(n.) es, CPUMCTX, CPUM_UNION_NM(s.) aSRegs);
823# ifndef _MSC_VER
824AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rax, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_xAX]);
825AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rcx, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_xCX]);
826AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rdx, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_xDX]);
827AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rbx, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_xBX]);
828AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rsp, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_xSP]);
829AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rbp, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_xBP]);
830AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rsi, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_xSI]);
831AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) rdi, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_xDI]);
832AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r8, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_x8]);
833AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r9, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_x9]);
834AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r10, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_x10]);
835AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r11, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_x11]);
836AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r12, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_x12]);
837AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r13, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_x13]);
838AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r14, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_x14]);
839AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(g,qw.) r15, CPUMCTX, CPUM_UNION_NM(g.) aGRegs[X86_GREG_x15]);
840AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(s,n.) es, CPUMCTX, CPUM_UNION_NM(s.) aSRegs[X86_SREG_ES]);
841AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(s,n.) cs, CPUMCTX, CPUM_UNION_NM(s.) aSRegs[X86_SREG_CS]);
842AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(s,n.) ss, CPUMCTX, CPUM_UNION_NM(s.) aSRegs[X86_SREG_SS]);
843AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(s,n.) ds, CPUMCTX, CPUM_UNION_NM(s.) aSRegs[X86_SREG_DS]);
844AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(s,n.) fs, CPUMCTX, CPUM_UNION_NM(s.) aSRegs[X86_SREG_FS]);
845AssertCompileMembersAtSameOffset(CPUMCTX, CPUM_UNION_STRUCT_NM(s,n.) gs, CPUMCTX, CPUM_UNION_NM(s.) aSRegs[X86_SREG_GS]);
846# endif
847
848/**
849 * Calculates the pointer to the given extended state component.
850 *
851 * @returns Pointer of type @a a_PtrType
852 * @param a_pCtx Pointer to the context.
853 * @param a_iCompBit The extended state component bit number. This bit
854 * must be set in CPUMCTX::fXStateMask.
855 * @param a_PtrType The pointer type of the extended state component.
856 *
857 */
858#if defined(VBOX_STRICT) && defined(RT_COMPILER_SUPPORTS_LAMBDA)
859# define CPUMCTX_XSAVE_C_PTR(a_pCtx, a_iCompBit, a_PtrType) \
860 ([](PCCPUMCTX a_pLambdaCtx) -> a_PtrType \
861 { \
862 AssertCompile((a_iCompBit) < 64U); \
863 AssertMsg(a_pLambdaCtx->fXStateMask & RT_BIT_64(a_iCompBit), (#a_iCompBit "\n")); \
864 AssertMsg(a_pLambdaCtx->aoffXState[(a_iCompBit)] != UINT16_MAX, (#a_iCompBit "\n")); \
865 return (a_PtrType)((uint8_t *)a_pLambdaCtx->CTX_SUFF(pXState) + a_pLambdaCtx->aoffXState[(a_iCompBit)]); \
866 }(a_pCtx))
867#elif defined(VBOX_STRICT) && defined(__GNUC__)
868# define CPUMCTX_XSAVE_C_PTR(a_pCtx, a_iCompBit, a_PtrType) \
869 __extension__ (\
870 { \
871 AssertCompile((a_iCompBit) < 64U); \
872 AssertMsg((a_pCtx)->fXStateMask & RT_BIT_64(a_iCompBit), (#a_iCompBit "\n")); \
873 AssertMsg((a_pCtx)->aoffXState[(a_iCompBit)] != UINT16_MAX, (#a_iCompBit "\n")); \
874 (a_PtrType)((uint8_t *)(a_pCtx)->CTX_SUFF(pXState) + (a_pCtx)->aoffXState[(a_iCompBit)]); \
875 })
876#else
877# define CPUMCTX_XSAVE_C_PTR(a_pCtx, a_iCompBit, a_PtrType) \
878 ((a_PtrType)((uint8_t *)(a_pCtx)->CTX_SUFF(pXState) + (a_pCtx)->aoffXState[(a_iCompBit)]))
879#endif
880
881/**
882 * Gets the CPUMCTXCORE part of a CPUMCTX.
883 */
884# define CPUMCTX2CORE(pCtx) ((PCPUMCTXCORE)(void *)&(pCtx)->rax)
885
886/**
887 * Gets the CPUMCTX part from a CPUMCTXCORE.
888 */
889# define CPUMCTX_FROM_CORE(a_pCtxCore) RT_FROM_MEMBER(a_pCtxCore, CPUMCTX, rax)
890
891/**
892 * Gets the first selector register of a CPUMCTX.
893 *
894 * Use this with X86_SREG_COUNT to loop thru the selector registers.
895 */
896# define CPUMCTX_FIRST_SREG(a_pCtx) (&(a_pCtx)->es)
897
898#endif /* !VBOX_FOR_DTRACE_LIB */
899
900
901/** @name CPUMCTX_EXTRN_XXX
902 * Used for parts of the CPUM state that is externalized and needs fetching
903 * before use.
904 *
905 * @{ */
906/** External state keeper: Invalid. */
907#define CPUMCTX_EXTRN_KEEPER_INVALID UINT64_C(0x0000000000000000)
908/** External state keeper: HM. */
909#define CPUMCTX_EXTRN_KEEPER_HM UINT64_C(0x0000000000000001)
910/** External state keeper: NEM. */
911#define CPUMCTX_EXTRN_KEEPER_NEM UINT64_C(0x0000000000000002)
912/** External state keeper: REM. */
913#define CPUMCTX_EXTRN_KEEPER_REM UINT64_C(0x0000000000000003)
914/** External state keeper mask. */
915#define CPUMCTX_EXTRN_KEEPER_MASK UINT64_C(0x0000000000000003)
916
917/** The RIP register value is kept externally. */
918#define CPUMCTX_EXTRN_RIP UINT64_C(0x0000000000000004)
919/** The RFLAGS register values are kept externally. */
920#define CPUMCTX_EXTRN_RFLAGS UINT64_C(0x0000000000000008)
921
922/** The RAX register value is kept externally. */
923#define CPUMCTX_EXTRN_RAX UINT64_C(0x0000000000000010)
924/** The RCX register value is kept externally. */
925#define CPUMCTX_EXTRN_RCX UINT64_C(0x0000000000000020)
926/** The RDX register value is kept externally. */
927#define CPUMCTX_EXTRN_RDX UINT64_C(0x0000000000000040)
928/** The RBX register value is kept externally. */
929#define CPUMCTX_EXTRN_RBX UINT64_C(0x0000000000000080)
930/** The RSP register value is kept externally. */
931#define CPUMCTX_EXTRN_RSP UINT64_C(0x0000000000000100)
932/** The RBP register value is kept externally. */
933#define CPUMCTX_EXTRN_RBP UINT64_C(0x0000000000000200)
934/** The RSI register value is kept externally. */
935#define CPUMCTX_EXTRN_RSI UINT64_C(0x0000000000000400)
936/** The RDI register value is kept externally. */
937#define CPUMCTX_EXTRN_RDI UINT64_C(0x0000000000000800)
938/** The R8 thru R15 register values are kept externally. */
939#define CPUMCTX_EXTRN_R8_R15 UINT64_C(0x0000000000001000)
940/** General purpose registers mask. */
941#define CPUMCTX_EXTRN_GPRS_MASK UINT64_C(0x0000000000001ff0)
942
943/** The ES register values are kept externally. */
944#define CPUMCTX_EXTRN_ES UINT64_C(0x0000000000002000)
945/** The CS register values are kept externally. */
946#define CPUMCTX_EXTRN_CS UINT64_C(0x0000000000004000)
947/** The SS register values are kept externally. */
948#define CPUMCTX_EXTRN_SS UINT64_C(0x0000000000008000)
949/** The DS register values are kept externally. */
950#define CPUMCTX_EXTRN_DS UINT64_C(0x0000000000010000)
951/** The FS register values are kept externally. */
952#define CPUMCTX_EXTRN_FS UINT64_C(0x0000000000020000)
953/** The GS register values are kept externally. */
954#define CPUMCTX_EXTRN_GS UINT64_C(0x0000000000040000)
955/** Segment registers (includes CS). */
956#define CPUMCTX_EXTRN_SREG_MASK UINT64_C(0x000000000007e000)
957/** Converts a X86_XREG_XXX index to a CPUMCTX_EXTRN_xS mask. */
958#define CPUMCTX_EXTRN_SREG_FROM_IDX(a_SRegIdx) RT_BIT_64((a_SRegIdx) + 13)
959#ifndef VBOX_FOR_DTRACE_LIB
960AssertCompile(CPUMCTX_EXTRN_SREG_FROM_IDX(X86_SREG_ES) == CPUMCTX_EXTRN_ES);
961AssertCompile(CPUMCTX_EXTRN_SREG_FROM_IDX(X86_SREG_CS) == CPUMCTX_EXTRN_CS);
962AssertCompile(CPUMCTX_EXTRN_SREG_FROM_IDX(X86_SREG_DS) == CPUMCTX_EXTRN_DS);
963AssertCompile(CPUMCTX_EXTRN_SREG_FROM_IDX(X86_SREG_FS) == CPUMCTX_EXTRN_FS);
964AssertCompile(CPUMCTX_EXTRN_SREG_FROM_IDX(X86_SREG_GS) == CPUMCTX_EXTRN_GS);
965#endif
966
967/** The GDTR register values are kept externally. */
968#define CPUMCTX_EXTRN_GDTR UINT64_C(0x0000000000080000)
969/** The IDTR register values are kept externally. */
970#define CPUMCTX_EXTRN_IDTR UINT64_C(0x0000000000100000)
971/** The LDTR register values are kept externally. */
972#define CPUMCTX_EXTRN_LDTR UINT64_C(0x0000000000200000)
973/** The TR register values are kept externally. */
974#define CPUMCTX_EXTRN_TR UINT64_C(0x0000000000400000)
975/** Table register mask. */
976#define CPUMCTX_EXTRN_TABLE_MASK UINT64_C(0x0000000000780000)
977
978/** The CR0 register value is kept externally. */
979#define CPUMCTX_EXTRN_CR0 UINT64_C(0x0000000000800000)
980/** The CR2 register value is kept externally. */
981#define CPUMCTX_EXTRN_CR2 UINT64_C(0x0000000001000000)
982/** The CR3 register value is kept externally. */
983#define CPUMCTX_EXTRN_CR3 UINT64_C(0x0000000002000000)
984/** The CR4 register value is kept externally. */
985#define CPUMCTX_EXTRN_CR4 UINT64_C(0x0000000004000000)
986/** Control register mask. */
987#define CPUMCTX_EXTRN_CR_MASK UINT64_C(0x0000000007800000)
988/** The TPR/CR8 register value is kept externally. */
989#define CPUMCTX_EXTRN_APIC_TPR UINT64_C(0x0000000008000000)
990/** The EFER register value is kept externally. */
991#define CPUMCTX_EXTRN_EFER UINT64_C(0x0000000010000000)
992
993/** The DR0, DR1, DR2 and DR3 register values are kept externally. */
994#define CPUMCTX_EXTRN_DR0_DR3 UINT64_C(0x0000000020000000)
995/** The DR6 register value is kept externally. */
996#define CPUMCTX_EXTRN_DR6 UINT64_C(0x0000000040000000)
997/** The DR7 register value is kept externally. */
998#define CPUMCTX_EXTRN_DR7 UINT64_C(0x0000000080000000)
999/** Debug register mask. */
1000#define CPUMCTX_EXTRN_DR_MASK UINT64_C(0x00000000e0000000)
1001
1002/** The XSAVE_C_X87 state is kept externally. */
1003#define CPUMCTX_EXTRN_X87 UINT64_C(0x0000000100000000)
1004/** The XSAVE_C_SSE, XSAVE_C_YMM, XSAVE_C_ZMM_HI256, XSAVE_C_ZMM_16HI and
1005 * XSAVE_C_OPMASK state is kept externally. */
1006#define CPUMCTX_EXTRN_SSE_AVX UINT64_C(0x0000000200000000)
1007/** The state of XSAVE components not covered by CPUMCTX_EXTRN_X87 and
1008 * CPUMCTX_EXTRN_SEE_AVX is kept externally. */
1009#define CPUMCTX_EXTRN_OTHER_XSAVE UINT64_C(0x0000000400000000)
1010/** The state of XCR0 and XCR1 register values are kept externally. */
1011#define CPUMCTX_EXTRN_XCRx UINT64_C(0x0000000800000000)
1012
1013
1014/** The KERNEL GS BASE MSR value is kept externally. */
1015#define CPUMCTX_EXTRN_KERNEL_GS_BASE UINT64_C(0x0000001000000000)
1016/** The STAR, LSTAR, CSTAR and SFMASK MSR values are kept externally. */
1017#define CPUMCTX_EXTRN_SYSCALL_MSRS UINT64_C(0x0000002000000000)
1018/** The SYSENTER_CS, SYSENTER_EIP and SYSENTER_ESP MSR values are kept externally. */
1019#define CPUMCTX_EXTRN_SYSENTER_MSRS UINT64_C(0x0000004000000000)
1020/** The TSC_AUX MSR is kept externally. */
1021#define CPUMCTX_EXTRN_TSC_AUX UINT64_C(0x0000008000000000)
1022/** All other stateful MSRs not covered by CPUMCTX_EXTRN_EFER,
1023 * CPUMCTX_EXTRN_KERNEL_GS_BASE, CPUMCTX_EXTRN_SYSCALL_MSRS,
1024 * CPUMCTX_EXTRN_SYSENTER_MSRS, and CPUMCTX_EXTRN_TSC_AUX. */
1025#define CPUMCTX_EXTRN_OTHER_MSRS UINT64_C(0x0000010000000000)
1026
1027/** Mask of all the MSRs. */
1028#define CPUMCTX_EXTRN_ALL_MSRS ( CPUMCTX_EXTRN_EFER | CPUMCTX_EXTRN_KERNEL_GS_BASE | CPUMCTX_EXTRN_SYSCALL_MSRS \
1029 | CPUMCTX_EXTRN_SYSENTER_MSRS | CPUMCTX_EXTRN_TSC_AUX | CPUMCTX_EXTRN_OTHER_MSRS)
1030
1031/** Hardware-virtualization (SVM or VMX) state is kept externally. */
1032#define CPUMCTX_EXTRN_HWVIRT UINT64_C(0x0000020000000000)
1033
1034/** Mask of bits the keepers can use for state tracking. */
1035#define CPUMCTX_EXTRN_KEEPER_STATE_MASK UINT64_C(0xffff000000000000)
1036
1037/** NEM/Win: Event injection (known was interruption) pending state. */
1038#define CPUMCTX_EXTRN_NEM_WIN_EVENT_INJECT UINT64_C(0x0001000000000000)
1039/** NEM/Win: Inhibit maskable interrupts (VMCPU_FF_INHIBIT_INTERRUPTS). */
1040#define CPUMCTX_EXTRN_NEM_WIN_INHIBIT_INT UINT64_C(0x0002000000000000)
1041/** NEM/Win: Inhibit non-maskable interrupts (VMCPU_FF_BLOCK_NMIS). */
1042#define CPUMCTX_EXTRN_NEM_WIN_INHIBIT_NMI UINT64_C(0x0004000000000000)
1043/** NEM/Win: Mask. */
1044#define CPUMCTX_EXTRN_NEM_WIN_MASK UINT64_C(0x0007000000000000)
1045
1046/** HM/SVM: Inhibit maskable interrupts (VMCPU_FF_INHIBIT_INTERRUPTS). */
1047#define CPUMCTX_EXTRN_HM_SVM_INT_SHADOW UINT64_C(0x0001000000000000)
1048/** HM/SVM: Nested-guest interrupt pending (VMCPU_FF_INTERRUPT_NESTED_GUEST). */
1049#define CPUMCTX_EXTRN_HM_SVM_HWVIRT_VIRQ UINT64_C(0x0002000000000000)
1050/** HM/SVM: Mask. */
1051#define CPUMCTX_EXTRN_HM_SVM_MASK UINT64_C(0x0003000000000000)
1052
1053/** HM/VMX: Guest-interruptibility state (VMCPU_FF_INHIBIT_INTERRUPTS,
1054 * VMCPU_FF_BLOCK_NMIS). */
1055#define CPUMCTX_EXTRN_HM_VMX_INT_STATE UINT64_C(0x0001000000000000)
1056/** HM/VMX: Mask. */
1057#define CPUMCTX_EXTRN_HM_VMX_MASK UINT64_C(0x0001000000000000)
1058
1059/** All CPUM state bits, not including keeper specific ones. */
1060#define CPUMCTX_EXTRN_ALL UINT64_C(0x000003fffffffffc)
1061/** All CPUM state bits, including keeper specific ones. */
1062#define CPUMCTX_EXTRN_ABSOLUTELY_ALL UINT64_C(0xfffffffffffffffc)
1063/** @} */
1064
1065
1066/**
1067 * Additional guest MSRs (i.e. not part of the CPU context structure).
1068 *
1069 * @remarks Never change the order here because of the saved stated! The size
1070 * can in theory be changed, but keep older VBox versions in mind.
1071 */
1072typedef union CPUMCTXMSRS
1073{
1074 struct
1075 {
1076 uint64_t TscAux; /**< MSR_K8_TSC_AUX */
1077 uint64_t MiscEnable; /**< MSR_IA32_MISC_ENABLE */
1078 uint64_t MtrrDefType; /**< IA32_MTRR_DEF_TYPE */
1079 uint64_t MtrrFix64K_00000; /**< IA32_MTRR_FIX16K_80000 */
1080 uint64_t MtrrFix16K_80000; /**< IA32_MTRR_FIX16K_80000 */
1081 uint64_t MtrrFix16K_A0000; /**< IA32_MTRR_FIX16K_A0000 */
1082 uint64_t MtrrFix4K_C0000; /**< IA32_MTRR_FIX4K_C0000 */
1083 uint64_t MtrrFix4K_C8000; /**< IA32_MTRR_FIX4K_C8000 */
1084 uint64_t MtrrFix4K_D0000; /**< IA32_MTRR_FIX4K_D0000 */
1085 uint64_t MtrrFix4K_D8000; /**< IA32_MTRR_FIX4K_D8000 */
1086 uint64_t MtrrFix4K_E0000; /**< IA32_MTRR_FIX4K_E0000 */
1087 uint64_t MtrrFix4K_E8000; /**< IA32_MTRR_FIX4K_E8000 */
1088 uint64_t MtrrFix4K_F0000; /**< IA32_MTRR_FIX4K_F0000 */
1089 uint64_t MtrrFix4K_F8000; /**< IA32_MTRR_FIX4K_F8000 */
1090 uint64_t PkgCStateCfgCtrl; /**< MSR_PKG_CST_CONFIG_CONTROL */
1091 uint64_t SpecCtrl; /**< IA32_SPEC_CTRL */
1092 uint64_t ArchCaps; /**< IA32_ARCH_CAPABILITIES */
1093 } msr;
1094 uint64_t au64[64];
1095} CPUMCTXMSRS;
1096/** Pointer to the guest MSR state. */
1097typedef CPUMCTXMSRS *PCPUMCTXMSRS;
1098/** Pointer to the const guest MSR state. */
1099typedef const CPUMCTXMSRS *PCCPUMCTXMSRS;
1100
1101/** @} */
1102
1103RT_C_DECLS_END
1104
1105#endif /* !VBOX_INCLUDED_vmm_cpumctx_h */
1106
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