VirtualBox

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

Last change on this file since 14981 was 13742, checked in by vboxsync, 16 years ago

Some initial VM data restructuring.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 13.0 KB
Line 
1/* $Id: EMInternal.h 13742 2008-11-03 12:19:40Z 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 STAMCOUNTER StatRZLmsw;
149 STAMCOUNTER StatR3Lmsw;
150
151 STAMCOUNTER StatRZInterpretFailed;
152 STAMCOUNTER StatR3InterpretFailed;
153
154 STAMCOUNTER StatRZFailedAnd;
155 STAMCOUNTER StatR3FailedAnd;
156 STAMCOUNTER StatRZFailedCpuId;
157 STAMCOUNTER StatR3FailedCpuId;
158 STAMCOUNTER StatRZFailedDec;
159 STAMCOUNTER StatR3FailedDec;
160 STAMCOUNTER StatRZFailedHlt;
161 STAMCOUNTER StatR3FailedHlt;
162 STAMCOUNTER StatRZFailedInc;
163 STAMCOUNTER StatR3FailedInc;
164 STAMCOUNTER StatRZFailedInvlPg;
165 STAMCOUNTER StatR3FailedInvlPg;
166 STAMCOUNTER StatRZFailedIret;
167 STAMCOUNTER StatR3FailedIret;
168 STAMCOUNTER StatRZFailedLLdt;
169 STAMCOUNTER StatR3FailedLLdt;
170 STAMCOUNTER StatRZFailedLGdt;
171 STAMCOUNTER StatR3FailedLGdt;
172 STAMCOUNTER StatRZFailedLIdt;
173 STAMCOUNTER StatR3FailedLIdt;
174 STAMCOUNTER StatRZFailedMisc;
175 STAMCOUNTER StatR3FailedMisc;
176 STAMCOUNTER StatRZFailedMov;
177 STAMCOUNTER StatR3FailedMov;
178 STAMCOUNTER StatRZFailedMovCRx;
179 STAMCOUNTER StatR3FailedMovCRx;
180 STAMCOUNTER StatRZFailedMovDRx;
181 STAMCOUNTER StatR3FailedMovDRx;
182 STAMCOUNTER StatRZFailedOr;
183 STAMCOUNTER StatR3FailedOr;
184 STAMCOUNTER StatRZFailedPop;
185 STAMCOUNTER StatR3FailedPop;
186 STAMCOUNTER StatRZFailedSti;
187 STAMCOUNTER StatR3FailedSti;
188 STAMCOUNTER StatRZFailedXchg;
189 STAMCOUNTER StatR3FailedXchg;
190 STAMCOUNTER StatRZFailedXor;
191 STAMCOUNTER StatR3FailedXor;
192 STAMCOUNTER StatRZFailedMonitor;
193 STAMCOUNTER StatR3FailedMonitor;
194 STAMCOUNTER StatRZFailedMWait;
195 STAMCOUNTER StatR3FailedMWait;
196 STAMCOUNTER StatR3FailedRdmsr;
197 STAMCOUNTER StatR3FailedWrmsr;
198 STAMCOUNTER StatRZFailedRdmsr;
199 STAMCOUNTER StatRZFailedWrmsr;
200 STAMCOUNTER StatRZFailedLmsw;
201 STAMCOUNTER StatR3FailedLmsw;
202
203 STAMCOUNTER StatRZFailedAdd;
204 STAMCOUNTER StatR3FailedAdd;
205 STAMCOUNTER StatRZFailedAdc;
206 STAMCOUNTER StatR3FailedAdc;
207 STAMCOUNTER StatRZFailedBtr;
208 STAMCOUNTER StatR3FailedBtr;
209 STAMCOUNTER StatRZFailedBts;
210 STAMCOUNTER StatR3FailedBts;
211 STAMCOUNTER StatRZFailedBtc;
212 STAMCOUNTER StatR3FailedBtc;
213 STAMCOUNTER StatRZFailedCli;
214 STAMCOUNTER StatR3FailedCli;
215 STAMCOUNTER StatRZFailedCmpXchg;
216 STAMCOUNTER StatR3FailedCmpXchg;
217 STAMCOUNTER StatRZFailedCmpXchg8b;
218 STAMCOUNTER StatR3FailedCmpXchg8b;
219 STAMCOUNTER StatRZFailedXAdd;
220 STAMCOUNTER StatR3FailedXAdd;
221 STAMCOUNTER StatR3FailedMovNTPS;
222 STAMCOUNTER StatRZFailedMovNTPS;
223 STAMCOUNTER StatRZFailedStosWD;
224 STAMCOUNTER StatR3FailedStosWD;
225 STAMCOUNTER StatRZFailedSub;
226 STAMCOUNTER StatR3FailedSub;
227 STAMCOUNTER StatRZFailedWbInvd;
228 STAMCOUNTER StatR3FailedWbInvd;
229 STAMCOUNTER StatRZFailedRdtsc;
230 STAMCOUNTER StatR3FailedRdtsc;
231 STAMCOUNTER StatRZFailedClts;
232 STAMCOUNTER StatR3FailedClts;
233
234 STAMCOUNTER StatRZFailedUserMode;
235 STAMCOUNTER StatR3FailedUserMode;
236 STAMCOUNTER StatRZFailedPrefix;
237 STAMCOUNTER StatR3FailedPrefix;
238 /** @} */
239
240 /** @name Privileged Instructions Ending Up In HC.
241 * @{ */
242 STAMCOUNTER StatCli;
243 STAMCOUNTER StatSti;
244 STAMCOUNTER StatIn;
245 STAMCOUNTER StatOut;
246 STAMCOUNTER StatInvlpg;
247 STAMCOUNTER StatHlt;
248 STAMCOUNTER StatMovReadCR[USE_REG_CR4 + 1];
249 STAMCOUNTER StatMovWriteCR[USE_REG_CR4 + 1];
250 STAMCOUNTER StatMovDRx;
251 STAMCOUNTER StatIret;
252 STAMCOUNTER StatMovLgdt;
253 STAMCOUNTER StatMovLldt;
254 STAMCOUNTER StatMovLidt;
255 STAMCOUNTER StatMisc;
256 STAMCOUNTER StatSysEnter;
257 STAMCOUNTER StatSysExit;
258 STAMCOUNTER StatSysCall;
259 STAMCOUNTER StatSysRet;
260 /** @} */
261
262} EMSTATS;
263/** Pointer to the excessive EM statistics. */
264typedef EMSTATS *PEMSTATS;
265
266
267/**
268 * Converts a EM pointer into a VM pointer.
269 * @returns Pointer to the VM structure the EM is part of.
270 * @param pEM Pointer to EM instance data.
271 */
272#define EM2VM(pEM) ( (PVM)((char*)pEM - pEM->offVM) )
273
274/**
275 * EM VM Instance data.
276 * Changes to this must checked against the padding of the cfgm union in VM!
277 */
278typedef struct EM
279{
280 /** Offset to the VM structure.
281 * See EM2VM(). */
282 RTUINT offVM;
283
284 /** Execution Manager State. */
285 EMSTATE volatile enmState;
286 /** Force raw-mode execution.
287 * This is used to prevent REM from trying to execute patch code.
288 * The flag is cleared upon entering emR3RawExecute() and updated in certain return paths. */
289 bool fForceRAW;
290
291#ifdef DEBUG_TRACING_ENABLED
292 /** @see DEBUG_TRACING_ENABLED */
293 bool fTracing;
294#endif
295
296 uint8_t u8Padding[GC_ARCH_BITS == 64 ? 6 : 2];
297
298 /** Inhibit interrupts for this instruction. Valid only when VM_FF_INHIBIT_INTERRUPTS is set. */
299 RTGCUINTPTR GCPtrInhibitInterrupts;
300
301
302 /** Pointer to the PATM status structure. (R3 Ptr) */
303 R3PTRTYPE(PPATMGCSTATE) pPatmGCState;
304
305 /** Pointer to the guest CPUM state. (R3 Ptr) */
306 R3PTRTYPE(PCPUMCTX) pCtx;
307
308#if GC_ARCH_BITS == 64
309 RTGCPTR aPadding1;
310#endif
311
312 union
313 {
314 /** Padding used in the other rings.
315 * This must be larger than jmp_buf on any supported platform. */
316 char achPaddingFatalLongJump[HC_ARCH_BITS == 32 ? 176 : 256];
317#ifdef IN_RING3
318 /** Long buffer jump for fatal VM errors.
319 * It will jump to before the outer EM loop is entered. */
320 jmp_buf FatalLongJump;
321#endif
322 } u;
323
324 /** @name Execution profiling.
325 * @{ */
326 STAMPROFILE StatForcedActions;
327 STAMPROFILE StatHalted;
328 STAMPROFILEADV StatHwAccEntry;
329 STAMPROFILE StatHwAccExec;
330 STAMPROFILE StatREMEmu;
331 STAMPROFILE StatREMExec;
332 STAMPROFILE StatREMSync;
333 STAMPROFILEADV StatREMTotal;
334 STAMPROFILE StatRAWExec;
335 STAMPROFILEADV StatRAWEntry;
336 STAMPROFILEADV StatRAWTail;
337 STAMPROFILEADV StatRAWTotal;
338 STAMPROFILEADV StatTotal;
339 /** @} */
340
341 /** R3: Profiling of emR3RawExecuteIOInstruction. */
342 STAMPROFILE StatIOEmu;
343 /** R3: Profiling of emR3RawPrivileged. */
344 STAMPROFILE StatPrivEmu;
345 /** R3: Profiling of emR3RawExecuteInstruction. */
346 STAMPROFILE StatMiscEmu;
347 /** R3: Number of time emR3HwAccExecute is called. */
348 STAMCOUNTER StatHwAccExecuteEntry;
349
350 /** More statistics (R3). */
351 R3PTRTYPE(PEMSTATS) pStatsR3;
352 /** More statistics (R0). */
353 R0PTRTYPE(PEMSTATS) pStatsR0;
354 /** More statistics (RC). */
355 RCPTRTYPE(PEMSTATS) pStatsRC;
356#if HC_ARCH_BITS == 64
357 RTRCPTR padding0;
358#endif
359
360 /** Tree for keeping track of cli occurances (debug only). */
361 R3PTRTYPE(PAVLPVNODECORE) pCliStatTree;
362 STAMCOUNTER StatTotalClis;
363#if 0
364 /** 64-bit Visual C++ rounds the struct size up to 16 byte. */
365 uint64_t padding1;
366#endif
367
368} EM;
369/** Pointer to EM VM instance data. */
370typedef EM *PEM;
371
372
373/**
374 * EM VMCPU Instance data.
375 */
376typedef struct EMCPU
377{
378 /** Offset to the VM structure.
379 * See EMCPU2VM(). */
380 RTUINT offVMCPU;
381} EMCPU;
382/** Pointer to EM VM instance data. */
383typedef EMCPU *PEMCPU;
384
385/** @} */
386
387__END_DECLS
388
389#endif
390
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