VirtualBox

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

Last change on this file since 13232 was 13160, checked in by vboxsync, 16 years ago

Extra statistics

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 12.8 KB
Line 
1/* $Id: EMInternal.h 13160 2008-10-10 11:00:58Z vboxsync $ */
2/** @file
3 * EM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
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 * Cli node structure
52 */
53typedef struct CLISTAT
54{
55 /** The key is the cli address. */
56 AVLPVNODECORE Core;
57 /** Occurrences. */
58 STAMCOUNTER Counter;
59} CLISTAT, *PCLISTAT;
60
61
62/**
63 * Excessive EM statistics.
64 */
65typedef struct EMSTATS
66{
67 /** GC: Profiling of EMInterpretInstruction(). */
68 STAMPROFILE StatRZEmulate;
69 /** HC: Profiling of EMInterpretInstruction(). */
70 STAMPROFILE StatR3Emulate;
71
72 /** @name Interpreter Instruction statistics.
73 * @{
74 */
75 STAMCOUNTER StatRZInterpretSucceeded;
76 STAMCOUNTER StatR3InterpretSucceeded;
77
78 STAMCOUNTER StatRZAnd;
79 STAMCOUNTER StatR3And;
80 STAMCOUNTER StatRZCpuId;
81 STAMCOUNTER StatR3CpuId;
82 STAMCOUNTER StatRZDec;
83 STAMCOUNTER StatR3Dec;
84 STAMCOUNTER StatRZHlt;
85 STAMCOUNTER StatR3Hlt;
86 STAMCOUNTER StatRZInc;
87 STAMCOUNTER StatR3Inc;
88 STAMCOUNTER StatRZInvlPg;
89 STAMCOUNTER StatR3InvlPg;
90 STAMCOUNTER StatRZIret;
91 STAMCOUNTER StatR3Iret;
92 STAMCOUNTER StatRZLLdt;
93 STAMCOUNTER StatR3LLdt;
94 STAMCOUNTER StatRZLIdt;
95 STAMCOUNTER StatR3LIdt;
96 STAMCOUNTER StatRZLGdt;
97 STAMCOUNTER StatR3LGdt;
98 STAMCOUNTER StatRZMov;
99 STAMCOUNTER StatR3Mov;
100 STAMCOUNTER StatRZMovCRx;
101 STAMCOUNTER StatR3MovCRx;
102 STAMCOUNTER StatRZMovDRx;
103 STAMCOUNTER StatR3MovDRx;
104 STAMCOUNTER StatRZOr;
105 STAMCOUNTER StatR3Or;
106 STAMCOUNTER StatRZPop;
107 STAMCOUNTER StatR3Pop;
108 STAMCOUNTER StatRZSti;
109 STAMCOUNTER StatR3Sti;
110 STAMCOUNTER StatRZXchg;
111 STAMCOUNTER StatR3Xchg;
112 STAMCOUNTER StatRZXor;
113 STAMCOUNTER StatR3Xor;
114 STAMCOUNTER StatRZMonitor;
115 STAMCOUNTER StatR3Monitor;
116 STAMCOUNTER StatRZMWait;
117 STAMCOUNTER StatR3MWait;
118 STAMCOUNTER StatRZAdd;
119 STAMCOUNTER StatR3Add;
120 STAMCOUNTER StatRZSub;
121 STAMCOUNTER StatR3Sub;
122 STAMCOUNTER StatRZAdc;
123 STAMCOUNTER StatR3Adc;
124 STAMCOUNTER StatRZRdtsc;
125 STAMCOUNTER StatR3Rdtsc;
126 STAMCOUNTER StatRZBtr;
127 STAMCOUNTER StatR3Btr;
128 STAMCOUNTER StatRZBts;
129 STAMCOUNTER StatR3Bts;
130 STAMCOUNTER StatRZBtc;
131 STAMCOUNTER StatR3Btc;
132 STAMCOUNTER StatRZCmpXchg;
133 STAMCOUNTER StatR3CmpXchg;
134 STAMCOUNTER StatRZCmpXchg8b;
135 STAMCOUNTER StatR3CmpXchg8b;
136 STAMCOUNTER StatRZXAdd;
137 STAMCOUNTER StatR3XAdd;
138 STAMCOUNTER StatRZClts;
139 STAMCOUNTER StatR3Clts;
140 STAMCOUNTER StatRZStosWD;
141 STAMCOUNTER StatR3StosWD;
142 STAMCOUNTER StatR3Rdmsr;
143 STAMCOUNTER StatR3Wrmsr;
144 STAMCOUNTER StatRZRdmsr;
145 STAMCOUNTER StatRZWrmsr;
146 STAMCOUNTER StatRZWbInvd;
147 STAMCOUNTER StatR3WbInvd;
148
149 STAMCOUNTER StatRZInterpretFailed;
150 STAMCOUNTER StatR3InterpretFailed;
151
152 STAMCOUNTER StatRZFailedAnd;
153 STAMCOUNTER StatR3FailedAnd;
154 STAMCOUNTER StatRZFailedCpuId;
155 STAMCOUNTER StatR3FailedCpuId;
156 STAMCOUNTER StatRZFailedDec;
157 STAMCOUNTER StatR3FailedDec;
158 STAMCOUNTER StatRZFailedHlt;
159 STAMCOUNTER StatR3FailedHlt;
160 STAMCOUNTER StatRZFailedInc;
161 STAMCOUNTER StatR3FailedInc;
162 STAMCOUNTER StatRZFailedInvlPg;
163 STAMCOUNTER StatR3FailedInvlPg;
164 STAMCOUNTER StatRZFailedIret;
165 STAMCOUNTER StatR3FailedIret;
166 STAMCOUNTER StatRZFailedLLdt;
167 STAMCOUNTER StatR3FailedLLdt;
168 STAMCOUNTER StatRZFailedLGdt;
169 STAMCOUNTER StatR3FailedLGdt;
170 STAMCOUNTER StatRZFailedLIdt;
171 STAMCOUNTER StatR3FailedLIdt;
172 STAMCOUNTER StatRZFailedMisc;
173 STAMCOUNTER StatR3FailedMisc;
174 STAMCOUNTER StatRZFailedMov;
175 STAMCOUNTER StatR3FailedMov;
176 STAMCOUNTER StatRZFailedMovCRx;
177 STAMCOUNTER StatR3FailedMovCRx;
178 STAMCOUNTER StatRZFailedMovDRx;
179 STAMCOUNTER StatR3FailedMovDRx;
180 STAMCOUNTER StatRZFailedOr;
181 STAMCOUNTER StatR3FailedOr;
182 STAMCOUNTER StatRZFailedPop;
183 STAMCOUNTER StatR3FailedPop;
184 STAMCOUNTER StatRZFailedSti;
185 STAMCOUNTER StatR3FailedSti;
186 STAMCOUNTER StatRZFailedXchg;
187 STAMCOUNTER StatR3FailedXchg;
188 STAMCOUNTER StatRZFailedXor;
189 STAMCOUNTER StatR3FailedXor;
190 STAMCOUNTER StatRZFailedMonitor;
191 STAMCOUNTER StatR3FailedMonitor;
192 STAMCOUNTER StatRZFailedMWait;
193 STAMCOUNTER StatR3FailedMWait;
194 STAMCOUNTER StatR3FailedRdmsr;
195 STAMCOUNTER StatR3FailedWrmsr;
196 STAMCOUNTER StatRZFailedRdmsr;
197 STAMCOUNTER StatRZFailedWrmsr;
198
199 STAMCOUNTER StatRZFailedAdd;
200 STAMCOUNTER StatR3FailedAdd;
201 STAMCOUNTER StatRZFailedAdc;
202 STAMCOUNTER StatR3FailedAdc;
203 STAMCOUNTER StatRZFailedBtr;
204 STAMCOUNTER StatR3FailedBtr;
205 STAMCOUNTER StatRZFailedBts;
206 STAMCOUNTER StatR3FailedBts;
207 STAMCOUNTER StatRZFailedBtc;
208 STAMCOUNTER StatR3FailedBtc;
209 STAMCOUNTER StatRZFailedCli;
210 STAMCOUNTER StatR3FailedCli;
211 STAMCOUNTER StatRZFailedCmpXchg;
212 STAMCOUNTER StatR3FailedCmpXchg;
213 STAMCOUNTER StatRZFailedCmpXchg8b;
214 STAMCOUNTER StatR3FailedCmpXchg8b;
215 STAMCOUNTER StatRZFailedXAdd;
216 STAMCOUNTER StatR3FailedXAdd;
217 STAMCOUNTER StatR3FailedMovNTPS;
218 STAMCOUNTER StatRZFailedMovNTPS;
219 STAMCOUNTER StatRZFailedStosWD;
220 STAMCOUNTER StatR3FailedStosWD;
221 STAMCOUNTER StatRZFailedSub;
222 STAMCOUNTER StatR3FailedSub;
223 STAMCOUNTER StatRZFailedWbInvd;
224 STAMCOUNTER StatR3FailedWbInvd;
225 STAMCOUNTER StatRZFailedRdtsc;
226 STAMCOUNTER StatR3FailedRdtsc;
227 STAMCOUNTER StatRZFailedClts;
228 STAMCOUNTER StatR3FailedClts;
229
230 STAMCOUNTER StatRZFailedUserMode;
231 STAMCOUNTER StatR3FailedUserMode;
232 STAMCOUNTER StatRZFailedPrefix;
233 STAMCOUNTER StatR3FailedPrefix;
234 /** @} */
235
236 /** @name Privileged Instructions Ending Up In HC.
237 * @{ */
238 STAMCOUNTER StatCli;
239 STAMCOUNTER StatSti;
240 STAMCOUNTER StatIn;
241 STAMCOUNTER StatOut;
242 STAMCOUNTER StatInvlpg;
243 STAMCOUNTER StatHlt;
244 STAMCOUNTER StatMovReadCR[USE_REG_CR4 + 1];
245 STAMCOUNTER StatMovWriteCR[USE_REG_CR4 + 1];
246 STAMCOUNTER StatMovDRx;
247 STAMCOUNTER StatIret;
248 STAMCOUNTER StatMovLgdt;
249 STAMCOUNTER StatMovLldt;
250 STAMCOUNTER StatMovLidt;
251 STAMCOUNTER StatMisc;
252 STAMCOUNTER StatSysEnter;
253 STAMCOUNTER StatSysExit;
254 STAMCOUNTER StatSysCall;
255 STAMCOUNTER StatSysRet;
256 /** @} */
257
258} EMSTATS;
259/** Pointer to the excessive EM statistics. */
260typedef EMSTATS *PEMSTATS;
261
262
263/**
264 * Converts a EM pointer into a VM pointer.
265 * @returns Pointer to the VM structure the EM is part of.
266 * @param pEM Pointer to EM instance data.
267 */
268#define EM2VM(pEM) ( (PVM)((char*)pEM - pEM->offVM) )
269
270/**
271 * EM VM Instance data.
272 * Changes to this must checked against the padding of the cfgm union in VM!
273 */
274typedef struct EM
275{
276 /** Offset to the VM structure.
277 * See EM2VM(). */
278 RTUINT offVM;
279
280 /** Execution Manager State. */
281 EMSTATE volatile enmState;
282 /** Force raw-mode execution.
283 * This is used to prevent REM from trying to execute patch code.
284 * The flag is cleared upon entering emR3RawExecute() and updated in certain return paths. */
285 bool fForceRAW;
286
287#ifdef DEBUG_TRACING_ENABLED
288 /** @see DEBUG_TRACING_ENABLED */
289 bool fTracing;
290#endif
291
292 /* Set when the translation blocks in the recompiler cache need to be flushed. */
293 bool fREMFlushTBs;
294
295 uint8_t u8Padding[GC_ARCH_BITS == 64 ? 5 : 1];
296
297 /** Inhibit interrupts for this instruction. Valid only when VM_FF_INHIBIT_INTERRUPTS is set. */
298 RTGCUINTPTR GCPtrInhibitInterrupts;
299
300
301 /** Pointer to the PATM status structure. (R3 Ptr) */
302 R3PTRTYPE(PPATMGCSTATE) pPatmGCState;
303
304 /** Pointer to the guest CPUM state. (R3 Ptr) */
305 R3PTRTYPE(PCPUMCTX) pCtx;
306
307#if GC_ARCH_BITS == 64
308 RTGCPTR aPadding1;
309#endif
310
311 union
312 {
313 /** Padding used in the other rings.
314 * This must be larger than jmp_buf on any supported platform. */
315 char achPaddingFatalLongJump[HC_ARCH_BITS == 32 ? 176 : 256];
316#ifdef IN_RING3
317 /** Long buffer jump for fatal VM errors.
318 * It will jump to before the outer EM loop is entered. */
319 jmp_buf FatalLongJump;
320#endif
321 } u;
322
323 /** @name Execution profiling.
324 * @{ */
325 STAMPROFILE StatForcedActions;
326 STAMPROFILE StatHalted;
327 STAMPROFILEADV StatHwAccEntry;
328 STAMPROFILE StatHwAccExec;
329 STAMPROFILE StatREMEmu;
330 STAMPROFILE StatREMExec;
331 STAMPROFILE StatREMSync;
332 STAMPROFILEADV StatREMTotal;
333 STAMPROFILE StatRAWExec;
334 STAMPROFILEADV StatRAWEntry;
335 STAMPROFILEADV StatRAWTail;
336 STAMPROFILEADV StatRAWTotal;
337 STAMPROFILEADV StatTotal;
338 /** @} */
339
340 /** R3: Profiling of emR3RawExecuteIOInstruction. */
341 STAMPROFILE StatIOEmu;
342 /** R3: Profiling of emR3RawPrivileged. */
343 STAMPROFILE StatPrivEmu;
344 /** R3: Profiling of emR3RawExecuteInstruction. */
345 STAMPROFILE StatMiscEmu;
346 /** R3: Number of time emR3HwAccExecute is called. */
347 STAMCOUNTER StatHwAccExecuteEntry;
348
349 /** More statistics (R3). */
350 R3PTRTYPE(PEMSTATS) pStatsR3;
351 /** More statistics (R0). */
352 R0PTRTYPE(PEMSTATS) pStatsR0;
353 /** More statistics (RC). */
354 RCPTRTYPE(PEMSTATS) pStatsRC;
355#if HC_ARCH_BITS == 64
356 RTRCPTR padding0;
357#endif
358
359 /** Tree for keeping track of cli occurances (debug only). */
360 R3PTRTYPE(PAVLPVNODECORE) pCliStatTree;
361 STAMCOUNTER StatTotalClis;
362#if 0
363 /** 64-bit Visual C++ rounds the struct size up to 16 byte. */
364 uint64_t padding1;
365#endif
366
367} EM;
368/** Pointer to EM VM instance data. */
369typedef EM *PEM;
370
371
372
373/** @} */
374
375__END_DECLS
376
377#endif
378
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