VirtualBox

source: vbox/trunk/include/VBox/pgm.h@ 28425

Last change on this file since 28425 was 28418, checked in by vboxsync, 15 years ago

Case sensitive

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 29.1 KB
Line 
1/** @file
2 * PGM - Page Monitor / Monitor. (VMM)
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#include <VBox/VMMDev.h> /* for VMMDEVSHAREDREGIONDESC */
40
41RT_C_DECLS_BEGIN
42
43/** @defgroup grp_pgm The Page Monitor / Manager API
44 * @{
45 */
46
47/** Chunk size for dynamically allocated physical memory. */
48#define PGM_DYNAMIC_CHUNK_SIZE (1*1024*1024)
49/** Shift GC physical address by 20 bits to get the offset into the pvHCChunkHC array. */
50#define PGM_DYNAMIC_CHUNK_SHIFT 20
51/** Dynamic chunk offset mask. */
52#define PGM_DYNAMIC_CHUNK_OFFSET_MASK 0xfffff
53/** Dynamic chunk base mask. */
54#define PGM_DYNAMIC_CHUNK_BASE_MASK (~(RTGCPHYS)PGM_DYNAMIC_CHUNK_OFFSET_MASK)
55
56
57/**
58 * FNPGMRELOCATE callback mode.
59 */
60typedef enum PGMRELOCATECALL
61{
62 /** The callback is for checking if the suggested address is suitable. */
63 PGMRELOCATECALL_SUGGEST = 1,
64 /** The callback is for executing the relocation. */
65 PGMRELOCATECALL_RELOCATE
66} PGMRELOCATECALL;
67
68
69/**
70 * Callback function which will be called when PGM is trying to find
71 * a new location for the mapping.
72 *
73 * The callback is called in two modes, 1) the check mode and 2) the relocate mode.
74 * In 1) the callback should say if it objects to a suggested new location. If it
75 * accepts the new location, it is called again for doing it's relocation.
76 *
77 *
78 * @returns true if the location is ok.
79 * @returns false if another location should be found.
80 * @param GCPtrOld The old virtual address.
81 * @param GCPtrNew The new virtual address.
82 * @param enmMode Used to indicate the callback mode.
83 * @param pvUser User argument.
84 * @remark The return value is no a failure indicator, it's an acceptance
85 * indicator. Relocation can not fail!
86 */
87typedef DECLCALLBACK(bool) FNPGMRELOCATE(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser);
88/** Pointer to a relocation callback function. */
89typedef FNPGMRELOCATE *PFNPGMRELOCATE;
90
91
92/**
93 * Physical page access handler type.
94 */
95typedef enum PGMPHYSHANDLERTYPE
96{
97 /** MMIO range. Pages are not present, all access is done in interpreter or recompiler. */
98 PGMPHYSHANDLERTYPE_MMIO = 1,
99 /** Handler all write access to a physical page range. */
100 PGMPHYSHANDLERTYPE_PHYSICAL_WRITE,
101 /** Handler all access to a physical page range. */
102 PGMPHYSHANDLERTYPE_PHYSICAL_ALL
103
104} PGMPHYSHANDLERTYPE;
105
106/**
107 * \#PF Handler callback for physical access handler ranges in RC.
108 *
109 * @returns VBox status code (appropriate for RC return).
110 * @param pVM VM Handle.
111 * @param uErrorCode CPU Error code.
112 * @param pRegFrame Trap register frame.
113 * NULL on DMA and other non CPU access.
114 * @param pvFault The fault address (cr2).
115 * @param GCPhysFault The GC physical address corresponding to pvFault.
116 * @param pvUser User argument.
117 */
118typedef DECLCALLBACK(int) FNPGMRCPHYSHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
119/** Pointer to PGM access callback. */
120typedef FNPGMRCPHYSHANDLER *PFNPGMRCPHYSHANDLER;
121
122/**
123 * \#PF Handler callback for physical access handler ranges in R0.
124 *
125 * @returns VBox status code (appropriate for R0 return).
126 * @param pVM VM Handle.
127 * @param uErrorCode CPU Error code.
128 * @param pRegFrame Trap register frame.
129 * NULL on DMA and other non CPU access.
130 * @param pvFault The fault address (cr2).
131 * @param GCPhysFault The GC physical address corresponding to pvFault.
132 * @param pvUser User argument.
133 */
134typedef DECLCALLBACK(int) FNPGMR0PHYSHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
135/** Pointer to PGM access callback. */
136typedef FNPGMR0PHYSHANDLER *PFNPGMR0PHYSHANDLER;
137
138/**
139 * Guest Access type
140 */
141typedef enum PGMACCESSTYPE
142{
143 /** Read access. */
144 PGMACCESSTYPE_READ = 1,
145 /** Write access. */
146 PGMACCESSTYPE_WRITE
147} PGMACCESSTYPE;
148
149/**
150 * \#PF Handler callback for physical access handler ranges (MMIO among others) in HC.
151 *
152 * The handler can not raise any faults, it's mainly for monitoring write access
153 * to certain pages.
154 *
155 * @returns VINF_SUCCESS if the handler have carried out the operation.
156 * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
157 * @param pVM VM Handle.
158 * @param GCPhys The physical address the guest is writing to.
159 * @param pvPhys The HC mapping of that address.
160 * @param pvBuf What the guest is reading/writing.
161 * @param cbBuf How much it's reading/writing.
162 * @param enmAccessType The access type.
163 * @param pvUser User argument.
164 */
165typedef DECLCALLBACK(int) FNPGMR3PHYSHANDLER(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
166/** Pointer to PGM access callback. */
167typedef FNPGMR3PHYSHANDLER *PFNPGMR3PHYSHANDLER;
168
169
170/**
171 * Virtual access handler type.
172 */
173typedef enum PGMVIRTHANDLERTYPE
174{
175 /** Write access handled. */
176 PGMVIRTHANDLERTYPE_WRITE = 1,
177 /** All access handled. */
178 PGMVIRTHANDLERTYPE_ALL,
179 /** Hypervisor write access handled.
180 * This is used to catch the guest trying to write to LDT, TSS and any other
181 * system structure which the brain dead intel guys let unprivilegde code find. */
182 PGMVIRTHANDLERTYPE_HYPERVISOR
183} PGMVIRTHANDLERTYPE;
184
185/**
186 * \#PF Handler callback for virtual access handler ranges, RC.
187 *
188 * Important to realize that a physical page in a range can have aliases, and
189 * for ALL and WRITE handlers these will also trigger.
190 *
191 * @returns VBox status code (appropriate for GC return).
192 * @param pVM VM Handle.
193 * @param uErrorCode CPU Error code.
194 * @param pRegFrame Trap register frame.
195 * @param pvFault The fault address (cr2).
196 * @param pvRange The base address of the handled virtual range.
197 * @param offRange The offset of the access into this range.
198 * (If it's a EIP range this's the EIP, if not it's pvFault.)
199 */
200typedef DECLCALLBACK(int) FNPGMRCVIRTHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange);
201/** Pointer to PGM access callback. */
202typedef FNPGMRCVIRTHANDLER *PFNPGMRCVIRTHANDLER;
203
204/**
205 * \#PF Handler callback for virtual access handler ranges, R3.
206 *
207 * Important to realize that a physical page in a range can have aliases, and
208 * for ALL and WRITE handlers these will also trigger.
209 *
210 * @returns VINF_SUCCESS if the handler have carried out the operation.
211 * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
212 * @param pVM VM Handle.
213 * @param GCPtr The virtual address the guest is writing to. (not correct if it's an alias!)
214 * @param pvPtr The HC mapping of that address.
215 * @param pvBuf What the guest is reading/writing.
216 * @param cbBuf How much it's reading/writing.
217 * @param enmAccessType The access type.
218 * @param pvUser User argument.
219 */
220typedef DECLCALLBACK(int) FNPGMR3VIRTHANDLER(PVM pVM, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
221/** Pointer to PGM access callback. */
222typedef FNPGMR3VIRTHANDLER *PFNPGMR3VIRTHANDLER;
223
224
225/**
226 * \#PF Handler callback for invalidation of virtual access handler ranges.
227 *
228 * @param pVM VM Handle.
229 * @param GCPtr The virtual address the guest has changed.
230 */
231typedef DECLCALLBACK(int) FNPGMR3VIRTINVALIDATE(PVM pVM, RTGCPTR GCPtr);
232/** Pointer to PGM invalidation callback. */
233typedef FNPGMR3VIRTINVALIDATE *PFNPGMR3VIRTINVALIDATE;
234
235/**
236 * Paging mode.
237 */
238typedef enum PGMMODE
239{
240 /** The usual invalid value. */
241 PGMMODE_INVALID = 0,
242 /** Real mode. */
243 PGMMODE_REAL,
244 /** Protected mode, no paging. */
245 PGMMODE_PROTECTED,
246 /** 32-bit paging. */
247 PGMMODE_32_BIT,
248 /** PAE paging. */
249 PGMMODE_PAE,
250 /** PAE paging with NX enabled. */
251 PGMMODE_PAE_NX,
252 /** 64-bit AMD paging (long mode). */
253 PGMMODE_AMD64,
254 /** 64-bit AMD paging (long mode) with NX enabled. */
255 PGMMODE_AMD64_NX,
256 /** Nested paging mode (shadow only; guest physical to host physical). */
257 PGMMODE_NESTED,
258 /** Extended paging (Intel) mode. */
259 PGMMODE_EPT,
260 /** The max number of modes */
261 PGMMODE_MAX,
262 /** 32bit hackishness. */
263 PGMMODE_32BIT_HACK = 0x7fffffff
264} PGMMODE;
265
266/** Macro for checking if the guest is using paging.
267 * @param enmMode PGMMODE_*.
268 * @remark ASSUMES certain order of the PGMMODE_* values.
269 */
270#define PGMMODE_WITH_PAGING(enmMode) ((enmMode) >= PGMMODE_32_BIT)
271
272/** Macro for checking if it's one of the long mode modes.
273 * @param enmMode PGMMODE_*.
274 */
275#define PGMMODE_IS_LONG_MODE(enmMode) ((enmMode) == PGMMODE_AMD64_NX || (enmMode) == PGMMODE_AMD64)
276
277/**
278 * Is the ROM mapped (true) or is the shadow RAM mapped (false).
279 *
280 * @returns boolean.
281 * @param enmProt The PGMROMPROT value, must be valid.
282 */
283#define PGMROMPROT_IS_ROM(enmProt) \
284 ( (enmProt) == PGMROMPROT_READ_ROM_WRITE_IGNORE \
285 || (enmProt) == PGMROMPROT_READ_ROM_WRITE_RAM )
286
287
288
289VMMDECL(bool) PGMIsLocked(PVM pVM);
290VMMDECL(bool) PGMIsLockOwner(PVM pVM);
291
292VMMDECL(int) PGMRegisterStringFormatTypes(void);
293VMMDECL(void) PGMDeregisterStringFormatTypes(void);
294VMMDECL(RTHCPHYS) PGMGetHyperCR3(PVMCPU pVCpu);
295VMMDECL(RTHCPHYS) PGMGetNestedCR3(PVMCPU pVCpu, PGMMODE enmShadowMode);
296VMMDECL(RTHCPHYS) PGMGetInterHCCR3(PVM pVM);
297VMMDECL(RTHCPHYS) PGMGetInterRCCR3(PVM pVM, PVMCPU pVCpu);
298VMMDECL(RTHCPHYS) PGMGetInter32BitCR3(PVM pVM);
299VMMDECL(RTHCPHYS) PGMGetInterPaeCR3(PVM pVM);
300VMMDECL(RTHCPHYS) PGMGetInterAmd64CR3(PVM pVM);
301VMMDECL(int) PGMTrap0eHandler(PVMCPU pVCpu, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
302VMMDECL(int) PGMPrefetchPage(PVMCPU pVCpu, RTGCPTR GCPtrPage);
303VMMDECL(int) PGMVerifyAccess(PVMCPU pVCpu, RTGCPTR Addr, uint32_t cbSize, uint32_t fAccess);
304VMMDECL(int) PGMIsValidAccess(PVMCPU pVCpu, RTGCPTR Addr, uint32_t cbSize, uint32_t fAccess);
305VMMDECL(int) PGMInterpretInstruction(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
306VMMDECL(int) PGMMap(PVM pVM, RTGCPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags);
307VMMDECL(int) PGMMapSetPage(PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags);
308VMMDECL(int) PGMMapModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
309#ifndef IN_RING0
310VMMDECL(bool) PGMMapHasConflicts(PVM pVM);
311#endif
312#ifdef VBOX_STRICT
313VMMDECL(void) PGMMapCheck(PVM pVM);
314#endif
315VMMDECL(int) PGMShwGetPage(PVMCPU pVCpu, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
316VMMDECL(int) PGMShwSetPage(PVMCPU pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
317VMMDECL(int) PGMShwModifyPage(PVMCPU pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
318VMMDECL(int) PGMGstGetPage(PVMCPU pVCpu, RTGCPTR GCPtr, uint64_t *pfFlags, PRTGCPHYS pGCPhys);
319VMMDECL(bool) PGMGstIsPagePresent(PVMCPU pVCpu, RTGCPTR GCPtr);
320VMMDECL(int) PGMGstSetPage(PVMCPU pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
321VMMDECL(int) PGMGstModifyPage(PVMCPU pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
322VMMDECL(X86PDPE) PGMGstGetPaePDPtr(PVMCPU pVCpu, unsigned iPdPt);
323
324VMMDECL(int) PGMInvalidatePage(PVMCPU pVCpu, RTGCPTR GCPtrPage);
325VMMDECL(int) PGMFlushTLB(PVMCPU pVCpu, uint64_t cr3, bool fGlobal);
326VMMDECL(int) PGMSyncCR3(PVMCPU pVCpu, uint64_t cr0, uint64_t cr3, uint64_t cr4, bool fGlobal);
327VMMDECL(int) PGMUpdateCR3(PVMCPU pVCpu, uint64_t cr3);
328VMMDECL(int) PGMChangeMode(PVMCPU pVCpu, uint64_t cr0, uint64_t cr4, uint64_t efer);
329VMMDECL(PGMMODE) PGMGetGuestMode(PVMCPU pVCpu);
330VMMDECL(PGMMODE) PGMGetShadowMode(PVMCPU pVCpu);
331VMMDECL(PGMMODE) PGMGetHostMode(PVM pVM);
332VMMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
333VMMDECL(bool) PGMHasDirtyPages(PVM pVM);
334VMMDECL(int) PGMHandlerPhysicalRegisterEx(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
335 R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
336 R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
337 RCPTRTYPE(PFNPGMRCPHYSHANDLER) pfnHandlerRC, RTRCPTR pvUserRC,
338 R3PTRTYPE(const char *) pszDesc);
339VMMDECL(int) PGMHandlerPhysicalModify(PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
340VMMDECL(int) PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys);
341VMMDECL(int) PGMHandlerPhysicalChangeCallbacks(PVM pVM, RTGCPHYS GCPhys,
342 R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
343 R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
344 RCPTRTYPE(PFNPGMRCPHYSHANDLER) pfnHandlerRC, RTRCPTR pvUserRC,
345 R3PTRTYPE(const char *) pszDesc);
346VMMDECL(int) PGMHandlerPhysicalSplit(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
347VMMDECL(int) PGMHandlerPhysicalJoin(PVM pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
348VMMDECL(int) PGMHandlerPhysicalPageTempOff(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
349VMMDECL(int) PGMHandlerPhysicalPageAlias(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTGCPHYS GCPhysPageRemap);
350VMMDECL(int) PGMHandlerPhysicalPageAliasHC(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTHCPHYS HCPhysPageRemap);
351VMMDECL(int) PGMHandlerPhysicalReset(PVM pVM, RTGCPHYS GCPhys);
352VMMDECL(bool) PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys);
353VMMDECL(bool) PGMHandlerVirtualIsRegistered(PVM pVM, RTGCPTR GCPtr);
354VMMDECL(bool) PGMPhysIsA20Enabled(PVMCPU pVCpu);
355VMMDECL(bool) PGMPhysIsGCPhysValid(PVM pVM, RTGCPHYS GCPhys);
356VMMDECL(bool) PGMPhysIsGCPhysNormal(PVM pVM, RTGCPHYS GCPhys);
357VMMDECL(int) PGMPhysGCPhys2HCPhys(PVM pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
358VMMDECL(int) PGMPhysGCPtr2GCPhys(PVMCPU pVCpu, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
359VMMDECL(int) PGMPhysGCPtr2HCPhys(PVMCPU pVCpu, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
360VMMDECL(void) PGMPhysInvalidatePageMapTLB(PVM pVM);
361VMMDECL(void) PGMPhysInvalidatePageMapTLBEntry(PVM pVM, RTGCPHYS GCPhys);
362VMMDECL(int) PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
363VMMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
364VMMDECL(int) PGMPhysGCPtr2CCPtr(PVMCPU pVCpu, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
365VMMDECL(int) PGMPhysGCPtr2CCPtrReadOnly(PVMCPU pVCpu, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
366VMMDECL(void) PGMPhysReleasePageMappingLock(PVM pVM, PPGMPAGEMAPLOCK pLock);
367VMMDECL(int) PGMPhysGCPhys2R3Ptr(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, PRTR3PTR pR3Ptr);
368#ifdef VBOX_STRICT
369VMMDECL(RTR3PTR) PGMPhysGCPhys2R3PtrAssert(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange);
370#endif
371VMMDECL(int) PGMPhysGCPtr2R3Ptr(PVMCPU pVCpu, RTGCPTR GCPtr, PRTR3PTR pR3Ptr);
372VMMDECL(int) PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
373VMMDECL(int) PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
374VMMDECL(int) PGMPhysSimpleReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
375VMMDECL(int) PGMPhysSimpleWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
376VMMDECL(int) PGMPhysSimpleReadGCPtr(PVMCPU pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
377VMMDECL(int) PGMPhysSimpleWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
378VMMDECL(int) PGMPhysReadGCPtr(PVMCPU pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
379VMMDECL(int) PGMPhysWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
380VMMDECL(int) PGMPhysSimpleDirtyWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
381VMMDECL(int) PGMPhysInterpretedRead(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
382VMMDECL(int) PGMPhysInterpretedReadNoHandlers(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb, bool fRaiseTrap);
383VMMDECL(int) PGMPhysInterpretedWriteNoHandlers(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, bool fRaiseTrap);
384#ifdef VBOX_STRICT
385VMMDECL(unsigned) PGMAssertHandlerAndFlagsInSync(PVM pVM);
386VMMDECL(unsigned) PGMAssertNoMappingConflicts(PVM pVM);
387VMMDECL(unsigned) PGMAssertCR3(PVM pVM, PVMCPU pVCpu, uint64_t cr3, uint64_t cr4);
388#endif /* VBOX_STRICT */
389
390#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE)
391VMMDECL(int) PGMDynMapGCPage(PVM pVM, RTGCPHYS GCPhys, void **ppv);
392VMMDECL(int) PGMDynMapGCPageOff(PVM pVM, RTGCPHYS GCPhys, void **ppv);
393# ifdef IN_RC
394VMMDECL(int) PGMDynMapHCPage(PVM pVM, RTHCPHYS HCPhys, void **ppv);
395VMMDECL(void) PGMDynLockHCPage(PVM pVM, RCPTRTYPE(uint8_t *) GCPage);
396VMMDECL(void) PGMDynUnlockHCPage(PVM pVM, RCPTRTYPE(uint8_t *) GCPage);
397# ifdef VBOX_STRICT
398VMMDECL(void) PGMDynCheckLocks(PVM pVM);
399# endif
400# endif
401VMMDECL(void) PGMDynMapStartAutoSet(PVMCPU pVCpu);
402VMMDECL(bool) PGMDynMapStartOrMigrateAutoSet(PVMCPU pVCpu);
403VMMDECL(void) PGMDynMapReleaseAutoSet(PVMCPU pVCpu);
404VMMDECL(void) PGMDynMapFlushAutoSet(PVMCPU pVCpu);
405VMMDECL(void) PGMDynMapMigrateAutoSet(PVMCPU pVCpu);
406VMMDECL(uint32_t) PGMDynMapPushAutoSubset(PVMCPU pVCpu);
407VMMDECL(void) PGMDynMapPopAutoSubset(PVMCPU pVCpu, uint32_t iPrevSubset);
408#endif
409
410
411VMMDECL(void) PGMSetLargePageUsage(PVM pVM, bool fUseLargePages);
412
413/**
414 * Query large page usage state
415 *
416 * @returns 0 - disabled, 1 - enabled
417 * @param pVM The VM to operate on.
418 */
419#define PGMIsUsingLargePages(pVM) (pVM->fUseLargePages)
420
421
422#ifdef IN_RC
423/** @defgroup grp_pgm_gc The PGM Guest Context API
424 * @ingroup grp_pgm
425 * @{
426 */
427/** @} */
428#endif /* IN_RC */
429
430
431#ifdef IN_RING0
432/** @defgroup grp_pgm_r0 The PGM Host Context Ring-0 API
433 * @ingroup grp_pgm
434 * @{
435 */
436VMMR0DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM, PVMCPU pVCpu);
437VMMR0DECL(int) PGMR0PhysAllocateLargeHandyPage(PVM pVM, PVMCPU pVCpu);
438VMMR0DECL(int) PGMR0Trap0eHandlerNestedPaging(PVM pVM, PVMCPU pVCpu, PGMMODE enmShwPagingMode, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault);
439# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
440VMMR0DECL(int) PGMR0DynMapInit(void);
441VMMR0DECL(void) PGMR0DynMapTerm(void);
442VMMR0DECL(int) PGMR0DynMapInitVM(PVM pVM);
443VMMR0DECL(void) PGMR0DynMapTermVM(PVM pVM);
444VMMR0DECL(int) PGMR0DynMapAssertIntegrity(void);
445# endif
446/** @} */
447#endif /* IN_RING0 */
448
449
450
451#ifdef IN_RING3
452/** @defgroup grp_pgm_r3 The PGM Host Context Ring-3 API
453 * @ingroup grp_pgm
454 * @{
455 */
456VMMR3DECL(int) PGMR3Init(PVM pVM);
457VMMR3DECL(int) PGMR3InitCPU(PVM pVM);
458VMMR3DECL(int) PGMR3InitDynMap(PVM pVM);
459VMMR3DECL(int) PGMR3InitFinalize(PVM pVM);
460VMMR3DECL(void) PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
461VMMR3DECL(void) PGMR3ResetUnpluggedCpu(PVM pVM, PVMCPU pVCpu);
462VMMR3DECL(void) PGMR3Reset(PVM pVM);
463VMMR3DECL(int) PGMR3Term(PVM pVM);
464VMMR3DECL(int) PGMR3TermCPU(PVM pVM);
465VMMR3DECL(int) PGMR3LockCall(PVM pVM);
466VMMR3DECL(int) PGMR3ChangeMode(PVM pVM, PVMCPU pVCpu, PGMMODE enmGuestMode);
467
468VMMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
469VMMR3DECL(int) PGMR3PhysChangeMemBalloon(PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage);
470VMMR3DECL(int) PGMR3QueryVMMMemoryStats(PVM pVM, uint64_t *puTotalAllocSize, uint64_t *puTotalFreeSize, uint64_t *puTotalBalloonSize);
471VMMR3DECL(int) PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb,
472 R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
473 R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
474 RCPTRTYPE(PFNPGMRCPHYSHANDLER) pfnHandlerRC, RTRCPTR pvUserRC,
475 R3PTRTYPE(const char *) pszDesc);
476VMMR3DECL(int) PGMR3PhysMMIODeregister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb);
477VMMR3DECL(int) PGMR3PhysMMIO2Register(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc);
478VMMR3DECL(int) PGMR3PhysMMIO2Deregister(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion);
479VMMR3DECL(int) PGMR3PhysMMIO2Map(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
480VMMR3DECL(int) PGMR3PhysMMIO2Unmap(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
481VMMR3DECL(bool) PGMR3PhysMMIO2IsBase(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys);
482VMMR3DECL(int) PGMR3PhysMMIO2GetHCPhys(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, PRTHCPHYS pHCPhys);
483VMMR3DECL(int) PGMR3PhysMMIO2MapKernel(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, const char *pszDesc, PRTR0PTR pR0Ptr);
484
485/** @name PGMR3PhysRegisterRom flags.
486 * @{ */
487/** Inidicates that ROM shadowing should be enabled. */
488#define PGMPHYS_ROM_FLAGS_SHADOWED RT_BIT_32(0)
489/** Indicates that what pvBinary points to won't go away
490 * and can be used for strictness checks. */
491#define PGMPHYS_ROM_FLAGS_PERMANENT_BINARY RT_BIT_32(1)
492/** @} */
493
494VMMR3DECL(int) PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
495 const void *pvBinary, uint32_t fFlags, const char *pszDesc);
496VMMR3DECL(int) PGMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMROMPROT enmProt);
497VMMR3DECL(int) PGMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
498VMMDECL(void) PGMR3PhysSetA20(PVMCPU pVCpu, bool fEnable);
499/** @name PGMR3MapPT flags.
500 * @{ */
501/** The mapping may be unmapped later. The default is permanent mappings. */
502#define PGMR3MAPPT_FLAGS_UNMAPPABLE RT_BIT(0)
503/** @} */
504VMMR3DECL(int) PGMR3MapPT(PVM pVM, RTGCPTR GCPtr, uint32_t cb, uint32_t fFlags, PFNPGMRELOCATE pfnRelocate, void *pvUser, const char *pszDesc);
505VMMR3DECL(int) PGMR3UnmapPT(PVM pVM, RTGCPTR GCPtr);
506VMMR3DECL(int) PGMR3FinalizeMappings(PVM pVM);
507VMMR3DECL(int) PGMR3MappingsDisable(PVM pVM);
508VMMR3DECL(int) PGMR3MappingsSize(PVM pVM, uint32_t *pcb);
509VMMR3DECL(int) PGMR3MappingsFix(PVM pVM, RTGCPTR GCPtrBase, uint32_t cb);
510VMMR3DECL(int) PGMR3MappingsUnfix(PVM pVM);
511VMMR3DECL(bool) PGMR3MappingsNeedReFixing(PVM pVM);
512VMMR3DECL(int) PGMR3MapIntermediate(PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
513VMMR3DECL(int) PGMR3MapRead(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
514
515VMMR3DECL(int) PGMR3HandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
516 PFNPGMR3PHYSHANDLER pfnHandlerR3, void *pvUserR3,
517 const char *pszModR0, const char *pszHandlerR0, RTR0PTR pvUserR0,
518 const char *pszModRC, const char *pszHandlerRC, RTRCPTR pvUserRC, const char *pszDesc);
519VMMDECL(int) PGMR3HandlerVirtualRegisterEx(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
520 R3PTRTYPE(PFNPGMR3VIRTINVALIDATE) pfnInvalidateR3,
521 R3PTRTYPE(PFNPGMR3VIRTHANDLER) pfnHandlerR3,
522 RCPTRTYPE(PFNPGMRCVIRTHANDLER) pfnHandlerRC,
523 R3PTRTYPE(const char *) pszDesc);
524VMMR3DECL(int) PGMR3HandlerVirtualRegister(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
525 PFNPGMR3VIRTINVALIDATE pfnInvalidateR3,
526 PFNPGMR3VIRTHANDLER pfnHandlerR3,
527 const char *pszHandlerRC, const char *pszModRC, const char *pszDesc);
528VMMDECL(int) PGMHandlerVirtualChangeInvalidateCallback(PVM pVM, RTGCPTR GCPtr, R3PTRTYPE(PFNPGMR3VIRTINVALIDATE) pfnInvalidateR3);
529VMMDECL(int) PGMHandlerVirtualDeregister(PVM pVM, RTGCPTR GCPtr);
530VMMR3DECL(int) PGMR3PoolGrow(PVM pVM);
531#ifdef ___VBox_dbgf_h /** @todo fix this! */
532VMMR3DECL(int) PGMR3DumpHierarchyHC(PVM pVM, uint64_t cr3, uint64_t cr4, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp);
533#endif
534VMMR3DECL(int) PGMR3DumpHierarchyGC(PVM pVM, uint64_t cr3, uint64_t cr4, RTGCPHYS PhysSearch);
535
536VMMR3DECL(int) PGMR3PhysTlbGCPhys2Ptr(PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **ppv);
537VMMR3DECL(uint8_t) PGMR3PhysReadU8(PVM pVM, RTGCPHYS GCPhys);
538VMMR3DECL(uint16_t) PGMR3PhysReadU16(PVM pVM, RTGCPHYS GCPhys);
539VMMR3DECL(uint32_t) PGMR3PhysReadU32(PVM pVM, RTGCPHYS GCPhys);
540VMMR3DECL(uint64_t) PGMR3PhysReadU64(PVM pVM, RTGCPHYS GCPhys);
541VMMR3DECL(void) PGMR3PhysWriteU8(PVM pVM, RTGCPHYS GCPhys, uint8_t Value);
542VMMR3DECL(void) PGMR3PhysWriteU16(PVM pVM, RTGCPHYS GCPhys, uint16_t Value);
543VMMR3DECL(void) PGMR3PhysWriteU32(PVM pVM, RTGCPHYS GCPhys, uint32_t Value);
544VMMR3DECL(void) PGMR3PhysWriteU64(PVM pVM, RTGCPHYS GCPhys, uint64_t Value);
545VMMR3DECL(int) PGMR3PhysReadExternal(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
546VMMR3DECL(int) PGMR3PhysWriteExternal(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, const char *pszWho);
547VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrExternal(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
548VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrReadOnlyExternal(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
549VMMR3DECL(int) PGMR3PhysChunkMap(PVM pVM, uint32_t idChunk);
550VMMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM);
551VMMR3DECL(int) PGMR3PhysAllocateHandyPages(PVM pVM);
552VMMR3DECL(int) PGMR3PhysAllocateLargeHandyPage(PVM pVM, RTGCPHYS GCPhys);
553
554VMMR3DECL(void) PGMR3ReleaseOwnedLocks(PVM pVM);
555
556VMMR3DECL(int) PGMR3CheckIntegrity(PVM pVM);
557
558VMMR3DECL(int) PGMR3DbgR3Ptr2GCPhys(PVM pVM, RTR3PTR R3Ptr, PRTGCPHYS pGCPhys);
559VMMR3DECL(int) PGMR3DbgR3Ptr2HCPhys(PVM pVM, RTR3PTR R3Ptr, PRTHCPHYS pHCPhys);
560VMMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PVM pVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
561VMMR3DECL(int) PGMR3DbgReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
562VMMR3DECL(int) PGMR3DbgWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
563VMMR3DECL(int) PGMR3DbgReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
564VMMR3DECL(int) PGMR3DbgWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
565VMMR3DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, RTGCPHYS GCPhysAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
566VMMR3DECL(int) PGMR3DbgScanVirtual(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, RTGCPTR cbRange, RTGCPTR GCPtrAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
567
568
569/** @name Page sharing
570 * @{ */
571VMMR3DECL(int) PGMR3SharedModuleRegister(PVM pVM, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule, unsigned cRegions, VMMDEVSHAREDREGIONDESC *pRegions);
572VMMR3DECL(int) PGMR3SharedModuleUnregister(PVM pVM, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule);
573VMMR3DECL(int) PGMR3SharedModuleCheck(PVM pVM);
574/** @} */
575
576/** @} */
577#endif /* IN_RING3 */
578
579RT_C_DECLS_END
580
581/** @} */
582#endif
583
Note: See TracBrowser for help on using the repository browser.

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