VirtualBox

source: vbox/trunk/src/VBox/VMM/HWACCMInternal.h@ 3272

Last change on this file since 3272 was 2981, checked in by vboxsync, 18 years ago

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.4 KB
Line 
1/* $Id: HWACCMInternal.h 2981 2007-06-01 16:01:28Z vboxsync $ */
2/** @file
3 * HWACCM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#ifndef __HWACCMInternal_h__
23#define __HWACCMInternal_h__
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <VBox/em.h>
28#include <VBox/stam.h>
29#include <VBox/dis.h>
30#include <VBox/hwaccm.h>
31#include <VBox/pgm.h>
32
33__BEGIN_DECLS
34
35
36/** @defgroup grp_hwaccm_int Internal
37 * @ingroup grp_hwaccm
38 * @internal
39 * @{
40 */
41
42
43/**
44 * Converts a HWACCM pointer into a VM pointer.
45 * @returns Pointer to the VM structure the EM is part of.
46 * @param pHWACCM Pointer to HWACCM instance data.
47 */
48#define HWACCM2VM(pHWACCM) ( (PVM)((char*)pHWACCM - pHWACCM->offVM) )
49
50/** Maximum number of exit reason statistics counters. */
51#define MAX_EXITREASON_STAT 0x100
52#define MASK_EXITREASON_STAT 0xff
53
54/** @name Changed flags
55 * These flags are used to keep track of which important registers that
56 * have been changed since last they were reset.
57 * @{
58 */
59#define HWACCM_CHANGED_GUEST_FPU BIT(0)
60#define HWACCM_CHANGED_GUEST_CR0 BIT(1)
61#define HWACCM_CHANGED_GUEST_CR3 BIT(2)
62#define HWACCM_CHANGED_GUEST_CR4 BIT(3)
63#define HWACCM_CHANGED_GUEST_GDTR BIT(4)
64#define HWACCM_CHANGED_GUEST_IDTR BIT(5)
65#define HWACCM_CHANGED_GUEST_LDTR BIT(6)
66#define HWACCM_CHANGED_GUEST_TR BIT(7)
67#define HWACCM_CHANGED_GUEST_SYSENTER_MSR BIT(8)
68#define HWACCM_CHANGED_GUEST_SEGMENT_REGS BIT(9)
69#define HWACCM_CHANGED_GUEST_DEBUG BIT(10)
70#define HWACCM_CHANGED_HOST_CONTEXT BIT(11)
71
72#define HWACCM_CHANGED_ALL ( HWACCM_CHANGED_GUEST_SEGMENT_REGS \
73 | HWACCM_CHANGED_GUEST_CR0 \
74 | HWACCM_CHANGED_GUEST_CR3 \
75 | HWACCM_CHANGED_GUEST_CR4 \
76 | HWACCM_CHANGED_GUEST_GDTR \
77 | HWACCM_CHANGED_GUEST_IDTR \
78 | HWACCM_CHANGED_GUEST_LDTR \
79 | HWACCM_CHANGED_GUEST_TR \
80 | HWACCM_CHANGED_GUEST_SYSENTER_MSR \
81 | HWACCM_CHANGED_GUEST_FPU \
82 | HWACCM_CHANGED_GUEST_DEBUG \
83 | HWACCM_CHANGED_HOST_CONTEXT)
84
85#define HWACCM_CHANGED_ALL_GUEST ( HWACCM_CHANGED_GUEST_SEGMENT_REGS \
86 | HWACCM_CHANGED_GUEST_CR0 \
87 | HWACCM_CHANGED_GUEST_CR3 \
88 | HWACCM_CHANGED_GUEST_CR4 \
89 | HWACCM_CHANGED_GUEST_GDTR \
90 | HWACCM_CHANGED_GUEST_IDTR \
91 | HWACCM_CHANGED_GUEST_LDTR \
92 | HWACCM_CHANGED_GUEST_TR \
93 | HWACCM_CHANGED_GUEST_SYSENTER_MSR \
94 | HWACCM_CHANGED_GUEST_DEBUG \
95 | HWACCM_CHANGED_GUEST_FPU)
96
97/** @} */
98
99/** @name Intercepted traps
100 * Traps that need to be intercepted so we can correctly dispatch them to the guest if required.
101 * Currently #NM and #PF only
102 */
103#ifdef VBOX_STRICT
104#define HWACCM_VMX_TRAP_MASK BIT(0) | BIT(7) | BIT(14) | BIT(6) | BIT(11) | BIT(12) | BIT(13) | BIT(16)
105#define HWACCM_SVM_TRAP_MASK HWACCM_VMX_TRAP_MASK
106#else
107#define HWACCM_VMX_TRAP_MASK BIT(7) | BIT(14)
108#define HWACCM_SVM_TRAP_MASK HWACCM_VMX_TRAP_MASK
109#endif
110/** @} */
111
112
113/** @name HWACCM SSM version
114 */
115#define HWACCM_SSM_VERSION 3
116
117/**
118 * HWACCM VM Instance data.
119 * Changes to this must checked against the padding of the cfgm union in VM!
120 */
121typedef struct HWACCM
122{
123 /** Offset to the VM structure.
124 * See HWACCM2VM(). */
125 RTUINT offVM;
126
127 /** Set when we've initialized VMX or SVM. */
128 bool fInitialized;
129 /** Set when we're using VMX/SVN at that moment. */
130 bool fActive;
131
132 /** Set when hardware acceleration is allowed. */
133 bool fAllowed;
134
135 /** HWACCM_CHANGED_* flags. */
136 uint32_t fContextUseFlags;
137
138 /** Old style FPU reporting trap mask override performed (optimization) */
139 uint32_t fFPUOldStyleOverride;
140
141 struct
142 {
143 /** Set by the ring-0 driver to indicate VMX is supported by the CPU. */
144 bool fSupported;
145
146 /** Set when we've enabled VMX. */
147 bool fEnabled;
148
149 /** Set if we can use VMXResume to execute guest code. */
150 bool fResumeVM;
151
152 /** Physical address of the VM control structure (VMCS). */
153 RTHCPHYS pVMCSPhys;
154 /** Virtual address of the VM control structure (VMCS). */
155 void *pVMCS;
156
157 /** Physical address of the VMXON page. */
158 RTHCPHYS pVMXONPhys;
159 /** Virtual address of the VMXON page. */
160 void *pVMXON;
161
162 /** Physical address of the TSS page used for real mode emulation. */
163 RTHCPHYS pRealModeTSSPhys;
164 /** Virtual address of the TSS page used for real mode emulation. */
165 PVBOXTSS pRealModeTSS;
166
167 /** Host CR4 value (set by ring-0 VMX init) */
168 uint32_t hostCR4;
169
170 /** Current VMX_VMCS_CTRL_PROC_EXEC_CONTROLS. */
171 uint64_t proc_ctls;
172
173 /** Current CR0 mask. */
174 uint64_t cr0_mask;
175 /** Current CR4 mask. */
176 uint64_t cr4_mask;
177
178 /** VMX MSR values */
179 struct
180 {
181 uint64_t feature_ctrl;
182 uint64_t vmx_basic_info;
183 uint64_t vmx_pin_ctls;
184 uint64_t vmx_proc_ctls;
185 uint64_t vmx_exit;
186 uint64_t vmx_entry;
187 uint64_t vmx_misc;
188 uint64_t vmx_cr0_fixed0;
189 uint64_t vmx_cr0_fixed1;
190 uint64_t vmx_cr4_fixed0;
191 uint64_t vmx_cr4_fixed1;
192 uint64_t vmx_vmcs_enum;
193 } msr;
194 } vmx;
195
196 struct
197 {
198 /** Set by the ring-0 driver to indicate SVM is supported by the CPU. */
199 bool fSupported;
200
201 /** Set when we've enabled SVM. */
202 bool fEnabled;
203
204 /** Set if we don't have to flush the TLB on VM entry. */
205 bool fResumeVM;
206
207 /** Physical address of the VM control block (VMCB). */
208 RTHCPHYS pVMCBPhys;
209 /** Virtual address of the VM control block (VMCB). */
210 void *pVMCB;
211
212 /** Physical address of the host VM control block (VMCB). */
213 RTHCPHYS pVMCBHostPhys;
214 /** Virtual address of the host VM control block (VMCB). */
215 void *pVMCBHost;
216
217 /** Physical address of the Host State page. */
218 RTHCPHYS pHStatePhys;
219 /** Virtual address of the Host State page. */
220 void *pHState;
221
222 /** Physical address of the IO bitmap (12kb). */
223 RTHCPHYS pIOBitmapPhys;
224 /** Virtual address of the IO bitmap. */
225 void *pIOBitmap;
226
227 /** Physical address of the MSR bitmap (8kb). */
228 RTHCPHYS pMSRBitmapPhys;
229 /** Virtual address of the MSR bitmap. */
230 void *pMSRBitmap;
231
232 /** SVM revision. */
233 uint32_t u32Rev;
234
235 /** Maximum ASID allowed. */
236 uint32_t u32MaxASID;
237 } svm;
238
239 struct
240 {
241 uint32_t u32AMDFeatureECX;
242 uint32_t u32AMDFeatureEDX;
243 } cpuid;
244
245 /* Event injection state. */
246 struct
247 {
248 uint32_t fPending;
249 uint32_t errCode;
250 uint64_t intInfo;
251 } Event;
252
253 /** Currenty shadow paging mode. */
254 PGMMODE enmShadowMode;
255
256 STAMPROFILEADV StatEntry;
257 STAMPROFILEADV StatExit;
258 STAMPROFILEADV StatInGC;
259
260 STAMCOUNTER StatIntInject;
261
262 STAMCOUNTER StatExitShadowNM;
263 STAMCOUNTER StatExitGuestNM;
264 STAMCOUNTER StatExitShadowPF;
265 STAMCOUNTER StatExitGuestPF;
266 STAMCOUNTER StatExitGuestUD;
267 STAMCOUNTER StatExitGuestSS;
268 STAMCOUNTER StatExitGuestNP;
269 STAMCOUNTER StatExitGuestGP;
270 STAMCOUNTER StatExitGuestDE;
271 STAMCOUNTER StatExitGuestMF;
272 STAMCOUNTER StatExitInvpg;
273 STAMCOUNTER StatExitInvd;
274 STAMCOUNTER StatExitCpuid;
275 STAMCOUNTER StatExitRdtsc;
276 STAMCOUNTER StatExitCRxWrite;
277 STAMCOUNTER StatExitCRxRead;
278 STAMCOUNTER StatExitDRxWrite;
279 STAMCOUNTER StatExitDRxRead;
280 STAMCOUNTER StatExitCLTS;
281 STAMCOUNTER StatExitLMSW;
282 STAMCOUNTER StatExitIOWrite;
283 STAMCOUNTER StatExitIORead;
284 STAMCOUNTER StatExitIOStringWrite;
285 STAMCOUNTER StatExitIOStringRead;
286 STAMCOUNTER StatExitIrqWindow;
287 STAMCOUNTER StatIntReinject;
288 STAMCOUNTER StatPendingHostIrq;
289
290 STAMCOUNTER StatSwitchGuestIrq;
291 STAMCOUNTER StatSwitchToR3;
292
293 R3PTRTYPE(PSTAMCOUNTER) pStatExitReason;
294 R0PTRTYPE(PSTAMCOUNTER) pStatExitReasonR0;
295} HWACCM;
296/** Pointer to HWACCM VM instance data. */
297typedef HWACCM *PHWACCM;
298
299
300#ifdef IN_RING0
301
302#ifdef VBOX_STRICT
303HWACCMR0DECL(void) HWACCMDumpRegs(PCPUMCTX pCtx);
304HWACCMR0DECL(void) HWACCMR0DumpDescriptor(PX86DESCHC Desc, RTSEL Sel, const char *pszMsg);
305#else
306#define HWACCMDumpRegs(a) do { } while (0)
307#define HWACCMR0DumpDescriptor(a, b, c) do { } while (0)
308#endif
309
310#endif
311
312/** @} */
313
314__END_DECLS
315
316#endif
317
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