VirtualBox

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

Last change on this file since 19702 was 19440, checked in by vboxsync, 16 years ago

Deal with pause/resume for pause & wait for sipi states.

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