1 | /** @file
|
---|
2 | * PGM - Page Monitor/Monitor.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | *
|
---|
25 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
26 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
27 | * additional information or have any questions.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef ___VBox_pgm_h
|
---|
31 | #define ___VBox_pgm_h
|
---|
32 |
|
---|
33 | #include <VBox/cdefs.h>
|
---|
34 | #include <VBox/types.h>
|
---|
35 | #include <VBox/sup.h>
|
---|
36 | #include <VBox/vmapi.h>
|
---|
37 | #include <VBox/x86.h>
|
---|
38 |
|
---|
39 | __BEGIN_DECLS
|
---|
40 |
|
---|
41 | /** @defgroup grp_pgm The Page Monitor/Manager API
|
---|
42 | * @{
|
---|
43 | */
|
---|
44 |
|
---|
45 | /** Chunk size for dynamically allocated physical memory. */
|
---|
46 | #define PGM_DYNAMIC_CHUNK_SIZE (1*1024*1024)
|
---|
47 | /** Shift GC physical address by 20 bits to get the offset into the pvHCChunkHC array. */
|
---|
48 | #define PGM_DYNAMIC_CHUNK_SHIFT 20
|
---|
49 | /** Dynamic chunk offset mask. */
|
---|
50 | #define PGM_DYNAMIC_CHUNK_OFFSET_MASK 0xfffff
|
---|
51 | /** Dynamic chunk base mask. */
|
---|
52 | #define PGM_DYNAMIC_CHUNK_BASE_MASK (~(RTGCPHYS)PGM_DYNAMIC_CHUNK_OFFSET_MASK)
|
---|
53 |
|
---|
54 |
|
---|
55 | /** Page flags used for PGMHyperSetPageFlags
|
---|
56 | * @deprecated
|
---|
57 | * @{ */
|
---|
58 | #define PGMPAGE_READ 1
|
---|
59 | #define PGMPAGE_WRITE 2
|
---|
60 | #define PGMPAGE_USER 4
|
---|
61 | #define PGMPAGE_SYSTEM 8
|
---|
62 | #define PGMPAGE_NOTPRESENT 16
|
---|
63 | /** @} */
|
---|
64 |
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * FNPGMRELOCATE callback mode.
|
---|
68 | */
|
---|
69 | typedef enum PGMRELOCATECALL
|
---|
70 | {
|
---|
71 | /** The callback is for checking if the suggested address is suitable. */
|
---|
72 | PGMRELOCATECALL_SUGGEST = 1,
|
---|
73 | /** The callback is for executing the relocation. */
|
---|
74 | PGMRELOCATECALL_RELOCATE
|
---|
75 | } PGMRELOCATECALL;
|
---|
76 |
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Callback function which will be called when PGM is trying to find
|
---|
80 | * a new location for the mapping.
|
---|
81 | *
|
---|
82 | * The callback is called in two modes, 1) the check mode and 2) the relocate mode.
|
---|
83 | * In 1) the callback should say if it objects to a suggested new location. If it
|
---|
84 | * accepts the new location, it is called again for doing it's relocation.
|
---|
85 | *
|
---|
86 | *
|
---|
87 | * @returns true if the location is ok.
|
---|
88 | * @returns false if another location should be found.
|
---|
89 | * @param GCPtrOld The old virtual address.
|
---|
90 | * @param GCPtrNew The new virtual address.
|
---|
91 | * @param enmMode Used to indicate the callback mode.
|
---|
92 | * @param pvUser User argument.
|
---|
93 | * @remark The return value is no a failure indicator, it's an acceptance
|
---|
94 | * indicator. Relocation can not fail!
|
---|
95 | */
|
---|
96 | typedef DECLCALLBACK(bool) FNPGMRELOCATE(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser);
|
---|
97 | /** Pointer to a relocation callback function. */
|
---|
98 | typedef FNPGMRELOCATE *PFNPGMRELOCATE;
|
---|
99 |
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * Physical page access handler type.
|
---|
103 | */
|
---|
104 | typedef enum PGMPHYSHANDLERTYPE
|
---|
105 | {
|
---|
106 | /** MMIO range. Pages are not present, all access is done in interpreter or recompiler. */
|
---|
107 | PGMPHYSHANDLERTYPE_MMIO = 1,
|
---|
108 | /** Handler all write access to a physical page range. */
|
---|
109 | PGMPHYSHANDLERTYPE_PHYSICAL_WRITE,
|
---|
110 | /** Handler all access to a physical page range. */
|
---|
111 | PGMPHYSHANDLERTYPE_PHYSICAL_ALL
|
---|
112 |
|
---|
113 | } PGMPHYSHANDLERTYPE;
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * \#PF Handler callback for physical access handler ranges (MMIO among others) in GC.
|
---|
117 | *
|
---|
118 | * @returns VBox status code (appropriate for GC return).
|
---|
119 | * @param pVM VM Handle.
|
---|
120 | * @param uErrorCode CPU Error code.
|
---|
121 | * @param pRegFrame Trap register frame.
|
---|
122 | * NULL on DMA and other non CPU access.
|
---|
123 | * @param pvFault The fault address (cr2).
|
---|
124 | * @param GCPhysFault The GC physical address corresponding to pvFault.
|
---|
125 | * @param pvUser User argument.
|
---|
126 | */
|
---|
127 | typedef DECLCALLBACK(int) FNPGMGCPHYSHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
|
---|
128 | /** Pointer to PGM access callback. */
|
---|
129 | typedef FNPGMGCPHYSHANDLER *PFNPGMGCPHYSHANDLER;
|
---|
130 |
|
---|
131 | /**
|
---|
132 | * \#PF Handler callback for physical access handler ranges (MMIO among others) in R0.
|
---|
133 | *
|
---|
134 | * @returns VBox status code (appropriate for GC return).
|
---|
135 | * @param pVM VM Handle.
|
---|
136 | * @param uErrorCode CPU Error code.
|
---|
137 | * @param pRegFrame Trap register frame.
|
---|
138 | * NULL on DMA and other non CPU access.
|
---|
139 | * @param pvFault The fault address (cr2).
|
---|
140 | * @param GCPhysFault The GC physical address corresponding to pvFault.
|
---|
141 | * @param pvUser User argument.
|
---|
142 | */
|
---|
143 | typedef DECLCALLBACK(int) FNPGMR0PHYSHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
|
---|
144 | /** Pointer to PGM access callback. */
|
---|
145 | typedef FNPGMR0PHYSHANDLER *PFNPGMR0PHYSHANDLER;
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * Guest Access type
|
---|
149 | */
|
---|
150 | typedef enum PGMACCESSTYPE
|
---|
151 | {
|
---|
152 | /** Read access. */
|
---|
153 | PGMACCESSTYPE_READ = 1,
|
---|
154 | /** Write access. */
|
---|
155 | PGMACCESSTYPE_WRITE
|
---|
156 | } PGMACCESSTYPE;
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * \#PF Handler callback for physical access handler ranges (MMIO among others) in HC.
|
---|
160 | *
|
---|
161 | * The handler can not raise any faults, it's mainly for monitoring write access
|
---|
162 | * to certain pages.
|
---|
163 | *
|
---|
164 | * @returns VINF_SUCCESS if the handler have carried out the operation.
|
---|
165 | * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
|
---|
166 | * @param pVM VM Handle.
|
---|
167 | * @param GCPhys The physical address the guest is writing to.
|
---|
168 | * @param pvPhys The HC mapping of that address.
|
---|
169 | * @param pvBuf What the guest is reading/writing.
|
---|
170 | * @param cbBuf How much it's reading/writing.
|
---|
171 | * @param enmAccessType The access type.
|
---|
172 | * @param pvUser User argument.
|
---|
173 | */
|
---|
174 | typedef DECLCALLBACK(int) FNPGMR3PHYSHANDLER(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
|
---|
175 | /** Pointer to PGM access callback. */
|
---|
176 | typedef FNPGMR3PHYSHANDLER *PFNPGMR3PHYSHANDLER;
|
---|
177 |
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Virtual access handler type.
|
---|
181 | */
|
---|
182 | typedef enum PGMVIRTHANDLERTYPE
|
---|
183 | {
|
---|
184 | /** Write access handled. */
|
---|
185 | PGMVIRTHANDLERTYPE_WRITE = 1,
|
---|
186 | /** All access handled. */
|
---|
187 | PGMVIRTHANDLERTYPE_ALL,
|
---|
188 | /** Hypervisor write access handled.
|
---|
189 | * This is used to catch the guest trying to write to LDT, TSS and any other
|
---|
190 | * system structure which the brain dead intel guys let unprivilegde code find. */
|
---|
191 | PGMVIRTHANDLERTYPE_HYPERVISOR
|
---|
192 | } PGMVIRTHANDLERTYPE;
|
---|
193 |
|
---|
194 | /**
|
---|
195 | * \#PF Handler callback for virtual access handler ranges.
|
---|
196 | *
|
---|
197 | * Important to realize that a physical page in a range can have aliases, and
|
---|
198 | * for ALL and WRITE handlers these will also trigger.
|
---|
199 | *
|
---|
200 | * @returns VBox status code (appropriate for GC return).
|
---|
201 | * @param pVM VM Handle.
|
---|
202 | * @param uErrorCode CPU Error code.
|
---|
203 | * @param pRegFrame Trap register frame.
|
---|
204 | * @param pvFault The fault address (cr2).
|
---|
205 | * @param pvRange The base address of the handled virtual range.
|
---|
206 | * @param offRange The offset of the access into this range.
|
---|
207 | * (If it's a EIP range this's the EIP, if not it's pvFault.)
|
---|
208 | */
|
---|
209 | typedef DECLCALLBACK(int) FNPGMGCVIRTHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange);
|
---|
210 | /** Pointer to PGM access callback. */
|
---|
211 | typedef FNPGMGCVIRTHANDLER *PFNPGMGCVIRTHANDLER;
|
---|
212 |
|
---|
213 | /**
|
---|
214 | * \#PF Handler callback for virtual access handler ranges.
|
---|
215 | *
|
---|
216 | * Important to realize that a physical page in a range can have aliases, and
|
---|
217 | * for ALL and WRITE handlers these will also trigger.
|
---|
218 | *
|
---|
219 | * @returns VINF_SUCCESS if the handler have carried out the operation.
|
---|
220 | * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
|
---|
221 | * @param pVM VM Handle.
|
---|
222 | * @param GCPtr The virtual address the guest is writing to. (not correct if it's an alias!)
|
---|
223 | * @param pvPtr The HC mapping of that address.
|
---|
224 | * @param pvBuf What the guest is reading/writing.
|
---|
225 | * @param cbBuf How much it's reading/writing.
|
---|
226 | * @param enmAccessType The access type.
|
---|
227 | * @param pvUser User argument.
|
---|
228 | */
|
---|
229 | typedef DECLCALLBACK(int) FNPGMHCVIRTHANDLER(PVM pVM, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
|
---|
230 | /** Pointer to PGM access callback. */
|
---|
231 | typedef FNPGMHCVIRTHANDLER *PFNPGMHCVIRTHANDLER;
|
---|
232 |
|
---|
233 |
|
---|
234 | /**
|
---|
235 | * \#PF Handler callback for invalidation of virtual access handler ranges.
|
---|
236 | *
|
---|
237 | * @param pVM VM Handle.
|
---|
238 | * @param GCPtr The virtual address the guest has changed.
|
---|
239 | */
|
---|
240 | typedef DECLCALLBACK(int) FNPGMHCVIRTINVALIDATE(PVM pVM, RTGCPTR GCPtr);
|
---|
241 | /** Pointer to PGM invalidation callback. */
|
---|
242 | typedef FNPGMHCVIRTINVALIDATE *PFNPGMHCVIRTINVALIDATE;
|
---|
243 |
|
---|
244 | /**
|
---|
245 | * Paging mode.
|
---|
246 | */
|
---|
247 | typedef enum PGMMODE
|
---|
248 | {
|
---|
249 | /** The usual invalid value. */
|
---|
250 | PGMMODE_INVALID = 0,
|
---|
251 | /** Real mode. */
|
---|
252 | PGMMODE_REAL,
|
---|
253 | /** Protected mode, no paging. */
|
---|
254 | PGMMODE_PROTECTED,
|
---|
255 | /** 32-bit paging. */
|
---|
256 | PGMMODE_32_BIT,
|
---|
257 | /** PAE paging. */
|
---|
258 | PGMMODE_PAE,
|
---|
259 | /** PAE paging with NX enabled. */
|
---|
260 | PGMMODE_PAE_NX,
|
---|
261 | /** 64-bit AMD paging (long mode). */
|
---|
262 | PGMMODE_AMD64,
|
---|
263 | /** 64-bit AMD paging (long mode) with NX enabled. */
|
---|
264 | PGMMODE_AMD64_NX,
|
---|
265 | /** Nested paging mode (shadow only; guest physical to host physical). */
|
---|
266 | PGMMODE_NESTED,
|
---|
267 | /** Extended paging (Intel) mode. */
|
---|
268 | PGMMODE_EPT,
|
---|
269 | /** The max number of modes */
|
---|
270 | PGMMODE_MAX,
|
---|
271 | /** 32bit hackishness. */
|
---|
272 | PGMMODE_32BIT_HACK = 0x7fffffff
|
---|
273 | } PGMMODE;
|
---|
274 |
|
---|
275 | /**
|
---|
276 | * The current ROM page protection.
|
---|
277 | */
|
---|
278 | typedef enum PGMROMPROT
|
---|
279 | {
|
---|
280 | /** The customary invalid value. */
|
---|
281 | PGMROMPROT_INVALID = 0,
|
---|
282 | /** Read from the virgin ROM page, ignore writes.
|
---|
283 | * Map the virgin page, use write access handler to ignore writes. */
|
---|
284 | PGMROMPROT_READ_ROM_WRITE_IGNORE,
|
---|
285 | /** Read from the virgin ROM page, write to the shadow RAM.
|
---|
286 | * Map the virgin page, use write access handler change the RAM. */
|
---|
287 | PGMROMPROT_READ_ROM_WRITE_RAM,
|
---|
288 | /** Read from the shadow ROM page, ignore writes.
|
---|
289 | * Map the shadow page read-only, use write access handler to ignore writes. */
|
---|
290 | PGMROMPROT_READ_RAM_WRITE_IGNORE,
|
---|
291 | /** Read from the shadow ROM page, ignore writes.
|
---|
292 | * Map the shadow page read-write, disabled write access handler. */
|
---|
293 | PGMROMPROT_READ_RAM_WRITE_RAM,
|
---|
294 | /** The end of valid values. */
|
---|
295 | PGMROMPROT_END,
|
---|
296 | /** The usual 32-bit type size hack. */
|
---|
297 | PGMROMPROT_32BIT_HACK = 0x7fffffff
|
---|
298 | } PGMROMPROT;
|
---|
299 |
|
---|
300 | /**
|
---|
301 | * Is the ROM mapped (true) or is the shadow RAM mapped (false).
|
---|
302 | *
|
---|
303 | * @returns boolean.
|
---|
304 | * @param enmProt The PGMROMPROT value, must be valid.
|
---|
305 | */
|
---|
306 | #define PGMROMPROT_IS_ROM(enmProt) \
|
---|
307 | ( (enmProt) == PGMROMPROT_READ_ROM_WRITE_IGNORE \
|
---|
308 | || (enmProt) == PGMROMPROT_READ_ROM_WRITE_RAM )
|
---|
309 |
|
---|
310 |
|
---|
311 | PGMDECL(RTHCPHYS) PGMGetHyperCR3(PVM pVM);
|
---|
312 | PGMDECL(RTHCPHYS) PGMGetNestedCR3(PVM pVM, PGMMODE enmShadowMode);
|
---|
313 | PGMDECL(RTHCPHYS) PGMGetHyper32BitCR3(PVM pVM);
|
---|
314 | PGMDECL(RTHCPHYS) PGMGetHyperPaeCR3(PVM pVM);
|
---|
315 | PGMDECL(RTHCPHYS) PGMGetHyperAmd64CR3(PVM pVM);
|
---|
316 | PGMDECL(RTHCPHYS) PGMGetInterHCCR3(PVM pVM);
|
---|
317 | PGMDECL(RTHCPHYS) PGMGetInterGCCR3(PVM pVM);
|
---|
318 | PGMDECL(RTHCPHYS) PGMGetInter32BitCR3(PVM pVM);
|
---|
319 | PGMDECL(RTHCPHYS) PGMGetInterPaeCR3(PVM pVM);
|
---|
320 | PGMDECL(RTHCPHYS) PGMGetInterAmd64CR3(PVM pVM);
|
---|
321 | PGMDECL(int) PGMTrap0eHandler(PVM pVM, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
|
---|
322 | PGMDECL(int) PGMPrefetchPage(PVM pVM, RTGCPTR GCPtrPage);
|
---|
323 | PGMDECL(int) PGMVerifyAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
|
---|
324 | PGMDECL(int) PGMIsValidAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
|
---|
325 | PGMDECL(int) PGMInterpretInstruction(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
|
---|
326 | PGMDECL(int) PGMMap(PVM pVM, RTGCUINTPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags);
|
---|
327 | PGMDECL(int) PGMMapSetPage(PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags);
|
---|
328 | PGMDECL(int) PGMMapModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
|
---|
329 | PGMDECL(int) PGMShwGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
|
---|
330 | PGMDECL(int) PGMShwSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
|
---|
331 | PGMDECL(int) PGMShwModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
|
---|
332 | PGMDECL(int) PGMShwSyncLongModePDPtr(PVM pVM, RTGCUINTPTR64 GCPtr, PX86PML4E pGstPml4e, PX86PDPE pGstPdpe, PX86PDPAE *ppPD);
|
---|
333 | PGMDECL(int) PGMShwGetLongModePDPtr(PVM pVM, RTGCUINTPTR64 GCPtr, PX86PDPT *ppPdpt, PX86PDPAE *ppPD);
|
---|
334 | PGMDECL(int) PGMShwSyncPAEPDPtr(PVM pVM, RTGCUINTPTR GCPtr, PX86PDPE pGstPdpe, PX86PDPAE *ppPD);
|
---|
335 | PGMDECL(int) PGMShwGetPAEPDPtr(PVM pVM, RTGCUINTPTR GCPtr, PX86PDPT *ppPdpt, PX86PDPAE *ppPD);
|
---|
336 | PGMDECL(int) PGMGstGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTGCPHYS pGCPhys);
|
---|
337 | PGMDECL(bool) PGMGstIsPagePresent(PVM pVM, RTGCPTR GCPtr);
|
---|
338 | PGMDECL(int) PGMGstSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
|
---|
339 | PGMDECL(int) PGMGstModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
|
---|
340 | PGMDECL(int) PGMFlushTLB(PVM pVM, uint64_t cr3, bool fGlobal);
|
---|
341 | PGMDECL(int) PGMUpdateCR3(PVM pVM, uint64_t cr3);
|
---|
342 | PGMDECL(int) PGMSyncCR3(PVM pVM, uint64_t cr0, uint64_t cr3, uint64_t cr4, bool fGlobal);
|
---|
343 | PGMDECL(int) PGMChangeMode(PVM pVM, uint64_t cr0, uint64_t cr4, uint64_t efer);
|
---|
344 | PGMDECL(PGMMODE) PGMGetGuestMode(PVM pVM);
|
---|
345 | PGMDECL(PGMMODE) PGMGetShadowMode(PVM pVM);
|
---|
346 | PGMDECL(PGMMODE) PGMGetHostMode(PVM pVM);
|
---|
347 | PGMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
|
---|
348 | PGMDECL(int) PGMHandlerPhysicalRegisterEx(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
|
---|
349 | R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
|
---|
350 | R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
|
---|
351 | RCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RCPTRTYPE(void *) pvUserGC,
|
---|
352 | R3PTRTYPE(const char *) pszDesc);
|
---|
353 | PGMDECL(int) PGMHandlerPhysicalModify(PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
|
---|
354 | PGMDECL(int) PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys);
|
---|
355 | PGMDECL(int) PGMHandlerPhysicalChangeCallbacks(PVM pVM, RTGCPHYS GCPhys,
|
---|
356 | R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
|
---|
357 | R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
|
---|
358 | RCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RCPTRTYPE(void *) pvUserGC,
|
---|
359 | R3PTRTYPE(const char *) pszDesc);
|
---|
360 | PGMDECL(int) PGMHandlerPhysicalSplit(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
|
---|
361 | PGMDECL(int) PGMHandlerPhysicalJoin(PVM pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
|
---|
362 | PGMDECL(int) PGMHandlerPhysicalPageTempOff(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
|
---|
363 | PGMDECL(int) PGMHandlerPhysicalReset(PVM pVM, RTGCPHYS GCPhys);
|
---|
364 | PGMDECL(int) PGMHandlerPhysicalPageReset(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
|
---|
365 | PGMDECL(bool) PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys);
|
---|
366 | PGMDECL(bool) PGMPhysIsA20Enabled(PVM pVM);
|
---|
367 | PGMDECL(bool) PGMPhysIsGCPhysValid(PVM pVM, RTGCPHYS GCPhys);
|
---|
368 | PGMDECL(bool) PGMPhysIsGCPhysNormal(PVM pVM, RTGCPHYS GCPhys);
|
---|
369 | PGMDECL(int) PGMPhysGCPhys2HCPhys(PVM pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
|
---|
370 | PGMDECL(int) PGMPhysGCPtr2GCPhys(PVM pVM, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
|
---|
371 | PGMDECL(int) PGMPhysGCPtr2HCPhys(PVM pVM, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
|
---|
372 | PDMDECL(void) PGMPhysInvalidatePageGCMapTLB(PVM pVM);
|
---|
373 | PDMDECL(void) PGMPhysInvalidatePageR0MapTLB(PVM pVM);
|
---|
374 | PDMDECL(void) PGMPhysInvalidatePageR3MapTLB(PVM pVM);
|
---|
375 |
|
---|
376 | /**
|
---|
377 | * Page mapping lock.
|
---|
378 | *
|
---|
379 | * @remarks This doesn't work in structures shared between
|
---|
380 | * ring-3, ring-0 and/or GC.
|
---|
381 | */
|
---|
382 | typedef struct PGMPAGEMAPLOCK
|
---|
383 | {
|
---|
384 | /** @todo see PGMPhysIsPageMappingLockValid for possibly incorrect assumptions */
|
---|
385 | #ifdef IN_GC
|
---|
386 | /** Just a dummy for the time being. */
|
---|
387 | uint32_t u32Dummy;
|
---|
388 | #else
|
---|
389 | /** Pointer to the PGMPAGE. */
|
---|
390 | void *pvPage;
|
---|
391 | /** Pointer to the PGMCHUNKR3MAP. */
|
---|
392 | void *pvMap;
|
---|
393 | #endif
|
---|
394 | } PGMPAGEMAPLOCK;
|
---|
395 | /** Pointer to a page mapping lock. */
|
---|
396 | typedef PGMPAGEMAPLOCK *PPGMPAGEMAPLOCK;
|
---|
397 |
|
---|
398 | PGMDECL(int) PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
|
---|
399 | PGMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
|
---|
400 | PGMDECL(int) PGMPhysGCPtr2CCPtr(PVM pVM, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
|
---|
401 | PGMDECL(int) PGMPhysGCPtr2CCPtrReadOnly(PVM pVM, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
|
---|
402 | PGMDECL(void) PGMPhysReleasePageMappingLock(PVM pVM, PPGMPAGEMAPLOCK pLock);
|
---|
403 |
|
---|
404 | /**
|
---|
405 | * Checks if the lock structure is valid
|
---|
406 | *
|
---|
407 | * @param pVM The VM handle.
|
---|
408 | * @param pLock The lock structure initialized by the mapping function.
|
---|
409 | */
|
---|
410 | DECLINLINE(bool) PGMPhysIsPageMappingLockValid(PVM pVM, PPGMPAGEMAPLOCK pLock)
|
---|
411 | {
|
---|
412 | /** @todo -> complete/change this */
|
---|
413 | #ifdef IN_GC
|
---|
414 | return !!(pLock->u32Dummy);
|
---|
415 | #else
|
---|
416 | return !!(pLock->pvPage);
|
---|
417 | #endif
|
---|
418 | }
|
---|
419 |
|
---|
420 | PGMDECL(int) PGMPhysGCPhys2HCPtr(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR pHCPtr);
|
---|
421 | PGMDECL(int) PGMPhysGCPtr2HCPtr(PVM pVM, RTGCPTR GCPtr, PRTHCPTR pHCPtr);
|
---|
422 | PGMDECL(int) PGMPhysGCPtr2HCPtrByGstCR3(PVM pVM, RTGCPTR GCPtr, uint64_t cr3, unsigned fFlags, PRTHCPTR pHCPtr);
|
---|
423 | PGMDECL(void) PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
|
---|
424 | PGMDECL(void) PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
|
---|
425 | #ifndef IN_GC /* Only ring 0 & 3. */
|
---|
426 | PGMDECL(int) PGMPhysReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
|
---|
427 | PGMDECL(int) PGMPhysWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
|
---|
428 | PGMDECL(int) PGMPhysReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
|
---|
429 | PGMDECL(int) PGMPhysWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
|
---|
430 | PGMDECL(int) PGMPhysReadGCPtrSafe(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
|
---|
431 | PGMDECL(int) PGMPhysWriteGCPtrSafe(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
|
---|
432 | PGMDECL(int) PGMPhysWriteGCPtrDirty(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
|
---|
433 | PGMDECL(int) PGMInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
|
---|
434 | #endif /* !IN_GC */
|
---|
435 | PGMDECL(int) PGMPhysInterpretedRead(PVM pVM, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb);
|
---|
436 | #ifdef VBOX_STRICT
|
---|
437 | PGMDECL(unsigned) PGMAssertHandlerAndFlagsInSync(PVM pVM);
|
---|
438 | PGMDECL(unsigned) PGMAssertNoMappingConflicts(PVM pVM);
|
---|
439 | PGMDECL(unsigned) PGMAssertCR3(PVM pVM, uint64_t cr3, uint64_t cr4);
|
---|
440 | #endif /* VBOX_STRICT */
|
---|
441 |
|
---|
442 |
|
---|
443 | #ifdef IN_GC
|
---|
444 | /** @defgroup grp_pgm_gc The PGM Guest Context API
|
---|
445 | * @ingroup grp_pgm
|
---|
446 | * @{
|
---|
447 | */
|
---|
448 | PGMGCDECL(int) PGMGCDynMapGCPage(PVM pVM, RTGCPHYS GCPhys, void **ppv);
|
---|
449 | PGMGCDECL(int) PGMGCDynMapGCPageEx(PVM pVM, RTGCPHYS GCPhys, void **ppv);
|
---|
450 | PGMGCDECL(int) PGMGCDynMapHCPage(PVM pVM, RTHCPHYS HCPhys, void **ppv);
|
---|
451 | PGMGCDECL(int) PGMGCInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
|
---|
452 | /** @} */
|
---|
453 | #endif /* IN_GC */
|
---|
454 |
|
---|
455 |
|
---|
456 | #ifdef IN_RING0
|
---|
457 | /** @defgroup grp_pgm_r0 The PGM Host Context Ring-0 API
|
---|
458 | * @ingroup grp_pgm
|
---|
459 | * @{
|
---|
460 | */
|
---|
461 | PGMR0DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM);
|
---|
462 | PGMR0DECL(int) PGMR0Trap0eHandlerNestedPaging(PVM pVM, PGMMODE enmShwPagingMode, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault);
|
---|
463 | /** @} */
|
---|
464 | #endif /* IN_RING0 */
|
---|
465 |
|
---|
466 |
|
---|
467 |
|
---|
468 | #ifdef IN_RING3
|
---|
469 | /** @defgroup grp_pgm_r3 The PGM Host Context Ring-3 API
|
---|
470 | * @ingroup grp_pgm
|
---|
471 | * @{
|
---|
472 | */
|
---|
473 | PGMR3DECL(int) PGMR3Init(PVM pVM);
|
---|
474 | PGMR3DECL(int) PGMR3InitDynMap(PVM pVM);
|
---|
475 | PGMR3DECL(int) PGMR3InitFinalize(PVM pVM);
|
---|
476 | PGMR3DECL(void) PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
477 | PGMR3DECL(void) PGMR3Reset(PVM pVM);
|
---|
478 | PGMR3DECL(int) PGMR3Term(PVM pVM);
|
---|
479 | PDMR3DECL(int) PGMR3LockCall(PVM pVM);
|
---|
480 | PGMR3DECL(int) PGMR3ChangeShwPDMappings(PVM pVM, bool fEnable);
|
---|
481 | PGMR3DECL(int) PGMR3ChangeMode(PVM pVM, PGMMODE enmGuestMode);
|
---|
482 |
|
---|
483 | #ifndef VBOX_WITH_NEW_PHYS_CODE
|
---|
484 | PGMR3DECL(int) PGM3PhysGrowRange(PVM pVM, PCRTGCPHYS GCPhys);
|
---|
485 | #endif /* !VBOX_WITH_NEW_PHYS_CODE */
|
---|
486 | PGMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
|
---|
487 | PDMR3DECL(int) PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb,
|
---|
488 | R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
|
---|
489 | R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
|
---|
490 | RCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RTGCPTR pvUserGC,
|
---|
491 | R3PTRTYPE(const char *) pszDesc);
|
---|
492 | PDMR3DECL(int) PGMR3PhysMMIODeregister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb);
|
---|
493 | PDMR3DECL(int) PGMR3PhysMMIO2Register(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc);
|
---|
494 | PDMR3DECL(int) PGMR3PhysMMIO2Deregister(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion);
|
---|
495 | PDMR3DECL(int) PGMR3PhysMMIO2Map(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
|
---|
496 | PDMR3DECL(int) PGMR3PhysMMIO2Unmap(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
|
---|
497 | PDMR3DECL(bool) PGMR3PhysMMIO2IsBase(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys);
|
---|
498 | PDMR3DECL(int) PGMR3PhysMMIO2GetHCPhys(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, PRTHCPHYS pHCPhys);
|
---|
499 |
|
---|
500 | /** @group PGMR3PhysRegisterRom flags.
|
---|
501 | * @{ */
|
---|
502 | /** Inidicates that ROM shadowing should be enabled. */
|
---|
503 | #define PGMPHYS_ROM_FLAG_SHADOWED RT_BIT_32(0)
|
---|
504 | /** Indicates that what pvBinary points to won't go away
|
---|
505 | * and can be used for strictness checks. */
|
---|
506 | #define PGMPHYS_ROM_FLAG_PERMANENT_BINARY RT_BIT_32(1)
|
---|
507 | /** @} */
|
---|
508 |
|
---|
509 | PGMR3DECL(int) PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
|
---|
510 | const void *pvBinary, uint32_t fFlags, const char *pszDesc);
|
---|
511 | PGMR3DECL(int) PGMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMROMPROT enmProt);
|
---|
512 | PGMR3DECL(int) PGMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
|
---|
513 | #ifndef VBOX_WITH_NEW_PHYS_CODE
|
---|
514 | PGMR3DECL(int) PGMR3PhysRegisterChunk(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
|
---|
515 | #endif /* !VBOX_WITH_NEW_PHYS_CODE */
|
---|
516 | PGMR3DECL(int) PGMR3PhysSetFlags(PVM pVM, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, unsigned fMask);
|
---|
517 | PGMDECL(void) PGMR3PhysSetA20(PVM pVM, bool fEnable);
|
---|
518 | PGMR3DECL(int) PGMR3MapPT(PVM pVM, RTGCPTR GCPtr, uint32_t cb, PFNPGMRELOCATE pfnRelocate, void *pvUser, const char *pszDesc);
|
---|
519 | PGMR3DECL(int) PGMR3UnmapPT(PVM pVM, RTGCPTR GCPtr);
|
---|
520 | PGMR3DECL(int) PGMR3MappingsSize(PVM pVM, uint32_t *pcb);
|
---|
521 | PGMR3DECL(int) PGMR3MappingsFix(PVM pVM, RTGCPTR GCPtrBase, uint32_t cb);
|
---|
522 | PGMR3DECL(int) PGMR3MappingsUnfix(PVM pVM);
|
---|
523 | PGMR3DECL(int) PGMR3MapIntermediate(PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
|
---|
524 | PGMR3DECL(bool) PGMR3MapHasConflicts(PVM pVM, uint64_t cr3, bool fRawR0);
|
---|
525 | PGMR3DECL(int) PGMR3MapRead(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
|
---|
526 | PGMR3DECL(int) PGMR3HandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
|
---|
527 | PFNPGMR3PHYSHANDLER pfnHandlerR3, void *pvUserR3,
|
---|
528 | const char *pszModR0, const char *pszHandlerR0, RTR0PTR pvUserR0,
|
---|
529 | const char *pszModGC, const char *pszHandlerGC, RTGCPTR pvUserGC, const char *pszDesc);
|
---|
530 | PGMDECL(int) PGMHandlerVirtualRegisterEx(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
|
---|
531 | PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
|
---|
532 | PFNPGMHCVIRTHANDLER pfnHandlerHC, RTGCPTR pfnHandlerGC,
|
---|
533 | R3PTRTYPE(const char *) pszDesc);
|
---|
534 | PGMR3DECL(int) PGMR3HandlerVirtualRegister(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
|
---|
535 | PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
|
---|
536 | PFNPGMHCVIRTHANDLER pfnHandlerHC,
|
---|
537 | const char *pszHandlerGC, const char *pszModGC, const char *pszDesc);
|
---|
538 | PGMDECL(int) PGMHandlerVirtualChangeInvalidateCallback(PVM pVM, RTGCPTR GCPtr, PFNPGMHCVIRTINVALIDATE pfnInvalidateHC);
|
---|
539 | PGMDECL(int) PGMHandlerVirtualDeregister(PVM pVM, RTGCPTR GCPtr);
|
---|
540 | PDMR3DECL(int) PGMR3PoolGrow(PVM pVM);
|
---|
541 | #ifdef ___VBox_dbgf_h /** @todo fix this! */
|
---|
542 | PGMR3DECL(int) PGMR3DumpHierarchyHC(PVM pVM, uint64_t cr3, uint64_t cr4, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp);
|
---|
543 | #endif
|
---|
544 | PGMR3DECL(int) PGMR3DumpHierarchyGC(PVM pVM, uint64_t cr3, uint64_t cr4, RTGCPHYS PhysSearch);
|
---|
545 |
|
---|
546 | PGMR3DECL(uint8_t) PGMR3PhysReadU8(PVM pVM, RTGCPHYS GCPhys);
|
---|
547 | PGMR3DECL(uint16_t) PGMR3PhysReadU16(PVM pVM, RTGCPHYS GCPhys);
|
---|
548 | PGMR3DECL(uint32_t) PGMR3PhysReadU32(PVM pVM, RTGCPHYS GCPhys);
|
---|
549 | PGMR3DECL(uint64_t) PGMR3PhysReadU64(PVM pVM, RTGCPHYS GCPhys);
|
---|
550 | PGMR3DECL(void) PGMR3PhysWriteU8(PVM pVM, RTGCPHYS GCPhys, uint8_t Value);
|
---|
551 | PGMR3DECL(void) PGMR3PhysWriteU16(PVM pVM, RTGCPHYS GCPhys, uint16_t Value);
|
---|
552 | PGMR3DECL(void) PGMR3PhysWriteU32(PVM pVM, RTGCPHYS GCPhys, uint32_t Value);
|
---|
553 | PGMR3DECL(void) PGMR3PhysWriteU64(PVM pVM, RTGCPHYS GCPhys, uint64_t Value);
|
---|
554 | PDMR3DECL(int) PGMR3PhysChunkMap(PVM pVM, uint32_t idChunk);
|
---|
555 | PGMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM);
|
---|
556 | PDMR3DECL(int) PGMR3PhysAllocateHandyPages(PVM pVM);
|
---|
557 |
|
---|
558 | PDMR3DECL(int) PGMR3CheckIntegrity(PVM pVM);
|
---|
559 |
|
---|
560 | PGMR3DECL(int) PGMR3DbgHCPtr2GCPhys(PVM pVM, RTHCPTR HCPtr, PRTGCPHYS pGCPhys);
|
---|
561 | PGMR3DECL(int) PGMR3DbgHCPtr2HCPhys(PVM pVM, RTHCPTR HCPtr, PRTHCPHYS pHCPhys);
|
---|
562 | PGMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PVM pVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
|
---|
563 | PDMR3DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
|
---|
564 | PDMR3DECL(int) PGMR3DbgScanVirtual(PVM pVM, RTGCUINTPTR GCPtr, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
|
---|
565 | /** @} */
|
---|
566 | #endif /* IN_RING3 */
|
---|
567 |
|
---|
568 | __END_DECLS
|
---|
569 |
|
---|
570 | /** @} */
|
---|
571 | #endif
|
---|
572 |
|
---|