VirtualBox

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

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

VMM/NEM,PGM: First bunch changes for watered down guest memory managment for NEM. (Gets stuck in bios.) bugref:10122

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 40.6 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);
356VMM_INT_DECL(bool) PGMGstArePaePdpesValid(PVMCPUCC pVCpu, PCX86PDPE paPaePdpes);
357VMM_INT_DECL(int) PGMGstMapPaePdpes(PVMCPUCC pVCpu, PCX86PDPE paPaePdpes);
358VMM_INT_DECL(int) PGMGstMapPaePdpesAtCr3(PVMCPUCC pVCpu, uint64_t cr3);
359
360VMMDECL(int) PGMInvalidatePage(PVMCPUCC pVCpu, RTGCPTR GCPtrPage);
361VMMDECL(int) PGMFlushTLB(PVMCPUCC pVCpu, uint64_t cr3, bool fGlobal, bool fPdpesMapped);
362VMMDECL(int) PGMSyncCR3(PVMCPUCC pVCpu, uint64_t cr0, uint64_t cr3, uint64_t cr4, bool fGlobal);
363VMMDECL(int) PGMUpdateCR3(PVMCPUCC pVCpu, uint64_t cr3, bool fPdpesMapped);
364VMMDECL(int) PGMChangeMode(PVMCPUCC pVCpu, uint64_t cr0, uint64_t cr4, uint64_t efer);
365VMM_INT_DECL(int) PGMHCChangeMode(PVMCC pVM, PVMCPUCC pVCpu, PGMMODE enmGuestMode);
366VMMDECL(void) PGMCr0WpEnabled(PVMCPUCC pVCpu);
367VMMDECL(PGMMODE) PGMGetGuestMode(PVMCPU pVCpu);
368VMMDECL(PGMMODE) PGMGetShadowMode(PVMCPU pVCpu);
369VMMDECL(PGMMODE) PGMGetHostMode(PVM pVM);
370VMMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
371VMM_INT_DECL(RTGCPHYS) PGMGetGuestCR3Phys(PVMCPU pVCpu);
372VMM_INT_DECL(void) PGMNotifyNxeChanged(PVMCPU pVCpu, bool fNxe);
373VMMDECL(bool) PGMHasDirtyPages(PVM pVM);
374
375/** PGM physical access handler type registration handle (heap offset, valid
376 * cross contexts without needing fixing up). Callbacks and handler type is
377 * associated with this and it is shared by all handler registrations. */
378typedef uint32_t PGMPHYSHANDLERTYPE;
379/** Pointer to a PGM physical handler type registration handle. */
380typedef PGMPHYSHANDLERTYPE *PPGMPHYSHANDLERTYPE;
381/** NIL value for PGM physical access handler type handle. */
382#define NIL_PGMPHYSHANDLERTYPE UINT32_MAX
383VMMDECL(uint32_t) PGMHandlerPhysicalTypeRelease(PVMCC pVM, PGMPHYSHANDLERTYPE hType);
384VMMDECL(uint32_t) PGMHandlerPhysicalTypeRetain(PVM pVM, PGMPHYSHANDLERTYPE hType);
385
386VMMDECL(int) PGMHandlerPhysicalRegister(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast, PGMPHYSHANDLERTYPE hType,
387 RTR3PTR pvUserR3, RTR0PTR pvUserR0, RTRCPTR pvUserRC,
388 R3PTRTYPE(const char *) pszDesc);
389VMMDECL(int) PGMHandlerPhysicalModify(PVMCC pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
390VMMDECL(int) PGMHandlerPhysicalDeregister(PVMCC pVM, RTGCPHYS GCPhys);
391VMMDECL(int) PGMHandlerPhysicalChangeUserArgs(PVMCC pVM, RTGCPHYS GCPhys, RTR3PTR pvUserR3, RTR0PTR pvUserR0);
392VMMDECL(int) PGMHandlerPhysicalSplit(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
393VMMDECL(int) PGMHandlerPhysicalJoin(PVMCC pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
394VMMDECL(int) PGMHandlerPhysicalPageTempOff(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
395VMMDECL(int) PGMHandlerPhysicalPageAliasMmio2(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage,
396 PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS offMMio2PageRemap);
397VMMDECL(int) PGMHandlerPhysicalPageAliasHC(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTHCPHYS HCPhysPageRemap);
398VMMDECL(int) PGMHandlerPhysicalReset(PVMCC pVM, RTGCPHYS GCPhys);
399VMMDECL(bool) PGMHandlerPhysicalIsRegistered(PVMCC pVM, RTGCPHYS GCPhys);
400
401
402/**
403 * Page type.
404 *
405 * @remarks This enum has to fit in a 3-bit field (see PGMPAGE::u3Type).
406 * @remarks This is used in the saved state, so changes to it requires bumping
407 * the saved state version.
408 * @todo So, convert to \#defines!
409 */
410typedef enum PGMPAGETYPE
411{
412 /** The usual invalid zero entry. */
413 PGMPAGETYPE_INVALID = 0,
414 /** RAM page. (RWX) */
415 PGMPAGETYPE_RAM,
416 /** MMIO2 page. (RWX) */
417 PGMPAGETYPE_MMIO2,
418 /** MMIO2 page aliased over an MMIO page. (RWX)
419 * See PGMHandlerPhysicalPageAlias(). */
420 PGMPAGETYPE_MMIO2_ALIAS_MMIO,
421 /** Special page aliased over an MMIO page. (RWX)
422 * See PGMHandlerPhysicalPageAliasHC(), but this is generally only used for
423 * VT-x's APIC access page at the moment. Treated as MMIO by everyone except
424 * the shadow paging code. */
425 PGMPAGETYPE_SPECIAL_ALIAS_MMIO,
426 /** Shadowed ROM. (RWX) */
427 PGMPAGETYPE_ROM_SHADOW,
428 /** ROM page. (R-X) */
429 PGMPAGETYPE_ROM,
430 /** MMIO page. (---) */
431 PGMPAGETYPE_MMIO,
432 /** End of valid entries. */
433 PGMPAGETYPE_END
434} PGMPAGETYPE;
435AssertCompile(PGMPAGETYPE_END == 8);
436
437/** @name PGM page type predicates.
438 * @{ */
439#define PGMPAGETYPE_IS_READABLE(a_enmType) ( (a_enmType) <= PGMPAGETYPE_ROM )
440#define PGMPAGETYPE_IS_WRITEABLE(a_enmType) ( (a_enmType) <= PGMPAGETYPE_ROM_SHADOW )
441#define PGMPAGETYPE_IS_RWX(a_enmType) ( (a_enmType) <= PGMPAGETYPE_ROM_SHADOW )
442#define PGMPAGETYPE_IS_ROX(a_enmType) ( (a_enmType) == PGMPAGETYPE_ROM )
443#define PGMPAGETYPE_IS_NP(a_enmType) ( (a_enmType) == PGMPAGETYPE_MMIO )
444/** @} */
445
446
447VMM_INT_DECL(PGMPAGETYPE) PGMPhysGetPageType(PVMCC pVM, RTGCPHYS GCPhys);
448
449VMM_INT_DECL(int) PGMPhysGCPhys2HCPhys(PVMCC pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
450VMM_INT_DECL(int) PGMPhysGCPtr2HCPhys(PVMCPUCC pVCpu, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
451VMM_INT_DECL(int) PGMPhysGCPhys2CCPtr(PVMCC pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
452VMM_INT_DECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVMCC pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
453VMM_INT_DECL(int) PGMPhysGCPtr2CCPtr(PVMCPU pVCpu, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
454VMM_INT_DECL(int) PGMPhysGCPtr2CCPtrReadOnly(PVMCPUCC pVCpu, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
455
456VMMDECL(bool) PGMPhysIsA20Enabled(PVMCPU pVCpu);
457VMMDECL(bool) PGMPhysIsGCPhysValid(PVMCC pVM, RTGCPHYS GCPhys);
458VMMDECL(bool) PGMPhysIsGCPhysNormal(PVMCC pVM, RTGCPHYS GCPhys);
459VMMDECL(int) PGMPhysGCPtr2GCPhys(PVMCPUCC pVCpu, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
460VMMDECL(void) PGMPhysReleasePageMappingLock(PVMCC pVM, PPGMPAGEMAPLOCK pLock);
461VMMDECL(void) PGMPhysBulkReleasePageMappingLocks(PVMCC pVM, uint32_t cPages, PPGMPAGEMAPLOCK paLock);
462
463/** @def PGM_PHYS_RW_IS_SUCCESS
464 * Check whether a PGMPhysRead, PGMPhysWrite, PGMPhysReadGCPtr or
465 * PGMPhysWriteGCPtr call completed the given task.
466 *
467 * @returns true if completed, false if not.
468 * @param a_rcStrict The status code.
469 * @sa IOM_SUCCESS
470 */
471#ifdef IN_RING3
472# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
473 ( (a_rcStrict) == VINF_SUCCESS \
474 || (a_rcStrict) == VINF_EM_DBG_STOP \
475 || (a_rcStrict) == VINF_EM_DBG_EVENT \
476 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
477 )
478#elif defined(IN_RING0)
479# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
480 ( (a_rcStrict) == VINF_SUCCESS \
481 || (a_rcStrict) == VINF_IOM_R3_MMIO_COMMIT_WRITE \
482 || (a_rcStrict) == VINF_EM_OFF \
483 || (a_rcStrict) == VINF_EM_SUSPEND \
484 || (a_rcStrict) == VINF_EM_RESET \
485 || (a_rcStrict) == VINF_EM_HALT \
486 || (a_rcStrict) == VINF_EM_DBG_STOP \
487 || (a_rcStrict) == VINF_EM_DBG_EVENT \
488 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
489 )
490#elif defined(IN_RC)
491# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
492 ( (a_rcStrict) == VINF_SUCCESS \
493 || (a_rcStrict) == VINF_IOM_R3_MMIO_COMMIT_WRITE \
494 || (a_rcStrict) == VINF_EM_OFF \
495 || (a_rcStrict) == VINF_EM_SUSPEND \
496 || (a_rcStrict) == VINF_EM_RESET \
497 || (a_rcStrict) == VINF_EM_HALT \
498 || (a_rcStrict) == VINF_SELM_SYNC_GDT \
499 || (a_rcStrict) == VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT \
500 || (a_rcStrict) == VINF_EM_DBG_STOP \
501 || (a_rcStrict) == VINF_EM_DBG_EVENT \
502 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
503 )
504#endif
505/** @def PGM_PHYS_RW_DO_UPDATE_STRICT_RC
506 * Updates the return code with a new result.
507 *
508 * Both status codes must be successes according to PGM_PHYS_RW_IS_SUCCESS.
509 *
510 * @param a_rcStrict The current return code, to be updated.
511 * @param a_rcStrict2 The new return code to merge in.
512 */
513#ifdef IN_RING3
514# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
515 do { \
516 Assert(rcStrict == VINF_SUCCESS); \
517 Assert(rcStrict2 == VINF_SUCCESS); \
518 } while (0)
519#elif defined(IN_RING0)
520# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
521 do { \
522 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict)); \
523 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict2)); \
524 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_LAST); \
525 if ((a_rcStrict2) == VINF_SUCCESS || (a_rcStrict) == (a_rcStrict2)) \
526 { /* likely */ } \
527 else if ( (a_rcStrict) == VINF_SUCCESS \
528 || (a_rcStrict) > (a_rcStrict2)) \
529 (a_rcStrict) = (a_rcStrict2); \
530 } while (0)
531#elif defined(IN_RC)
532# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
533 do { \
534 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict)); \
535 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict2)); \
536 AssertCompile(VINF_SELM_SYNC_GDT > VINF_EM_LAST); \
537 AssertCompile(VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT > VINF_EM_LAST); \
538 AssertCompile(VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT < VINF_SELM_SYNC_GDT); \
539 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_LAST); \
540 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_SELM_SYNC_GDT); \
541 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT); \
542 if ((a_rcStrict2) == VINF_SUCCESS || (a_rcStrict) == (a_rcStrict2)) \
543 { /* likely */ } \
544 else if ((a_rcStrict) == VINF_SUCCESS) \
545 (a_rcStrict) = (a_rcStrict2); \
546 else if ( ( (a_rcStrict) > (a_rcStrict2) \
547 && ( (a_rcStrict2) <= VINF_EM_RESET \
548 || (a_rcStrict) != VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT) ) \
549 || ( (a_rcStrict2) == VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT \
550 && (a_rcStrict) > VINF_EM_RESET) ) \
551 (a_rcStrict) = (a_rcStrict2); \
552 } while (0)
553#endif
554
555VMMDECL(VBOXSTRICTRC) PGMPhysRead(PVMCC pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
556VMMDECL(VBOXSTRICTRC) PGMPhysWrite(PVMCC pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
557VMMDECL(VBOXSTRICTRC) PGMPhysReadGCPtr(PVMCPUCC pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, PGMACCESSORIGIN enmOrigin);
558VMMDECL(VBOXSTRICTRC) PGMPhysWriteGCPtr(PVMCPUCC pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb, PGMACCESSORIGIN enmOrigin);
559
560VMMDECL(int) PGMPhysSimpleReadGCPhys(PVMCC pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
561VMMDECL(int) PGMPhysSimpleWriteGCPhys(PVMCC pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
562VMMDECL(int) PGMPhysSimpleReadGCPtr(PVMCPUCC pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
563VMMDECL(int) PGMPhysSimpleWriteGCPtr(PVMCPUCC pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
564VMMDECL(int) PGMPhysSimpleDirtyWriteGCPtr(PVMCPUCC pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
565VMMDECL(int) PGMPhysInterpretedRead(PVMCPUCC pVCpu, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
566VMMDECL(int) PGMPhysInterpretedReadNoHandlers(PVMCPUCC pVCpu, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb, bool fRaiseTrap);
567VMMDECL(int) PGMPhysInterpretedWriteNoHandlers(PVMCPUCC pVCpu, PCPUMCTXCORE pCtxCore, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, bool fRaiseTrap);
568
569VMM_INT_DECL(int) PGMPhysIemGCPhys2Ptr(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers, void **ppv, PPGMPAGEMAPLOCK pLock);
570VMM_INT_DECL(int) PGMPhysIemQueryAccess(PVMCC pVM, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers);
571VMM_INT_DECL(int) PGMPhysIemGCPhys2PtrNoLock(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, uint64_t const volatile *puTlbPhysRev,
572#if defined(IN_RC)
573 R3PTRTYPE(uint8_t *) *ppb,
574#else
575 R3R0PTRTYPE(uint8_t *) *ppb,
576#endif
577 uint64_t *pfTlb);
578/** @name Flags returned by PGMPhysIemGCPhys2PtrNoLock
579 * @{ */
580#define PGMIEMGCPHYS2PTR_F_NO_WRITE RT_BIT_32(3) /**< Not writable (IEMTLBE_F_PG_NO_WRITE). */
581#define PGMIEMGCPHYS2PTR_F_NO_READ RT_BIT_32(4) /**< Not readable (IEMTLBE_F_PG_NO_READ). */
582#define PGMIEMGCPHYS2PTR_F_NO_MAPPINGR3 RT_BIT_32(7) /**< No ring-3 mapping (IEMTLBE_F_NO_MAPPINGR3). */
583/** @} */
584
585/** Information returned by PGMPhysNemQueryPageInfo. */
586typedef struct PGMPHYSNEMPAGEINFO
587{
588 /** The host physical address of the page, NIL_HCPHYS if invalid page. */
589 RTHCPHYS HCPhys;
590 /** The NEM access mode for the page, NEM_PAGE_PROT_XXX */
591 uint32_t fNemProt : 8;
592 /** The NEM state associated with the PAGE. */
593 uint32_t u2NemState : 2;
594 /** The NEM state associated with the PAGE before pgmPhysPageMakeWritable was called. */
595 uint32_t u2OldNemState : 2;
596 /** Set if the page has handler. */
597 uint32_t fHasHandlers : 1;
598 /** Set if is the zero page backing it. */
599 uint32_t fZeroPage : 1;
600 /** Set if the page has handler. */
601 PGMPAGETYPE enmType;
602} PGMPHYSNEMPAGEINFO;
603/** Pointer to page information for NEM. */
604typedef PGMPHYSNEMPAGEINFO *PPGMPHYSNEMPAGEINFO;
605/**
606 * Callback for checking that the page is in sync while under the PGM lock.
607 *
608 * NEM passes this callback to PGMPhysNemQueryPageInfo to check that the page is
609 * in-sync between PGM and the native hypervisor API in an atomic fashion.
610 *
611 * @returns VBox status code.
612 * @param pVM The cross context VM structure.
613 * @param pVCpu The cross context per virtual CPU structure. Optional,
614 * see PGMPhysNemQueryPageInfo.
615 * @param GCPhys The guest physical address (not A20 masked).
616 * @param pInfo The page info structure. This function updates the
617 * u2NemState memory and the caller will update the PGMPAGE
618 * copy accordingly.
619 * @param pvUser Callback user argument.
620 */
621typedef DECLCALLBACKTYPE(int, FNPGMPHYSNEMCHECKPAGE,(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, PPGMPHYSNEMPAGEINFO pInfo, void *pvUser));
622/** Pointer to a FNPGMPHYSNEMCHECKPAGE function. */
623typedef FNPGMPHYSNEMCHECKPAGE *PFNPGMPHYSNEMCHECKPAGE;
624
625VMM_INT_DECL(int) PGMPhysNemPageInfoChecker(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, bool fMakeWritable,
626 PPGMPHYSNEMPAGEINFO pInfo, PFNPGMPHYSNEMCHECKPAGE pfnChecker, void *pvUser);
627
628/**
629 * Callback for use with PGMPhysNemEnumPagesByState.
630 * @returns VBox status code.
631 * Failure status will stop enumeration immediately and return.
632 * @param pVM The cross context VM structure.
633 * @param pVCpu The cross context per virtual CPU structure. Optional,
634 * see PGMPhysNemEnumPagesByState.
635 * @param GCPhys The guest physical address (not A20 masked).
636 * @param pu2NemState Pointer to variable with the NEM state. This can be
637 * update.
638 * @param pvUser The user argument.
639 */
640typedef DECLCALLBACKTYPE(int, FNPGMPHYSNEMENUMCALLBACK,(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys,
641 uint8_t *pu2NemState, void *pvUser));
642/** Pointer to a FNPGMPHYSNEMENUMCALLBACK function. */
643typedef FNPGMPHYSNEMENUMCALLBACK *PFNPGMPHYSNEMENUMCALLBACK;
644VMM_INT_DECL(int) PGMPhysNemEnumPagesByState(PVMCC pVM, PVMCPUCC VCpu, uint8_t uMinState,
645 PFNPGMPHYSNEMENUMCALLBACK pfnCallback, void *pvUser);
646
647
648#ifdef VBOX_STRICT
649VMMDECL(unsigned) PGMAssertHandlerAndFlagsInSync(PVMCC pVM);
650VMMDECL(unsigned) PGMAssertNoMappingConflicts(PVM pVM);
651VMMDECL(unsigned) PGMAssertCR3(PVMCC pVM, PVMCPUCC pVCpu, uint64_t cr3, uint64_t cr4);
652#endif /* VBOX_STRICT */
653
654VMMDECL(int) PGMSetLargePageUsage(PVMCC pVM, bool fUseLargePages);
655
656/**
657 * Query large page usage state
658 *
659 * @returns 0 - disabled, 1 - enabled
660 * @param pVM The cross context VM structure.
661 */
662#define PGMIsUsingLargePages(pVM) ((pVM)->pgm.s.fUseLargePages)
663
664
665#ifdef IN_RING0
666/** @defgroup grp_pgm_r0 The PGM Host Context Ring-0 API
667 * @{
668 */
669VMMR0_INT_DECL(int) PGMR0InitPerVMData(PGVM pGVM);
670VMMR0_INT_DECL(int) PGMR0InitVM(PGVM pGVM);
671VMMR0_INT_DECL(void) PGMR0CleanupVM(PGVM pGVM);
672VMMR0_INT_DECL(int) PGMR0PhysAllocateHandyPages(PGVM pGVM, VMCPUID idCpu);
673VMMR0_INT_DECL(int) PGMR0PhysFlushHandyPages(PGVM pGVM, VMCPUID idCpu);
674VMMR0_INT_DECL(int) PGMR0PhysAllocateLargeHandyPage(PGVM pGVM, VMCPUID idCpu);
675VMMR0_INT_DECL(int) PGMR0PhysMMIO2MapKernel(PGVM pGVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2,
676 size_t offSub, size_t cbSub, void **ppvMapping);
677VMMR0_INT_DECL(int) PGMR0PhysSetupIoMmu(PGVM pGVM);
678VMMR0DECL(int) PGMR0SharedModuleCheck(PVMCC pVM, PGVM pGVM, VMCPUID idCpu, PGMMSHAREDMODULE pModule,
679 PCRTGCPTR64 paRegionsGCPtrs);
680VMMR0DECL(int) PGMR0Trap0eHandlerNestedPaging(PGVM pGVM, PGVMCPU pGVCpu, PGMMODE enmShwPagingMode, RTGCUINT uErr,
681 PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault);
682VMMR0DECL(VBOXSTRICTRC) PGMR0Trap0eHandlerNPMisconfig(PGVM pGVM, PGVMCPU pGVCpu, PGMMODE enmShwPagingMode,
683 PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, uint32_t uErr);
684VMMR0_INT_DECL(int) PGMR0PoolGrow(PGVM pGVM, VMCPUID idCpu);
685/** @} */
686#endif /* IN_RING0 */
687
688
689
690#ifdef IN_RING3
691/** @defgroup grp_pgm_r3 The PGM Host Context Ring-3 API
692 * @{
693 */
694VMMR3_INT_DECL(void) PGMR3EnableNemMode(PVM pVM);
695VMMR3DECL(int) PGMR3Init(PVM pVM);
696VMMR3DECL(int) PGMR3InitDynMap(PVM pVM);
697VMMR3DECL(int) PGMR3InitFinalize(PVM pVM);
698VMMR3_INT_DECL(int) PGMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
699VMMR3DECL(void) PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
700VMMR3DECL(void) PGMR3ResetCpu(PVM pVM, PVMCPU pVCpu);
701VMMR3_INT_DECL(void) PGMR3Reset(PVM pVM);
702VMMR3_INT_DECL(void) PGMR3ResetNoMorePhysWritesFlag(PVM pVM);
703VMMR3_INT_DECL(void) PGMR3MemSetup(PVM pVM, bool fReset);
704VMMR3DECL(int) PGMR3Term(PVM pVM);
705
706VMMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
707VMMR3DECL(int) PGMR3PhysChangeMemBalloon(PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage);
708VMMR3DECL(int) PGMR3PhysWriteProtectRAM(PVM pVM);
709VMMR3DECL(uint32_t) PGMR3PhysGetRamRangeCount(PVM pVM);
710VMMR3DECL(int) PGMR3PhysGetRange(PVM pVM, uint32_t iRange, PRTGCPHYS pGCPhysStart, PRTGCPHYS pGCPhysLast,
711 const char **ppszDesc, bool *pfIsMmio);
712VMMR3DECL(int) PGMR3QueryMemoryStats(PUVM pUVM, uint64_t *pcbTotalMem, uint64_t *pcbPrivateMem, uint64_t *pcbSharedMem, uint64_t *pcbZeroMem);
713VMMR3DECL(int) PGMR3QueryGlobalMemoryStats(PUVM pUVM, uint64_t *pcbAllocMem, uint64_t *pcbFreeMem, uint64_t *pcbBallonedMem, uint64_t *pcbSharedMem);
714
715VMMR3DECL(int) PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMPHYSHANDLERTYPE hType,
716 RTR3PTR pvUserR3, RTR0PTR pvUserR0, RTRCPTR pvUserRC, const char *pszDesc);
717VMMR3DECL(int) PGMR3PhysMMIODeregister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb);
718VMMR3_INT_DECL(int) PGMR3PhysMmio2Register(PVM pVM, PPDMDEVINS pDevIns, uint32_t iSubDev, uint32_t iRegion, RTGCPHYS cb,
719 uint32_t fFlags, const char *pszDesc, void **ppv, PGMMMIO2HANDLE *phRegion);
720VMMR3_INT_DECL(int) PGMR3PhysMmio2Deregister(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2);
721VMMR3_INT_DECL(int) PGMR3PhysMmio2Map(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS GCPhys);
722VMMR3_INT_DECL(int) PGMR3PhysMmio2Unmap(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS GCPhys);
723VMMR3_INT_DECL(int) PGMR3PhysMmio2Reduce(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS cbRegion);
724VMMR3_INT_DECL(int) PGMR3PhysMmio2ValidateHandle(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2);
725VMMR3_INT_DECL(RTGCPHYS) PGMR3PhysMmio2GetMappingAddress(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2);
726VMMR3_INT_DECL(int) PGMR3PhysMmio2ChangeRegionNo(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, uint32_t iNewRegion);
727VMMR3_INT_DECL(int) PGMR3PhysMMIO2GetHCPhys(PVM pVM, PPDMDEVINS pDevIns, uint32_t iSubDev, uint32_t iRegion, RTGCPHYS off, PRTHCPHYS pHCPhys);
728
729
730/** @name PGMR3PhysRegisterRom flags.
731 * @{ */
732/** Inidicates that ROM shadowing should be enabled. */
733#define PGMPHYS_ROM_FLAGS_SHADOWED UINT8_C(0x01)
734/** Indicates that what pvBinary points to won't go away
735 * and can be used for strictness checks. */
736#define PGMPHYS_ROM_FLAGS_PERMANENT_BINARY UINT8_C(0x02)
737/** Indicates that the ROM is allowed to be missing from saved state.
738 * @note This is a hack for EFI, see @bugref{6940} */
739#define PGMPHYS_ROM_FLAGS_MAYBE_MISSING_FROM_STATE UINT8_C(0x04)
740/** Valid flags. */
741#define PGMPHYS_ROM_FLAGS_VALID_MASK UINT8_C(0x07)
742/** @} */
743
744VMMR3DECL(int) PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
745 const void *pvBinary, uint32_t cbBinary, uint8_t fFlags, const char *pszDesc);
746VMMR3DECL(int) PGMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMROMPROT enmProt);
747VMMR3DECL(int) PGMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
748VMMDECL(void) PGMR3PhysSetA20(PVMCPU pVCpu, bool fEnable);
749#ifndef PGM_WITHOUT_MAPPINGS
750/** @name PGMR3MapPT flags.
751 * @{ */
752/** The mapping may be unmapped later. The default is permanent mappings. */
753# define PGMR3MAPPT_FLAGS_UNMAPPABLE RT_BIT(0)
754/** @} */
755VMMR3DECL(int) PGMR3MapPT(PVM pVM, RTGCPTR GCPtr, uint32_t cb, uint32_t fFlags, PFNPGMRELOCATE pfnRelocate, void *pvUser, const char *pszDesc);
756VMMR3DECL(int) PGMR3UnmapPT(PVM pVM, RTGCPTR GCPtr);
757VMMR3DECL(int) PGMR3FinalizeMappings(PVM pVM);
758VMMR3DECL(bool) PGMR3MappingsNeedReFixing(PVM pVM);
759# if defined(VBOX_WITH_RAW_MODE) || HC_ARCH_BITS == 32 /* (latter for 64-bit guests on 32-bit hosts) */
760VMMR3DECL(int) PGMR3MapIntermediate(PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
761# endif
762VMMR3DECL(int) PGMR3MapRead(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
763#endif /* !PGM_WITHOUT_MAPPINGS */
764VMMR3DECL(int) PGMR3MappingsSize(PVM pVM, uint32_t *pcb);
765VMMR3DECL(int) PGMR3MappingsFix(PVM pVM, RTGCPTR GCPtrBase, uint32_t cb);
766VMMR3DECL(int) PGMR3MappingsUnfix(PVM pVM);
767
768VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegisterEx(PVM pVM, PGMPHYSHANDLERKIND enmKind,
769 PFNPGMPHYSHANDLER pfnHandlerR3,
770 R0PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR0,
771 R0PTRTYPE(PFNPGMRZPHYSPFHANDLER) pfnPfHandlerR0,
772 const char *pszDesc, PPGMPHYSHANDLERTYPE phType);
773VMMR3DECL(int) PGMR3HandlerPhysicalTypeRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind,
774 R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
775 const char *pszModR0, const char *pszHandlerR0, const char *pszPfHandlerR0,
776 const char *pszModRC, const char *pszHandlerRC, const char *pszPfHandlerRC,
777 const char *pszDesc,
778 PPGMPHYSHANDLERTYPE phType);
779VMMR3_INT_DECL(int) PGMR3PoolGrow(PVM pVM, PVMCPU pVCpu);
780
781VMMR3DECL(int) PGMR3PhysTlbGCPhys2Ptr(PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **ppv);
782VMMR3DECL(uint8_t) PGMR3PhysReadU8(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
783VMMR3DECL(uint16_t) PGMR3PhysReadU16(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
784VMMR3DECL(uint32_t) PGMR3PhysReadU32(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
785VMMR3DECL(uint64_t) PGMR3PhysReadU64(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
786VMMR3DECL(void) PGMR3PhysWriteU8(PVM pVM, RTGCPHYS GCPhys, uint8_t Value, PGMACCESSORIGIN enmOrigin);
787VMMR3DECL(void) PGMR3PhysWriteU16(PVM pVM, RTGCPHYS GCPhys, uint16_t Value, PGMACCESSORIGIN enmOrigin);
788VMMR3DECL(void) PGMR3PhysWriteU32(PVM pVM, RTGCPHYS GCPhys, uint32_t Value, PGMACCESSORIGIN enmOrigin);
789VMMR3DECL(void) PGMR3PhysWriteU64(PVM pVM, RTGCPHYS GCPhys, uint64_t Value, PGMACCESSORIGIN enmOrigin);
790VMMR3DECL(int) PGMR3PhysReadExternal(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
791VMMR3DECL(int) PGMR3PhysWriteExternal(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
792VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrExternal(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
793VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrReadOnlyExternal(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
794VMMR3DECL(int) PGMR3PhysBulkGCPhys2CCPtrExternal(PVM pVM, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
795 void **papvPages, PPGMPAGEMAPLOCK paLocks);
796VMMR3DECL(int) PGMR3PhysBulkGCPhys2CCPtrReadOnlyExternal(PVM pVM, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
797 void const **papvPages, PPGMPAGEMAPLOCK paLocks);
798VMMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM);
799VMMR3DECL(int) PGMR3PhysAllocateHandyPages(PVM pVM);
800VMMR3_INT_DECL(int) PGMR3PhysAllocateLargePage(PVM pVM, RTGCPHYS GCPhys);
801
802VMMR3DECL(int) PGMR3CheckIntegrity(PVM pVM);
803
804VMMR3DECL(int) PGMR3DbgR3Ptr2GCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTGCPHYS pGCPhys);
805VMMR3DECL(int) PGMR3DbgR3Ptr2HCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTHCPHYS pHCPhys);
806VMMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PUVM pUVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
807VMMR3_INT_DECL(int) PGMR3DbgReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
808VMMR3_INT_DECL(int) PGMR3DbgWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
809VMMR3_INT_DECL(int) PGMR3DbgReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
810VMMR3_INT_DECL(int) PGMR3DbgWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
811VMMR3_INT_DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, RTGCPHYS GCPhysAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
812VMMR3_INT_DECL(int) PGMR3DbgScanVirtual(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, RTGCPTR cbRange, RTGCPTR GCPtrAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
813VMMR3_INT_DECL(int) PGMR3DumpHierarchyShw(PVM pVM, uint64_t cr3, uint32_t fFlags, uint64_t u64FirstAddr, uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
814VMMR3_INT_DECL(int) PGMR3DumpHierarchyGst(PVM pVM, uint64_t cr3, uint32_t fFlags, RTGCPTR FirstAddr, RTGCPTR LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
815
816
817/** @name Page sharing
818 * @{ */
819VMMR3DECL(int) PGMR3SharedModuleRegister(PVM pVM, VBOXOSFAMILY enmGuestOS, char *pszModuleName, char *pszVersion,
820 RTGCPTR GCBaseAddr, uint32_t cbModule,
821 uint32_t cRegions, VMMDEVSHAREDREGIONDESC const *paRegions);
822VMMR3DECL(int) PGMR3SharedModuleUnregister(PVM pVM, char *pszModuleName, char *pszVersion,
823 RTGCPTR GCBaseAddr, uint32_t cbModule);
824VMMR3DECL(int) PGMR3SharedModuleCheckAll(PVM pVM);
825VMMR3DECL(int) PGMR3SharedModuleGetPageState(PVM pVM, RTGCPTR GCPtrPage, bool *pfShared, uint64_t *pfPageFlags);
826/** @} */
827
828/** @} */
829#endif /* IN_RING3 */
830
831RT_C_DECLS_END
832
833/** @} */
834#endif /* !VBOX_INCLUDED_vmm_pgm_h */
835
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