VirtualBox

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

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

Statistics for BTR.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.9 KB
Line 
1/* $Id: EMInternal.h 1985 2007-04-09 09:44:20Z vboxsync $ */
2/** @file
3 * EM - 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 __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 StatGCBtr;
129 STAMCOUNTER StatHCBtr;
130
131 STAMCOUNTER StatGCInterpretFailed;
132 STAMCOUNTER StatHCInterpretFailed;
133
134 STAMCOUNTER StatGCFailedAnd;
135 STAMCOUNTER StatHCFailedAnd;
136 STAMCOUNTER StatGCFailedCpuId;
137 STAMCOUNTER StatHCFailedCpuId;
138 STAMCOUNTER StatGCFailedDec;
139 STAMCOUNTER StatHCFailedDec;
140 STAMCOUNTER StatGCFailedHlt;
141 STAMCOUNTER StatHCFailedHlt;
142 STAMCOUNTER StatGCFailedInc;
143 STAMCOUNTER StatHCFailedInc;
144 STAMCOUNTER StatGCFailedInvlPg;
145 STAMCOUNTER StatHCFailedInvlPg;
146 STAMCOUNTER StatGCFailedIret;
147 STAMCOUNTER StatHCFailedIret;
148 STAMCOUNTER StatGCFailedLLdt;
149 STAMCOUNTER StatHCFailedLLdt;
150 STAMCOUNTER StatGCFailedMisc;
151 STAMCOUNTER StatHCFailedMisc;
152 STAMCOUNTER StatGCFailedMov;
153 STAMCOUNTER StatHCFailedMov;
154 STAMCOUNTER StatGCFailedMovCRx;
155 STAMCOUNTER StatHCFailedMovCRx;
156 STAMCOUNTER StatGCFailedMovDRx;
157 STAMCOUNTER StatHCFailedMovDRx;
158 STAMCOUNTER StatGCFailedOr;
159 STAMCOUNTER StatHCFailedOr;
160 STAMCOUNTER StatGCFailedPop;
161 STAMCOUNTER StatHCFailedPop;
162 STAMCOUNTER StatGCFailedSti;
163 STAMCOUNTER StatHCFailedSti;
164 STAMCOUNTER StatGCFailedXchg;
165 STAMCOUNTER StatHCFailedXchg;
166 STAMCOUNTER StatGCFailedXor;
167 STAMCOUNTER StatHCFailedXor;
168 STAMCOUNTER StatGCFailedMonitor;
169 STAMCOUNTER StatHCFailedMonitor;
170 STAMCOUNTER StatGCFailedMWait;
171 STAMCOUNTER StatHCFailedMWait;
172
173 STAMCOUNTER StatGCFailedAdd;
174 STAMCOUNTER StatHCFailedAdd;
175 STAMCOUNTER StatGCFailedAdc;
176 STAMCOUNTER StatHCFailedAdc;
177 STAMCOUNTER StatGCFailedBtr;
178 STAMCOUNTER StatHCFailedBtr;
179 STAMCOUNTER StatGCFailedBts;
180 STAMCOUNTER StatHCFailedBts;
181 STAMCOUNTER StatGCFailedCli;
182 STAMCOUNTER StatHCFailedCli;
183 STAMCOUNTER StatGCFailedCmpXchg;
184 STAMCOUNTER StatHCFailedCmpXchg;
185 STAMCOUNTER StatHCFailedMovNTPS;
186 STAMCOUNTER StatGCFailedMovNTPS;
187 STAMCOUNTER StatGCFailedStosWD;
188 STAMCOUNTER StatHCFailedStosWD;
189 STAMCOUNTER StatGCFailedSub;
190 STAMCOUNTER StatHCFailedSub;
191 STAMCOUNTER StatGCFailedWbInvd;
192 STAMCOUNTER StatHCFailedWbInvd;
193 STAMCOUNTER StatGCFailedRdtsc;
194
195 STAMCOUNTER StatGCFailedUserMode;
196 STAMCOUNTER StatHCFailedUserMode;
197 STAMCOUNTER StatGCFailedPrefix;
198 STAMCOUNTER StatHCFailedPrefix;
199 /** @} */
200
201 /** @name Privileged Instructions Ending Up In HC.
202 * @{ */
203 STAMCOUNTER StatCli;
204 STAMCOUNTER StatSti;
205 STAMCOUNTER StatIn;
206 STAMCOUNTER StatOut;
207 STAMCOUNTER StatInvlpg;
208 STAMCOUNTER StatHlt;
209 STAMCOUNTER StatMovReadCR[USE_REG_CR4 + 1];
210 STAMCOUNTER StatMovWriteCR[USE_REG_CR4 + 1];
211 STAMCOUNTER StatMovDRx;
212 STAMCOUNTER StatIret;
213 STAMCOUNTER StatMovLgdt;
214 STAMCOUNTER StatMovLldt;
215 STAMCOUNTER StatMovLidt;
216 STAMCOUNTER StatMisc;
217 STAMCOUNTER StatSysEnter;
218 STAMCOUNTER StatSysExit;
219 STAMCOUNTER StatSysCall;
220 STAMCOUNTER StatSysRet;
221 /** @} */
222
223} EMSTATS, *PEMSTATS;
224
225/**
226 * EM VM Instance data.
227 * Changes to this must checked against the padding of the cfgm union in VM!
228 */
229typedef struct EM
230{
231 /** Offset to the VM structure.
232 * See EM2VM(). */
233 RTUINT offVM;
234
235 /** Execution Manager State. */
236 volatile EMSTATE enmState;
237 /** Force raw-mode execution.
238 * This is used to prevent REM from trying to execute patch code.
239 * The flag is cleared upon entering emR3RawExecute() and updated in certain return paths. */
240 bool fForceRAW;
241
242#ifdef DEBUG_TRACING_ENABLED
243 /** @see DEBUG_TRACING_ENABLED */
244 bool fTracing;
245#endif
246
247 /** Inhibit interrupts for this instruction. Valid only when VM_FF_INHIBIT_INTERRUPTS is set. */
248 RTGCUINTPTR GCPtrInhibitInterrupts;
249
250
251 /** Pointer to the PATM status structure. (HC Ptr) */
252 HCPTRTYPE(PPATMGCSTATE) pPatmGCState;
253
254 /** Pointer to the guest CPUM state. (HC Ptr) */
255 HCPTRTYPE(PCPUMCTX) pCtx;
256
257
258 union
259 {
260 /** Padding used in the other rings.
261 * This must be larger than jmp_buf on any supported platform. */
262 char achPaddingFatalLongJump[HC_ARCH_BITS == 32 ? 176 : 256];
263#ifdef IN_RING3
264 /** Long buffer jump for fatal VM errors.
265 * It will jump to before the outer EM loop is entered. */
266 jmp_buf FatalLongJump;
267#endif
268 } u;
269
270 /** @name Execution profiling.
271 * @{ */
272 STAMPROFILE StatForcedActions;
273 STAMPROFILE StatHalted;
274 STAMPROFILEADV StatHwAccEntry;
275 STAMPROFILE StatHwAccExec;
276 STAMPROFILE StatREMEmu;
277 STAMPROFILE StatREMExec;
278 STAMPROFILE StatREMSync;
279 STAMPROFILEADV StatREMTotal;
280 STAMPROFILE StatRAWExec;
281 STAMPROFILEADV StatRAWEntry;
282 STAMPROFILEADV StatRAWTail;
283 STAMPROFILEADV StatRAWTotal;
284 STAMPROFILEADV StatTotal;
285 /** @} */
286
287 /** HC: Profiling of emR3RawExecuteIOInstruction. */
288 STAMPROFILE StatIOEmu;
289 /** HC: Profiling of emR3RawPrivileged. */
290 STAMPROFILE StatPrivEmu;
291 /** HC: Profiling of emR3RawExecuteInstruction. */
292 STAMPROFILE StatMiscEmu;
293
294 /** @todo r=bird: Are any of these actually used? */
295 STAMCOUNTER StatPatchTrap;
296 STAMCOUNTER StatPatchInt3;
297 STAMCOUNTER StatPatchIF0;
298 STAMCOUNTER StatPatchEmulate;
299 STAMCOUNTER StatPageOutOfSync;
300 STAMCOUNTER StatHwAccExecuteEntry;
301
302 /** More statistics (HC). */
303 HCPTRTYPE(PEMSTATS) pStatsHC;
304 /** More statistics (GC). */
305 GCPTRTYPE(PEMSTATS) pStatsGC;
306#if HC_ARCH_BITS != GC_ARCH_BITS && GC_ARCH_BITS == 32
307 RTGCPTR padding0;
308#endif
309
310 /** Tree for keeping track of cli occurances (debug only). */
311 HCPTRTYPE(PAVLPVNODECORE) pCliStatTree;
312 STAMCOUNTER StatTotalClis;
313#if 0
314 /** 64-bit Visual C++ rounds the struct size up to 16 byte. */
315 uint64_t padding1;
316#endif
317
318} EM;
319/** Pointer to EM VM instance data. */
320typedef EM *PEM;
321
322
323
324/** @} */
325
326__END_DECLS
327
328#endif
329
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