VirtualBox

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

Last change on this file since 30735 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

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