VirtualBox

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

Last change on this file since 92368 was 92368, checked in by vboxsync, 3 years ago

VMM/PGM,GMM: Baked PGMR3PhysAllocateLargePage into PGMR0PhysAllocateLargePage eliminating VMMCALLRING3_PGM_ALLOCATE_LARGE_HANDY_PAGE; adjusted GMMR0AllocateLargePage to be ring-0 callable. Changed the large page allocation backoff logic a bit. Some more release stats. bugref:10093

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 39.3 KB
Line 
1/** @file
2 * PGM - Page Monitor / Monitor.
3 */
4
5/*
6 * Copyright (C) 2006-2020 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_INCLUDED_vmm_pgm_h
27#define VBOX_INCLUDED_vmm_pgm_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <VBox/types.h>
33#include <VBox/sup.h>
34#include <VBox/vmm/vmapi.h>
35#include <VBox/vmm/gmm.h> /* for PGMMREGISTERSHAREDMODULEREQ */
36#include <iprt/x86.h>
37#include <VBox/param.h>
38
39RT_C_DECLS_BEGIN
40
41/** @defgroup grp_pgm The Page Monitor / Manager API
42 * @ingroup grp_vmm
43 * @{
44 */
45
46/**
47 * FNPGMRELOCATE callback mode.
48 */
49typedef enum PGMRELOCATECALL
50{
51 /** The callback is for checking if the suggested address is suitable. */
52 PGMRELOCATECALL_SUGGEST = 1,
53 /** The callback is for executing the relocation. */
54 PGMRELOCATECALL_RELOCATE
55} PGMRELOCATECALL;
56
57
58/**
59 * Callback function which will be called when PGM is trying to find
60 * a new location for the mapping.
61 *
62 * The callback is called in two modes, 1) the check mode and 2) the relocate mode.
63 * In 1) the callback should say if it objects to a suggested new location. If it
64 * accepts the new location, it is called again for doing it's relocation.
65 *
66 *
67 * @returns true if the location is ok.
68 * @returns false if another location should be found.
69 * @param pVM The cross context VM structure.
70 * @param GCPtrOld The old virtual address.
71 * @param GCPtrNew The new virtual address.
72 * @param enmMode Used to indicate the callback mode.
73 * @param pvUser User argument.
74 * @remark The return value is no a failure indicator, it's an acceptance
75 * indicator. Relocation can not fail!
76 */
77typedef DECLCALLBACKTYPE(bool, FNPGMRELOCATE,(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser));
78/** Pointer to a relocation callback function. */
79typedef FNPGMRELOCATE *PFNPGMRELOCATE;
80
81
82/**
83 * Memory access origin.
84 */
85typedef enum PGMACCESSORIGIN
86{
87 /** Invalid zero value. */
88 PGMACCESSORIGIN_INVALID = 0,
89 /** IEM is access memory. */
90 PGMACCESSORIGIN_IEM,
91 /** HM is access memory. */
92 PGMACCESSORIGIN_HM,
93 /** Some device is access memory. */
94 PGMACCESSORIGIN_DEVICE,
95 /** Someone debugging is access memory. */
96 PGMACCESSORIGIN_DEBUGGER,
97 /** SELM is access memory. */
98 PGMACCESSORIGIN_SELM,
99 /** FTM is access memory. */
100 PGMACCESSORIGIN_FTM,
101 /** REM is access memory. */
102 PGMACCESSORIGIN_REM,
103 /** IOM is access memory. */
104 PGMACCESSORIGIN_IOM,
105 /** End of valid values. */
106 PGMACCESSORIGIN_END,
107 /** Type size hack. */
108 PGMACCESSORIGIN_32BIT_HACK = 0x7fffffff
109} PGMACCESSORIGIN;
110
111
112/**
113 * Physical page access handler kind.
114 */
115typedef enum PGMPHYSHANDLERKIND
116{
117 /** MMIO range. Pages are not present, all access is done in interpreter or recompiler. */
118 PGMPHYSHANDLERKIND_MMIO = 1,
119 /** Handler all write access to a physical page range. */
120 PGMPHYSHANDLERKIND_WRITE,
121 /** Handler all access to a physical page range. */
122 PGMPHYSHANDLERKIND_ALL
123
124} PGMPHYSHANDLERKIND;
125
126/**
127 * Guest Access type
128 */
129typedef enum PGMACCESSTYPE
130{
131 /** Read access. */
132 PGMACCESSTYPE_READ = 1,
133 /** Write access. */
134 PGMACCESSTYPE_WRITE
135} PGMACCESSTYPE;
136
137
138/** @def PGM_ALL_CB_DECL
139 * Macro for declaring a handler callback for all contexts. The handler
140 * callback is static in ring-3, and exported in RC and R0.
141 * @sa PGM_ALL_CB2_DECL.
142 */
143#if defined(IN_RC) || defined(IN_RING0)
144# ifdef __cplusplus
145# define PGM_ALL_CB_DECL(type) extern "C" DECLCALLBACK(DECLEXPORT(type))
146# else
147# define PGM_ALL_CB_DECL(type) DECLCALLBACK(DECLEXPORT(type))
148# endif
149#else
150# define PGM_ALL_CB_DECL(type) static DECLCALLBACK(type)
151#endif
152
153/** @def PGM_ALL_CB2_DECL
154 * Macro for declaring a handler callback for all contexts. The handler
155 * callback is hidden in ring-3, and exported in RC and R0.
156 * @sa PGM_ALL_CB2_DECL.
157 */
158#if defined(IN_RC) || defined(IN_RING0)
159# ifdef __cplusplus
160# define PGM_ALL_CB2_DECL(type) extern "C" DECLCALLBACK(DECLEXPORT(type))
161# else
162# define PGM_ALL_CB2_DECL(type) DECLCALLBACK(DECLEXPORT(type))
163# endif
164#else
165# define PGM_ALL_CB2_DECL(type) DECL_HIDDEN_CALLBACK(type)
166#endif
167
168/** @def PGM_ALL_CB2_PROTO
169 * Macro for declaring a handler callback for all contexts. The handler
170 * callback is hidden in ring-3, and exported in RC and R0.
171 * @param fnType The callback function type.
172 * @sa PGM_ALL_CB2_DECL.
173 */
174#if defined(IN_RC) || defined(IN_RING0)
175# ifdef __cplusplus
176# define PGM_ALL_CB2_PROTO(fnType) extern "C" DECLEXPORT(fnType)
177# else
178# define PGM_ALL_CB2_PROTO(fnType) DECLEXPORT(fnType)
179# endif
180#else
181# define PGM_ALL_CB2_PROTO(fnType) DECLHIDDEN(fnType)
182#endif
183
184
185/**
186 * \#PF Handler callback for physical access handler ranges in RC and R0.
187 *
188 * @returns Strict VBox status code (appropriate for ring-0 and raw-mode).
189 * @param pVM The cross context VM structure.
190 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
191 * @param uErrorCode CPU Error code.
192 * @param pRegFrame Trap register frame.
193 * NULL on DMA and other non CPU access.
194 * @param pvFault The fault address (cr2).
195 * @param GCPhysFault The GC physical address corresponding to pvFault.
196 * @param pvUser User argument.
197 * @thread EMT(pVCpu)
198 */
199typedef DECLCALLBACKTYPE(VBOXSTRICTRC, FNPGMRZPHYSPFHANDLER,(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
200 RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser));
201/** Pointer to PGM access callback. */
202typedef FNPGMRZPHYSPFHANDLER *PFNPGMRZPHYSPFHANDLER;
203
204
205/**
206 * Access handler callback for physical access handler ranges.
207 *
208 * The handler can not raise any faults, it's mainly for monitoring write access
209 * to certain pages (like MMIO).
210 *
211 * @returns Strict VBox status code in ring-0 and raw-mode context, in ring-3
212 * the only supported informational status code is
213 * VINF_PGM_HANDLER_DO_DEFAULT.
214 * @retval VINF_SUCCESS if the handler have carried out the operation.
215 * @retval VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the
216 * access operation.
217 * @retval VINF_EM_XXX in ring-0 and raw-mode context.
218 *
219 * @param pVM The cross context VM structure.
220 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
221 * @param GCPhys The physical address the guest is writing to.
222 * @param pvPhys The HC mapping of that address.
223 * @param pvBuf What the guest is reading/writing.
224 * @param cbBuf How much it's reading/writing.
225 * @param enmAccessType The access type.
226 * @param enmOrigin The origin of this call.
227 * @param pvUser User argument.
228 * @thread EMT(pVCpu)
229 */
230typedef DECLCALLBACKTYPE(VBOXSTRICTRC, FNPGMPHYSHANDLER,(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys,
231 void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType,
232 PGMACCESSORIGIN enmOrigin, void *pvUser));
233/** Pointer to PGM access callback. */
234typedef FNPGMPHYSHANDLER *PFNPGMPHYSHANDLER;
235
236
237/**
238 * Paging mode.
239 *
240 * @note Part of saved state. Change with extreme care.
241 */
242typedef enum PGMMODE
243{
244 /** The usual invalid value. */
245 PGMMODE_INVALID = 0,
246 /** Real mode. */
247 PGMMODE_REAL,
248 /** Protected mode, no paging. */
249 PGMMODE_PROTECTED,
250 /** 32-bit paging. */
251 PGMMODE_32_BIT,
252 /** PAE paging. */
253 PGMMODE_PAE,
254 /** PAE paging with NX enabled. */
255 PGMMODE_PAE_NX,
256 /** 64-bit AMD paging (long mode). */
257 PGMMODE_AMD64,
258 /** 64-bit AMD paging (long mode) with NX enabled. */
259 PGMMODE_AMD64_NX,
260 /** 32-bit nested paging mode (shadow only; guest physical to host physical). */
261 PGMMODE_NESTED_32BIT,
262 /** PAE nested paging mode (shadow only; guest physical to host physical). */
263 PGMMODE_NESTED_PAE,
264 /** AMD64 nested paging mode (shadow only; guest physical to host physical). */
265 PGMMODE_NESTED_AMD64,
266 /** Extended paging (Intel) mode. */
267 PGMMODE_EPT,
268 /** Special mode used by NEM to indicate no shadow paging necessary. */
269 PGMMODE_NONE,
270 /** The max number of modes */
271 PGMMODE_MAX,
272 /** 32bit hackishness. */
273 PGMMODE_32BIT_HACK = 0x7fffffff
274} PGMMODE;
275
276/**
277 * Second level address translation mode.
278 */
279typedef enum PGMSLAT
280{
281 /** The usual invalid value. */
282 PGMSLAT_INVALID = 0,
283 /** No second level translation. */
284 PGMSLAT_DIRECT,
285 /** Intel Extended Page Tables (EPT). */
286 PGMSLAT_EPT,
287 /** AMD-V Nested Paging 32-bit. */
288 PGMSLAT_32BIT,
289 /** AMD-V Nested Paging PAE. */
290 PGMSLAT_PAE,
291 /** AMD-V Nested Paging 64-bit. */
292 PGMSLAT_AMD64,
293 /** 32bit hackishness. */
294 PGMSLAT_32BIT_HACK = 0x7fffffff
295} PGMSLAT;
296
297/** Macro for checking if the guest is using paging.
298 * @param enmMode PGMMODE_*.
299 * @remark ASSUMES certain order of the PGMMODE_* values.
300 */
301#define PGMMODE_WITH_PAGING(enmMode) ((enmMode) >= PGMMODE_32_BIT)
302
303/** Macro for checking if it's one of the long mode modes.
304 * @param enmMode PGMMODE_*.
305 */
306#define PGMMODE_IS_LONG_MODE(enmMode) ((enmMode) == PGMMODE_AMD64_NX || (enmMode) == PGMMODE_AMD64)
307
308/** Macro for checking if it's one of the AMD64 nested modes.
309 * @param enmMode PGMMODE_*.
310 */
311#define PGMMODE_IS_NESTED(enmMode) ( (enmMode) == PGMMODE_NESTED_32BIT \
312 || (enmMode) == PGMMODE_NESTED_PAE \
313 || (enmMode) == PGMMODE_NESTED_AMD64)
314
315/** Macro for checking if it's one of the PAE modes.
316 * @param enmMode PGMMODE_*.
317 */
318#define PGMMODE_IS_PAE(enmMode) ( (enmMode) == PGMMODE_PAE \
319 || (enmMode) == PGMMODE_PAE_NX)
320
321/**
322 * Is the ROM mapped (true) or is the shadow RAM mapped (false).
323 *
324 * @returns boolean.
325 * @param enmProt The PGMROMPROT value, must be valid.
326 */
327#define PGMROMPROT_IS_ROM(enmProt) \
328 ( (enmProt) == PGMROMPROT_READ_ROM_WRITE_IGNORE \
329 || (enmProt) == PGMROMPROT_READ_ROM_WRITE_RAM )
330
331
332VMMDECL(bool) PGMIsLockOwner(PVMCC pVM);
333
334VMMDECL(int) PGMRegisterStringFormatTypes(void);
335VMMDECL(void) PGMDeregisterStringFormatTypes(void);
336VMMDECL(RTHCPHYS) PGMGetHyperCR3(PVMCPU pVCpu);
337VMMDECL(int) PGMTrap0eHandler(PVMCPUCC pVCpu, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
338VMMDECL(int) PGMPrefetchPage(PVMCPUCC pVCpu, RTGCPTR GCPtrPage);
339VMMDECL(VBOXSTRICTRC) PGMInterpretInstruction(PVMCC pVM, PVMCPUCC pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
340VMMDECL(int) PGMShwGetPage(PVMCPUCC pVCpu, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
341VMMDECL(int) PGMShwMakePageReadonly(PVMCPUCC pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
342VMMDECL(int) PGMShwMakePageWritable(PVMCPUCC pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
343VMMDECL(int) PGMShwMakePageNotPresent(PVMCPUCC pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
344/** @name Flags for PGMShwMakePageReadonly, PGMShwMakePageWritable and
345 * PGMShwMakePageNotPresent
346 * @{ */
347/** The call is from an access handler for dealing with the a faulting write
348 * operation. The virtual address is within the same page. */
349#define PGM_MK_PG_IS_WRITE_FAULT RT_BIT(0)
350/** The page is an MMIO2. */
351#define PGM_MK_PG_IS_MMIO2 RT_BIT(1)
352/** @}*/
353VMMDECL(int) PGMGstGetPage(PVMCPUCC pVCpu, RTGCPTR GCPtr, uint64_t *pfFlags, PRTGCPHYS pGCPhys);
354VMMDECL(bool) PGMGstIsPagePresent(PVMCPUCC pVCpu, RTGCPTR GCPtr);
355VMMDECL(int) PGMGstSetPage(PVMCPUCC pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
356VMMDECL(int) PGMGstModifyPage(PVMCPUCC pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
357VMM_INT_DECL(bool) PGMGstArePaePdpesValid(PVMCPUCC pVCpu, PCX86PDPE paPaePdpes);
358VMM_INT_DECL(int) PGMGstMapPaePdpes(PVMCPUCC pVCpu, PCX86PDPE paPaePdpes);
359VMM_INT_DECL(int) PGMGstMapPaePdpesAtCr3(PVMCPUCC pVCpu, uint64_t cr3);
360
361VMMDECL(int) PGMInvalidatePage(PVMCPUCC pVCpu, RTGCPTR GCPtrPage);
362VMMDECL(int) PGMFlushTLB(PVMCPUCC pVCpu, uint64_t cr3, bool fGlobal, bool fPdpesMapped);
363VMMDECL(int) PGMSyncCR3(PVMCPUCC pVCpu, uint64_t cr0, uint64_t cr3, uint64_t cr4, bool fGlobal);
364VMMDECL(int) PGMUpdateCR3(PVMCPUCC pVCpu, uint64_t cr3, bool fPdpesMapped);
365VMMDECL(int) PGMChangeMode(PVMCPUCC pVCpu, uint64_t cr0, uint64_t cr4, uint64_t efer);
366VMM_INT_DECL(int) PGMHCChangeMode(PVMCC pVM, PVMCPUCC pVCpu, PGMMODE enmGuestMode);
367VMMDECL(void) PGMCr0WpEnabled(PVMCPUCC pVCpu);
368VMMDECL(PGMMODE) PGMGetGuestMode(PVMCPU pVCpu);
369VMMDECL(PGMMODE) PGMGetShadowMode(PVMCPU pVCpu);
370VMMDECL(PGMMODE) PGMGetHostMode(PVM pVM);
371VMMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
372#ifdef VBOX_WITH_NESTED_HWVIRT_VMX_EPT
373VMM_INT_DECL(const char *) PGMGetSlatModeName(PGMSLAT enmSlatMode);
374#endif
375VMM_INT_DECL(RTGCPHYS) PGMGetGuestCR3Phys(PVMCPU pVCpu);
376VMM_INT_DECL(void) PGMNotifyNxeChanged(PVMCPU pVCpu, bool fNxe);
377VMMDECL(bool) PGMHasDirtyPages(PVM pVM);
378VMM_INT_DECL(void) PGMSetGuestEptPtr(PVMCPUCC pVCpu, uint64_t uEptPtr);
379
380/** PGM physical access handler type registration handle (heap offset, valid
381 * cross contexts without needing fixing up). Callbacks and handler type is
382 * associated with this and it is shared by all handler registrations. */
383typedef uint32_t PGMPHYSHANDLERTYPE;
384/** Pointer to a PGM physical handler type registration handle. */
385typedef PGMPHYSHANDLERTYPE *PPGMPHYSHANDLERTYPE;
386/** NIL value for PGM physical access handler type handle. */
387#define NIL_PGMPHYSHANDLERTYPE UINT32_MAX
388VMMDECL(uint32_t) PGMHandlerPhysicalTypeRelease(PVMCC pVM, PGMPHYSHANDLERTYPE hType);
389VMMDECL(uint32_t) PGMHandlerPhysicalTypeRetain(PVM pVM, PGMPHYSHANDLERTYPE hType);
390
391VMMDECL(int) PGMHandlerPhysicalRegister(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast, PGMPHYSHANDLERTYPE hType,
392 RTR3PTR pvUserR3, RTR0PTR pvUserR0, RTRCPTR pvUserRC,
393 R3PTRTYPE(const char *) pszDesc);
394VMMDECL(int) PGMHandlerPhysicalModify(PVMCC pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
395VMMDECL(int) PGMHandlerPhysicalDeregister(PVMCC pVM, RTGCPHYS GCPhys);
396VMMDECL(int) PGMHandlerPhysicalChangeUserArgs(PVMCC pVM, RTGCPHYS GCPhys, RTR3PTR pvUserR3, RTR0PTR pvUserR0);
397VMMDECL(int) PGMHandlerPhysicalSplit(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
398VMMDECL(int) PGMHandlerPhysicalJoin(PVMCC pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
399VMMDECL(int) PGMHandlerPhysicalPageTempOff(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
400VMMDECL(int) PGMHandlerPhysicalPageAliasMmio2(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage,
401 PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS offMMio2PageRemap);
402VMMDECL(int) PGMHandlerPhysicalPageAliasHC(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTHCPHYS HCPhysPageRemap);
403VMMDECL(int) PGMHandlerPhysicalReset(PVMCC pVM, RTGCPHYS GCPhys);
404VMMDECL(bool) PGMHandlerPhysicalIsRegistered(PVMCC pVM, RTGCPHYS GCPhys);
405
406
407/**
408 * Page type.
409 *
410 * @remarks This enum has to fit in a 3-bit field (see PGMPAGE::u3Type).
411 * @remarks This is used in the saved state, so changes to it requires bumping
412 * the saved state version.
413 * @todo So, convert to \#defines!
414 */
415typedef enum PGMPAGETYPE
416{
417 /** The usual invalid zero entry. */
418 PGMPAGETYPE_INVALID = 0,
419 /** RAM page. (RWX) */
420 PGMPAGETYPE_RAM,
421 /** MMIO2 page. (RWX) */
422 PGMPAGETYPE_MMIO2,
423 /** MMIO2 page aliased over an MMIO page. (RWX)
424 * See PGMHandlerPhysicalPageAlias(). */
425 PGMPAGETYPE_MMIO2_ALIAS_MMIO,
426 /** Special page aliased over an MMIO page. (RWX)
427 * See PGMHandlerPhysicalPageAliasHC(), but this is generally only used for
428 * VT-x's APIC access page at the moment. Treated as MMIO by everyone except
429 * the shadow paging code. */
430 PGMPAGETYPE_SPECIAL_ALIAS_MMIO,
431 /** Shadowed ROM. (RWX) */
432 PGMPAGETYPE_ROM_SHADOW,
433 /** ROM page. (R-X) */
434 PGMPAGETYPE_ROM,
435 /** MMIO page. (---) */
436 PGMPAGETYPE_MMIO,
437 /** End of valid entries. */
438 PGMPAGETYPE_END
439} PGMPAGETYPE;
440AssertCompile(PGMPAGETYPE_END == 8);
441
442/** @name PGM page type predicates.
443 * @{ */
444#define PGMPAGETYPE_IS_READABLE(a_enmType) ( (a_enmType) <= PGMPAGETYPE_ROM )
445#define PGMPAGETYPE_IS_WRITEABLE(a_enmType) ( (a_enmType) <= PGMPAGETYPE_ROM_SHADOW )
446#define PGMPAGETYPE_IS_RWX(a_enmType) ( (a_enmType) <= PGMPAGETYPE_ROM_SHADOW )
447#define PGMPAGETYPE_IS_ROX(a_enmType) ( (a_enmType) == PGMPAGETYPE_ROM )
448#define PGMPAGETYPE_IS_NP(a_enmType) ( (a_enmType) == PGMPAGETYPE_MMIO )
449/** @} */
450
451
452VMM_INT_DECL(PGMPAGETYPE) PGMPhysGetPageType(PVMCC pVM, RTGCPHYS GCPhys);
453
454VMM_INT_DECL(int) PGMPhysGCPhys2HCPhys(PVMCC pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
455VMM_INT_DECL(int) PGMPhysGCPtr2HCPhys(PVMCPUCC pVCpu, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
456VMM_INT_DECL(int) PGMPhysGCPhys2CCPtr(PVMCC pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
457VMM_INT_DECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVMCC pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
458VMM_INT_DECL(int) PGMPhysGCPtr2CCPtr(PVMCPU pVCpu, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
459VMM_INT_DECL(int) PGMPhysGCPtr2CCPtrReadOnly(PVMCPUCC pVCpu, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
460
461VMMDECL(bool) PGMPhysIsA20Enabled(PVMCPU pVCpu);
462VMMDECL(bool) PGMPhysIsGCPhysValid(PVMCC pVM, RTGCPHYS GCPhys);
463VMMDECL(bool) PGMPhysIsGCPhysNormal(PVMCC pVM, RTGCPHYS GCPhys);
464VMMDECL(int) PGMPhysGCPtr2GCPhys(PVMCPUCC pVCpu, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
465VMMDECL(void) PGMPhysReleasePageMappingLock(PVMCC pVM, PPGMPAGEMAPLOCK pLock);
466VMMDECL(void) PGMPhysBulkReleasePageMappingLocks(PVMCC pVM, uint32_t cPages, PPGMPAGEMAPLOCK paLock);
467
468/** @def PGM_PHYS_RW_IS_SUCCESS
469 * Check whether a PGMPhysRead, PGMPhysWrite, PGMPhysReadGCPtr or
470 * PGMPhysWriteGCPtr call completed the given task.
471 *
472 * @returns true if completed, false if not.
473 * @param a_rcStrict The status code.
474 * @sa IOM_SUCCESS
475 */
476#ifdef IN_RING3
477# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
478 ( (a_rcStrict) == VINF_SUCCESS \
479 || (a_rcStrict) == VINF_EM_DBG_STOP \
480 || (a_rcStrict) == VINF_EM_DBG_EVENT \
481 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
482 )
483#elif defined(IN_RING0)
484# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
485 ( (a_rcStrict) == VINF_SUCCESS \
486 || (a_rcStrict) == VINF_IOM_R3_MMIO_COMMIT_WRITE \
487 || (a_rcStrict) == VINF_EM_OFF \
488 || (a_rcStrict) == VINF_EM_SUSPEND \
489 || (a_rcStrict) == VINF_EM_RESET \
490 || (a_rcStrict) == VINF_EM_HALT \
491 || (a_rcStrict) == VINF_EM_DBG_STOP \
492 || (a_rcStrict) == VINF_EM_DBG_EVENT \
493 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
494 )
495#elif defined(IN_RC)
496# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
497 ( (a_rcStrict) == VINF_SUCCESS \
498 || (a_rcStrict) == VINF_IOM_R3_MMIO_COMMIT_WRITE \
499 || (a_rcStrict) == VINF_EM_OFF \
500 || (a_rcStrict) == VINF_EM_SUSPEND \
501 || (a_rcStrict) == VINF_EM_RESET \
502 || (a_rcStrict) == VINF_EM_HALT \
503 || (a_rcStrict) == VINF_SELM_SYNC_GDT \
504 || (a_rcStrict) == VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT \
505 || (a_rcStrict) == VINF_EM_DBG_STOP \
506 || (a_rcStrict) == VINF_EM_DBG_EVENT \
507 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
508 )
509#endif
510/** @def PGM_PHYS_RW_DO_UPDATE_STRICT_RC
511 * Updates the return code with a new result.
512 *
513 * Both status codes must be successes according to PGM_PHYS_RW_IS_SUCCESS.
514 *
515 * @param a_rcStrict The current return code, to be updated.
516 * @param a_rcStrict2 The new return code to merge in.
517 */
518#ifdef IN_RING3
519# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
520 do { \
521 Assert(rcStrict == VINF_SUCCESS); \
522 Assert(rcStrict2 == VINF_SUCCESS); \
523 } while (0)
524#elif defined(IN_RING0)
525# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
526 do { \
527 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict)); \
528 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict2)); \
529 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_LAST); \
530 if ((a_rcStrict2) == VINF_SUCCESS || (a_rcStrict) == (a_rcStrict2)) \
531 { /* likely */ } \
532 else if ( (a_rcStrict) == VINF_SUCCESS \
533 || (a_rcStrict) > (a_rcStrict2)) \
534 (a_rcStrict) = (a_rcStrict2); \
535 } while (0)
536#elif defined(IN_RC)
537# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
538 do { \
539 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict)); \
540 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict2)); \
541 AssertCompile(VINF_SELM_SYNC_GDT > VINF_EM_LAST); \
542 AssertCompile(VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT > VINF_EM_LAST); \
543 AssertCompile(VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT < VINF_SELM_SYNC_GDT); \
544 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_LAST); \
545 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_SELM_SYNC_GDT); \
546 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT); \
547 if ((a_rcStrict2) == VINF_SUCCESS || (a_rcStrict) == (a_rcStrict2)) \
548 { /* likely */ } \
549 else if ((a_rcStrict) == VINF_SUCCESS) \
550 (a_rcStrict) = (a_rcStrict2); \
551 else if ( ( (a_rcStrict) > (a_rcStrict2) \
552 && ( (a_rcStrict2) <= VINF_EM_RESET \
553 || (a_rcStrict) != VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT) ) \
554 || ( (a_rcStrict2) == VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT \
555 && (a_rcStrict) > VINF_EM_RESET) ) \
556 (a_rcStrict) = (a_rcStrict2); \
557 } while (0)
558#endif
559
560VMMDECL(VBOXSTRICTRC) PGMPhysRead(PVMCC pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
561VMMDECL(VBOXSTRICTRC) PGMPhysWrite(PVMCC pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
562VMMDECL(VBOXSTRICTRC) PGMPhysReadGCPtr(PVMCPUCC pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, PGMACCESSORIGIN enmOrigin);
563VMMDECL(VBOXSTRICTRC) PGMPhysWriteGCPtr(PVMCPUCC pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb, PGMACCESSORIGIN enmOrigin);
564
565VMMDECL(int) PGMPhysSimpleReadGCPhys(PVMCC pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
566VMMDECL(int) PGMPhysSimpleWriteGCPhys(PVMCC pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
567VMMDECL(int) PGMPhysSimpleReadGCPtr(PVMCPUCC pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
568VMMDECL(int) PGMPhysSimpleWriteGCPtr(PVMCPUCC pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
569VMMDECL(int) PGMPhysSimpleDirtyWriteGCPtr(PVMCPUCC pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
570
571VMM_INT_DECL(int) PGMPhysIemGCPhys2Ptr(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers, void **ppv, PPGMPAGEMAPLOCK pLock);
572VMM_INT_DECL(int) PGMPhysIemQueryAccess(PVMCC pVM, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers);
573VMM_INT_DECL(int) PGMPhysIemGCPhys2PtrNoLock(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, uint64_t const volatile *puTlbPhysRev,
574#if defined(IN_RC)
575 R3PTRTYPE(uint8_t *) *ppb,
576#else
577 R3R0PTRTYPE(uint8_t *) *ppb,
578#endif
579 uint64_t *pfTlb);
580/** @name Flags returned by PGMPhysIemGCPhys2PtrNoLock
581 * @{ */
582#define PGMIEMGCPHYS2PTR_F_NO_WRITE RT_BIT_32(3) /**< Not writable (IEMTLBE_F_PG_NO_WRITE). */
583#define PGMIEMGCPHYS2PTR_F_NO_READ RT_BIT_32(4) /**< Not readable (IEMTLBE_F_PG_NO_READ). */
584#define PGMIEMGCPHYS2PTR_F_NO_MAPPINGR3 RT_BIT_32(7) /**< No ring-3 mapping (IEMTLBE_F_NO_MAPPINGR3). */
585/** @} */
586
587/** Information returned by PGMPhysNemQueryPageInfo. */
588typedef struct PGMPHYSNEMPAGEINFO
589{
590 /** The host physical address of the page, NIL_HCPHYS if invalid page. */
591 RTHCPHYS HCPhys;
592 /** The NEM access mode for the page, NEM_PAGE_PROT_XXX */
593 uint32_t fNemProt : 8;
594 /** The NEM state associated with the PAGE. */
595 uint32_t u2NemState : 2;
596 /** The NEM state associated with the PAGE before pgmPhysPageMakeWritable was called. */
597 uint32_t u2OldNemState : 2;
598 /** Set if the page has handler. */
599 uint32_t fHasHandlers : 1;
600 /** Set if is the zero page backing it. */
601 uint32_t fZeroPage : 1;
602 /** Set if the page has handler. */
603 PGMPAGETYPE enmType;
604} PGMPHYSNEMPAGEINFO;
605/** Pointer to page information for NEM. */
606typedef PGMPHYSNEMPAGEINFO *PPGMPHYSNEMPAGEINFO;
607/**
608 * Callback for checking that the page is in sync while under the PGM lock.
609 *
610 * NEM passes this callback to PGMPhysNemQueryPageInfo to check that the page is
611 * in-sync between PGM and the native hypervisor API in an atomic fashion.
612 *
613 * @returns VBox status code.
614 * @param pVM The cross context VM structure.
615 * @param pVCpu The cross context per virtual CPU structure. Optional,
616 * see PGMPhysNemQueryPageInfo.
617 * @param GCPhys The guest physical address (not A20 masked).
618 * @param pInfo The page info structure. This function updates the
619 * u2NemState memory and the caller will update the PGMPAGE
620 * copy accordingly.
621 * @param pvUser Callback user argument.
622 */
623typedef DECLCALLBACKTYPE(int, FNPGMPHYSNEMCHECKPAGE,(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, PPGMPHYSNEMPAGEINFO pInfo, void *pvUser));
624/** Pointer to a FNPGMPHYSNEMCHECKPAGE function. */
625typedef FNPGMPHYSNEMCHECKPAGE *PFNPGMPHYSNEMCHECKPAGE;
626
627VMM_INT_DECL(int) PGMPhysNemPageInfoChecker(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, bool fMakeWritable,
628 PPGMPHYSNEMPAGEINFO pInfo, PFNPGMPHYSNEMCHECKPAGE pfnChecker, void *pvUser);
629
630/**
631 * Callback for use with PGMPhysNemEnumPagesByState.
632 * @returns VBox status code.
633 * Failure status will stop enumeration immediately and return.
634 * @param pVM The cross context VM structure.
635 * @param pVCpu The cross context per virtual CPU structure. Optional,
636 * see PGMPhysNemEnumPagesByState.
637 * @param GCPhys The guest physical address (not A20 masked).
638 * @param pu2NemState Pointer to variable with the NEM state. This can be
639 * update.
640 * @param pvUser The user argument.
641 */
642typedef DECLCALLBACKTYPE(int, FNPGMPHYSNEMENUMCALLBACK,(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys,
643 uint8_t *pu2NemState, void *pvUser));
644/** Pointer to a FNPGMPHYSNEMENUMCALLBACK function. */
645typedef FNPGMPHYSNEMENUMCALLBACK *PFNPGMPHYSNEMENUMCALLBACK;
646VMM_INT_DECL(int) PGMPhysNemEnumPagesByState(PVMCC pVM, PVMCPUCC VCpu, uint8_t uMinState,
647 PFNPGMPHYSNEMENUMCALLBACK pfnCallback, void *pvUser);
648
649
650#ifdef VBOX_STRICT
651VMMDECL(unsigned) PGMAssertHandlerAndFlagsInSync(PVMCC pVM);
652VMMDECL(unsigned) PGMAssertNoMappingConflicts(PVM pVM);
653VMMDECL(unsigned) PGMAssertCR3(PVMCC pVM, PVMCPUCC pVCpu, uint64_t cr3, uint64_t cr4);
654#endif /* VBOX_STRICT */
655
656VMMDECL(int) PGMSetLargePageUsage(PVMCC pVM, bool fUseLargePages);
657
658/**
659 * Query large page usage state
660 *
661 * @returns 0 - disabled, 1 - enabled
662 * @param pVM The cross context VM structure.
663 */
664#define PGMIsUsingLargePages(pVM) ((pVM)->pgm.s.fUseLargePages)
665
666
667#ifdef IN_RING0
668/** @defgroup grp_pgm_r0 The PGM Host Context Ring-0 API
669 * @{
670 */
671VMMR0_INT_DECL(int) PGMR0InitPerVMData(PGVM pGVM);
672VMMR0_INT_DECL(int) PGMR0InitVM(PGVM pGVM);
673VMMR0_INT_DECL(void) PGMR0CleanupVM(PGVM pGVM);
674VMMR0_INT_DECL(int) PGMR0PhysAllocateHandyPages(PGVM pGVM, VMCPUID idCpu);
675VMMR0_INT_DECL(int) PGMR0PhysFlushHandyPages(PGVM pGVM, VMCPUID idCpu);
676VMMR0_INT_DECL(int) PGMR0PhysAllocateLargePage(PGVM pGVM, VMCPUID idCpu, RTGCPHYS GCPhys);
677VMMR0_INT_DECL(int) PGMR0PhysMMIO2MapKernel(PGVM pGVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2,
678 size_t offSub, size_t cbSub, void **ppvMapping);
679VMMR0_INT_DECL(int) PGMR0PhysSetupIoMmu(PGVM pGVM);
680VMMR0DECL(int) PGMR0SharedModuleCheck(PVMCC pVM, PGVM pGVM, VMCPUID idCpu, PGMMSHAREDMODULE pModule,
681 PCRTGCPTR64 paRegionsGCPtrs);
682VMMR0DECL(int) PGMR0Trap0eHandlerNestedPaging(PGVM pGVM, PGVMCPU pGVCpu, PGMMODE enmShwPagingMode, RTGCUINT uErr,
683 PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault);
684VMMR0DECL(VBOXSTRICTRC) PGMR0Trap0eHandlerNPMisconfig(PGVM pGVM, PGVMCPU pGVCpu, PGMMODE enmShwPagingMode,
685 PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, uint32_t uErr);
686VMMR0_INT_DECL(int) PGMR0PoolGrow(PGVM pGVM, VMCPUID idCpu);
687/** @} */
688#endif /* IN_RING0 */
689
690
691
692#ifdef IN_RING3
693/** @defgroup grp_pgm_r3 The PGM Host Context Ring-3 API
694 * @{
695 */
696VMMR3_INT_DECL(void) PGMR3EnableNemMode(PVM pVM);
697VMMR3DECL(int) PGMR3Init(PVM pVM);
698VMMR3DECL(int) PGMR3InitFinalize(PVM pVM);
699VMMR3_INT_DECL(int) PGMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
700VMMR3DECL(void) PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
701VMMR3DECL(void) PGMR3ResetCpu(PVM pVM, PVMCPU pVCpu);
702VMMR3_INT_DECL(void) PGMR3Reset(PVM pVM);
703VMMR3_INT_DECL(void) PGMR3ResetNoMorePhysWritesFlag(PVM pVM);
704VMMR3_INT_DECL(void) PGMR3MemSetup(PVM pVM, bool fReset);
705VMMR3DECL(int) PGMR3Term(PVM pVM);
706
707VMMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
708VMMR3DECL(int) PGMR3PhysChangeMemBalloon(PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage);
709VMMR3DECL(int) PGMR3PhysWriteProtectRAM(PVM pVM);
710VMMR3DECL(uint32_t) PGMR3PhysGetRamRangeCount(PVM pVM);
711VMMR3DECL(int) PGMR3PhysGetRange(PVM pVM, uint32_t iRange, PRTGCPHYS pGCPhysStart, PRTGCPHYS pGCPhysLast,
712 const char **ppszDesc, bool *pfIsMmio);
713VMMR3DECL(int) PGMR3QueryMemoryStats(PUVM pUVM, uint64_t *pcbTotalMem, uint64_t *pcbPrivateMem, uint64_t *pcbSharedMem, uint64_t *pcbZeroMem);
714VMMR3DECL(int) PGMR3QueryGlobalMemoryStats(PUVM pUVM, uint64_t *pcbAllocMem, uint64_t *pcbFreeMem, uint64_t *pcbBallonedMem, uint64_t *pcbSharedMem);
715
716VMMR3DECL(int) PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMPHYSHANDLERTYPE hType,
717 RTR3PTR pvUserR3, RTR0PTR pvUserR0, RTRCPTR pvUserRC, const char *pszDesc);
718VMMR3DECL(int) PGMR3PhysMMIODeregister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb);
719
720/** @name PGMPHYS_MMIO2_FLAGS_XXX - MMIO2 registration flags.
721 * @see PGMR3PhysMmio2Register, PDMDevHlpMmio2Create
722 * @{ */
723/** Track dirty pages.
724 * @see PGMR3PhysMmio2QueryAndResetDirtyBitmap(), PGMR3PhysMmio2ControlDirtyPageTracking(). */
725#define PGMPHYS_MMIO2_FLAGS_TRACK_DIRTY_PAGES RT_BIT_32(0)
726/** Valid flags. */
727#define PGMPHYS_MMIO2_FLAGS_VALID_MASK UINT32_C(0x00000001)
728/** @} */
729
730VMMR3_INT_DECL(int) PGMR3PhysMmio2Register(PVM pVM, PPDMDEVINS pDevIns, uint32_t iSubDev, uint32_t iRegion, RTGCPHYS cb,
731 uint32_t fFlags, const char *pszDesc, void **ppv, PGMMMIO2HANDLE *phRegion);
732VMMR3_INT_DECL(int) PGMR3PhysMmio2Deregister(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2);
733VMMR3_INT_DECL(int) PGMR3PhysMmio2Map(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS GCPhys);
734VMMR3_INT_DECL(int) PGMR3PhysMmio2Unmap(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS GCPhys);
735VMMR3_INT_DECL(int) PGMR3PhysMmio2Reduce(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS cbRegion);
736VMMR3_INT_DECL(int) PGMR3PhysMmio2ValidateHandle(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2);
737VMMR3_INT_DECL(RTGCPHYS) PGMR3PhysMmio2GetMappingAddress(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2);
738VMMR3_INT_DECL(int) PGMR3PhysMmio2ChangeRegionNo(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, uint32_t iNewRegion);
739VMMR3_INT_DECL(int) PGMR3PhysMmio2QueryAndResetDirtyBitmap(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2,
740 void *pvBitmap, size_t cbBitmap);
741VMMR3_INT_DECL(int) PGMR3PhysMmio2ControlDirtyPageTracking(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, bool fEnabled);
742
743/** @name PGMPHYS_ROM_FLAGS_XXX - ROM registration flags.
744 * @see PGMR3PhysRegisterRom, PDMDevHlpROMRegister
745 * @{ */
746/** Inidicates that ROM shadowing should be enabled. */
747#define PGMPHYS_ROM_FLAGS_SHADOWED UINT8_C(0x01)
748/** Indicates that what pvBinary points to won't go away
749 * and can be used for strictness checks. */
750#define PGMPHYS_ROM_FLAGS_PERMANENT_BINARY UINT8_C(0x02)
751/** Indicates that the ROM is allowed to be missing from saved state.
752 * @note This is a hack for EFI, see @bugref{6940} */
753#define PGMPHYS_ROM_FLAGS_MAYBE_MISSING_FROM_STATE UINT8_C(0x04)
754/** Valid flags. */
755#define PGMPHYS_ROM_FLAGS_VALID_MASK UINT8_C(0x07)
756/** @} */
757
758VMMR3DECL(int) PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
759 const void *pvBinary, uint32_t cbBinary, uint8_t fFlags, const char *pszDesc);
760VMMR3DECL(int) PGMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMROMPROT enmProt);
761VMMDECL(void) PGMR3PhysSetA20(PVMCPU pVCpu, bool fEnable);
762
763VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegisterEx(PVM pVM, PGMPHYSHANDLERKIND enmKind, bool fKeepPgmLock,
764 PFNPGMPHYSHANDLER pfnHandlerR3,
765 R0PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR0,
766 R0PTRTYPE(PFNPGMRZPHYSPFHANDLER) pfnPfHandlerR0,
767 const char *pszDesc, PPGMPHYSHANDLERTYPE phType);
768VMMR3DECL(int) PGMR3HandlerPhysicalTypeRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, bool fKeepPgmLock,
769 R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
770 const char *pszModR0, const char *pszHandlerR0, const char *pszPfHandlerR0,
771 const char *pszModRC, const char *pszHandlerRC, const char *pszPfHandlerRC,
772 const char *pszDesc,
773 PPGMPHYSHANDLERTYPE phType);
774VMMR3_INT_DECL(int) PGMR3PoolGrow(PVM pVM, PVMCPU pVCpu);
775
776VMMR3DECL(int) PGMR3PhysTlbGCPhys2Ptr(PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **ppv);
777VMMR3DECL(uint8_t) PGMR3PhysReadU8(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
778VMMR3DECL(uint16_t) PGMR3PhysReadU16(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
779VMMR3DECL(uint32_t) PGMR3PhysReadU32(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
780VMMR3DECL(uint64_t) PGMR3PhysReadU64(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
781VMMR3DECL(void) PGMR3PhysWriteU8(PVM pVM, RTGCPHYS GCPhys, uint8_t Value, PGMACCESSORIGIN enmOrigin);
782VMMR3DECL(void) PGMR3PhysWriteU16(PVM pVM, RTGCPHYS GCPhys, uint16_t Value, PGMACCESSORIGIN enmOrigin);
783VMMR3DECL(void) PGMR3PhysWriteU32(PVM pVM, RTGCPHYS GCPhys, uint32_t Value, PGMACCESSORIGIN enmOrigin);
784VMMR3DECL(void) PGMR3PhysWriteU64(PVM pVM, RTGCPHYS GCPhys, uint64_t Value, PGMACCESSORIGIN enmOrigin);
785VMMR3DECL(int) PGMR3PhysReadExternal(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
786VMMR3DECL(int) PGMR3PhysWriteExternal(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
787VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrExternal(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
788VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrReadOnlyExternal(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
789VMMR3DECL(int) PGMR3PhysBulkGCPhys2CCPtrExternal(PVM pVM, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
790 void **papvPages, PPGMPAGEMAPLOCK paLocks);
791VMMR3DECL(int) PGMR3PhysBulkGCPhys2CCPtrReadOnlyExternal(PVM pVM, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
792 void const **papvPages, PPGMPAGEMAPLOCK paLocks);
793VMMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM);
794VMMR3DECL(int) PGMR3PhysAllocateHandyPages(PVM pVM);
795
796VMMR3DECL(int) PGMR3CheckIntegrity(PVM pVM);
797
798VMMR3DECL(int) PGMR3DbgR3Ptr2GCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTGCPHYS pGCPhys);
799VMMR3DECL(int) PGMR3DbgR3Ptr2HCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTHCPHYS pHCPhys);
800VMMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PUVM pUVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
801VMMR3_INT_DECL(int) PGMR3DbgReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
802VMMR3_INT_DECL(int) PGMR3DbgWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
803VMMR3_INT_DECL(int) PGMR3DbgReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
804VMMR3_INT_DECL(int) PGMR3DbgWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
805VMMR3_INT_DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, RTGCPHYS GCPhysAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
806VMMR3_INT_DECL(int) PGMR3DbgScanVirtual(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, RTGCPTR cbRange, RTGCPTR GCPtrAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
807VMMR3_INT_DECL(int) PGMR3DumpHierarchyShw(PVM pVM, uint64_t cr3, uint32_t fFlags, uint64_t u64FirstAddr, uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
808VMMR3_INT_DECL(int) PGMR3DumpHierarchyGst(PVM pVM, uint64_t cr3, uint32_t fFlags, RTGCPTR FirstAddr, RTGCPTR LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
809
810
811/** @name Page sharing
812 * @{ */
813VMMR3DECL(int) PGMR3SharedModuleRegister(PVM pVM, VBOXOSFAMILY enmGuestOS, char *pszModuleName, char *pszVersion,
814 RTGCPTR GCBaseAddr, uint32_t cbModule,
815 uint32_t cRegions, VMMDEVSHAREDREGIONDESC const *paRegions);
816VMMR3DECL(int) PGMR3SharedModuleUnregister(PVM pVM, char *pszModuleName, char *pszVersion,
817 RTGCPTR GCBaseAddr, uint32_t cbModule);
818VMMR3DECL(int) PGMR3SharedModuleCheckAll(PVM pVM);
819VMMR3DECL(int) PGMR3SharedModuleGetPageState(PVM pVM, RTGCPTR GCPtrPage, bool *pfShared, uint64_t *pfPageFlags);
820/** @} */
821
822/** @} */
823#endif /* IN_RING3 */
824
825RT_C_DECLS_END
826
827/** @} */
828#endif /* !VBOX_INCLUDED_vmm_pgm_h */
829
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