VirtualBox

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

Last change on this file since 80027 was 79726, checked in by vboxsync, 5 years ago

cpumctx.h: Nested VMX: bugref:9180 Nit.

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