VirtualBox

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

Last change on this file since 31491 was 31402, checked in by vboxsync, 14 years ago

PGM: Replaced the hazzardous raw-mode context dynamic mapping code with the PGMR0DynMap code used by darwin/x86. This is a risky change but it should pay off once stable by providing 100% certainty that dynamically mapped pages aren't resued behind our back (this has been observed in seemingly benign code paths recently).

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