VirtualBox

source: vbox/trunk/src/VBox/VMM/EMInternal.h@ 3389

Last change on this file since 3389 was 2981, checked in by vboxsync, 17 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.3 KB
Line 
1/* $Id: EMInternal.h 2981 2007-06-01 16:01:28Z vboxsync $ */
2/** @file
3 * EM - 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 __EMInternal_h__
23#define __EMInternal_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/patm.h>
30#include <VBox/dis.h>
31#include <iprt/avl.h>
32#include <setjmp.h>
33
34__BEGIN_DECLS
35
36
37/** @defgroup grp_em_int Internal
38 * @ingroup grp_em
39 * @internal
40 * @{
41 */
42
43/** The saved state version. */
44#define EM_SAVED_STATE_VERSION 2
45
46/** Enable for tracing in raw mode.
47 * @remark SvL: debugging help primarily for myself. */
48#define DEBUG_TRACING_ENABLED
49
50/**
51 * Converts a EM pointer into a VM pointer.
52 * @returns Pointer to the VM structure the EM is part of.
53 * @param pEM Pointer to EM instance data.
54 */
55#define EM2VM(pEM) ( (PVM)((char*)pEM - pEM->offVM) )
56
57/**
58 * Cli node structure
59 */
60typedef struct CLISTAT
61{
62 /** The key is the cli address. */
63 AVLPVNODECORE Core;
64 /** Occurrences. */
65 STAMCOUNTER Counter;
66} CLISTAT, *PCLISTAT;
67
68
69/**
70 * Excessive EM statistics.
71 */
72typedef struct EMSTATS
73{
74 /** GC: Profiling of EMInterpretInstruction(). */
75 STAMPROFILE StatGCEmulate;
76 /** HC: Profiling of EMInterpretInstruction(). */
77 STAMPROFILE StatHCEmulate;
78
79 /** @name Interpreter Instruction statistics.
80 * @{
81 */
82 STAMCOUNTER StatGCInterpretSucceeded;
83 STAMCOUNTER StatHCInterpretSucceeded;
84
85 STAMCOUNTER StatGCAnd;
86 STAMCOUNTER StatHCAnd;
87 STAMCOUNTER StatGCCpuId;
88 STAMCOUNTER StatHCCpuId;
89 STAMCOUNTER StatGCDec;
90 STAMCOUNTER StatHCDec;
91 STAMCOUNTER StatGCHlt;
92 STAMCOUNTER StatHCHlt;
93 STAMCOUNTER StatGCInc;
94 STAMCOUNTER StatHCInc;
95 STAMCOUNTER StatGCInvlPg;
96 STAMCOUNTER StatHCInvlPg;
97 STAMCOUNTER StatGCIret;
98 STAMCOUNTER StatHCIret;
99 STAMCOUNTER StatGCLLdt;
100 STAMCOUNTER StatHCLLdt;
101 STAMCOUNTER StatGCMov;
102 STAMCOUNTER StatHCMov;
103 STAMCOUNTER StatGCMovCRx;
104 STAMCOUNTER StatHCMovCRx;
105 STAMCOUNTER StatGCMovDRx;
106 STAMCOUNTER StatHCMovDRx;
107 STAMCOUNTER StatGCOr;
108 STAMCOUNTER StatHCOr;
109 STAMCOUNTER StatGCPop;
110 STAMCOUNTER StatHCPop;
111 STAMCOUNTER StatGCSti;
112 STAMCOUNTER StatHCSti;
113 STAMCOUNTER StatGCXchg;
114 STAMCOUNTER StatHCXchg;
115 STAMCOUNTER StatGCXor;
116 STAMCOUNTER StatHCXor;
117 STAMCOUNTER StatGCMonitor;
118 STAMCOUNTER StatHCMonitor;
119 STAMCOUNTER StatGCMWait;
120 STAMCOUNTER StatHCMWait;
121 STAMCOUNTER StatGCAdd;
122 STAMCOUNTER StatHCAdd;
123 STAMCOUNTER StatGCSub;
124 STAMCOUNTER StatHCSub;
125 STAMCOUNTER StatGCAdc;
126 STAMCOUNTER StatHCAdc;
127 STAMCOUNTER StatGCRdtsc;
128 STAMCOUNTER StatHCRdtsc;
129 STAMCOUNTER StatGCBtr;
130 STAMCOUNTER StatHCBtr;
131 STAMCOUNTER StatGCBts;
132 STAMCOUNTER StatHCBts;
133 STAMCOUNTER StatGCBtc;
134 STAMCOUNTER StatHCBtc;
135 STAMCOUNTER StatGCCmpXchg;
136 STAMCOUNTER StatHCCmpXchg;
137
138 STAMCOUNTER StatGCInterpretFailed;
139 STAMCOUNTER StatHCInterpretFailed;
140
141 STAMCOUNTER StatGCFailedAnd;
142 STAMCOUNTER StatHCFailedAnd;
143 STAMCOUNTER StatGCFailedCpuId;
144 STAMCOUNTER StatHCFailedCpuId;
145 STAMCOUNTER StatGCFailedDec;
146 STAMCOUNTER StatHCFailedDec;
147 STAMCOUNTER StatGCFailedHlt;
148 STAMCOUNTER StatHCFailedHlt;
149 STAMCOUNTER StatGCFailedInc;
150 STAMCOUNTER StatHCFailedInc;
151 STAMCOUNTER StatGCFailedInvlPg;
152 STAMCOUNTER StatHCFailedInvlPg;
153 STAMCOUNTER StatGCFailedIret;
154 STAMCOUNTER StatHCFailedIret;
155 STAMCOUNTER StatGCFailedLLdt;
156 STAMCOUNTER StatHCFailedLLdt;
157 STAMCOUNTER StatGCFailedMisc;
158 STAMCOUNTER StatHCFailedMisc;
159 STAMCOUNTER StatGCFailedMov;
160 STAMCOUNTER StatHCFailedMov;
161 STAMCOUNTER StatGCFailedMovCRx;
162 STAMCOUNTER StatHCFailedMovCRx;
163 STAMCOUNTER StatGCFailedMovDRx;
164 STAMCOUNTER StatHCFailedMovDRx;
165 STAMCOUNTER StatGCFailedOr;
166 STAMCOUNTER StatHCFailedOr;
167 STAMCOUNTER StatGCFailedPop;
168 STAMCOUNTER StatHCFailedPop;
169 STAMCOUNTER StatGCFailedSti;
170 STAMCOUNTER StatHCFailedSti;
171 STAMCOUNTER StatGCFailedXchg;
172 STAMCOUNTER StatHCFailedXchg;
173 STAMCOUNTER StatGCFailedXor;
174 STAMCOUNTER StatHCFailedXor;
175 STAMCOUNTER StatGCFailedMonitor;
176 STAMCOUNTER StatHCFailedMonitor;
177 STAMCOUNTER StatGCFailedMWait;
178 STAMCOUNTER StatHCFailedMWait;
179
180 STAMCOUNTER StatGCFailedAdd;
181 STAMCOUNTER StatHCFailedAdd;
182 STAMCOUNTER StatGCFailedAdc;
183 STAMCOUNTER StatHCFailedAdc;
184 STAMCOUNTER StatGCFailedBtr;
185 STAMCOUNTER StatHCFailedBtr;
186 STAMCOUNTER StatGCFailedBts;
187 STAMCOUNTER StatHCFailedBts;
188 STAMCOUNTER StatGCFailedBtc;
189 STAMCOUNTER StatHCFailedBtc;
190 STAMCOUNTER StatGCFailedCli;
191 STAMCOUNTER StatHCFailedCli;
192 STAMCOUNTER StatGCFailedCmpXchg;
193 STAMCOUNTER StatHCFailedCmpXchg;
194 STAMCOUNTER StatHCFailedMovNTPS;
195 STAMCOUNTER StatGCFailedMovNTPS;
196 STAMCOUNTER StatGCFailedStosWD;
197 STAMCOUNTER StatHCFailedStosWD;
198 STAMCOUNTER StatGCFailedSub;
199 STAMCOUNTER StatHCFailedSub;
200 STAMCOUNTER StatGCFailedWbInvd;
201 STAMCOUNTER StatHCFailedWbInvd;
202 STAMCOUNTER StatGCFailedRdtsc;
203 STAMCOUNTER StatHCFailedRdtsc;
204
205 STAMCOUNTER StatGCFailedUserMode;
206 STAMCOUNTER StatHCFailedUserMode;
207 STAMCOUNTER StatGCFailedPrefix;
208 STAMCOUNTER StatHCFailedPrefix;
209 /** @} */
210
211 /** @name Privileged Instructions Ending Up In HC.
212 * @{ */
213 STAMCOUNTER StatCli;
214 STAMCOUNTER StatSti;
215 STAMCOUNTER StatIn;
216 STAMCOUNTER StatOut;
217 STAMCOUNTER StatInvlpg;
218 STAMCOUNTER StatHlt;
219 STAMCOUNTER StatMovReadCR[USE_REG_CR4 + 1];
220 STAMCOUNTER StatMovWriteCR[USE_REG_CR4 + 1];
221 STAMCOUNTER StatMovDRx;
222 STAMCOUNTER StatIret;
223 STAMCOUNTER StatMovLgdt;
224 STAMCOUNTER StatMovLldt;
225 STAMCOUNTER StatMovLidt;
226 STAMCOUNTER StatMisc;
227 STAMCOUNTER StatSysEnter;
228 STAMCOUNTER StatSysExit;
229 STAMCOUNTER StatSysCall;
230 STAMCOUNTER StatSysRet;
231 /** @} */
232
233} EMSTATS, *PEMSTATS;
234
235/**
236 * EM VM Instance data.
237 * Changes to this must checked against the padding of the cfgm union in VM!
238 */
239typedef struct EM
240{
241 /** Offset to the VM structure.
242 * See EM2VM(). */
243 RTUINT offVM;
244
245 /** Execution Manager State. */
246 volatile EMSTATE enmState;
247 /** Force raw-mode execution.
248 * This is used to prevent REM from trying to execute patch code.
249 * The flag is cleared upon entering emR3RawExecute() and updated in certain return paths. */
250 bool fForceRAW;
251
252#ifdef DEBUG_TRACING_ENABLED
253 /** @see DEBUG_TRACING_ENABLED */
254 bool fTracing;
255#endif
256
257 /** Inhibit interrupts for this instruction. Valid only when VM_FF_INHIBIT_INTERRUPTS is set. */
258 RTGCUINTPTR GCPtrInhibitInterrupts;
259
260
261 /** Pointer to the PATM status structure. (HC Ptr) */
262 HCPTRTYPE(PPATMGCSTATE) pPatmGCState;
263
264 /** Pointer to the guest CPUM state. (HC Ptr) */
265 HCPTRTYPE(PCPUMCTX) pCtx;
266
267
268 union
269 {
270 /** Padding used in the other rings.
271 * This must be larger than jmp_buf on any supported platform. */
272 char achPaddingFatalLongJump[HC_ARCH_BITS == 32 ? 176 : 256];
273#ifdef IN_RING3
274 /** Long buffer jump for fatal VM errors.
275 * It will jump to before the outer EM loop is entered. */
276 jmp_buf FatalLongJump;
277#endif
278 } u;
279
280 /** @name Execution profiling.
281 * @{ */
282 STAMPROFILE StatForcedActions;
283 STAMPROFILE StatHalted;
284 STAMPROFILEADV StatHwAccEntry;
285 STAMPROFILE StatHwAccExec;
286 STAMPROFILE StatREMEmu;
287 STAMPROFILE StatREMExec;
288 STAMPROFILE StatREMSync;
289 STAMPROFILEADV StatREMTotal;
290 STAMPROFILE StatRAWExec;
291 STAMPROFILEADV StatRAWEntry;
292 STAMPROFILEADV StatRAWTail;
293 STAMPROFILEADV StatRAWTotal;
294 STAMPROFILEADV StatTotal;
295 /** @} */
296
297 /** HC: Profiling of emR3RawExecuteIOInstruction. */
298 STAMPROFILE StatIOEmu;
299 /** HC: Profiling of emR3RawPrivileged. */
300 STAMPROFILE StatPrivEmu;
301 /** HC: Profiling of emR3RawExecuteInstruction. */
302 STAMPROFILE StatMiscEmu;
303
304 /** @todo r=bird: Are any of these actually used? */
305 STAMCOUNTER StatPatchTrap;
306 STAMCOUNTER StatPatchInt3;
307 STAMCOUNTER StatPatchIF0;
308 STAMCOUNTER StatPatchEmulate;
309 STAMCOUNTER StatPageOutOfSync;
310 STAMCOUNTER StatHwAccExecuteEntry;
311
312 /** More statistics (HC). */
313 HCPTRTYPE(PEMSTATS) pStatsHC;
314 /** More statistics (GC). */
315 GCPTRTYPE(PEMSTATS) pStatsGC;
316#if HC_ARCH_BITS != GC_ARCH_BITS && GC_ARCH_BITS == 32
317 RTGCPTR padding0;
318#endif
319
320 /** Tree for keeping track of cli occurances (debug only). */
321 HCPTRTYPE(PAVLPVNODECORE) pCliStatTree;
322 STAMCOUNTER StatTotalClis;
323#if 0
324 /** 64-bit Visual C++ rounds the struct size up to 16 byte. */
325 uint64_t padding1;
326#endif
327
328} EM;
329/** Pointer to EM VM instance data. */
330typedef EM *PEM;
331
332
333
334/** @} */
335
336__END_DECLS
337
338#endif
339
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