VirtualBox

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

Last change on this file since 80673 was 80069, checked in by vboxsync, 5 years ago

VMM: Kicking out raw-mode and 32-bit hosts - CPUM. bugref:9517 bugref:9511

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 56.2 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#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 uint64_t cr4;
415 /** @} */
416
417 /** Debug registers.
418 * @remarks DR4 and DR5 should not be used since they are aliases for
419 * DR6 and DR7 respectively on both AMD and Intel CPUs.
420 * @remarks DR8-15 are currently not supported by AMD or Intel, so
421 * neither do we.
422 */
423 uint64_t dr[8];
424
425 /** Padding before the structure so the 64-bit member is correctly aligned.
426 * @todo fix this structure! */
427 uint16_t gdtrPadding[3];
428 /** Global Descriptor Table register. */
429 VBOXGDTR gdtr;
430
431 /** Padding before the structure so the 64-bit member is correctly aligned.
432 * @todo fix this structure! */
433 uint16_t idtrPadding[3];
434 /** Interrupt Descriptor Table register. */
435 VBOXIDTR idtr;
436
437 /** The task register.
438 * Only the guest context uses all the members. */
439 CPUMSELREG ldtr;
440 /** The task register.
441 * Only the guest context uses all the members. */
442 CPUMSELREG tr;
443
444 /** The sysenter msr registers.
445 * This member is not used by the hypervisor context. */
446 CPUMSYSENTER SysEnter;
447
448 /** @name System MSRs.
449 * @{ */
450 uint64_t msrEFER;
451 uint64_t msrSTAR; /**< Legacy syscall eip, cs & ss. */
452 uint64_t msrPAT; /**< Page attribute table. */
453 uint64_t msrLSTAR; /**< 64 bits mode syscall rip. */
454 uint64_t msrCSTAR; /**< Compatibility mode syscall rip. */
455 uint64_t msrSFMASK; /**< syscall flag mask. */
456 uint64_t msrKERNELGSBASE; /**< swapgs exchange value. */
457 uint64_t uMsrPadding0; /**< no longer used (used to hold a copy of APIC base MSR). */
458 /** @} */
459
460 /** The XCR0..XCR1 registers. */
461 uint64_t aXcr[2];
462 /** The mask to pass to XSAVE/XRSTOR in EDX:EAX. If zero we use
463 * FXSAVE/FXRSTOR (since bit 0 will always be set, we only need to test it). */
464 uint64_t fXStateMask;
465
466 /** Pointer to the FPU/SSE/AVX/XXXX state ring-0 mapping. */
467 R0PTRTYPE(PX86XSAVEAREA) pXStateR0;
468 /** Pointer to the FPU/SSE/AVX/XXXX state ring-3 mapping. */
469 R3PTRTYPE(PX86XSAVEAREA) pXStateR3;
470 /** State component offsets into pXState, UINT16_MAX if not present. */
471 uint16_t aoffXState[64];
472
473 /** 0x2d4 - World switcher flags, CPUMCTX_WSF_XXX. */
474 uint32_t fWorldSwitcher;
475 uint32_t fUnused;
476 /** 0x2d8 - Externalized state tracker, CPUMCTX_EXTRN_XXX.
477 * Currently only used internally in NEM/win. */
478 uint64_t fExtrn;
479
480 /** 0x2e0 - Hardware virtualization state. */
481 struct
482 {
483 union /* no tag! */
484 {
485 struct
486 {
487 /** 0x2e0 - MSR holding physical address of the Guest's Host-state. */
488 uint64_t uMsrHSavePa;
489 /** 0x2e8 - Guest physical address of the nested-guest VMCB. */
490 RTGCPHYS GCPhysVmcb;
491 /** 0x2f0 - Cache of the nested-guest VMCB - R0 ptr. */
492 R0PTRTYPE(PSVMVMCB) pVmcbR0;
493 /** 0x2f8 - Cache of the nested-guest VMCB - R3 ptr. */
494 R3PTRTYPE(PSVMVMCB) pVmcbR3;
495 /** 0x300 - Guest's host-state save area. */
496 SVMHOSTSTATE HostState;
497 /** 0x3b8 - Guest TSC time-stamp of when the previous PAUSE instr. was executed. */
498 uint64_t uPrevPauseTick;
499 /** 0x3c0 - Pause filter count. */
500 uint16_t cPauseFilter;
501 /** 0x3c2 - Pause filter threshold. */
502 uint16_t cPauseFilterThreshold;
503 /** 0x3c4 - Whether the injected event is subject to event intercepts. */
504 bool fInterceptEvents;
505 /** 0x3c5 - Padding. */
506 bool afPadding[3];
507 /** 0x3c8 - MSR permission bitmap - R0 ptr. */
508 R0PTRTYPE(void *) pvMsrBitmapR0;
509 /** 0x3d0 - MSR permission bitmap - R3 ptr. */
510 R3PTRTYPE(void *) pvMsrBitmapR3;
511 /** 0x3d8 - IO permission bitmap - R0 ptr. */
512 R0PTRTYPE(void *) pvIoBitmapR0;
513 /** 0x3e0 - IO permission bitmap - R3 ptr. */
514 R3PTRTYPE(void *) pvIoBitmapR3;
515 /** 0x3e8 - Host physical address of the nested-guest VMCB. */
516 RTHCPHYS HCPhysVmcb;
517 /** 0x3f0 - Padding. */
518 uint8_t abPadding0[272];
519 } svm;
520
521 struct
522 {
523 /** 0x2e4 - Guest physical address of the VMXON region. */
524 RTGCPHYS GCPhysVmxon;
525 /** 0x2e8 - Guest physical address of the current VMCS pointer. */
526 RTGCPHYS GCPhysVmcs;
527 /** 0x2f0 - Guest physical address of the shadow VMCS pointer. */
528 RTGCPHYS GCPhysShadowVmcs;
529 /** 0x2f8 - Last emulated VMX instruction/VM-exit diagnostic. */
530 VMXVDIAG enmDiag;
531 /** 0x2fc - VMX abort reason. */
532 VMXABORT enmAbort;
533 /** 0x300 - Last emulated VMX instruction/VM-exit diagnostic auxiliary info. (mainly
534 * used for info. that's not part of the VMCS). */
535 uint64_t uDiagAux;
536 /** 0x308 - VMX abort auxiliary info. */
537 uint32_t uAbortAux;
538 /** 0x30c - Whether the guest is in VMX root mode. */
539 bool fInVmxRootMode;
540 /** 0x30d - Whether the guest is in VMX non-root mode. */
541 bool fInVmxNonRootMode;
542 /** 0x30e - Whether the injected events are subjected to event intercepts. */
543 bool fInterceptEvents;
544 /** 0x30f - Whether blocking of NMI (or virtual-NMIs) was in effect in VMX non-root
545 * mode before execution of IRET. */
546 bool fNmiUnblockingIret;
547 /** 0x310 - The current VMCS - R0 ptr. */
548 R0PTRTYPE(PVMXVVMCS) pVmcsR0;
549 /** 0x318 - The curent VMCS - R3 ptr. */
550 R3PTRTYPE(PVMXVVMCS) pVmcsR3;
551 /** 0X320 - The shadow VMCS - R0 ptr. */
552 R0PTRTYPE(PVMXVVMCS) pShadowVmcsR0;
553 /** 0x328 - The shadow VMCS - R3 ptr. */
554 R3PTRTYPE(PVMXVVMCS) pShadowVmcsR3;
555 /** 0x330 - The virtual-APIC page - R0 ptr. */
556 R0PTRTYPE(void *) pvVirtApicPageR0;
557 /** 0x338 - The virtual-APIC page - R3 ptr. */
558 R3PTRTYPE(void *) pvVirtApicPageR3;
559 /** 0x340 - The VMREAD bitmap - R0 ptr. */
560 R0PTRTYPE(void *) pvVmreadBitmapR0;
561 /** 0x348 - The VMREAD bitmap - R3 ptr. */
562 R3PTRTYPE(void *) pvVmreadBitmapR3;
563 /** 0x350 - The VMWRITE bitmap - R0 ptr. */
564 R0PTRTYPE(void *) pvVmwriteBitmapR0;
565 /** 0x358 - The VMWRITE bitmap - R3 ptr. */
566 R3PTRTYPE(void *) pvVmwriteBitmapR3;
567 /** 0x360 - The VM-entry MSR-load area - R0 ptr. */
568 R0PTRTYPE(PVMXAUTOMSR) pEntryMsrLoadAreaR0;
569 /** 0x368 - The VM-entry MSR-load area - R3 ptr. */
570 R3PTRTYPE(PVMXAUTOMSR) pEntryMsrLoadAreaR3;
571 /** 0x370 - The VM-exit MSR-store area - R0 ptr. */
572 R0PTRTYPE(PVMXAUTOMSR) pExitMsrStoreAreaR0;
573 /** 0x378 - The VM-exit MSR-store area - R3 ptr. */
574 R3PTRTYPE(PVMXAUTOMSR) pExitMsrStoreAreaR3;
575 /** 0x380 - The VM-exit MSR-load area - R0 ptr. */
576 R0PTRTYPE(PVMXAUTOMSR) pExitMsrLoadAreaR0;
577 /** 0x388 - The VM-exit MSR-load area - R3 ptr. */
578 R3PTRTYPE(PVMXAUTOMSR) pExitMsrLoadAreaR3;
579 /** 0x390 - MSR bitmap - R0 ptr. */
580 R0PTRTYPE(void *) pvMsrBitmapR0;
581 /** 0x398 - The MSR bitmap - R3 ptr. */
582 R3PTRTYPE(void *) pvMsrBitmapR3;
583 /** 0x3a0 - The I/O bitmap - R0 ptr. */
584 R0PTRTYPE(void *) pvIoBitmapR0;
585 /** 0x3a8 - The I/O bitmap - R3 ptr. */
586 R3PTRTYPE(void *) pvIoBitmapR3;
587 /** 0x3b0 - Guest TSC timestamp of the first PAUSE instruction that is considered to
588 * be the first in a loop. */
589 uint64_t uFirstPauseLoopTick;
590 /** 0x3b8 - Guest TSC timestamp of the previous PAUSE instruction. */
591 uint64_t uPrevPauseTick;
592 /** 0x3c0 - Guest TSC timestamp of VM-entry (used for VMX-preemption timer). */
593 uint64_t uEntryTick;
594 /** 0x3c8 - Virtual-APIC write offset (until trap-like VM-exit). */
595 uint16_t offVirtApicWrite;
596 /** 0x3ca - Whether virtual-NMI blocking is in effect. */
597 bool fVirtNmiBlocking;
598 /** 0x3cc - Padding. */
599 uint8_t abPadding0[5];
600 /** 0x3d0 - Guest VMX MSRs. */
601 VMXMSRS Msrs;
602 /** 0x4b0 - Host physical address of the VMCS. */
603 RTHCPHYS HCPhysVmcs;
604 /** 0x4b8 - Host physical address of the shadow VMCS. */
605 RTHCPHYS HCPhysShadowVmcs;
606 /** 0x4c0 - Host physical address of the virtual-APIC page. */
607 RTHCPHYS HCPhysVirtApicPage;
608 /** 0x4c8 - Host physical address of the VMREAD bitmap. */
609 RTHCPHYS HCPhysVmreadBitmap;
610 /** 0x4d0 - Host physical address of the VMWRITE bitmap. */
611 RTHCPHYS HCPhysVmwriteBitmap;
612 /** 0x4d8 - Host physical address of the VM-entry MSR-load area. */
613 RTHCPHYS HCPhysEntryMsrLoadArea;
614 /** 0x4e0 - Host physical address of the VM-exit MSR-store area. */
615 RTHCPHYS HCPhysExitMsrStoreArea;
616 /** 0x4e8 - Host physical address of the VM-exit MSR-load area. */
617 RTHCPHYS HCPhysExitMsrLoadArea;
618 /** 0x4f0 - Host physical address of the MSR bitmap. */
619 RTHCPHYS HCPhysMsrBitmap;
620 /** 0x4f8 - Host physical address of the I/O bitmap. */
621 RTHCPHYS HCPhysIoBitmap;
622 } vmx;
623 } CPUM_UNION_NM(s);
624
625 /** 0x500 - Hardware virtualization type currently in use. */
626 CPUMHWVIRT enmHwvirt;
627 /** 0x504 - Global interrupt flag - AMD only (always true on Intel). */
628 bool fGif;
629 bool afPadding1[3];
630 /** 0x508 - A subset of guest force flags that are saved while running the
631 * nested-guest. */
632#ifdef VMCPU_WITH_64_BIT_FFS
633 uint64_t fLocalForcedActions;
634#else
635 uint32_t fLocalForcedActions;
636 uint32_t fPadding;
637#endif
638 /** 0x510 - Pad to 64 byte boundary. */
639 uint8_t abPadding0[48];
640 } hwvirt;
641 /** @} */
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_WSF_XXX
902 * @{ */
903/** Touch IA32_PRED_CMD.IBPB on VM exit. */
904#define CPUMCTX_WSF_IBPB_EXIT RT_BIT_32(0)
905/** Touch IA32_PRED_CMD.IBPB on VM entry. */
906#define CPUMCTX_WSF_IBPB_ENTRY RT_BIT_32(1)
907/** Touch IA32_FLUSH_CMD.L1D on VM entry. */
908#define CPUMCTX_WSF_L1D_ENTRY RT_BIT_32(2)
909/** Flush MDS buffers on VM entry. */
910#define CPUMCTX_WSF_MDS_ENTRY RT_BIT_32(3)
911/** @} */
912
913/** @name CPUMCTX_EXTRN_XXX
914 * Used for parts of the CPUM state that is externalized and needs fetching
915 * before use.
916 *
917 * @{ */
918/** External state keeper: Invalid. */
919#define CPUMCTX_EXTRN_KEEPER_INVALID UINT64_C(0x0000000000000000)
920/** External state keeper: HM. */
921#define CPUMCTX_EXTRN_KEEPER_HM UINT64_C(0x0000000000000001)
922/** External state keeper: NEM. */
923#define CPUMCTX_EXTRN_KEEPER_NEM UINT64_C(0x0000000000000002)
924/** External state keeper: REM. */
925#define CPUMCTX_EXTRN_KEEPER_REM UINT64_C(0x0000000000000003)
926/** External state keeper mask. */
927#define CPUMCTX_EXTRN_KEEPER_MASK UINT64_C(0x0000000000000003)
928
929/** The RIP register value is kept externally. */
930#define CPUMCTX_EXTRN_RIP UINT64_C(0x0000000000000004)
931/** The RFLAGS register values are kept externally. */
932#define CPUMCTX_EXTRN_RFLAGS UINT64_C(0x0000000000000008)
933
934/** The RAX register value is kept externally. */
935#define CPUMCTX_EXTRN_RAX UINT64_C(0x0000000000000010)
936/** The RCX register value is kept externally. */
937#define CPUMCTX_EXTRN_RCX UINT64_C(0x0000000000000020)
938/** The RDX register value is kept externally. */
939#define CPUMCTX_EXTRN_RDX UINT64_C(0x0000000000000040)
940/** The RBX register value is kept externally. */
941#define CPUMCTX_EXTRN_RBX UINT64_C(0x0000000000000080)
942/** The RSP register value is kept externally. */
943#define CPUMCTX_EXTRN_RSP UINT64_C(0x0000000000000100)
944/** The RBP register value is kept externally. */
945#define CPUMCTX_EXTRN_RBP UINT64_C(0x0000000000000200)
946/** The RSI register value is kept externally. */
947#define CPUMCTX_EXTRN_RSI UINT64_C(0x0000000000000400)
948/** The RDI register value is kept externally. */
949#define CPUMCTX_EXTRN_RDI UINT64_C(0x0000000000000800)
950/** The R8 thru R15 register values are kept externally. */
951#define CPUMCTX_EXTRN_R8_R15 UINT64_C(0x0000000000001000)
952/** General purpose registers mask. */
953#define CPUMCTX_EXTRN_GPRS_MASK UINT64_C(0x0000000000001ff0)
954
955/** The ES register values are kept externally. */
956#define CPUMCTX_EXTRN_ES UINT64_C(0x0000000000002000)
957/** The CS register values are kept externally. */
958#define CPUMCTX_EXTRN_CS UINT64_C(0x0000000000004000)
959/** The SS register values are kept externally. */
960#define CPUMCTX_EXTRN_SS UINT64_C(0x0000000000008000)
961/** The DS register values are kept externally. */
962#define CPUMCTX_EXTRN_DS UINT64_C(0x0000000000010000)
963/** The FS register values are kept externally. */
964#define CPUMCTX_EXTRN_FS UINT64_C(0x0000000000020000)
965/** The GS register values are kept externally. */
966#define CPUMCTX_EXTRN_GS UINT64_C(0x0000000000040000)
967/** Segment registers (includes CS). */
968#define CPUMCTX_EXTRN_SREG_MASK UINT64_C(0x000000000007e000)
969/** Converts a X86_XREG_XXX index to a CPUMCTX_EXTRN_xS mask. */
970#define CPUMCTX_EXTRN_SREG_FROM_IDX(a_SRegIdx) RT_BIT_64((a_SRegIdx) + 13)
971#ifndef VBOX_FOR_DTRACE_LIB
972AssertCompile(CPUMCTX_EXTRN_SREG_FROM_IDX(X86_SREG_ES) == CPUMCTX_EXTRN_ES);
973AssertCompile(CPUMCTX_EXTRN_SREG_FROM_IDX(X86_SREG_CS) == CPUMCTX_EXTRN_CS);
974AssertCompile(CPUMCTX_EXTRN_SREG_FROM_IDX(X86_SREG_DS) == CPUMCTX_EXTRN_DS);
975AssertCompile(CPUMCTX_EXTRN_SREG_FROM_IDX(X86_SREG_FS) == CPUMCTX_EXTRN_FS);
976AssertCompile(CPUMCTX_EXTRN_SREG_FROM_IDX(X86_SREG_GS) == CPUMCTX_EXTRN_GS);
977#endif
978
979/** The GDTR register values are kept externally. */
980#define CPUMCTX_EXTRN_GDTR UINT64_C(0x0000000000080000)
981/** The IDTR register values are kept externally. */
982#define CPUMCTX_EXTRN_IDTR UINT64_C(0x0000000000100000)
983/** The LDTR register values are kept externally. */
984#define CPUMCTX_EXTRN_LDTR UINT64_C(0x0000000000200000)
985/** The TR register values are kept externally. */
986#define CPUMCTX_EXTRN_TR UINT64_C(0x0000000000400000)
987/** Table register mask. */
988#define CPUMCTX_EXTRN_TABLE_MASK UINT64_C(0x0000000000780000)
989
990/** The CR0 register value is kept externally. */
991#define CPUMCTX_EXTRN_CR0 UINT64_C(0x0000000000800000)
992/** The CR2 register value is kept externally. */
993#define CPUMCTX_EXTRN_CR2 UINT64_C(0x0000000001000000)
994/** The CR3 register value is kept externally. */
995#define CPUMCTX_EXTRN_CR3 UINT64_C(0x0000000002000000)
996/** The CR4 register value is kept externally. */
997#define CPUMCTX_EXTRN_CR4 UINT64_C(0x0000000004000000)
998/** Control register mask. */
999#define CPUMCTX_EXTRN_CR_MASK UINT64_C(0x0000000007800000)
1000/** The TPR/CR8 register value is kept externally. */
1001#define CPUMCTX_EXTRN_APIC_TPR UINT64_C(0x0000000008000000)
1002/** The EFER register value is kept externally. */
1003#define CPUMCTX_EXTRN_EFER UINT64_C(0x0000000010000000)
1004
1005/** The DR0, DR1, DR2 and DR3 register values are kept externally. */
1006#define CPUMCTX_EXTRN_DR0_DR3 UINT64_C(0x0000000020000000)
1007/** The DR6 register value is kept externally. */
1008#define CPUMCTX_EXTRN_DR6 UINT64_C(0x0000000040000000)
1009/** The DR7 register value is kept externally. */
1010#define CPUMCTX_EXTRN_DR7 UINT64_C(0x0000000080000000)
1011/** Debug register mask. */
1012#define CPUMCTX_EXTRN_DR_MASK UINT64_C(0x00000000e0000000)
1013
1014/** The XSAVE_C_X87 state is kept externally. */
1015#define CPUMCTX_EXTRN_X87 UINT64_C(0x0000000100000000)
1016/** The XSAVE_C_SSE, XSAVE_C_YMM, XSAVE_C_ZMM_HI256, XSAVE_C_ZMM_16HI and
1017 * XSAVE_C_OPMASK state is kept externally. */
1018#define CPUMCTX_EXTRN_SSE_AVX UINT64_C(0x0000000200000000)
1019/** The state of XSAVE components not covered by CPUMCTX_EXTRN_X87 and
1020 * CPUMCTX_EXTRN_SEE_AVX is kept externally. */
1021#define CPUMCTX_EXTRN_OTHER_XSAVE UINT64_C(0x0000000400000000)
1022/** The state of XCR0 and XCR1 register values are kept externally. */
1023#define CPUMCTX_EXTRN_XCRx UINT64_C(0x0000000800000000)
1024
1025
1026/** The KERNEL GS BASE MSR value is kept externally. */
1027#define CPUMCTX_EXTRN_KERNEL_GS_BASE UINT64_C(0x0000001000000000)
1028/** The STAR, LSTAR, CSTAR and SFMASK MSR values are kept externally. */
1029#define CPUMCTX_EXTRN_SYSCALL_MSRS UINT64_C(0x0000002000000000)
1030/** The SYSENTER_CS, SYSENTER_EIP and SYSENTER_ESP MSR values are kept externally. */
1031#define CPUMCTX_EXTRN_SYSENTER_MSRS UINT64_C(0x0000004000000000)
1032/** The TSC_AUX MSR is kept externally. */
1033#define CPUMCTX_EXTRN_TSC_AUX UINT64_C(0x0000008000000000)
1034/** All other stateful MSRs not covered by CPUMCTX_EXTRN_EFER,
1035 * CPUMCTX_EXTRN_KERNEL_GS_BASE, CPUMCTX_EXTRN_SYSCALL_MSRS,
1036 * CPUMCTX_EXTRN_SYSENTER_MSRS, and CPUMCTX_EXTRN_TSC_AUX. */
1037#define CPUMCTX_EXTRN_OTHER_MSRS UINT64_C(0x0000010000000000)
1038
1039/** Mask of all the MSRs. */
1040#define CPUMCTX_EXTRN_ALL_MSRS ( CPUMCTX_EXTRN_EFER | CPUMCTX_EXTRN_KERNEL_GS_BASE | CPUMCTX_EXTRN_SYSCALL_MSRS \
1041 | CPUMCTX_EXTRN_SYSENTER_MSRS | CPUMCTX_EXTRN_TSC_AUX | CPUMCTX_EXTRN_OTHER_MSRS)
1042
1043/** Hardware-virtualization (SVM or VMX) state is kept externally. */
1044#define CPUMCTX_EXTRN_HWVIRT UINT64_C(0x0000020000000000)
1045
1046/** Mask of bits the keepers can use for state tracking. */
1047#define CPUMCTX_EXTRN_KEEPER_STATE_MASK UINT64_C(0xffff000000000000)
1048
1049/** NEM/Win: Event injection (known was interruption) pending state. */
1050#define CPUMCTX_EXTRN_NEM_WIN_EVENT_INJECT UINT64_C(0x0001000000000000)
1051/** NEM/Win: Inhibit maskable interrupts (VMCPU_FF_INHIBIT_INTERRUPTS). */
1052#define CPUMCTX_EXTRN_NEM_WIN_INHIBIT_INT UINT64_C(0x0002000000000000)
1053/** NEM/Win: Inhibit non-maskable interrupts (VMCPU_FF_BLOCK_NMIS). */
1054#define CPUMCTX_EXTRN_NEM_WIN_INHIBIT_NMI UINT64_C(0x0004000000000000)
1055/** NEM/Win: Mask. */
1056#define CPUMCTX_EXTRN_NEM_WIN_MASK UINT64_C(0x0007000000000000)
1057
1058/** HM/SVM: Inhibit maskable interrupts (VMCPU_FF_INHIBIT_INTERRUPTS). */
1059#define CPUMCTX_EXTRN_HM_SVM_INT_SHADOW UINT64_C(0x0001000000000000)
1060/** HM/SVM: Nested-guest interrupt pending (VMCPU_FF_INTERRUPT_NESTED_GUEST). */
1061#define CPUMCTX_EXTRN_HM_SVM_HWVIRT_VIRQ UINT64_C(0x0002000000000000)
1062/** HM/SVM: Mask. */
1063#define CPUMCTX_EXTRN_HM_SVM_MASK UINT64_C(0x0003000000000000)
1064
1065/** HM/VMX: Guest-interruptibility state (VMCPU_FF_INHIBIT_INTERRUPTS,
1066 * VMCPU_FF_BLOCK_NMIS). */
1067#define CPUMCTX_EXTRN_HM_VMX_INT_STATE UINT64_C(0x0001000000000000)
1068/** HM/VMX: Mask. */
1069#define CPUMCTX_EXTRN_HM_VMX_MASK UINT64_C(0x0001000000000000)
1070
1071/** All CPUM state bits, not including keeper specific ones. */
1072#define CPUMCTX_EXTRN_ALL UINT64_C(0x000003fffffffffc)
1073/** All CPUM state bits, including keeper specific ones. */
1074#define CPUMCTX_EXTRN_ABSOLUTELY_ALL UINT64_C(0xfffffffffffffffc)
1075/** @} */
1076
1077
1078/**
1079 * Additional guest MSRs (i.e. not part of the CPU context structure).
1080 *
1081 * @remarks Never change the order here because of the saved stated! The size
1082 * can in theory be changed, but keep older VBox versions in mind.
1083 */
1084typedef union CPUMCTXMSRS
1085{
1086 struct
1087 {
1088 uint64_t TscAux; /**< MSR_K8_TSC_AUX */
1089 uint64_t MiscEnable; /**< MSR_IA32_MISC_ENABLE */
1090 uint64_t MtrrDefType; /**< IA32_MTRR_DEF_TYPE */
1091 uint64_t MtrrFix64K_00000; /**< IA32_MTRR_FIX16K_80000 */
1092 uint64_t MtrrFix16K_80000; /**< IA32_MTRR_FIX16K_80000 */
1093 uint64_t MtrrFix16K_A0000; /**< IA32_MTRR_FIX16K_A0000 */
1094 uint64_t MtrrFix4K_C0000; /**< IA32_MTRR_FIX4K_C0000 */
1095 uint64_t MtrrFix4K_C8000; /**< IA32_MTRR_FIX4K_C8000 */
1096 uint64_t MtrrFix4K_D0000; /**< IA32_MTRR_FIX4K_D0000 */
1097 uint64_t MtrrFix4K_D8000; /**< IA32_MTRR_FIX4K_D8000 */
1098 uint64_t MtrrFix4K_E0000; /**< IA32_MTRR_FIX4K_E0000 */
1099 uint64_t MtrrFix4K_E8000; /**< IA32_MTRR_FIX4K_E8000 */
1100 uint64_t MtrrFix4K_F0000; /**< IA32_MTRR_FIX4K_F0000 */
1101 uint64_t MtrrFix4K_F8000; /**< IA32_MTRR_FIX4K_F8000 */
1102 uint64_t PkgCStateCfgCtrl; /**< MSR_PKG_CST_CONFIG_CONTROL */
1103 uint64_t SpecCtrl; /**< IA32_SPEC_CTRL */
1104 uint64_t ArchCaps; /**< IA32_ARCH_CAPABILITIES */
1105 } msr;
1106 uint64_t au64[64];
1107} CPUMCTXMSRS;
1108/** Pointer to the guest MSR state. */
1109typedef CPUMCTXMSRS *PCPUMCTXMSRS;
1110/** Pointer to the const guest MSR state. */
1111typedef const CPUMCTXMSRS *PCCPUMCTXMSRS;
1112
1113/** @} */
1114
1115RT_C_DECLS_END
1116
1117#endif /* !VBOX_INCLUDED_vmm_cpumctx_h */
1118
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