VirtualBox

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

Last change on this file since 62476 was 62476, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 41.4 KB
Line 
1/** @file
2 * PGM - Page Monitor / Monitor.
3 */
4
5/*
6 * Copyright (C) 2006-2016 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_vmm_pgm_h
27#define ___VBox_vmm_pgm_h
28
29#include <VBox/types.h>
30#include <VBox/sup.h>
31#include <VBox/vmm/vmapi.h>
32#include <VBox/vmm/gmm.h> /* for PGMMREGISTERSHAREDMODULEREQ */
33#include <iprt/x86.h>
34#include <VBox/VMMDev.h> /* for VMMDEVSHAREDREGIONDESC */
35#include <VBox/param.h>
36
37RT_C_DECLS_BEGIN
38
39/** @defgroup grp_pgm The Page Monitor / Manager API
40 * @ingroup grp_vmm
41 * @{
42 */
43
44/**
45 * FNPGMRELOCATE callback mode.
46 */
47typedef enum PGMRELOCATECALL
48{
49 /** The callback is for checking if the suggested address is suitable. */
50 PGMRELOCATECALL_SUGGEST = 1,
51 /** The callback is for executing the relocation. */
52 PGMRELOCATECALL_RELOCATE
53} PGMRELOCATECALL;
54
55
56/**
57 * Callback function which will be called when PGM is trying to find
58 * a new location for the mapping.
59 *
60 * The callback is called in two modes, 1) the check mode and 2) the relocate mode.
61 * In 1) the callback should say if it objects to a suggested new location. If it
62 * accepts the new location, it is called again for doing it's relocation.
63 *
64 *
65 * @returns true if the location is ok.
66 * @returns false if another location should be found.
67 * @param pVM The cross context VM structure.
68 * @param GCPtrOld The old virtual address.
69 * @param GCPtrNew The new virtual address.
70 * @param enmMode Used to indicate the callback mode.
71 * @param pvUser User argument.
72 * @remark The return value is no a failure indicator, it's an acceptance
73 * indicator. Relocation can not fail!
74 */
75typedef DECLCALLBACK(bool) FNPGMRELOCATE(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser);
76/** Pointer to a relocation callback function. */
77typedef FNPGMRELOCATE *PFNPGMRELOCATE;
78
79
80/**
81 * Memory access origin.
82 */
83typedef enum PGMACCESSORIGIN
84{
85 /** Invalid zero value. */
86 PGMACCESSORIGIN_INVALID = 0,
87 /** IEM is access memory. */
88 PGMACCESSORIGIN_IEM,
89 /** HM is access memory. */
90 PGMACCESSORIGIN_HM,
91 /** Some device is access memory. */
92 PGMACCESSORIGIN_DEVICE,
93 /** Someone debugging is access memory. */
94 PGMACCESSORIGIN_DEBUGGER,
95 /** SELM is access memory. */
96 PGMACCESSORIGIN_SELM,
97 /** FTM is access memory. */
98 PGMACCESSORIGIN_FTM,
99 /** REM is access memory. */
100 PGMACCESSORIGIN_REM,
101 /** IOM is access memory. */
102 PGMACCESSORIGIN_IOM,
103 /** End of valid values. */
104 PGMACCESSORIGIN_END,
105 /** Type size hack. */
106 PGMACCESSORIGIN_32BIT_HACK = 0x7fffffff
107} PGMACCESSORIGIN;
108
109
110/**
111 * Physical page access handler kind.
112 */
113typedef enum PGMPHYSHANDLERKIND
114{
115 /** MMIO range. Pages are not present, all access is done in interpreter or recompiler. */
116 PGMPHYSHANDLERKIND_MMIO = 1,
117 /** Handler all write access to a physical page range. */
118 PGMPHYSHANDLERKIND_WRITE,
119 /** Handler all access to a physical page range. */
120 PGMPHYSHANDLERKIND_ALL
121
122} PGMPHYSHANDLERKIND;
123
124/**
125 * Guest Access type
126 */
127typedef enum PGMACCESSTYPE
128{
129 /** Read access. */
130 PGMACCESSTYPE_READ = 1,
131 /** Write access. */
132 PGMACCESSTYPE_WRITE
133} PGMACCESSTYPE;
134
135
136/** @def PGM_ALL_CB_DECL
137 * Macro for declaring a handler callback for all contexts. The handler
138 * callback is static in ring-3, and exported in RC and R0.
139 * @sa PGM_ALL_CB2_DECL.
140 */
141#if defined(IN_RC) || defined(IN_RING0)
142# ifdef __cplusplus
143# define PGM_ALL_CB_DECL(type) extern "C" DECLEXPORT(type)
144# else
145# define PGM_ALL_CB_DECL(type) DECLEXPORT(type)
146# endif
147#else
148# define PGM_ALL_CB_DECL(type) static type
149#endif
150
151/** @def PGM_ALL_CB2_DECL
152 * Macro for declaring a handler callback for all contexts. The handler
153 * callback is hidden in ring-3, and exported in RC and R0.
154 * @sa PGM_ALL_CB2_DECL.
155 */
156#if defined(IN_RC) || defined(IN_RING0)
157# ifdef __cplusplus
158# define PGM_ALL_CB2_DECL(type) extern "C" DECLEXPORT(type)
159# else
160# define PGM_ALL_CB2_DECL(type) DECLEXPORT(type)
161# endif
162#else
163# define PGM_ALL_CB2_DECL(type) DECLHIDDEN(type)
164#endif
165
166
167/**
168 * \#PF Handler callback for physical access handler ranges in RC and R0.
169 *
170 * @returns Strict VBox status code (appropriate for ring-0 and raw-mode).
171 * @param pVM The cross context VM structure.
172 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
173 * @param uErrorCode CPU Error code.
174 * @param pRegFrame Trap register frame.
175 * NULL on DMA and other non CPU access.
176 * @param pvFault The fault address (cr2).
177 * @param GCPhysFault The GC physical address corresponding to pvFault.
178 * @param pvUser User argument.
179 * @thread EMT(pVCpu)
180 */
181typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMRZPHYSPFHANDLER(PVM pVM, PVMCPU pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
182 RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
183/** Pointer to PGM access callback. */
184typedef FNPGMRZPHYSPFHANDLER *PFNPGMRZPHYSPFHANDLER;
185
186
187/**
188 * Access handler callback for physical access handler ranges.
189 *
190 * The handler can not raise any faults, it's mainly for monitoring write access
191 * to certain pages (like MMIO).
192 *
193 * @returns Strict VBox status code in ring-0 and raw-mode context, in ring-3
194 * the only supported informational status code is
195 * VINF_PGM_HANDLER_DO_DEFAULT.
196 * @retval VINF_SUCCESS if the handler have carried out the operation.
197 * @retval VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the
198 * access operation.
199 * @retval VINF_EM_XXX in ring-0 and raw-mode context.
200 *
201 * @param pVM The cross context VM structure.
202 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
203 * @param GCPhys The physical address the guest is writing to.
204 * @param pvPhys The HC mapping of that address.
205 * @param pvBuf What the guest is reading/writing.
206 * @param cbBuf How much it's reading/writing.
207 * @param enmAccessType The access type.
208 * @param enmOrigin The origin of this call.
209 * @param pvUser User argument.
210 * @thread EMT(pVCpu)
211 */
212typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMPHYSHANDLER(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
213 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser);
214/** Pointer to PGM access callback. */
215typedef FNPGMPHYSHANDLER *PFNPGMPHYSHANDLER;
216
217
218/**
219 * Virtual access handler type.
220 */
221typedef enum PGMVIRTHANDLERKIND
222{
223 /** Write access handled. */
224 PGMVIRTHANDLERKIND_WRITE = 1,
225 /** All access handled. */
226 PGMVIRTHANDLERKIND_ALL,
227 /** Hypervisor write access handled.
228 * This is used to catch the guest trying to write to LDT, TSS and any other
229 * system structure which the brain dead intel guys let unprivilegde code find. */
230 PGMVIRTHANDLERKIND_HYPERVISOR
231} PGMVIRTHANDLERKIND;
232
233/**
234 * \#PF handler callback for virtual access handler ranges, RC.
235 *
236 * Important to realize that a physical page in a range can have aliases, and
237 * for ALL and WRITE handlers these will also trigger.
238 *
239 * @returns Strict VBox status code (appropriate for raw-mode).
240 * @param pVM The cross context VM structure.
241 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
242 * @param uErrorCode CPU Error code (X86_TRAP_PF_XXX).
243 * @param pRegFrame Trap register frame.
244 * @param pvFault The fault address (cr2).
245 * @param pvRange The base address of the handled virtual range.
246 * @param offRange The offset of the access into this range.
247 * (If it's a EIP range this is the EIP, if not it's pvFault.)
248 * @param pvUser User argument.
249 * @thread EMT(pVCpu)
250 */
251typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMRCVIRTPFHANDLER(PVM pVM, PVMCPU pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
252 RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange, void *pvUser);
253/** Pointer to PGM access callback. */
254typedef FNPGMRCVIRTPFHANDLER *PFNPGMRCVIRTPFHANDLER;
255
256/**
257 * Access handler callback for virtual access handler ranges.
258 *
259 * Important to realize that a physical page in a range can have aliases, and
260 * for ALL and WRITE handlers these will also trigger.
261 *
262 * @returns VINF_SUCCESS if the handler have carried out the operation.
263 * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
264 * @param pVM The cross context VM structure.
265 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
266 * @param GCPtr The virtual address the guest is writing to. This
267 * is the registered address corresponding to the
268 * access, so no aliasing trouble here.
269 * @param pvPtr The HC mapping of that address.
270 * @param pvBuf What the guest is reading/writing.
271 * @param cbBuf How much it's reading/writing.
272 * @param enmAccessType The access type.
273 * @param enmOrigin Who is calling.
274 * @param pvUser User argument.
275 * @thread EMT(pVCpu)
276 */
277typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMVIRTHANDLER(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf,
278 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser);
279/** Pointer to PGM access callback. */
280typedef FNPGMVIRTHANDLER *PFNPGMVIRTHANDLER;
281
282/**
283 * \#PF Handler callback for invalidation of virtual access handler ranges.
284 *
285 * @param pVM The cross context VM structure.
286 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
287 * @param GCPtr The virtual address the guest has changed.
288 * @param pvUser User argument.
289 * @thread EMT(pVCpu)
290 *
291 * @todo FNPGMR3VIRTINVALIDATE will not actually be called! It was introduced
292 * in r13179 (1.1) and stopped working with r13806 (PGMPool merge,
293 * v1.2), exactly a month later.
294 */
295typedef DECLCALLBACK(int) FNPGMR3VIRTINVALIDATE(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvUser);
296/** Pointer to PGM invalidation callback. */
297typedef FNPGMR3VIRTINVALIDATE *PFNPGMR3VIRTINVALIDATE;
298
299
300/**
301 * PGMR3PhysEnumDirtyFTPages callback for syncing dirty physical pages
302 *
303 * @param pVM The cross context VM structure.
304 * @param GCPhys GC physical address
305 * @param pRange HC virtual address of the page(s)
306 * @param cbRange Size of the dirty range in bytes.
307 * @param pvUser User argument.
308 */
309typedef DECLCALLBACK(int) FNPGMENUMDIRTYFTPAGES(PVM pVM, RTGCPHYS GCPhys, uint8_t *pRange, unsigned cbRange, void *pvUser);
310/** Pointer to PGMR3PhysEnumDirtyFTPages callback. */
311typedef FNPGMENUMDIRTYFTPAGES *PFNPGMENUMDIRTYFTPAGES;
312
313
314/**
315 * Paging mode.
316 */
317typedef enum PGMMODE
318{
319 /** The usual invalid value. */
320 PGMMODE_INVALID = 0,
321 /** Real mode. */
322 PGMMODE_REAL,
323 /** Protected mode, no paging. */
324 PGMMODE_PROTECTED,
325 /** 32-bit paging. */
326 PGMMODE_32_BIT,
327 /** PAE paging. */
328 PGMMODE_PAE,
329 /** PAE paging with NX enabled. */
330 PGMMODE_PAE_NX,
331 /** 64-bit AMD paging (long mode). */
332 PGMMODE_AMD64,
333 /** 64-bit AMD paging (long mode) with NX enabled. */
334 PGMMODE_AMD64_NX,
335 /** Nested paging mode (shadow only; guest physical to host physical). */
336 PGMMODE_NESTED,
337 /** Extended paging (Intel) mode. */
338 PGMMODE_EPT,
339 /** The max number of modes */
340 PGMMODE_MAX,
341 /** 32bit hackishness. */
342 PGMMODE_32BIT_HACK = 0x7fffffff
343} PGMMODE;
344
345/** Macro for checking if the guest is using paging.
346 * @param enmMode PGMMODE_*.
347 * @remark ASSUMES certain order of the PGMMODE_* values.
348 */
349#define PGMMODE_WITH_PAGING(enmMode) ((enmMode) >= PGMMODE_32_BIT)
350
351/** Macro for checking if it's one of the long mode modes.
352 * @param enmMode PGMMODE_*.
353 */
354#define PGMMODE_IS_LONG_MODE(enmMode) ((enmMode) == PGMMODE_AMD64_NX || (enmMode) == PGMMODE_AMD64)
355
356/**
357 * Is the ROM mapped (true) or is the shadow RAM mapped (false).
358 *
359 * @returns boolean.
360 * @param enmProt The PGMROMPROT value, must be valid.
361 */
362#define PGMROMPROT_IS_ROM(enmProt) \
363 ( (enmProt) == PGMROMPROT_READ_ROM_WRITE_IGNORE \
364 || (enmProt) == PGMROMPROT_READ_ROM_WRITE_RAM )
365
366
367VMMDECL(bool) PGMIsLockOwner(PVM pVM);
368
369VMMDECL(int) PGMRegisterStringFormatTypes(void);
370VMMDECL(void) PGMDeregisterStringFormatTypes(void);
371VMMDECL(RTHCPHYS) PGMGetHyperCR3(PVMCPU pVCpu);
372VMMDECL(RTHCPHYS) PGMGetNestedCR3(PVMCPU pVCpu, PGMMODE enmShadowMode);
373VMMDECL(RTHCPHYS) PGMGetInterHCCR3(PVM pVM);
374VMMDECL(RTHCPHYS) PGMGetInterRCCR3(PVM pVM, PVMCPU pVCpu);
375VMMDECL(RTHCPHYS) PGMGetInter32BitCR3(PVM pVM);
376VMMDECL(RTHCPHYS) PGMGetInterPaeCR3(PVM pVM);
377VMMDECL(RTHCPHYS) PGMGetInterAmd64CR3(PVM pVM);
378VMMDECL(int) PGMTrap0eHandler(PVMCPU pVCpu, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
379VMMDECL(int) PGMPrefetchPage(PVMCPU pVCpu, RTGCPTR GCPtrPage);
380VMMDECL(int) PGMVerifyAccess(PVMCPU pVCpu, RTGCPTR Addr, uint32_t cbSize, uint32_t fAccess);
381VMMDECL(int) PGMIsValidAccess(PVMCPU pVCpu, RTGCPTR Addr, uint32_t cbSize, uint32_t fAccess);
382VMMDECL(VBOXSTRICTRC) PGMInterpretInstruction(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
383VMMDECL(int) PGMMap(PVM pVM, RTGCPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags);
384VMMDECL(int) PGMMapGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
385VMMDECL(int) PGMMapSetPage(PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags);
386VMMDECL(int) PGMMapModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
387#ifndef IN_RING0
388VMMDECL(bool) PGMMapHasConflicts(PVM pVM);
389#endif
390#ifdef VBOX_STRICT
391VMMDECL(void) PGMMapCheck(PVM pVM);
392#endif
393VMMDECL(int) PGMShwGetPage(PVMCPU pVCpu, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
394VMMDECL(int) PGMShwMakePageReadonly(PVMCPU pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
395VMMDECL(int) PGMShwMakePageWritable(PVMCPU pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
396VMMDECL(int) PGMShwMakePageNotPresent(PVMCPU pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
397/** @name Flags for PGMShwMakePageReadonly, PGMShwMakePageWritable and
398 * PGMShwMakePageNotPresent
399 * @{ */
400/** The call is from an access handler for dealing with the a faulting write
401 * operation. The virtual address is within the same page. */
402#define PGM_MK_PG_IS_WRITE_FAULT RT_BIT(0)
403/** The page is an MMIO2. */
404#define PGM_MK_PG_IS_MMIO2 RT_BIT(1)
405/** @}*/
406VMMDECL(int) PGMGstGetPage(PVMCPU pVCpu, RTGCPTR GCPtr, uint64_t *pfFlags, PRTGCPHYS pGCPhys);
407VMMDECL(bool) PGMGstIsPagePresent(PVMCPU pVCpu, RTGCPTR GCPtr);
408VMMDECL(int) PGMGstSetPage(PVMCPU pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
409VMMDECL(int) PGMGstModifyPage(PVMCPU pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
410VMM_INT_DECL(int) PGMGstGetPaePdpes(PVMCPU pVCpu, PX86PDPE paPdpes);
411VMM_INT_DECL(void) PGMGstUpdatePaePdpes(PVMCPU pVCpu, PCX86PDPE paPdpes);
412
413VMMDECL(int) PGMInvalidatePage(PVMCPU pVCpu, RTGCPTR GCPtrPage);
414VMMDECL(int) PGMFlushTLB(PVMCPU pVCpu, uint64_t cr3, bool fGlobal);
415VMMDECL(int) PGMSyncCR3(PVMCPU pVCpu, uint64_t cr0, uint64_t cr3, uint64_t cr4, bool fGlobal);
416VMMDECL(int) PGMUpdateCR3(PVMCPU pVCpu, uint64_t cr3);
417VMMDECL(int) PGMChangeMode(PVMCPU pVCpu, uint64_t cr0, uint64_t cr4, uint64_t efer);
418VMMDECL(void) PGMCr0WpEnabled(PVMCPU pVCpu);
419VMMDECL(PGMMODE) PGMGetGuestMode(PVMCPU pVCpu);
420VMMDECL(PGMMODE) PGMGetShadowMode(PVMCPU pVCpu);
421VMMDECL(PGMMODE) PGMGetHostMode(PVM pVM);
422VMMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
423VMM_INT_DECL(void) PGMNotifyNxeChanged(PVMCPU pVCpu, bool fNxe);
424VMMDECL(bool) PGMHasDirtyPages(PVM pVM);
425
426/** PGM physical access handler type registration handle (heap offset, valid
427 * cross contexts without needing fixing up). Callbacks and handler type is
428 * associated with this and it is shared by all handler registrations. */
429typedef uint32_t PGMPHYSHANDLERTYPE;
430/** Pointer to a PGM physical handler type registration handle. */
431typedef PGMPHYSHANDLERTYPE *PPGMPHYSHANDLERTYPE;
432/** NIL value for PGM physical access handler type handle. */
433#define NIL_PGMPHYSHANDLERTYPE UINT32_MAX
434VMMDECL(uint32_t) PGMHandlerPhysicalTypeRelease(PVM pVM, PGMPHYSHANDLERTYPE hType);
435VMMDECL(uint32_t) PGMHandlerPhysicalTypeRetain(PVM pVM, PGMPHYSHANDLERTYPE hType);
436
437VMMDECL(int) PGMHandlerPhysicalRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast, PGMPHYSHANDLERTYPE hType,
438 RTR3PTR pvUserR3, RTR0PTR pvUserR0, RTRCPTR pvUserRC,
439 R3PTRTYPE(const char *) pszDesc);
440VMMDECL(int) PGMHandlerPhysicalModify(PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
441VMMDECL(int) PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys);
442VMMDECL(int) PGMHandlerPhysicalChangeUserArgs(PVM pVM, RTGCPHYS GCPhys, RTR3PTR pvUserR3, RTR0PTR pvUserR0, RTRCPTR pvUserRC);
443VMMDECL(int) PGMHandlerPhysicalSplit(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
444VMMDECL(int) PGMHandlerPhysicalJoin(PVM pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
445VMMDECL(int) PGMHandlerPhysicalPageTempOff(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
446VMMDECL(int) PGMHandlerPhysicalPageAlias(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTGCPHYS GCPhysPageRemap);
447VMMDECL(int) PGMHandlerPhysicalPageAliasHC(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTHCPHYS HCPhysPageRemap);
448VMMDECL(int) PGMHandlerPhysicalReset(PVM pVM, RTGCPHYS GCPhys);
449VMMDECL(bool) PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys);
450
451/** PGM virtual access handler type registration handle (heap offset, valid
452 * cross contexts without needing fixing up). Callbacks and handler type is
453 * associated with this and it is shared by all handler registrations. */
454typedef uint32_t PGMVIRTHANDLERTYPE;
455/** Pointer to a PGM virtual handler type registration handle. */
456typedef PGMVIRTHANDLERTYPE *PPGMVIRTHANDLERTYPE;
457/** NIL value for PGM virtual access handler type handle. */
458#define NIL_PGMVIRTHANDLERTYPE UINT32_MAX
459#ifdef VBOX_WITH_RAW_MODE
460VMM_INT_DECL(uint32_t) PGMHandlerVirtualTypeRelease(PVM pVM, PGMVIRTHANDLERTYPE hType);
461VMM_INT_DECL(uint32_t) PGMHandlerVirtualTypeRetain(PVM pVM, PGMVIRTHANDLERTYPE hType);
462VMM_INT_DECL(bool) PGMHandlerVirtualIsRegistered(PVM pVM, RTGCPTR GCPtr);
463#endif
464
465
466/**
467 * Page type.
468 *
469 * @remarks This enum has to fit in a 3-bit field (see PGMPAGE::u3Type).
470 * @remarks This is used in the saved state, so changes to it requires bumping
471 * the saved state version.
472 * @todo So, convert to \#defines!
473 */
474typedef enum PGMPAGETYPE
475{
476 /** The usual invalid zero entry. */
477 PGMPAGETYPE_INVALID = 0,
478 /** RAM page. (RWX) */
479 PGMPAGETYPE_RAM,
480 /** MMIO2 page. (RWX) */
481 PGMPAGETYPE_MMIO2,
482 /** MMIO2 page aliased over an MMIO page. (RWX)
483 * See PGMHandlerPhysicalPageAlias(). */
484 PGMPAGETYPE_MMIO2_ALIAS_MMIO,
485 /** Special page aliased over an MMIO page. (RWX)
486 * See PGMHandlerPhysicalPageAliasHC(), but this is generally only used for
487 * VT-x's APIC access page at the moment. Treated as MMIO by everyone except
488 * the shadow paging code. */
489 PGMPAGETYPE_SPECIAL_ALIAS_MMIO,
490 /** Shadowed ROM. (RWX) */
491 PGMPAGETYPE_ROM_SHADOW,
492 /** ROM page. (R-X) */
493 PGMPAGETYPE_ROM,
494 /** MMIO page. (---) */
495 PGMPAGETYPE_MMIO,
496 /** End of valid entries. */
497 PGMPAGETYPE_END
498} PGMPAGETYPE;
499AssertCompile(PGMPAGETYPE_END == 8);
500
501VMM_INT_DECL(PGMPAGETYPE) PGMPhysGetPageType(PVM pVM, RTGCPHYS GCPhys);
502
503VMM_INT_DECL(int) PGMPhysGCPhys2HCPhys(PVM pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
504VMM_INT_DECL(int) PGMPhysGCPtr2HCPhys(PVMCPU pVCpu, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
505VMM_INT_DECL(int) PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
506VMM_INT_DECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
507VMM_INT_DECL(int) PGMPhysGCPtr2CCPtr(PVMCPU pVCpu, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
508VMM_INT_DECL(int) PGMPhysGCPtr2CCPtrReadOnly(PVMCPU pVCpu, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
509
510VMMDECL(bool) PGMPhysIsA20Enabled(PVMCPU pVCpu);
511VMMDECL(bool) PGMPhysIsGCPhysValid(PVM pVM, RTGCPHYS GCPhys);
512VMMDECL(bool) PGMPhysIsGCPhysNormal(PVM pVM, RTGCPHYS GCPhys);
513VMMDECL(int) PGMPhysGCPtr2GCPhys(PVMCPU pVCpu, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
514VMMDECL(void) PGMPhysReleasePageMappingLock(PVM pVM, PPGMPAGEMAPLOCK pLock);
515
516/** @def PGM_PHYS_RW_IS_SUCCESS
517 * Check whether a PGMPhysRead, PGMPhysWrite, PGMPhysReadGCPtr or
518 * PGMPhysWriteGCPtr call completed the given task.
519 *
520 * @returns true if completed, false if not.
521 * @param a_rcStrict The status code.
522 * @sa IOM_SUCCESS
523 */
524#ifdef IN_RING3
525# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
526 ( (a_rcStrict) == VINF_SUCCESS \
527 || (a_rcStrict) == VINF_EM_DBG_STOP \
528 || (a_rcStrict) == VINF_EM_DBG_EVENT \
529 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
530 )
531#elif defined(IN_RING0)
532# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
533 ( (a_rcStrict) == VINF_SUCCESS \
534 || (a_rcStrict) == VINF_IOM_R3_MMIO_COMMIT_WRITE \
535 || (a_rcStrict) == VINF_EM_OFF \
536 || (a_rcStrict) == VINF_EM_SUSPEND \
537 || (a_rcStrict) == VINF_EM_RESET \
538 || (a_rcStrict) == VINF_EM_HALT \
539 || (a_rcStrict) == VINF_EM_DBG_STOP \
540 || (a_rcStrict) == VINF_EM_DBG_EVENT \
541 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
542 )
543#elif defined(IN_RC)
544# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
545 ( (a_rcStrict) == VINF_SUCCESS \
546 || (a_rcStrict) == VINF_IOM_R3_MMIO_COMMIT_WRITE \
547 || (a_rcStrict) == VINF_EM_OFF \
548 || (a_rcStrict) == VINF_EM_SUSPEND \
549 || (a_rcStrict) == VINF_EM_RESET \
550 || (a_rcStrict) == VINF_EM_HALT \
551 || (a_rcStrict) == VINF_SELM_SYNC_GDT \
552 || (a_rcStrict) == VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT \
553 || (a_rcStrict) == VINF_EM_DBG_STOP \
554 || (a_rcStrict) == VINF_EM_DBG_EVENT \
555 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
556 )
557#endif
558/** @def PGM_PHYS_RW_DO_UPDATE_STRICT_RC
559 * Updates the return code with a new result.
560 *
561 * Both status codes must be successes according to PGM_PHYS_RW_IS_SUCCESS.
562 *
563 * @param a_rcStrict The current return code, to be updated.
564 * @param a_rcStrict2 The new return code to merge in.
565 */
566#ifdef IN_RING3
567# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
568 do { \
569 Assert(rcStrict == VINF_SUCCESS); \
570 Assert(rcStrict2 == VINF_SUCCESS); \
571 } while (0)
572#elif defined(IN_RING0)
573# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
574 do { \
575 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict)); \
576 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict2)); \
577 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_LAST); \
578 if ((a_rcStrict2) == VINF_SUCCESS || (a_rcStrict) == (a_rcStrict2)) \
579 { /* likely */ } \
580 else if ( (a_rcStrict) == VINF_SUCCESS \
581 || (a_rcStrict) > (a_rcStrict2)) \
582 (a_rcStrict) = (a_rcStrict2); \
583 } while (0)
584#elif defined(IN_RC)
585# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
586 do { \
587 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict)); \
588 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict2)); \
589 AssertCompile(VINF_SELM_SYNC_GDT > VINF_EM_LAST); \
590 AssertCompile(VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT > VINF_EM_LAST); \
591 AssertCompile(VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT < VINF_SELM_SYNC_GDT); \
592 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_LAST); \
593 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_SELM_SYNC_GDT); \
594 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT); \
595 if ((a_rcStrict2) == VINF_SUCCESS || (a_rcStrict) == (a_rcStrict2)) \
596 { /* likely */ } \
597 else if ((a_rcStrict) == VINF_SUCCESS) \
598 (a_rcStrict) = (a_rcStrict2); \
599 else if ( ( (a_rcStrict) > (a_rcStrict2) \
600 && ( (a_rcStrict2) <= VINF_EM_RESET \
601 || (a_rcStrict) != VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT) ) \
602 || ( (a_rcStrict2) == VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT \
603 && (a_rcStrict) > VINF_EM_RESET) ) \
604 (a_rcStrict) = (a_rcStrict2); \
605 } while (0)
606#endif
607
608VMMDECL(VBOXSTRICTRC) PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
609VMMDECL(VBOXSTRICTRC) PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
610VMMDECL(VBOXSTRICTRC) PGMPhysReadGCPtr(PVMCPU pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, PGMACCESSORIGIN enmOrigin);
611VMMDECL(VBOXSTRICTRC) PGMPhysWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb, PGMACCESSORIGIN enmOrigin);
612
613VMMDECL(int) PGMPhysSimpleReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
614VMMDECL(int) PGMPhysSimpleWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
615VMMDECL(int) PGMPhysSimpleReadGCPtr(PVMCPU pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
616VMMDECL(int) PGMPhysSimpleWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
617VMMDECL(int) PGMPhysSimpleDirtyWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
618VMMDECL(int) PGMPhysInterpretedRead(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
619VMMDECL(int) PGMPhysInterpretedReadNoHandlers(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb, bool fRaiseTrap);
620VMMDECL(int) PGMPhysInterpretedWriteNoHandlers(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, bool fRaiseTrap);
621
622VMM_INT_DECL(int) PGMPhysIemGCPhys2Ptr(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers, void **ppv, PPGMPAGEMAPLOCK pLock);
623VMM_INT_DECL(int) PGMPhysIemQueryAccess(PVM pVM, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers);
624VMM_INT_DECL(int) PGMPhysIemGCPhys2PtrNoLock(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, uint64_t const volatile *puTlbPhysRev,
625#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
626 R3PTRTYPE(uint8_t *) *ppb,
627#else
628 R3R0PTRTYPE(uint8_t *) *ppb,
629#endif
630 uint64_t *pfTlb);
631/** @name Flags returned by PGMPhysIemGCPhys2PtrNoLock
632 * @{ */
633#define PGMIEMGCPHYS2PTR_F_NO_WRITE RT_BIT_32(3) /**< Not writable (IEMTLBE_F_PG_NO_WRITE). */
634#define PGMIEMGCPHYS2PTR_F_NO_READ RT_BIT_32(4) /**< Not readable (IEMTLBE_F_PG_NO_READ). */
635#define PGMIEMGCPHYS2PTR_F_NO_MAPPINGR3 RT_BIT_32(7) /**< No ring-3 mapping (IEMTLBE_F_NO_MAPPINGR3). */
636/** @} */
637
638#ifdef VBOX_STRICT
639VMMDECL(unsigned) PGMAssertHandlerAndFlagsInSync(PVM pVM);
640VMMDECL(unsigned) PGMAssertNoMappingConflicts(PVM pVM);
641VMMDECL(unsigned) PGMAssertCR3(PVM pVM, PVMCPU pVCpu, uint64_t cr3, uint64_t cr4);
642#endif /* VBOX_STRICT */
643
644#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE)
645VMMDECL(void) PGMRZDynMapStartAutoSet(PVMCPU pVCpu);
646VMMDECL(void) PGMRZDynMapReleaseAutoSet(PVMCPU pVCpu);
647VMMDECL(void) PGMRZDynMapFlushAutoSet(PVMCPU pVCpu);
648VMMDECL(uint32_t) PGMRZDynMapPushAutoSubset(PVMCPU pVCpu);
649VMMDECL(void) PGMRZDynMapPopAutoSubset(PVMCPU pVCpu, uint32_t iPrevSubset);
650#endif
651
652VMMDECL(int) PGMSetLargePageUsage(PVM pVM, bool fUseLargePages);
653
654/**
655 * Query large page usage state
656 *
657 * @returns 0 - disabled, 1 - enabled
658 * @param pVM The cross context VM structure.
659 */
660#define PGMIsUsingLargePages(pVM) ((pVM)->fUseLargePages)
661
662
663#ifdef IN_RC
664/** @defgroup grp_pgm_gc The PGM Guest Context API
665 * @{
666 */
667VMMRCDECL(int) PGMRCDynMapInit(PVM pVM);
668/** @} */
669#endif /* IN_RC */
670
671
672#ifdef IN_RING0
673/** @defgroup grp_pgm_r0 The PGM Host Context Ring-0 API
674 * @{
675 */
676VMMR0_INT_DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM, PVMCPU pVCpu);
677VMMR0_INT_DECL(int) PGMR0PhysFlushHandyPages(PVM pVM, PVMCPU pVCpu);
678VMMR0_INT_DECL(int) PGMR0PhysAllocateLargeHandyPage(PVM pVM, PVMCPU pVCpu);
679VMMR0_INT_DECL(int) PGMR0PhysSetupIommu(PVM pVM);
680VMMR0DECL(int) PGMR0SharedModuleCheck(PVM pVM, PGVM pGVM, VMCPUID idCpu, PGMMSHAREDMODULE pModule, PCRTGCPTR64 paRegionsGCPtrs);
681VMMR0DECL(int) PGMR0Trap0eHandlerNestedPaging(PVM pVM, PVMCPU pVCpu, PGMMODE enmShwPagingMode, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault);
682VMMR0DECL(VBOXSTRICTRC) PGMR0Trap0eHandlerNPMisconfig(PVM pVM, PVMCPU pVCpu, PGMMODE enmShwPagingMode, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, uint32_t uErr);
683# ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
684VMMR0DECL(int) PGMR0DynMapInit(void);
685VMMR0DECL(void) PGMR0DynMapTerm(void);
686VMMR0DECL(int) PGMR0DynMapInitVM(PVM pVM);
687VMMR0DECL(void) PGMR0DynMapTermVM(PVM pVM);
688VMMR0DECL(int) PGMR0DynMapAssertIntegrity(void);
689VMMR0DECL(bool) PGMR0DynMapStartOrMigrateAutoSet(PVMCPU pVCpu);
690VMMR0DECL(void) PGMR0DynMapMigrateAutoSet(PVMCPU pVCpu);
691# endif
692/** @} */
693#endif /* IN_RING0 */
694
695
696
697#ifdef IN_RING3
698/** @defgroup grp_pgm_r3 The PGM Host Context Ring-3 API
699 * @{
700 */
701VMMR3DECL(int) PGMR3Init(PVM pVM);
702VMMR3DECL(int) PGMR3InitDynMap(PVM pVM);
703VMMR3DECL(int) PGMR3InitFinalize(PVM pVM);
704VMMR3_INT_DECL(int) PGMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
705VMMR3DECL(void) PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
706VMMR3DECL(void) PGMR3ResetCpu(PVM pVM, PVMCPU pVCpu);
707VMMR3_INT_DECL(void) PGMR3Reset(PVM pVM);
708VMMR3_INT_DECL(void) PGMR3ResetNoMorePhysWritesFlag(PVM pVM);
709VMMR3_INT_DECL(void) PGMR3MemSetup(PVM pVM, bool fReset);
710VMMR3DECL(int) PGMR3Term(PVM pVM);
711VMMR3DECL(int) PGMR3LockCall(PVM pVM);
712VMMR3DECL(int) PGMR3ChangeMode(PVM pVM, PVMCPU pVCpu, PGMMODE enmGuestMode);
713
714VMMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
715VMMR3DECL(int) PGMR3PhysChangeMemBalloon(PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage);
716VMMR3DECL(int) PGMR3PhysWriteProtectRAM(PVM pVM);
717VMMR3DECL(int) PGMR3PhysEnumDirtyFTPages(PVM pVM, PFNPGMENUMDIRTYFTPAGES pfnEnum, void *pvUser);
718VMMR3DECL(uint32_t) PGMR3PhysGetRamRangeCount(PVM pVM);
719VMMR3DECL(int) PGMR3PhysGetRange(PVM pVM, uint32_t iRange, PRTGCPHYS pGCPhysStart, PRTGCPHYS pGCPhysLast,
720 const char **ppszDesc, bool *pfIsMmio);
721VMMR3DECL(int) PGMR3QueryMemoryStats(PUVM pUVM, uint64_t *pcbTotalMem, uint64_t *pcbPrivateMem, uint64_t *pcbSharedMem, uint64_t *pcbZeroMem);
722VMMR3DECL(int) PGMR3QueryGlobalMemoryStats(PUVM pUVM, uint64_t *pcbAllocMem, uint64_t *pcbFreeMem, uint64_t *pcbBallonedMem, uint64_t *pcbSharedMem);
723
724VMMR3DECL(int) PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMPHYSHANDLERTYPE hType,
725 RTR3PTR pvUserR3, RTR0PTR pvUserR0, RTRCPTR pvUserRC, const char *pszDesc);
726VMMR3DECL(int) PGMR3PhysMMIODeregister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb);
727VMMR3DECL(int) PGMR3PhysMMIO2Register(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc);
728VMMR3DECL(int) PGMR3PhysMMIO2Deregister(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion);
729VMMR3DECL(int) PGMR3PhysMMIO2Map(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
730VMMR3DECL(int) PGMR3PhysMMIO2Unmap(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
731VMMR3DECL(bool) PGMR3PhysMMIO2IsBase(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys);
732VMMR3DECL(int) PGMR3PhysMMIO2GetHCPhys(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, PRTHCPHYS pHCPhys);
733VMMR3DECL(int) PGMR3PhysMMIO2MapKernel(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, const char *pszDesc, PRTR0PTR pR0Ptr);
734
735/** @name PGMR3PhysRegisterRom flags.
736 * @{ */
737/** Inidicates that ROM shadowing should be enabled. */
738#define PGMPHYS_ROM_FLAGS_SHADOWED RT_BIT_32(0)
739/** Indicates that what pvBinary points to won't go away
740 * and can be used for strictness checks. */
741#define PGMPHYS_ROM_FLAGS_PERMANENT_BINARY RT_BIT_32(1)
742/** @} */
743
744VMMR3DECL(int) PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
745 const void *pvBinary, uint32_t cbBinary, uint32_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/** @name PGMR3MapPT flags.
750 * @{ */
751/** The mapping may be unmapped later. The default is permanent mappings. */
752#define PGMR3MAPPT_FLAGS_UNMAPPABLE RT_BIT(0)
753/** @} */
754VMMR3DECL(int) PGMR3MapPT(PVM pVM, RTGCPTR GCPtr, uint32_t cb, uint32_t fFlags, PFNPGMRELOCATE pfnRelocate, void *pvUser, const char *pszDesc);
755VMMR3DECL(int) PGMR3UnmapPT(PVM pVM, RTGCPTR GCPtr);
756VMMR3DECL(int) PGMR3FinalizeMappings(PVM pVM);
757VMMR3DECL(int) PGMR3MappingsSize(PVM pVM, uint32_t *pcb);
758VMMR3DECL(int) PGMR3MappingsFix(PVM pVM, RTGCPTR GCPtrBase, uint32_t cb);
759VMMR3DECL(int) PGMR3MappingsUnfix(PVM pVM);
760VMMR3DECL(bool) PGMR3MappingsNeedReFixing(PVM pVM);
761#if defined(VBOX_WITH_RAW_MODE) || HC_ARCH_BITS == 32 /* (latter for 64-bit guests on 32-bit hosts) */
762VMMR3DECL(int) PGMR3MapIntermediate(PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
763#endif
764VMMR3DECL(int) PGMR3MapRead(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
765
766VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegisterEx(PVM pVM, PGMPHYSHANDLERKIND enmKind,
767 PFNPGMPHYSHANDLER pfnHandlerR3,
768 R0PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR0,
769 R0PTRTYPE(PFNPGMRZPHYSPFHANDLER) pfnPfHandlerR0,
770 RCPTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerRC,
771 RCPTRTYPE(PFNPGMRZPHYSPFHANDLER) pfnPfHandlerRC,
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);
779#ifdef VBOX_WITH_RAW_MODE
780VMMR3_INT_DECL(int) PGMR3HandlerVirtualTypeRegisterEx(PVM pVM, PGMVIRTHANDLERKIND enmKind, bool fRelocUserRC,
781 PFNPGMR3VIRTINVALIDATE pfnInvalidateR3,
782 PFNPGMVIRTHANDLER pfnHandlerR3,
783 RCPTRTYPE(FNPGMVIRTHANDLER) pfnHandlerRC,
784 RCPTRTYPE(FNPGMRCVIRTPFHANDLER) pfnPfHandlerRC,
785 const char *pszDesc, PPGMVIRTHANDLERTYPE phType);
786VMMR3_INT_DECL(int) PGMR3HandlerVirtualTypeRegister(PVM pVM, PGMVIRTHANDLERKIND enmKind, bool fRelocUserRC,
787 PFNPGMR3VIRTINVALIDATE pfnInvalidateR3,
788 PFNPGMVIRTHANDLER pfnHandlerR3,
789 const char *pszHandlerRC, const char *pszPfHandlerRC, const char *pszDesc,
790 PPGMVIRTHANDLERTYPE phType);
791VMMR3_INT_DECL(int) PGMR3HandlerVirtualRegister(PVM pVM, PVMCPU pVCpu, PGMVIRTHANDLERTYPE hType, RTGCPTR GCPtr,
792 RTGCPTR GCPtrLast, void *pvUserR3, RTRCPTR pvUserRC, const char *pszDesc);
793VMMR3_INT_DECL(int) PGMHandlerVirtualChangeType(PVM pVM, RTGCPTR GCPtr, PGMVIRTHANDLERTYPE hNewType);
794VMMR3_INT_DECL(int) PGMHandlerVirtualDeregister(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, bool fHypervisor);
795#endif
796VMMR3DECL(int) PGMR3PoolGrow(PVM pVM);
797
798VMMR3DECL(int) PGMR3PhysTlbGCPhys2Ptr(PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **ppv);
799VMMR3DECL(uint8_t) PGMR3PhysReadU8(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
800VMMR3DECL(uint16_t) PGMR3PhysReadU16(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
801VMMR3DECL(uint32_t) PGMR3PhysReadU32(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
802VMMR3DECL(uint64_t) PGMR3PhysReadU64(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
803VMMR3DECL(void) PGMR3PhysWriteU8(PVM pVM, RTGCPHYS GCPhys, uint8_t Value, PGMACCESSORIGIN enmOrigin);
804VMMR3DECL(void) PGMR3PhysWriteU16(PVM pVM, RTGCPHYS GCPhys, uint16_t Value, PGMACCESSORIGIN enmOrigin);
805VMMR3DECL(void) PGMR3PhysWriteU32(PVM pVM, RTGCPHYS GCPhys, uint32_t Value, PGMACCESSORIGIN enmOrigin);
806VMMR3DECL(void) PGMR3PhysWriteU64(PVM pVM, RTGCPHYS GCPhys, uint64_t Value, PGMACCESSORIGIN enmOrigin);
807VMMR3DECL(int) PGMR3PhysReadExternal(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
808VMMR3DECL(int) PGMR3PhysWriteExternal(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
809VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrExternal(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
810VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrReadOnlyExternal(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
811VMMR3DECL(int) PGMR3PhysChunkMap(PVM pVM, uint32_t idChunk);
812VMMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM);
813VMMR3DECL(int) PGMR3PhysAllocateHandyPages(PVM pVM);
814VMMR3DECL(int) PGMR3PhysAllocateLargeHandyPage(PVM pVM, RTGCPHYS GCPhys);
815
816VMMR3DECL(int) PGMR3CheckIntegrity(PVM pVM);
817
818VMMR3DECL(int) PGMR3DbgR3Ptr2GCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTGCPHYS pGCPhys);
819VMMR3DECL(int) PGMR3DbgR3Ptr2HCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTHCPHYS pHCPhys);
820VMMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PUVM pUVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
821VMMR3_INT_DECL(int) PGMR3DbgReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
822VMMR3_INT_DECL(int) PGMR3DbgWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
823VMMR3_INT_DECL(int) PGMR3DbgReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
824VMMR3_INT_DECL(int) PGMR3DbgWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
825VMMR3_INT_DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, RTGCPHYS GCPhysAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
826VMMR3_INT_DECL(int) PGMR3DbgScanVirtual(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, RTGCPTR cbRange, RTGCPTR GCPtrAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
827VMMR3_INT_DECL(int) PGMR3DumpHierarchyShw(PVM pVM, uint64_t cr3, uint32_t fFlags, uint64_t u64FirstAddr, uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
828VMMR3_INT_DECL(int) PGMR3DumpHierarchyGst(PVM pVM, uint64_t cr3, uint32_t fFlags, RTGCPTR FirstAddr, RTGCPTR LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
829
830
831/** @name Page sharing
832 * @{ */
833VMMR3DECL(int) PGMR3SharedModuleRegister(PVM pVM, VBOXOSFAMILY enmGuestOS, char *pszModuleName, char *pszVersion,
834 RTGCPTR GCBaseAddr, uint32_t cbModule,
835 uint32_t cRegions, VMMDEVSHAREDREGIONDESC const *paRegions);
836VMMR3DECL(int) PGMR3SharedModuleUnregister(PVM pVM, char *pszModuleName, char *pszVersion,
837 RTGCPTR GCBaseAddr, uint32_t cbModule);
838VMMR3DECL(int) PGMR3SharedModuleCheckAll(PVM pVM);
839VMMR3DECL(int) PGMR3SharedModuleGetPageState(PVM pVM, RTGCPTR GCPtrPage, bool *pfShared, uint64_t *pfPageFlags);
840/** @} */
841
842/** @} */
843#endif /* IN_RING3 */
844
845RT_C_DECLS_END
846
847/** @} */
848#endif
849
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