VirtualBox

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

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

PGM,DBC,MM: Dump more information about shadow/guest pages.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 30.0 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 * PGMR3PhysEnumDirtyFTPages callback for syncing dirty physical pages
234 *
235 * @param pVM VM Handle.
236 * @param GCPhys GC physical address
237 * @param pRange HC virtual address of the page(s)
238 * @param cbRange Size of the dirty range in bytes.
239 * @param pvUser User argument.
240 */
241typedef DECLCALLBACK(int) FNPGMENUMDIRTYFTPAGES(PVM pVM, RTGCPHYS GCPhys, uint8_t *pRange, unsigned cbRange, void *pvUser);
242/** Pointer to PGMR3PhysEnumDirtyFTPages callback. */
243typedef FNPGMENUMDIRTYFTPAGES *PFNPGMENUMDIRTYFTPAGES;
244
245/**
246 * Paging mode.
247 */
248typedef enum PGMMODE
249{
250 /** The usual invalid value. */
251 PGMMODE_INVALID = 0,
252 /** Real mode. */
253 PGMMODE_REAL,
254 /** Protected mode, no paging. */
255 PGMMODE_PROTECTED,
256 /** 32-bit paging. */
257 PGMMODE_32_BIT,
258 /** PAE paging. */
259 PGMMODE_PAE,
260 /** PAE paging with NX enabled. */
261 PGMMODE_PAE_NX,
262 /** 64-bit AMD paging (long mode). */
263 PGMMODE_AMD64,
264 /** 64-bit AMD paging (long mode) with NX enabled. */
265 PGMMODE_AMD64_NX,
266 /** Nested paging mode (shadow only; guest physical to host physical). */
267 PGMMODE_NESTED,
268 /** Extended paging (Intel) mode. */
269 PGMMODE_EPT,
270 /** The max number of modes */
271 PGMMODE_MAX,
272 /** 32bit hackishness. */
273 PGMMODE_32BIT_HACK = 0x7fffffff
274} PGMMODE;
275
276/** Macro for checking if the guest is using paging.
277 * @param enmMode PGMMODE_*.
278 * @remark ASSUMES certain order of the PGMMODE_* values.
279 */
280#define PGMMODE_WITH_PAGING(enmMode) ((enmMode) >= PGMMODE_32_BIT)
281
282/** Macro for checking if it's one of the long mode modes.
283 * @param enmMode PGMMODE_*.
284 */
285#define PGMMODE_IS_LONG_MODE(enmMode) ((enmMode) == PGMMODE_AMD64_NX || (enmMode) == PGMMODE_AMD64)
286
287/**
288 * Is the ROM mapped (true) or is the shadow RAM mapped (false).
289 *
290 * @returns boolean.
291 * @param enmProt The PGMROMPROT value, must be valid.
292 */
293#define PGMROMPROT_IS_ROM(enmProt) \
294 ( (enmProt) == PGMROMPROT_READ_ROM_WRITE_IGNORE \
295 || (enmProt) == PGMROMPROT_READ_ROM_WRITE_RAM )
296
297
298
299VMMDECL(bool) PGMIsLocked(PVM pVM);
300VMMDECL(bool) PGMIsLockOwner(PVM pVM);
301
302VMMDECL(int) PGMRegisterStringFormatTypes(void);
303VMMDECL(void) PGMDeregisterStringFormatTypes(void);
304VMMDECL(RTHCPHYS) PGMGetHyperCR3(PVMCPU pVCpu);
305VMMDECL(RTHCPHYS) PGMGetNestedCR3(PVMCPU pVCpu, PGMMODE enmShadowMode);
306VMMDECL(RTHCPHYS) PGMGetInterHCCR3(PVM pVM);
307VMMDECL(RTHCPHYS) PGMGetInterRCCR3(PVM pVM, PVMCPU pVCpu);
308VMMDECL(RTHCPHYS) PGMGetInter32BitCR3(PVM pVM);
309VMMDECL(RTHCPHYS) PGMGetInterPaeCR3(PVM pVM);
310VMMDECL(RTHCPHYS) PGMGetInterAmd64CR3(PVM pVM);
311VMMDECL(int) PGMTrap0eHandler(PVMCPU pVCpu, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
312VMMDECL(int) PGMPrefetchPage(PVMCPU pVCpu, RTGCPTR GCPtrPage);
313VMMDECL(int) PGMVerifyAccess(PVMCPU pVCpu, RTGCPTR Addr, uint32_t cbSize, uint32_t fAccess);
314VMMDECL(int) PGMIsValidAccess(PVMCPU pVCpu, RTGCPTR Addr, uint32_t cbSize, uint32_t fAccess);
315VMMDECL(VBOXSTRICTRC) PGMInterpretInstruction(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
316VMMDECL(int) PGMMap(PVM pVM, RTGCPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags);
317VMMDECL(int) PGMMapGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
318VMMDECL(int) PGMMapSetPage(PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags);
319VMMDECL(int) PGMMapModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
320#ifndef IN_RING0
321VMMDECL(bool) PGMMapHasConflicts(PVM pVM);
322#endif
323#ifdef VBOX_STRICT
324VMMDECL(void) PGMMapCheck(PVM pVM);
325#endif
326VMMDECL(int) PGMShwGetPage(PVMCPU pVCpu, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
327VMMDECL(int) PGMShwMakePageReadonly(PVMCPU pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
328VMMDECL(int) PGMShwMakePageWritable(PVMCPU pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
329VMMDECL(int) PGMShwMakePageNotPresent(PVMCPU pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
330/** @name Flags for PGMShwMakePageReadonly, PGMShwMakePageWritable and
331 * PGMShwMakePageNotPresent
332 * @{ */
333/** The call is from an access handler for dealing with the a faulting write
334 * operation. The virtual address is within the same page. */
335#define PGM_MK_PG_IS_WRITE_FAULT RT_BIT(0)
336/** The page is an MMIO2. */
337#define PGM_MK_PG_IS_MMIO2 RT_BIT(1)
338/** @}*/
339VMMDECL(int) PGMGstGetPage(PVMCPU pVCpu, RTGCPTR GCPtr, uint64_t *pfFlags, PRTGCPHYS pGCPhys);
340VMMDECL(bool) PGMGstIsPagePresent(PVMCPU pVCpu, RTGCPTR GCPtr);
341VMMDECL(int) PGMGstSetPage(PVMCPU pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
342VMMDECL(int) PGMGstModifyPage(PVMCPU pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
343VMMDECL(X86PDPE) PGMGstGetPaePDPtr(PVMCPU pVCpu, unsigned iPdPt);
344
345VMMDECL(int) PGMInvalidatePage(PVMCPU pVCpu, RTGCPTR GCPtrPage);
346VMMDECL(int) PGMFlushTLB(PVMCPU pVCpu, uint64_t cr3, bool fGlobal);
347VMMDECL(int) PGMSyncCR3(PVMCPU pVCpu, uint64_t cr0, uint64_t cr3, uint64_t cr4, bool fGlobal);
348VMMDECL(int) PGMUpdateCR3(PVMCPU pVCpu, uint64_t cr3);
349VMMDECL(int) PGMChangeMode(PVMCPU pVCpu, uint64_t cr0, uint64_t cr4, uint64_t efer);
350VMMDECL(PGMMODE) PGMGetGuestMode(PVMCPU pVCpu);
351VMMDECL(PGMMODE) PGMGetShadowMode(PVMCPU pVCpu);
352VMMDECL(PGMMODE) PGMGetHostMode(PVM pVM);
353VMMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
354VMM_INT_DECL(void) PGMNotifyNxeChanged(PVMCPU pVCpu, bool fNxe);
355VMMDECL(bool) PGMHasDirtyPages(PVM pVM);
356VMMDECL(int) PGMHandlerPhysicalRegisterEx(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
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) PGMHandlerPhysicalModify(PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
362VMMDECL(int) PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys);
363VMMDECL(int) PGMHandlerPhysicalChangeCallbacks(PVM pVM, RTGCPHYS GCPhys,
364 R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
365 R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
366 RCPTRTYPE(PFNPGMRCPHYSHANDLER) pfnHandlerRC, RTRCPTR pvUserRC,
367 R3PTRTYPE(const char *) pszDesc);
368VMMDECL(int) PGMHandlerPhysicalSplit(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
369VMMDECL(int) PGMHandlerPhysicalJoin(PVM pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
370VMMDECL(int) PGMHandlerPhysicalPageTempOff(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
371VMMDECL(int) PGMHandlerPhysicalPageAlias(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTGCPHYS GCPhysPageRemap);
372VMMDECL(int) PGMHandlerPhysicalPageAliasHC(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTHCPHYS HCPhysPageRemap);
373VMMDECL(int) PGMHandlerPhysicalReset(PVM pVM, RTGCPHYS GCPhys);
374VMMDECL(bool) PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys);
375VMMDECL(bool) PGMHandlerVirtualIsRegistered(PVM pVM, RTGCPTR GCPtr);
376VMMDECL(bool) PGMPhysIsA20Enabled(PVMCPU pVCpu);
377VMMDECL(bool) PGMPhysIsGCPhysValid(PVM pVM, RTGCPHYS GCPhys);
378VMMDECL(bool) PGMPhysIsGCPhysNormal(PVM pVM, RTGCPHYS GCPhys);
379VMMDECL(int) PGMPhysGCPtr2GCPhys(PVMCPU pVCpu, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
380VMMDECL(void) PGMPhysInvalidatePageMapTLB(PVM pVM);
381VMMDECL(void) PGMPhysInvalidatePageMapTLBEntry(PVM pVM, RTGCPHYS GCPhys);
382VMMDECL(void) PGMPhysReleasePageMappingLock(PVM pVM, PPGMPAGEMAPLOCK pLock);
383VMMDECL(int) PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
384VMMDECL(int) PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
385VMMDECL(int) PGMPhysSimpleReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
386VMMDECL(int) PGMPhysSimpleWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
387VMMDECL(int) PGMPhysSimpleReadGCPtr(PVMCPU pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
388VMMDECL(int) PGMPhysSimpleWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
389VMMDECL(int) PGMPhysReadGCPtr(PVMCPU pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
390VMMDECL(int) PGMPhysWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
391VMMDECL(int) PGMPhysSimpleDirtyWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
392VMMDECL(int) PGMPhysInterpretedRead(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
393VMMDECL(int) PGMPhysInterpretedReadNoHandlers(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb, bool fRaiseTrap);
394VMMDECL(int) PGMPhysInterpretedWriteNoHandlers(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, bool fRaiseTrap);
395#ifdef VBOX_STRICT
396VMMDECL(unsigned) PGMAssertHandlerAndFlagsInSync(PVM pVM);
397VMMDECL(unsigned) PGMAssertNoMappingConflicts(PVM pVM);
398VMMDECL(unsigned) PGMAssertCR3(PVM pVM, PVMCPU pVCpu, uint64_t cr3, uint64_t cr4);
399#endif /* VBOX_STRICT */
400
401#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE)
402VMMDECL(void) PGMRZDynMapStartAutoSet(PVMCPU pVCpu);
403VMMDECL(void) PGMRZDynMapReleaseAutoSet(PVMCPU pVCpu);
404VMMDECL(void) PGMRZDynMapFlushAutoSet(PVMCPU pVCpu);
405VMMDECL(uint32_t) PGMRZDynMapPushAutoSubset(PVMCPU pVCpu);
406VMMDECL(void) PGMRZDynMapPopAutoSubset(PVMCPU pVCpu, uint32_t iPrevSubset);
407#endif
408
409VMMDECL(void) PGMSetLargePageUsage(PVM pVM, bool fUseLargePages);
410
411/**
412 * Query large page usage state
413 *
414 * @returns 0 - disabled, 1 - enabled
415 * @param pVM The VM to operate on.
416 */
417#define PGMIsUsingLargePages(pVM) ((pVM)->fUseLargePages)
418
419
420#ifdef IN_RC
421/** @defgroup grp_pgm_gc The PGM Guest Context API
422 * @ingroup grp_pgm
423 * @{
424 */
425VMMRCDECL(int) PGMRCDynMapInit(PVM pVM);
426/** @} */
427#endif /* IN_RC */
428
429
430#ifdef IN_RING0
431/** @defgroup grp_pgm_r0 The PGM Host Context Ring-0 API
432 * @ingroup grp_pgm
433 * @{
434 */
435VMMR0DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM, PVMCPU pVCpu);
436VMMR0DECL(int) PGMR0PhysAllocateLargeHandyPage(PVM pVM, PVMCPU pVCpu);
437VMMR0DECL(int) PGMR0SharedModuleCheck(PVM pVM, PGVM pGVM, VMCPUID idCpu, PGMMSHAREDMODULE pModule, uint32_t cRegions, PGMMSHAREDREGIONDESC pRegions);
438VMMR0DECL(int) PGMR0Trap0eHandlerNestedPaging(PVM pVM, PVMCPU pVCpu, PGMMODE enmShwPagingMode, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault);
439VMMR0DECL(VBOXSTRICTRC) PGMR0Trap0eHandlerNPMisconfig(PVM pVM, PVMCPU pVCpu, PGMMODE enmShwPagingMode, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, uint32_t uErr);
440# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
441VMMR0DECL(int) PGMR0DynMapInit(void);
442VMMR0DECL(void) PGMR0DynMapTerm(void);
443VMMR0DECL(int) PGMR0DynMapInitVM(PVM pVM);
444VMMR0DECL(void) PGMR0DynMapTermVM(PVM pVM);
445VMMR0DECL(int) PGMR0DynMapAssertIntegrity(void);
446VMMR0DECL(bool) PGMR0DynMapStartOrMigrateAutoSet(PVMCPU pVCpu);
447VMMR0DECL(void) PGMR0DynMapMigrateAutoSet(PVMCPU pVCpu);
448# endif
449/** @} */
450#endif /* IN_RING0 */
451
452
453
454#ifdef IN_RING3
455/** @defgroup grp_pgm_r3 The PGM Host Context Ring-3 API
456 * @ingroup grp_pgm
457 * @{
458 */
459VMMR3DECL(int) PGMR3Init(PVM pVM);
460VMMR3DECL(int) PGMR3InitCPU(PVM pVM);
461VMMR3DECL(int) PGMR3InitDynMap(PVM pVM);
462VMMR3DECL(int) PGMR3InitFinalize(PVM pVM);
463VMMR3DECL(void) PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
464VMMR3DECL(void) PGMR3ResetUnpluggedCpu(PVM pVM, PVMCPU pVCpu);
465VMMR3DECL(void) PGMR3Reset(PVM pVM);
466VMMR3DECL(int) PGMR3Term(PVM pVM);
467VMMR3DECL(int) PGMR3TermCPU(PVM pVM);
468VMMR3DECL(int) PGMR3LockCall(PVM pVM);
469VMMR3DECL(int) PGMR3ChangeMode(PVM pVM, PVMCPU pVCpu, PGMMODE enmGuestMode);
470
471VMMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
472VMMR3DECL(int) PGMR3PhysChangeMemBalloon(PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage);
473VMMR3DECL(int) PGMR3PhysWriteProtectRAM(PVM pVM);
474VMMR3DECL(int) PGMR3PhysEnumDirtyFTPages(PVM pVM, PFNPGMENUMDIRTYFTPAGES pfnEnum, void *pvUser);
475VMMR3DECL(int) PGMR3QueryVMMMemoryStats(PVM pVM, uint64_t *puTotalAllocSize, uint64_t *puTotalFreeSize, uint64_t *puTotalBalloonSize, uint64_t *puTotalSharedSize);
476VMMR3DECL(int) PGMR3QueryMemoryStats(PVM pVM, uint64_t *pulTotalMem, uint64_t *pulPrivateMem, uint64_t *puTotalSharedMem, uint64_t *puTotalZeroMem);
477VMMR3DECL(int) PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb,
478 R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
479 R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
480 RCPTRTYPE(PFNPGMRCPHYSHANDLER) pfnHandlerRC, RTRCPTR pvUserRC,
481 R3PTRTYPE(const char *) pszDesc);
482VMMR3DECL(int) PGMR3PhysMMIODeregister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb);
483VMMR3DECL(int) PGMR3PhysMMIO2Register(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc);
484VMMR3DECL(int) PGMR3PhysMMIO2Deregister(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion);
485VMMR3DECL(int) PGMR3PhysMMIO2Map(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
486VMMR3DECL(int) PGMR3PhysMMIO2Unmap(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
487VMMR3DECL(bool) PGMR3PhysMMIO2IsBase(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys);
488VMMR3DECL(int) PGMR3PhysMMIO2GetHCPhys(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, PRTHCPHYS pHCPhys);
489VMMR3DECL(int) PGMR3PhysMMIO2MapKernel(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, const char *pszDesc, PRTR0PTR pR0Ptr);
490
491/** @name PGMR3PhysRegisterRom flags.
492 * @{ */
493/** Inidicates that ROM shadowing should be enabled. */
494#define PGMPHYS_ROM_FLAGS_SHADOWED RT_BIT_32(0)
495/** Indicates that what pvBinary points to won't go away
496 * and can be used for strictness checks. */
497#define PGMPHYS_ROM_FLAGS_PERMANENT_BINARY RT_BIT_32(1)
498/** @} */
499
500VMMR3DECL(int) PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
501 const void *pvBinary, uint32_t fFlags, const char *pszDesc);
502VMMR3DECL(int) PGMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMROMPROT enmProt);
503VMMR3DECL(int) PGMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
504VMMDECL(void) PGMR3PhysSetA20(PVMCPU pVCpu, bool fEnable);
505/** @name PGMR3MapPT flags.
506 * @{ */
507/** The mapping may be unmapped later. The default is permanent mappings. */
508#define PGMR3MAPPT_FLAGS_UNMAPPABLE RT_BIT(0)
509/** @} */
510VMMR3DECL(int) PGMR3MapPT(PVM pVM, RTGCPTR GCPtr, uint32_t cb, uint32_t fFlags, PFNPGMRELOCATE pfnRelocate, void *pvUser, const char *pszDesc);
511VMMR3DECL(int) PGMR3UnmapPT(PVM pVM, RTGCPTR GCPtr);
512VMMR3DECL(int) PGMR3FinalizeMappings(PVM pVM);
513VMMR3DECL(int) PGMR3MappingsDisable(PVM pVM);
514VMMR3DECL(int) PGMR3MappingsSize(PVM pVM, uint32_t *pcb);
515VMMR3DECL(int) PGMR3MappingsFix(PVM pVM, RTGCPTR GCPtrBase, uint32_t cb);
516VMMR3DECL(int) PGMR3MappingsUnfix(PVM pVM);
517VMMR3DECL(bool) PGMR3MappingsNeedReFixing(PVM pVM);
518VMMR3DECL(int) PGMR3MapIntermediate(PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
519VMMR3DECL(int) PGMR3MapRead(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
520
521VMMR3DECL(int) PGMR3HandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
522 PFNPGMR3PHYSHANDLER pfnHandlerR3, void *pvUserR3,
523 const char *pszModR0, const char *pszHandlerR0, RTR0PTR pvUserR0,
524 const char *pszModRC, const char *pszHandlerRC, RTRCPTR pvUserRC, const char *pszDesc);
525VMMDECL(int) PGMR3HandlerVirtualRegisterEx(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
526 R3PTRTYPE(PFNPGMR3VIRTINVALIDATE) pfnInvalidateR3,
527 R3PTRTYPE(PFNPGMR3VIRTHANDLER) pfnHandlerR3,
528 RCPTRTYPE(PFNPGMRCVIRTHANDLER) pfnHandlerRC,
529 R3PTRTYPE(const char *) pszDesc);
530VMMR3DECL(int) PGMR3HandlerVirtualRegister(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
531 PFNPGMR3VIRTINVALIDATE pfnInvalidateR3,
532 PFNPGMR3VIRTHANDLER pfnHandlerR3,
533 const char *pszHandlerRC, const char *pszModRC, const char *pszDesc);
534VMMDECL(int) PGMHandlerVirtualChangeInvalidateCallback(PVM pVM, RTGCPTR GCPtr, R3PTRTYPE(PFNPGMR3VIRTINVALIDATE) pfnInvalidateR3);
535VMMDECL(int) PGMHandlerVirtualDeregister(PVM pVM, RTGCPTR GCPtr);
536VMMR3DECL(int) PGMR3PoolGrow(PVM pVM);
537
538VMMR3DECL(int) PGMR3PhysTlbGCPhys2Ptr(PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **ppv);
539VMMR3DECL(uint8_t) PGMR3PhysReadU8(PVM pVM, RTGCPHYS GCPhys);
540VMMR3DECL(uint16_t) PGMR3PhysReadU16(PVM pVM, RTGCPHYS GCPhys);
541VMMR3DECL(uint32_t) PGMR3PhysReadU32(PVM pVM, RTGCPHYS GCPhys);
542VMMR3DECL(uint64_t) PGMR3PhysReadU64(PVM pVM, RTGCPHYS GCPhys);
543VMMR3DECL(void) PGMR3PhysWriteU8(PVM pVM, RTGCPHYS GCPhys, uint8_t Value);
544VMMR3DECL(void) PGMR3PhysWriteU16(PVM pVM, RTGCPHYS GCPhys, uint16_t Value);
545VMMR3DECL(void) PGMR3PhysWriteU32(PVM pVM, RTGCPHYS GCPhys, uint32_t Value);
546VMMR3DECL(void) PGMR3PhysWriteU64(PVM pVM, RTGCPHYS GCPhys, uint64_t Value);
547VMMR3DECL(int) PGMR3PhysReadExternal(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
548VMMR3DECL(int) PGMR3PhysWriteExternal(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, const char *pszWho);
549VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrExternal(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
550VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrReadOnlyExternal(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
551VMMR3DECL(int) PGMR3PhysChunkMap(PVM pVM, uint32_t idChunk);
552VMMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM);
553VMMR3DECL(int) PGMR3PhysAllocateHandyPages(PVM pVM);
554VMMR3DECL(int) PGMR3PhysAllocateLargeHandyPage(PVM pVM, RTGCPHYS GCPhys);
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);
567VMMR3DECL(int) PGMR3DumpHierarchyHC(PVM pVM, uint64_t cr3, uint64_t cr4, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp);
568VMMR3_INT_DECL(int) PGMR3DumpHierarchyHCEx(PVM pVM, uint64_t cr3, uint32_t fFlags, uint64_t u64FirstAddr, uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
569VMMR3DECL(int) PGMR3DumpHierarchyGC(PVM pVM, uint64_t cr3, uint64_t cr4, RTGCPHYS PhysSearch);
570VMMR3_INT_DECL(int) PGMR3DumpHierarchyGCEx(PVM pVM, uint64_t cr3, uint32_t fFlags, RTGCPTR FirstAddr, RTGCPTR LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
571
572
573/** @name Page sharing
574 * @{ */
575VMMR3DECL(int) PGMR3SharedModuleRegister(PVM pVM, VBOXOSFAMILY enmGuestOS, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule, unsigned cRegions, VMMDEVSHAREDREGIONDESC *pRegions);
576VMMR3DECL(int) PGMR3SharedModuleUnregister(PVM pVM, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule);
577VMMR3DECL(int) PGMR3SharedModuleCheckAll(PVM pVM);
578VMMR3DECL(int) PGMR3SharedModuleGetPageState(PVM pVM, RTGCPTR GCPtrPage, bool *pfShared, uint64_t *puPageFlags);
579/** @} */
580
581/** @} */
582#endif /* IN_RING3 */
583
584RT_C_DECLS_END
585
586/** @} */
587#endif
588
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