VirtualBox

source: vbox/trunk/src/VBox/VMM/include/VMXInternal.h@ 92489

Last change on this file since 92489 was 92359, checked in by vboxsync, 3 years ago

VMM/include: Seperate some things we require both for HM and the NEM/VMX template on darwin into a dedicated header, bugref:10136 [fix]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 12.8 KB
Line 
1/* $Id: VMXInternal.h 92359 2021-11-11 11:06:08Z vboxsync $ */
2/** @file
3 * VMX - Internal header file for the VMX code template.
4 */
5
6/*
7 * Copyright (C) 2006-2021 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VMM_INCLUDED_SRC_include_VMXInternal_h
19#define VMM_INCLUDED_SRC_include_VMXInternal_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "HMVMXCommon.h"
25
26#if HC_ARCH_BITS == 32
27# error "32-bit hosts are no longer supported. Go back to 6.0 or earlier!"
28#endif
29
30/** @def HM_PROFILE_EXIT_DISPATCH
31 * Enables profiling of the VM exit handler dispatching. */
32#if 0 || defined(DOXYGEN_RUNNING)
33# define HM_PROFILE_EXIT_DISPATCH
34#endif
35
36RT_C_DECLS_BEGIN
37
38
39/** @defgroup grp_hm_int Internal
40 * @ingroup grp_hm
41 * @internal
42 * @{
43 */
44
45/** @addtogroup grp_hm_int_vmx VMX Internal
46 * @{ */
47/**
48 * VMX VMCS information, shared.
49 *
50 * This structure provides information maintained for and during the executing of a
51 * guest (or nested-guest) VMCS (VM control structure) using hardware-assisted VMX.
52 *
53 * Note! The members here are ordered and aligned based on estimated frequency of
54 * usage and grouped to fit within a cache line in hot code paths. Even subtle
55 * changes here have a noticeable effect in the bootsector benchmarks. Modify with
56 * care.
57 */
58
59/**
60 * VMX per-VCPU transient state.
61 *
62 * A state structure for holding miscellaneous information across
63 * VMX non-root operation and restored after the transition.
64 *
65 * Note: The members are ordered and aligned such that the most
66 * frequently used ones (in the guest execution loop) fall within
67 * the first cache line.
68 */
69typedef struct VMXTRANSIENT
70{
71 /** Mask of currently read VMCS fields; HMVMX_READ_XXX. */
72 uint32_t fVmcsFieldsRead;
73 /** The guest's TPR value used for TPR shadowing. */
74 uint8_t u8GuestTpr;
75 uint8_t abAlignment0[3];
76
77 /** Whether the VM-exit was caused by a page-fault during delivery of an
78 * external interrupt or NMI. */
79 bool fVectoringPF;
80 /** Whether the VM-exit was caused by a page-fault during delivery of a
81 * contributory exception or a page-fault. */
82 bool fVectoringDoublePF;
83 /** Whether the VM-entry failed or not. */
84 bool fVMEntryFailed;
85 /** Whether the TSC_AUX MSR needs to be removed from the auto-load/store MSR
86 * area after VM-exit. */
87 bool fRemoveTscAuxMsr;
88 /** Whether TSC-offsetting and VMX-preemption timer was updated before VM-entry. */
89 bool fUpdatedTscOffsettingAndPreemptTimer;
90 /** Whether we are currently executing a nested-guest. */
91 bool fIsNestedGuest;
92 /** Whether the guest debug state was active at the time of VM-exit. */
93 bool fWasGuestDebugStateActive;
94 /** Whether the hyper debug state was active at the time of VM-exit. */
95 bool fWasHyperDebugStateActive;
96
97 /** The basic VM-exit reason. */
98 uint32_t uExitReason;
99 /** The VM-exit interruption error code. */
100 uint32_t uExitIntErrorCode;
101
102 /** The host's rflags/eflags. */
103 RTCCUINTREG fEFlags;
104
105 /** The VM-exit exit code qualification. */
106 uint64_t uExitQual;
107
108 /** The VMCS info. object. */
109 PVMXVMCSINFO pVmcsInfo;
110
111 /** The VM-exit interruption-information field. */
112 uint32_t uExitIntInfo;
113 /** The VM-exit instruction-length field. */
114 uint32_t cbExitInstr;
115
116 /** The VM-exit instruction-information field. */
117 VMXEXITINSTRINFO ExitInstrInfo;
118 /** IDT-vectoring information field. */
119 uint32_t uIdtVectoringInfo;
120
121 /** IDT-vectoring error code. */
122 uint32_t uIdtVectoringErrorCode;
123 uint32_t u32Alignment0;
124
125 /** The Guest-linear address. */
126 uint64_t uGuestLinearAddr;
127
128 /** The Guest-physical address. */
129 uint64_t uGuestPhysicalAddr;
130
131 /** The Guest pending-debug exceptions. */
132 uint64_t uGuestPendingDbgXcpts;
133
134 /** The VM-entry interruption-information field. */
135 uint32_t uEntryIntInfo;
136 /** The VM-entry exception error code field. */
137 uint32_t uEntryXcptErrorCode;
138
139 /** The VM-entry instruction length field. */
140 uint32_t cbEntryInstr;
141} VMXTRANSIENT;
142AssertCompileMemberSize(VMXTRANSIENT, ExitInstrInfo, sizeof(uint32_t));
143AssertCompileMemberAlignment(VMXTRANSIENT, fVmcsFieldsRead, 8);
144AssertCompileMemberAlignment(VMXTRANSIENT, fVectoringPF, 8);
145AssertCompileMemberAlignment(VMXTRANSIENT, uExitReason, 8);
146AssertCompileMemberAlignment(VMXTRANSIENT, fEFlags, 8);
147AssertCompileMemberAlignment(VMXTRANSIENT, uExitQual, 8);
148AssertCompileMemberAlignment(VMXTRANSIENT, pVmcsInfo, 8);
149AssertCompileMemberAlignment(VMXTRANSIENT, uExitIntInfo, 8);
150AssertCompileMemberAlignment(VMXTRANSIENT, ExitInstrInfo, 8);
151AssertCompileMemberAlignment(VMXTRANSIENT, uIdtVectoringErrorCode, 8);
152AssertCompileMemberAlignment(VMXTRANSIENT, uGuestLinearAddr, 8);
153AssertCompileMemberAlignment(VMXTRANSIENT, uGuestPhysicalAddr, 8);
154AssertCompileMemberAlignment(VMXTRANSIENT, uEntryIntInfo, 8);
155AssertCompileMemberAlignment(VMXTRANSIENT, cbEntryInstr, 8);
156/** Pointer to VMX transient state. */
157typedef VMXTRANSIENT *PVMXTRANSIENT;
158/** Pointer to a const VMX transient state. */
159typedef const VMXTRANSIENT *PCVMXTRANSIENT;
160
161
162/**
163 * VMX statistics structure.
164 */
165typedef struct VMXSTATISTICS
166{
167 /* These two comes because they are accessed from assembly and we don't
168 want to detail all the stats in the assembly version of this structure. */
169 STAMCOUNTER StatVmxWriteHostRip;
170 STAMCOUNTER StatVmxWriteHostRsp;
171 STAMCOUNTER StatVmxVmLaunch;
172 STAMCOUNTER StatVmxVmResume;
173
174 STAMPROFILEADV StatEntry;
175 STAMPROFILEADV StatPreExit;
176 STAMPROFILEADV StatExitHandling;
177 STAMPROFILEADV StatExitIO;
178 STAMPROFILEADV StatExitMovCRx;
179 STAMPROFILEADV StatExitXcptNmi;
180 STAMPROFILEADV StatExitVmentry;
181 STAMPROFILEADV StatImportGuestState;
182 STAMPROFILEADV StatExportGuestState;
183 STAMPROFILEADV StatLoadGuestFpuState;
184 STAMPROFILEADV StatInGC;
185 STAMPROFILEADV StatPoke;
186 STAMPROFILEADV StatSpinPoke;
187 STAMPROFILEADV StatSpinPokeFailed;
188
189 STAMCOUNTER StatInjectInterrupt;
190 STAMCOUNTER StatInjectXcpt;
191 STAMCOUNTER StatInjectReflect;
192 STAMCOUNTER StatInjectConvertDF;
193 STAMCOUNTER StatInjectInterpret;
194 STAMCOUNTER StatInjectReflectNPF;
195
196 STAMCOUNTER StatExitAll;
197 STAMCOUNTER StatNestedExitAll;
198 STAMCOUNTER StatExitShadowNM;
199 STAMCOUNTER StatExitGuestNM;
200 STAMCOUNTER StatExitShadowPF; /**< Misleading, currently used for MMIO \#PFs as well. */
201 STAMCOUNTER StatExitShadowPFEM;
202 STAMCOUNTER StatExitGuestPF;
203 STAMCOUNTER StatExitGuestUD;
204 STAMCOUNTER StatExitGuestSS;
205 STAMCOUNTER StatExitGuestNP;
206 STAMCOUNTER StatExitGuestTS;
207 STAMCOUNTER StatExitGuestOF;
208 STAMCOUNTER StatExitGuestGP;
209 STAMCOUNTER StatExitGuestDE;
210 STAMCOUNTER StatExitGuestDF;
211 STAMCOUNTER StatExitGuestBR;
212 STAMCOUNTER StatExitGuestAC;
213 STAMCOUNTER StatExitGuestACSplitLock;
214 STAMCOUNTER StatExitGuestDB;
215 STAMCOUNTER StatExitGuestMF;
216 STAMCOUNTER StatExitGuestBP;
217 STAMCOUNTER StatExitGuestXF;
218 STAMCOUNTER StatExitGuestXcpUnk;
219 STAMCOUNTER StatExitDRxWrite;
220 STAMCOUNTER StatExitDRxRead;
221 STAMCOUNTER StatExitCR0Read;
222 STAMCOUNTER StatExitCR2Read;
223 STAMCOUNTER StatExitCR3Read;
224 STAMCOUNTER StatExitCR4Read;
225 STAMCOUNTER StatExitCR8Read;
226 STAMCOUNTER StatExitCR0Write;
227 STAMCOUNTER StatExitCR2Write;
228 STAMCOUNTER StatExitCR3Write;
229 STAMCOUNTER StatExitCR4Write;
230 STAMCOUNTER StatExitCR8Write;
231 STAMCOUNTER StatExitRdmsr;
232 STAMCOUNTER StatExitWrmsr;
233 STAMCOUNTER StatExitClts;
234 STAMCOUNTER StatExitXdtrAccess;
235 STAMCOUNTER StatExitLmsw;
236 STAMCOUNTER StatExitIOWrite;
237 STAMCOUNTER StatExitIORead;
238 STAMCOUNTER StatExitIOStringWrite;
239 STAMCOUNTER StatExitIOStringRead;
240 STAMCOUNTER StatExitIntWindow;
241 STAMCOUNTER StatExitExtInt;
242 STAMCOUNTER StatExitHostNmiInGC;
243 STAMCOUNTER StatExitHostNmiInGCIpi;
244 STAMCOUNTER StatExitPreemptTimer;
245 STAMCOUNTER StatExitTprBelowThreshold;
246 STAMCOUNTER StatExitTaskSwitch;
247 STAMCOUNTER StatExitApicAccess;
248 STAMCOUNTER StatExitReasonNpf;
249
250 STAMCOUNTER StatNestedExitReasonNpf;
251
252 STAMCOUNTER StatFlushPage;
253 STAMCOUNTER StatFlushPageManual;
254 STAMCOUNTER StatFlushPhysPageManual;
255 STAMCOUNTER StatFlushTlb;
256 STAMCOUNTER StatFlushTlbNstGst;
257 STAMCOUNTER StatFlushTlbManual;
258 STAMCOUNTER StatFlushTlbWorldSwitch;
259 STAMCOUNTER StatNoFlushTlbWorldSwitch;
260 STAMCOUNTER StatFlushEntire;
261 STAMCOUNTER StatFlushAsid;
262 STAMCOUNTER StatFlushNestedPaging;
263 STAMCOUNTER StatFlushTlbInvlpgVirt;
264 STAMCOUNTER StatFlushTlbInvlpgPhys;
265 STAMCOUNTER StatTlbShootdown;
266 STAMCOUNTER StatTlbShootdownFlush;
267
268 STAMCOUNTER StatSwitchPendingHostIrq;
269 STAMCOUNTER StatSwitchTprMaskedIrq;
270 STAMCOUNTER StatSwitchGuestIrq;
271 STAMCOUNTER StatSwitchHmToR3FF;
272 STAMCOUNTER StatSwitchVmReq;
273 STAMCOUNTER StatSwitchPgmPoolFlush;
274 STAMCOUNTER StatSwitchDma;
275 STAMCOUNTER StatSwitchExitToR3;
276 STAMCOUNTER StatSwitchLongJmpToR3;
277 STAMCOUNTER StatSwitchMaxResumeLoops;
278 STAMCOUNTER StatSwitchHltToR3;
279 STAMCOUNTER StatSwitchApicAccessToR3;
280 STAMCOUNTER StatSwitchPreempt;
281 STAMCOUNTER StatSwitchNstGstVmexit;
282
283 STAMCOUNTER StatTscParavirt;
284 STAMCOUNTER StatTscOffset;
285 STAMCOUNTER StatTscIntercept;
286
287 STAMCOUNTER StatDRxArmed;
288 STAMCOUNTER StatDRxContextSwitch;
289 STAMCOUNTER StatDRxIoCheck;
290
291 STAMCOUNTER StatExportMinimal;
292 STAMCOUNTER StatExportFull;
293 STAMCOUNTER StatLoadGuestFpu;
294 STAMCOUNTER StatExportHostState;
295
296 STAMCOUNTER StatVmxCheckBadRmSelBase;
297 STAMCOUNTER StatVmxCheckBadRmSelLimit;
298 STAMCOUNTER StatVmxCheckBadRmSelAttr;
299 STAMCOUNTER StatVmxCheckBadV86SelBase;
300 STAMCOUNTER StatVmxCheckBadV86SelLimit;
301 STAMCOUNTER StatVmxCheckBadV86SelAttr;
302 STAMCOUNTER StatVmxCheckRmOk;
303 STAMCOUNTER StatVmxCheckBadSel;
304 STAMCOUNTER StatVmxCheckBadRpl;
305 STAMCOUNTER StatVmxCheckPmOk;
306
307 STAMCOUNTER StatVmxPreemptionRecalcingDeadline;
308 STAMCOUNTER StatVmxPreemptionRecalcingDeadlineExpired;
309 STAMCOUNTER StatVmxPreemptionReusingDeadline;
310 STAMCOUNTER StatVmxPreemptionReusingDeadlineExpired;
311
312#ifdef VBOX_WITH_STATISTICS
313 STAMCOUNTER aStatExitReason[MAX_EXITREASON_STAT];
314 STAMCOUNTER aStatNestedExitReason[MAX_EXITREASON_STAT];
315 STAMCOUNTER aStatInjectedIrqs[256];
316 STAMCOUNTER aStatInjectedXcpts[X86_XCPT_LAST + 1];
317#endif
318#ifdef HM_PROFILE_EXIT_DISPATCH
319 STAMPROFILEADV StatExitDispatch;
320#endif
321} VMXSTATISTICS;
322/** Pointer to the VMX statistics. */
323typedef VMXSTATISTICS *PVMXSTATISTICS;
324/** Pointer to a const VMX statistics structure. */
325typedef const VMXSTATISTICS *PCVMXSTATISTICS;
326
327/** @} */
328
329/** @} */
330
331RT_C_DECLS_END
332
333#endif /* !VMM_INCLUDED_SRC_include_VMXInternal_h */
334
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