VirtualBox

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

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

More stats

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 11.1 KB
Line 
1/* $Id: HWACCMInternal.h 2213 2007-04-19 11:25:58Z vboxsync $ */
2/** @file
3 * HWACCM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung 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 2
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 /** Host CR4 value (set by ring-0 VMX init) */
163 uint32_t hostCR4;
164
165 /** Current VMX_VMCS_CTRL_PROC_EXEC_CONTROLS. */
166 uint64_t proc_ctls;
167
168 /** Current CR0 mask. */
169 uint64_t cr0_mask;
170 /** Current CR4 mask. */
171 uint64_t cr4_mask;
172
173 /** VMX MSR values */
174 struct
175 {
176 uint64_t feature_ctrl;
177 uint64_t vmx_basic_info;
178 uint64_t vmx_pin_ctls;
179 uint64_t vmx_proc_ctls;
180 uint64_t vmx_exit;
181 uint64_t vmx_entry;
182 uint64_t vmx_misc;
183 uint64_t vmx_cr0_fixed0;
184 uint64_t vmx_cr0_fixed1;
185 uint64_t vmx_cr4_fixed0;
186 uint64_t vmx_cr4_fixed1;
187 uint64_t vmx_vmcs_enum;
188 } msr;
189 } vmx;
190
191 struct
192 {
193 /** Set by the ring-0 driver to indicate SVM is supported by the CPU. */
194 bool fSupported;
195
196 /** Set when we've enabled SVM. */
197 bool fEnabled;
198
199 /** Set if we don't have to flush the TLB on VM entry. */
200 bool fResumeVM;
201
202 /** Physical address of the VM control block (VMCB). */
203 RTHCPHYS pVMCBPhys;
204 /** Virtual address of the VM control block (VMCB). */
205 void *pVMCB;
206
207 /** Physical address of the host VM control block (VMCB). */
208 RTHCPHYS pVMCBHostPhys;
209 /** Virtual address of the host VM control block (VMCB). */
210 void *pVMCBHost;
211
212 /** Physical address of the Host State page. */
213 RTHCPHYS pHStatePhys;
214 /** Virtual address of the Host State page. */
215 void *pHState;
216
217 /** Physical address of the IO bitmap (12kb). */
218 RTHCPHYS pIOBitmapPhys;
219 /** Virtual address of the IO bitmap. */
220 void *pIOBitmap;
221
222 /** Physical address of the MSR bitmap (8kb). */
223 RTHCPHYS pMSRBitmapPhys;
224 /** Virtual address of the MSR bitmap. */
225 void *pMSRBitmap;
226
227 /** SVM revision. */
228 uint32_t u32Rev;
229
230 /** Maximum ASID allowed. */
231 uint32_t u32MaxASID;
232 } svm;
233
234 struct
235 {
236 uint32_t u32AMDFeatureECX;
237 uint32_t u32AMDFeatureEDX;
238 } cpuid;
239
240 /* Event injection state. */
241 struct
242 {
243 uint32_t fPending;
244 uint32_t errCode;
245 uint64_t intInfo;
246 } Event;
247
248 /** Currenty shadow paging mode. */
249 PGMMODE enmShadowMode;
250
251 STAMPROFILEADV StatEntry;
252 STAMPROFILEADV StatExit;
253 STAMPROFILEADV StatInGC;
254
255 STAMCOUNTER StatIntInject;
256
257 STAMCOUNTER StatExitShadowNM;
258 STAMCOUNTER StatExitGuestNM;
259 STAMCOUNTER StatExitShadowPF;
260 STAMCOUNTER StatExitGuestPF;
261 STAMCOUNTER StatExitGuestUD;
262 STAMCOUNTER StatExitGuestSS;
263 STAMCOUNTER StatExitGuestNP;
264 STAMCOUNTER StatExitGuestGP;
265 STAMCOUNTER StatExitGuestDE;
266 STAMCOUNTER StatExitGuestMF;
267 STAMCOUNTER StatExitInvpg;
268 STAMCOUNTER StatExitInvd;
269 STAMCOUNTER StatExitCpuid;
270 STAMCOUNTER StatExitCRxWrite;
271 STAMCOUNTER StatExitCRxRead;
272 STAMCOUNTER StatExitDRxWrite;
273 STAMCOUNTER StatExitDRxRead;
274 STAMCOUNTER StatExitCLTS;
275 STAMCOUNTER StatExitLMSW;
276 STAMCOUNTER StatExitIOWrite;
277 STAMCOUNTER StatExitIORead;
278 STAMCOUNTER StatExitIOStringWrite;
279 STAMCOUNTER StatExitIOStringRead;
280 STAMCOUNTER StatExitIrqWindow;
281 STAMCOUNTER StatIntReinject;
282 STAMCOUNTER StatPendingHostIrq;
283
284 STAMCOUNTER StatSwitchGuestIrq;
285 STAMCOUNTER StatSwitchToR3;
286
287 PSTAMCOUNTER pStatExitReason;
288} HWACCM;
289/** Pointer to HWACCM VM instance data. */
290typedef HWACCM *PHWACCM;
291
292
293#ifdef IN_RING0
294
295#ifdef VBOX_STRICT
296HWACCMR0DECL(void) HWACCMDumpRegs(PCPUMCTX pCtx);
297HWACCMR0DECL(void) HWACCMR0DumpDescriptor(PVBOXDESC Desc, RTSEL Sel, const char *pszMsg);
298#else
299#define HWACCMDumpRegs(a) do { } while (0)
300#define HWACCMR0DumpDescriptor(a, b, c) do { } while (0)
301#endif
302
303#endif
304
305/** @} */
306
307__END_DECLS
308
309#endif
310
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