VirtualBox

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

最後變更 在這個檔案從20421是 20421,由 vboxsync 提交於 16 年 前

Rewrote rem notification handling.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 9.0 KB
 
1/* $Id: REMInternal.h 20421 2009-06-09 09:34:53Z 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.alldomusa.eu.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#ifdef REM_INCLUDE_CPU_H
31# include "target-i386/cpu.h"
32#endif
33
34
35
36/** @defgroup grp_rem_int Internals
37 * @ingroup grp_rem
38 * @internal
39 * @{
40 */
41
42/** The saved state version number. */
43#define REM_SAVED_STATE_VERSION_VER1_6 6
44#define REM_SAVED_STATE_VERSION 7
45
46
47/** @def REM_MONITOR_CODE_PAGES
48 * Enable to monitor code pages that have been translated by the recompiler. */
49/** Currently broken and interferes with CSAM monitoring (see #2784) */
50////#define REM_MONITOR_CODE_PAGES
51#ifdef DOXYGEN_RUNNING
52# define REM_MONITOR_CODE_PAGES
53#endif
54
55typedef enum REMHANDLERNOTIFICATIONKIND
56{
57 /** The usual invalid 0 entry. */
58 REMHANDLERNOTIFICATIONKIND_INVALID = 0,
59 /** REMR3NotifyHandlerPhysicalRegister. */
60 REMHANDLERNOTIFICATIONKIND_PHYSICAL_REGISTER,
61 /** REMR3NotifyHandlerPhysicalDeregister. */
62 REMHANDLERNOTIFICATIONKIND_PHYSICAL_DEREGISTER,
63 /** REMR3NotifyHandlerPhysicalModify. */
64 REMHANDLERNOTIFICATIONKIND_PHYSICAL_MODIFY,
65 /** The usual 32-bit hack. */
66 REMHANDLERNOTIFICATIONKIND_32BIT_HACK = 0x7fffffff
67} REMHANDLERNOTIFICATIONKIND;
68
69
70/**
71 * A recorded handler notificiation.
72 */
73typedef struct REMHANDLERNOTIFICATION
74{
75 /** The notification kind. */
76 REMHANDLERNOTIFICATIONKIND enmKind;
77 uint32_t padding;
78 /** Type specific data. */
79 union
80 {
81 struct
82 {
83 RTGCPHYS GCPhys;
84 RTGCPHYS cb;
85 PGMPHYSHANDLERTYPE enmType;
86 bool fHasHCHandler;
87 } PhysicalRegister;
88
89 struct
90 {
91 RTGCPHYS GCPhys;
92 RTGCPHYS cb;
93 PGMPHYSHANDLERTYPE enmType;
94 bool fHasHCHandler;
95 bool fRestoreAsRAM;
96 } PhysicalDeregister;
97
98 struct
99 {
100 RTGCPHYS GCPhysOld;
101 RTGCPHYS GCPhysNew;
102 RTGCPHYS cb;
103 PGMPHYSHANDLERTYPE enmType;
104 bool fHasHCHandler;
105 bool fRestoreAsRAM;
106 } PhysicalModify;
107 uint64_t padding[5];
108 } u;
109 uint32_t idxSelf;
110 uint32_t idxNext;
111} REMHANDLERNOTIFICATION, *PREMHANDLERNOTIFICATION;
112
113/**
114 * Converts a REM pointer into a VM pointer.
115 * @returns Pointer to the VM structure the REM is part of.
116 * @param pREM Pointer to REM instance data.
117 */
118#define REM2VM(pREM) ( (PVM)((char*)pREM - pREM->offVM) )
119
120
121/**
122 * REM Data (part of VM)
123 */
124typedef struct REM
125{
126 /** Offset to the VM structure. */
127 RTINT offVM;
128 /** Alignment padding. */
129 RTUINT uPadding0;
130
131 /** Cached pointer of the register context of the current VCPU. */
132 R3PTRTYPE(PCPUMCTX) pCtx;
133
134 /** In REM mode.
135 * I.e. the correct CPU state and some other bits are with REM. */
136 bool volatile fInREM;
137 /** In REMR3State. */
138 bool fInStateSync;
139
140 /** Set when the translation blocks cache need to be flushed. */
141 bool fFlushTBs;
142
143 /** Ignore all that can be ignored. */
144 bool fIgnoreAll;
145 /** Ignore CR3 load notifications from the REM. */
146 bool fIgnoreCR3Load;
147 /** Ignore invlpg notifications from the REM. */
148 bool fIgnoreInvlPg;
149 /** Ignore CR0, CR4 and EFER load. */
150 bool fIgnoreCpuMode;
151 /** Ignore set page. */
152 bool fIgnoreSetPage;
153
154 /** Number of times REMR3CanExecuteRaw has been called.
155 * It is used to prevent rescheduling on the first call. */
156 uint32_t cCanExecuteRaw;
157
158 /** Pending interrupt (~0 -> nothing). */
159 uint32_t u32PendingInterrupt;
160
161#if HC_ARCH_BITS == 64
162 /** Alignment padding. */
163 uint32_t u32Padding;
164#endif
165 /** Number of recorded invlpg instructions. */
166 uint32_t cInvalidatedPages;
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[32];
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 uint32_t uPendingExcptEIP;
190 uint32_t reserved_for_future_uPendingExcptRIP;
191 /** Pending exception's CR2 */
192 uint32_t uPendingExcptCR2;
193 uint32_t reserved_for_future_64bit_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 /** Time spent in QEMU. */
204 STAMPROFILEADV StatsInQEMU;
205 /** Time spent in rawmode.c. */
206 STAMPROFILEADV StatsInRAWEx;
207 /** Time spent switching state. */
208 STAMPROFILE StatsState;
209 /** Time spent switching state back. */
210 STAMPROFILE StatsStateBack;
211
212 /** Padding the CPUX86State structure to 32 byte. */
213 uint32_t abPadding[HC_ARCH_BITS == 32 ? 6 : 4];
214
215# define REM_ENV_SIZE 0xff00
216
217 /** Recompiler CPU state. */
218#ifdef REM_INCLUDE_CPU_H
219 CPUX86State Env;
220#else
221 struct FakeEnv
222 {
223 char achPadding[REM_ENV_SIZE];
224 } Env;
225#endif /* !REM_INCLUDE_CPU_H */
226} REM;
227
228/** Pointer to the REM Data. */
229typedef REM *PREM;
230
231
232#ifdef REM_INCLUDE_CPU_H
233bool remR3CanExecuteRaw(CPUState *env, RTGCPTR eip, unsigned fFlags, int *piException);
234void remR3CSAMCheckEIP(CPUState *env, RTGCPTR GCPtrCode);
235bool remR3GetOpcode(CPUState *env, RTGCPTR GCPtrInstr, uint8_t *pu8Byte);
236bool remR3DisasInstr(CPUState *env, int f32BitCode, char *pszPrefix);
237void remR3FlushPage(CPUState *env, RTGCPTR GCPtr);
238void remR3SetPage(CPUState *env, CPUTLBEntry *pRead, CPUTLBEntry *pWrite, int prot, int is_user);
239void remR3FlushTLB(CPUState *env, bool fGlobal);
240void remR3ProtectCode(CPUState *env, RTGCPTR GCPtr);
241void remR3ChangeCpuMode(CPUState *env);
242void remR3DmaRun(CPUState *env);
243void remR3TimersRun(CPUState *env);
244int remR3NotifyTrap(CPUState *env, uint32_t uTrap, uint32_t uErrorCode, RTGCPTR pvNextEIP);
245void remR3TrapStat(CPUState *env, uint32_t uTrap);
246void remR3CpuId(CPUState *env, unsigned uOperator, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX);
247void remR3RecordCall(CPUState *env);
248#endif /* REM_INCLUDE_CPU_H */
249void remR3TrapClear(PVM pVM);
250void remR3RaiseRC(PVM pVM, int rc);
251void remR3DumpLnxSyscall(PVMCPU pVCpu);
252void remR3DumpOBsdSyscall(PVMCPU pVCpu);
253
254
255/** @todo r=bird: clean up the RAWEx stats. */
256/* temporary hacks */
257#define RAWEx_ProfileStart(a, b) remR3ProfileStart(b)
258#define RAWEx_ProfileStop(a, b) remR3ProfileStop(b)
259
260
261#ifdef VBOX_WITH_STATISTICS
262
263# define STATS_EMULATE_SINGLE_INSTR 1
264# define STATS_QEMU_COMPILATION 2
265# define STATS_QEMU_RUN_EMULATED_CODE 3
266# define STATS_QEMU_TOTAL 4
267# define STATS_QEMU_RUN_TIMERS 5
268# define STATS_TLB_LOOKUP 6
269# define STATS_IRQ_HANDLING 7
270# define STATS_RAW_CHECK 8
271
272void remR3ProfileStart(int statcode);
273void remR3ProfileStop(int statcode);
274
275#else /* !VBOX_WITH_STATISTICS */
276# define remR3ProfileStart(c) do { } while (0)
277# define remR3ProfileStop(c) do { } while (0)
278#endif /* !VBOX_WITH_STATISTICS */
279
280/** @} */
281
282#endif
283
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette