VirtualBox

source: vbox/trunk/src/VBox/VMM/REMInternal.h@ 20543

Last change on this file since 20543 was 20430, checked in by vboxsync, 15 years ago

Attempt to fix compilation

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 9.1 KB
Line 
1/* $Id: REMInternal.h 20430 2009-06-09 11:47:03Z vboxsync $ */
2/** @file
3 * REM - 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 ___REMInternal_h
23#define ___REMInternal_h
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <VBox/cpum.h>
28#include <VBox/stam.h>
29#include <VBox/pgm.h>
30#include <VBox/pdmcritsect.h>
31#ifdef REM_INCLUDE_CPU_H
32# include "target-i386/cpu.h"
33#endif
34
35
36
37/** @defgroup grp_rem_int Internals
38 * @ingroup grp_rem
39 * @internal
40 * @{
41 */
42
43/** The saved state version number. */
44#define REM_SAVED_STATE_VERSION_VER1_6 6
45#define REM_SAVED_STATE_VERSION 7
46
47
48/** @def REM_MONITOR_CODE_PAGES
49 * Enable to monitor code pages that have been translated by the recompiler. */
50/** Currently broken and interferes with CSAM monitoring (see #2784) */
51////#define REM_MONITOR_CODE_PAGES
52#ifdef DOXYGEN_RUNNING
53# define REM_MONITOR_CODE_PAGES
54#endif
55
56typedef enum REMHANDLERNOTIFICATIONKIND
57{
58 /** The usual invalid 0 entry. */
59 REMHANDLERNOTIFICATIONKIND_INVALID = 0,
60 /** REMR3NotifyHandlerPhysicalRegister. */
61 REMHANDLERNOTIFICATIONKIND_PHYSICAL_REGISTER,
62 /** REMR3NotifyHandlerPhysicalDeregister. */
63 REMHANDLERNOTIFICATIONKIND_PHYSICAL_DEREGISTER,
64 /** REMR3NotifyHandlerPhysicalModify. */
65 REMHANDLERNOTIFICATIONKIND_PHYSICAL_MODIFY,
66 /** The usual 32-bit hack. */
67 REMHANDLERNOTIFICATIONKIND_32BIT_HACK = 0x7fffffff
68} REMHANDLERNOTIFICATIONKIND;
69
70
71/**
72 * A recorded handler notificiation.
73 */
74typedef struct REMHANDLERNOTIFICATION
75{
76 /** The notification kind. */
77 REMHANDLERNOTIFICATIONKIND enmKind;
78 uint32_t padding;
79 /** Type specific data. */
80 union
81 {
82 struct
83 {
84 RTGCPHYS GCPhys;
85 RTGCPHYS cb;
86 PGMPHYSHANDLERTYPE enmType;
87 bool fHasHCHandler;
88 } PhysicalRegister;
89
90 struct
91 {
92 RTGCPHYS GCPhys;
93 RTGCPHYS cb;
94 PGMPHYSHANDLERTYPE enmType;
95 bool fHasHCHandler;
96 bool fRestoreAsRAM;
97 } PhysicalDeregister;
98
99 struct
100 {
101 RTGCPHYS GCPhysOld;
102 RTGCPHYS GCPhysNew;
103 RTGCPHYS cb;
104 PGMPHYSHANDLERTYPE enmType;
105 bool fHasHCHandler;
106 bool fRestoreAsRAM;
107 } PhysicalModify;
108 uint64_t padding[5];
109 } u;
110 uint32_t idxSelf;
111 uint32_t idxNext;
112} REMHANDLERNOTIFICATION, *PREMHANDLERNOTIFICATION;
113
114/**
115 * Converts a REM pointer into a VM pointer.
116 * @returns Pointer to the VM structure the REM is part of.
117 * @param pREM Pointer to REM instance data.
118 */
119#define REM2VM(pREM) ( (PVM)((char*)pREM - pREM->offVM) )
120
121
122/**
123 * REM Data (part of VM)
124 */
125typedef struct REM
126{
127 /** Offset to the VM structure. */
128 RTINT offVM;
129 /** Alignment padding. */
130 RTUINT uPadding0;
131
132 /** Cached pointer of the register context of the current VCPU. */
133 R3PTRTYPE(PCPUMCTX) pCtx;
134
135 /** In REM mode.
136 * I.e. the correct CPU state and some other bits are with REM. */
137 bool volatile fInREM;
138 /** In REMR3State. */
139 bool fInStateSync;
140
141 /** Set when the translation blocks cache need to be flushed. */
142 bool fFlushTBs;
143
144 /** Ignore CR3 load notifications from the REM. */
145 bool fIgnoreCR3Load;
146 /** Ignore invlpg notifications from the REM. */
147 bool fIgnoreInvlPg;
148 /** Ignore CR0, CR4 and EFER load. */
149 bool fIgnoreCpuMode;
150 /** Ignore set page. */
151 bool fIgnoreSetPage;
152 bool bPadding1;
153
154 /** Ignore all that can be ignored. */
155 uint32_t cIgnoreAll;
156
157 /** Number of times REMR3CanExecuteRaw has been called.
158 * It is used to prevent rescheduling on the first call. */
159 uint32_t cCanExecuteRaw;
160
161 /** Pending interrupt (~0 -> nothing). */
162 uint32_t u32PendingInterrupt;
163
164 /** Number of recorded invlpg instructions. */
165 uint32_t cInvalidatedPages;
166#if HC_ARCH_BITS == 32
167 uint32_t uPadding2;
168#endif
169 /** Array of recorded invlpg instruction.
170 * These instructions are replayed when entering REM. */
171 RTGCPTR aGCPtrInvalidatedPages[48];
172
173 /** Array of recorded handler noticications.
174 * These are replayed when entering REM. */
175 REMHANDLERNOTIFICATION aHandlerNotifications[32];
176 volatile uint32_t idxPendingList;
177 volatile uint32_t idxFreeList;
178
179 /** MMIO memory type.
180 * This is used to register MMIO physical access handlers. */
181 int32_t iMMIOMemType;
182 /** Handler memory type.
183 * This is used to register non-MMIO physical access handlers which are executed in HC. */
184 int32_t iHandlerMemType;
185
186 /** Pending exception */
187 uint32_t uPendingException;
188 /** Nr of pending exceptions */
189 uint32_t cPendingExceptions;
190 /** Pending exception's EIP */
191 RTGCPTR uPendingExcptEIP;
192 /** Pending exception's CR2 */
193 RTGCPTR uPendingExcptCR2;
194
195 /** The highest known RAM address. */
196 RTGCPHYS GCPhysLastRam;
197 /** Whether GCPhysLastRam has been fixed (see REMR3Init()). */
198 bool fGCPhysLastRamFixed;
199
200 /** Pending rc. */
201 int32_t rc;
202
203 /** REM critical section.
204 * This protects cpu_register_physical_memory usage
205 */
206 PDMCRITSECT CritSectRegister;
207
208 /** Time spent in QEMU. */
209 STAMPROFILEADV StatsInQEMU;
210 /** Time spent in rawmode.c. */
211 STAMPROFILEADV StatsInRAWEx;
212 /** Time spent switching state. */
213 STAMPROFILE StatsState;
214 /** Time spent switching state back. */
215 STAMPROFILE StatsStateBack;
216
217 /** Padding the CPUX86State structure to 32 byte. */
218 uint32_t abPadding[HC_ARCH_BITS == 32 ? 2 : 6];
219
220# define REM_ENV_SIZE 0xff00
221
222 /** Recompiler CPU state. */
223#ifdef REM_INCLUDE_CPU_H
224 CPUX86State Env;
225#else
226 struct FakeEnv
227 {
228 char achPadding[REM_ENV_SIZE];
229 } Env;
230#endif /* !REM_INCLUDE_CPU_H */
231} REM;
232
233/** Pointer to the REM Data. */
234typedef REM *PREM;
235
236
237#ifdef REM_INCLUDE_CPU_H
238bool remR3CanExecuteRaw(CPUState *env, RTGCPTR eip, unsigned fFlags, int *piException);
239void remR3CSAMCheckEIP(CPUState *env, RTGCPTR GCPtrCode);
240bool remR3GetOpcode(CPUState *env, RTGCPTR GCPtrInstr, uint8_t *pu8Byte);
241bool remR3DisasInstr(CPUState *env, int f32BitCode, char *pszPrefix);
242void remR3FlushPage(CPUState *env, RTGCPTR GCPtr);
243void remR3SetPage(CPUState *env, CPUTLBEntry *pRead, CPUTLBEntry *pWrite, int prot, int is_user);
244void remR3FlushTLB(CPUState *env, bool fGlobal);
245void remR3ProtectCode(CPUState *env, RTGCPTR GCPtr);
246void remR3ChangeCpuMode(CPUState *env);
247void remR3DmaRun(CPUState *env);
248void remR3TimersRun(CPUState *env);
249int remR3NotifyTrap(CPUState *env, uint32_t uTrap, uint32_t uErrorCode, RTGCPTR pvNextEIP);
250void remR3TrapStat(CPUState *env, uint32_t uTrap);
251void remR3CpuId(CPUState *env, unsigned uOperator, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX);
252void remR3RecordCall(CPUState *env);
253#endif /* REM_INCLUDE_CPU_H */
254void remR3TrapClear(PVM pVM);
255void remR3RaiseRC(PVM pVM, int rc);
256void remR3DumpLnxSyscall(PVMCPU pVCpu);
257void remR3DumpOBsdSyscall(PVMCPU pVCpu);
258
259
260/** @todo r=bird: clean up the RAWEx stats. */
261/* temporary hacks */
262#define RAWEx_ProfileStart(a, b) remR3ProfileStart(b)
263#define RAWEx_ProfileStop(a, b) remR3ProfileStop(b)
264
265
266#ifdef VBOX_WITH_STATISTICS
267
268# define STATS_EMULATE_SINGLE_INSTR 1
269# define STATS_QEMU_COMPILATION 2
270# define STATS_QEMU_RUN_EMULATED_CODE 3
271# define STATS_QEMU_TOTAL 4
272# define STATS_QEMU_RUN_TIMERS 5
273# define STATS_TLB_LOOKUP 6
274# define STATS_IRQ_HANDLING 7
275# define STATS_RAW_CHECK 8
276
277void remR3ProfileStart(int statcode);
278void remR3ProfileStop(int statcode);
279
280#else /* !VBOX_WITH_STATISTICS */
281# define remR3ProfileStart(c) do { } while (0)
282# define remR3ProfileStop(c) do { } while (0)
283#endif /* !VBOX_WITH_STATISTICS */
284
285/** @} */
286
287#endif
288
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