VirtualBox

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

Last change on this file since 13333 was 13265, checked in by vboxsync, 16 years ago

Lmsw emulation.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 12.9 KB
Line 
1/* $Id: EMInternal.h 13265 2008-10-14 14:26:42Z 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 /* Set when the translation blocks in the recompiler cache need to be flushed. */
297 bool fREMFlushTBs;
298
299 uint8_t u8Padding[GC_ARCH_BITS == 64 ? 5 : 1];
300
301 /** Inhibit interrupts for this instruction. Valid only when VM_FF_INHIBIT_INTERRUPTS is set. */
302 RTGCUINTPTR GCPtrInhibitInterrupts;
303
304
305 /** Pointer to the PATM status structure. (R3 Ptr) */
306 R3PTRTYPE(PPATMGCSTATE) pPatmGCState;
307
308 /** Pointer to the guest CPUM state. (R3 Ptr) */
309 R3PTRTYPE(PCPUMCTX) pCtx;
310
311#if GC_ARCH_BITS == 64
312 RTGCPTR aPadding1;
313#endif
314
315 union
316 {
317 /** Padding used in the other rings.
318 * This must be larger than jmp_buf on any supported platform. */
319 char achPaddingFatalLongJump[HC_ARCH_BITS == 32 ? 176 : 256];
320#ifdef IN_RING3
321 /** Long buffer jump for fatal VM errors.
322 * It will jump to before the outer EM loop is entered. */
323 jmp_buf FatalLongJump;
324#endif
325 } u;
326
327 /** @name Execution profiling.
328 * @{ */
329 STAMPROFILE StatForcedActions;
330 STAMPROFILE StatHalted;
331 STAMPROFILEADV StatHwAccEntry;
332 STAMPROFILE StatHwAccExec;
333 STAMPROFILE StatREMEmu;
334 STAMPROFILE StatREMExec;
335 STAMPROFILE StatREMSync;
336 STAMPROFILEADV StatREMTotal;
337 STAMPROFILE StatRAWExec;
338 STAMPROFILEADV StatRAWEntry;
339 STAMPROFILEADV StatRAWTail;
340 STAMPROFILEADV StatRAWTotal;
341 STAMPROFILEADV StatTotal;
342 /** @} */
343
344 /** R3: Profiling of emR3RawExecuteIOInstruction. */
345 STAMPROFILE StatIOEmu;
346 /** R3: Profiling of emR3RawPrivileged. */
347 STAMPROFILE StatPrivEmu;
348 /** R3: Profiling of emR3RawExecuteInstruction. */
349 STAMPROFILE StatMiscEmu;
350 /** R3: Number of time emR3HwAccExecute is called. */
351 STAMCOUNTER StatHwAccExecuteEntry;
352
353 /** More statistics (R3). */
354 R3PTRTYPE(PEMSTATS) pStatsR3;
355 /** More statistics (R0). */
356 R0PTRTYPE(PEMSTATS) pStatsR0;
357 /** More statistics (RC). */
358 RCPTRTYPE(PEMSTATS) pStatsRC;
359#if HC_ARCH_BITS == 64
360 RTRCPTR padding0;
361#endif
362
363 /** Tree for keeping track of cli occurances (debug only). */
364 R3PTRTYPE(PAVLPVNODECORE) pCliStatTree;
365 STAMCOUNTER StatTotalClis;
366#if 0
367 /** 64-bit Visual C++ rounds the struct size up to 16 byte. */
368 uint64_t padding1;
369#endif
370
371} EM;
372/** Pointer to EM VM instance data. */
373typedef EM *PEM;
374
375
376
377/** @} */
378
379__END_DECLS
380
381#endif
382
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