VirtualBox

source: vbox/trunk/include/VBox/vmm/pgm.h@ 41788

Last change on this file since 41788 was 40054, checked in by vboxsync, 13 years ago

VMM,VMMDev: Page sharing cleanup.

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

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