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