VirtualBox

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

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

VMM/PGM: Move 'fUseLargePages' into PGM.

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