VirtualBox

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

Last change on this file since 96927 was 96735, checked in by vboxsync, 2 years ago

VMM: Nested VMX: bugref:10092 Added newer EPT paging bits into PGMPTATTRS. Adjusted some parameter names of PGMR0NestedTrap0eHandlerNestedPaging.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 54.3 KB
Line 
1/** @file
2 * PGM - Page Monitor / Monitor.
3 */
4
5/*
6 * Copyright (C) 2006-2022 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef VBOX_INCLUDED_vmm_pgm_h
37#define VBOX_INCLUDED_vmm_pgm_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <VBox/types.h>
43#include <VBox/sup.h>
44#include <VBox/vmm/vmapi.h>
45#include <VBox/vmm/gmm.h> /* for PGMMREGISTERSHAREDMODULEREQ */
46#include <VBox/vmm/hm_vmx.h>
47#include <iprt/x86.h>
48#include <VBox/param.h>
49
50RT_C_DECLS_BEGIN
51
52/** @defgroup grp_pgm The Page Monitor / Manager API
53 * @ingroup grp_vmm
54 * @{
55 */
56
57/**
58 * FNPGMRELOCATE callback mode.
59 */
60typedef enum PGMRELOCATECALL
61{
62 /** The callback is for checking if the suggested address is suitable. */
63 PGMRELOCATECALL_SUGGEST = 1,
64 /** The callback is for executing the relocation. */
65 PGMRELOCATECALL_RELOCATE
66} PGMRELOCATECALL;
67
68
69/**
70 * Callback function which will be called when PGM is trying to find
71 * a new location for the mapping.
72 *
73 * The callback is called in two modes, 1) the check mode and 2) the relocate mode.
74 * In 1) the callback should say if it objects to a suggested new location. If it
75 * accepts the new location, it is called again for doing it's relocation.
76 *
77 *
78 * @returns true if the location is ok.
79 * @returns false if another location should be found.
80 * @param pVM The cross context VM structure.
81 * @param GCPtrOld The old virtual address.
82 * @param GCPtrNew The new virtual address.
83 * @param enmMode Used to indicate the callback mode.
84 * @param pvUser User argument.
85 * @remark The return value is no a failure indicator, it's an acceptance
86 * indicator. Relocation can not fail!
87 */
88typedef DECLCALLBACKTYPE(bool, FNPGMRELOCATE,(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser));
89/** Pointer to a relocation callback function. */
90typedef FNPGMRELOCATE *PFNPGMRELOCATE;
91
92
93/**
94 * Memory access origin.
95 */
96typedef enum PGMACCESSORIGIN
97{
98 /** Invalid zero value. */
99 PGMACCESSORIGIN_INVALID = 0,
100 /** IEM is access memory. */
101 PGMACCESSORIGIN_IEM,
102 /** HM is access memory. */
103 PGMACCESSORIGIN_HM,
104 /** Some device is access memory. */
105 PGMACCESSORIGIN_DEVICE,
106 /** Someone debugging is access memory. */
107 PGMACCESSORIGIN_DEBUGGER,
108 /** SELM is access memory. */
109 PGMACCESSORIGIN_SELM,
110 /** FTM is access memory. */
111 PGMACCESSORIGIN_FTM,
112 /** REM is access memory. */
113 PGMACCESSORIGIN_REM,
114 /** IOM is access memory. */
115 PGMACCESSORIGIN_IOM,
116 /** End of valid values. */
117 PGMACCESSORIGIN_END,
118 /** Type size hack. */
119 PGMACCESSORIGIN_32BIT_HACK = 0x7fffffff
120} PGMACCESSORIGIN;
121
122
123/**
124 * Physical page access handler kind.
125 */
126typedef enum PGMPHYSHANDLERKIND
127{
128 /** Invalid zero value. */
129 PGMPHYSHANDLERKIND_INVALID = 0,
130 /** MMIO range. Pages are not present, all access is done in interpreter or recompiler. */
131 PGMPHYSHANDLERKIND_MMIO,
132 /** Handler all write access to a physical page range. */
133 PGMPHYSHANDLERKIND_WRITE,
134 /** Handler all access to a physical page range. */
135 PGMPHYSHANDLERKIND_ALL,
136 /** End of the valid values. */
137 PGMPHYSHANDLERKIND_END,
138 /** Type size hack. */
139 PGMPHYSHANDLERKIND_32BIT_HACK = 0x7fffffff
140} PGMPHYSHANDLERKIND;
141
142/**
143 * Guest Access type
144 */
145typedef enum PGMACCESSTYPE
146{
147 /** Read access. */
148 PGMACCESSTYPE_READ = 1,
149 /** Write access. */
150 PGMACCESSTYPE_WRITE
151} PGMACCESSTYPE;
152
153
154/** @def PGM_ALL_CB_DECL
155 * Macro for declaring a handler callback for all contexts. The handler
156 * callback is static in ring-3, and exported in RC and R0.
157 * @sa PGM_ALL_CB2_DECL.
158 */
159#if defined(IN_RC) || defined(IN_RING0)
160# ifdef __cplusplus
161# define PGM_ALL_CB_DECL(type) extern "C" DECLCALLBACK(DECLEXPORT(type))
162# else
163# define PGM_ALL_CB_DECL(type) DECLCALLBACK(DECLEXPORT(type))
164# endif
165#else
166# define PGM_ALL_CB_DECL(type) static DECLCALLBACK(type)
167#endif
168
169/** @def PGM_ALL_CB2_DECL
170 * Macro for declaring a handler callback for all contexts. The handler
171 * callback is hidden in ring-3, and exported in RC and R0.
172 * @sa PGM_ALL_CB2_DECL.
173 */
174#if defined(IN_RC) || defined(IN_RING0)
175# ifdef __cplusplus
176# define PGM_ALL_CB2_DECL(type) extern "C" DECLCALLBACK(DECLEXPORT(type))
177# else
178# define PGM_ALL_CB2_DECL(type) DECLCALLBACK(DECLEXPORT(type))
179# endif
180#else
181# define PGM_ALL_CB2_DECL(type) DECL_HIDDEN_CALLBACK(type)
182#endif
183
184/** @def PGM_ALL_CB2_PROTO
185 * Macro for declaring a handler callback for all contexts. The handler
186 * callback is hidden in ring-3, and exported in RC and R0.
187 * @param fnType The callback function type.
188 * @sa PGM_ALL_CB2_DECL.
189 */
190#if defined(IN_RC) || defined(IN_RING0)
191# ifdef __cplusplus
192# define PGM_ALL_CB2_PROTO(fnType) extern "C" DECLEXPORT(fnType)
193# else
194# define PGM_ALL_CB2_PROTO(fnType) DECLEXPORT(fnType)
195# endif
196#else
197# define PGM_ALL_CB2_PROTO(fnType) DECLHIDDEN(fnType)
198#endif
199
200
201/**
202 * \#PF Handler callback for physical access handler ranges in RC and R0.
203 *
204 * @returns Strict VBox status code (appropriate for ring-0 and raw-mode).
205 * @param pVM The cross context VM structure.
206 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
207 * @param uErrorCode CPU Error code.
208 * @param pRegFrame Trap register frame.
209 * NULL on DMA and other non CPU access.
210 * @param pvFault The fault address (cr2).
211 * @param GCPhysFault The GC physical address corresponding to pvFault.
212 * @param uUser User argument (not a pointer).
213 * @thread EMT(pVCpu)
214 */
215typedef DECLCALLBACKTYPE(VBOXSTRICTRC, FNPGMRZPHYSPFHANDLER,(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
216 RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser));
217/** Pointer to PGM access callback. */
218typedef FNPGMRZPHYSPFHANDLER *PFNPGMRZPHYSPFHANDLER;
219
220
221/**
222 * Access handler callback for physical access handler ranges.
223 *
224 * The handler can not raise any faults, it's mainly for monitoring write access
225 * to certain pages (like MMIO).
226 *
227 * @returns Strict VBox status code in ring-0 and raw-mode context, in ring-3
228 * the only supported informational status code is
229 * VINF_PGM_HANDLER_DO_DEFAULT.
230 * @retval VINF_SUCCESS if the handler have carried out the operation.
231 * @retval VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the
232 * access operation.
233 * @retval VINF_EM_XXX in ring-0 and raw-mode context.
234 *
235 * @param pVM The cross context VM structure.
236 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
237 * @param GCPhys The physical address the guest is writing to.
238 * @param pvPhys The HC mapping of that address.
239 * @param pvBuf What the guest is reading/writing.
240 * @param cbBuf How much it's reading/writing.
241 * @param enmAccessType The access type.
242 * @param enmOrigin The origin of this call.
243 * @param uUser User argument (not a pointer).
244 * @thread EMT(pVCpu)
245 */
246typedef DECLCALLBACKTYPE(VBOXSTRICTRC, FNPGMPHYSHANDLER,(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys,
247 void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType,
248 PGMACCESSORIGIN enmOrigin, uint64_t uUser));
249/** Pointer to PGM access callback. */
250typedef FNPGMPHYSHANDLER *PFNPGMPHYSHANDLER;
251
252
253/**
254 * Paging mode.
255 *
256 * @note Part of saved state. Change with extreme care.
257 */
258typedef enum PGMMODE
259{
260 /** The usual invalid value. */
261 PGMMODE_INVALID = 0,
262 /** Real mode. */
263 PGMMODE_REAL,
264 /** Protected mode, no paging. */
265 PGMMODE_PROTECTED,
266 /** 32-bit paging. */
267 PGMMODE_32_BIT,
268 /** PAE paging. */
269 PGMMODE_PAE,
270 /** PAE paging with NX enabled. */
271 PGMMODE_PAE_NX,
272 /** 64-bit AMD paging (long mode). */
273 PGMMODE_AMD64,
274 /** 64-bit AMD paging (long mode) with NX enabled. */
275 PGMMODE_AMD64_NX,
276 /** 32-bit nested paging mode (shadow only; guest physical to host physical). */
277 PGMMODE_NESTED_32BIT,
278 /** PAE nested paging mode (shadow only; guest physical to host physical). */
279 PGMMODE_NESTED_PAE,
280 /** AMD64 nested paging mode (shadow only; guest physical to host physical). */
281 PGMMODE_NESTED_AMD64,
282 /** Extended paging (Intel) mode. */
283 PGMMODE_EPT,
284 /** Special mode used by NEM to indicate no shadow paging necessary. */
285 PGMMODE_NONE,
286 /** The max number of modes */
287 PGMMODE_MAX,
288 /** 32bit hackishness. */
289 PGMMODE_32BIT_HACK = 0x7fffffff
290} PGMMODE;
291
292/**
293 * Second level address translation (SLAT) mode.
294 */
295typedef enum PGMSLAT
296{
297 /** The usual invalid value. */
298 PGMSLAT_INVALID = 0,
299 /** No second level translation. */
300 PGMSLAT_DIRECT,
301 /** Intel Extended Page Tables (EPT). */
302 PGMSLAT_EPT,
303 /** AMD-V Nested Paging 32-bit. */
304 PGMSLAT_32BIT,
305 /** AMD-V Nested Paging PAE. */
306 PGMSLAT_PAE,
307 /** AMD-V Nested Paging 64-bit. */
308 PGMSLAT_AMD64,
309 /** 32bit hackishness. */
310 PGMSLAT_32BIT_HACK = 0x7fffffff
311} PGMSLAT;
312
313
314/** @name PGMPTWALK::fFailed flags.
315 * These flags indicate the type of a page-walk failure.
316 * @{
317 */
318typedef uint32_t PGMWALKFAIL;
319/** Regular page fault (MBZ since guest Walk code don't set these explicitly). */
320#define PGM_WALKFAIL_PAGE_FAULT UINT32_C(0)
321/** EPT violation - Intel. */
322#define PGM_WALKFAIL_EPT_VIOLATION RT_BIT_32(0)
323/** EPT violation, convertible to \#VE exception - Intel. */
324#define PGM_WALKFAIL_EPT_VIOLATION_CONVERTIBLE RT_BIT_32(1)
325/** EPT misconfiguration - Intel. */
326#define PGM_WALKFAIL_EPT_MISCONFIG RT_BIT_32(2)
327
328/** Mask of all EPT induced page-walk failures - Intel. */
329#define PGM_WALKFAIL_EPT ( PGM_WALKFAIL_EPT_VIOLATION \
330 | PGM_WALKFAIL_EPT_VIOLATION_CONVERTIBLE \
331 | PGM_WALKFAIL_EPT_MISCONFIG)
332/** @} */
333
334
335/** @name PGMPTATTRS - PGM page-table attributes.
336 *
337 * This is VirtualBox's combined page table attributes. It combines regular page
338 * table and Intel EPT attributes. It's 64-bit in size so there's ample room for
339 * bits added in the future to EPT or regular page tables (for e.g. Protection Key).
340 *
341 * The following bits map 1:1 (shifted by PGM_PTATTRS_EPT_SHIFT) to the Intel EPT
342 * attributes as these are unique to EPT and fit within 64-bits despite the shift:
343 * - EPT_R : Read access.
344 * - EPT_W : Write access.
345 * - EPT_X_SUPER : Execute or execute for supervisor-mode linear addr access.
346 * - EPT_MEMTYPE : EPT memory type.
347 * - EPT_IGNORE_PAT: Ignore PAT memory type.
348 * - EPT_X_USER : Execute access for user-mode linear addresses.
349 *
350 * For regular page tables, the R bit is always 1 (same as P bit).
351 * For Intel EPT, the EPT_R and EPT_W bits are copied to R and W bits respectively.
352 *
353 * The following EPT attributes are mapped to the following positions because they
354 * exist in the regular page tables at these positions OR are exclusive to EPT and
355 * have been mapped to arbitrarily chosen positions:
356 * - EPT_A : Accessed (EPT bit 8 maps to bit 5).
357 * - EPT_D : Dirty (EPT bit 9 maps to bit 6).
358 * - EPT_SUPER_SHW_STACK : Supervisor Shadow Stack (EPT bit 60 maps to bit 24).
359 * - EPT_SUPPRESS_VE_XCPT: Suppress \#VE exception (EPT bit 63 maps to bit 25).
360 *
361 * Bits 12, 11:9 and 43 are deliberately kept unused (correspond to bit PS and bits
362 * 11:9 in the regular page-table structures and to bit 11 in the EPT structures
363 * respectively) as bit 12 is the page-size bit and bits 11:9 are reserved for
364 * use by software and we may want to use/preserve them in the future.
365 *
366 * @{ */
367typedef uint64_t PGMPTATTRS;
368/** Pointer to a PGMPTATTRS type. */
369typedef PGMPTATTRS *PPGMPTATTRS;
370
371/** Read bit (always 1 for regular PT, copy of EPT_R for EPT). */
372#define PGM_PTATTRS_R_SHIFT 0
373#define PGM_PTATTRS_R_MASK RT_BIT_64(PGM_PTATTRS_R_SHIFT)
374/** Write access bit (aka read/write bit for regular PT). */
375#define PGM_PTATTRS_W_SHIFT 1
376#define PGM_PTATTRS_W_MASK RT_BIT_64(PGM_PTATTRS_W_SHIFT)
377/** User-mode access bit. */
378#define PGM_PTATTRS_US_SHIFT 2
379#define PGM_PTATTRS_US_MASK RT_BIT_64(PGM_PTATTRS_US_SHIFT)
380/** Write through cache bit. */
381#define PGM_PTATTRS_PWT_SHIFT 3
382#define PGM_PTATTRS_PWT_MASK RT_BIT_64(PGM_PTATTRS_PWT_SHIFT)
383/** Cache disabled bit. */
384#define PGM_PTATTRS_PCD_SHIFT 4
385#define PGM_PTATTRS_PCD_MASK RT_BIT_64(PGM_PTATTRS_PCD_SHIFT)
386/** Accessed bit. */
387#define PGM_PTATTRS_A_SHIFT 5
388#define PGM_PTATTRS_A_MASK RT_BIT_64(PGM_PTATTRS_A_SHIFT)
389/** Dirty bit. */
390#define PGM_PTATTRS_D_SHIFT 6
391#define PGM_PTATTRS_D_MASK RT_BIT_64(PGM_PTATTRS_D_SHIFT)
392/** The PAT bit. */
393#define PGM_PTATTRS_PAT_SHIFT 7
394#define PGM_PTATTRS_PAT_MASK RT_BIT_64(PGM_PTATTRS_PAT_SHIFT)
395/** The global bit. */
396#define PGM_PTATTRS_G_SHIFT 8
397#define PGM_PTATTRS_G_MASK RT_BIT_64(PGM_PTATTRS_G_SHIFT)
398/** Reserved (bits 12:9) unused. */
399#define PGM_PTATTRS_RSVD_12_9_SHIFT 9
400#define PGM_PTATTRS_RSVD_12_9_MASK UINT64_C(0x0000000000001e00)
401/** Read access bit - EPT only. */
402#define PGM_PTATTRS_EPT_R_SHIFT 13
403#define PGM_PTATTRS_EPT_R_MASK RT_BIT_64(PGM_PTATTRS_EPT_R_SHIFT)
404/** Write access bit - EPT only. */
405#define PGM_PTATTRS_EPT_W_SHIFT 14
406#define PGM_PTATTRS_EPT_W_MASK RT_BIT_64(PGM_PTATTRS_EPT_W_SHIFT)
407/** Execute or execute access for supervisor-mode linear addresses - EPT only. */
408#define PGM_PTATTRS_EPT_X_SUPER_SHIFT 15
409#define PGM_PTATTRS_EPT_X_SUPER_MASK RT_BIT_64(PGM_PTATTRS_EPT_X_SUPER_SHIFT)
410/** EPT memory type - EPT only. */
411#define PGM_PTATTRS_EPT_MEMTYPE_SHIFT 16
412#define PGM_PTATTRS_EPT_MEMTYPE_MASK UINT64_C(0x0000000000070000)
413/** Ignore PAT memory type - EPT only. */
414#define PGM_PTATTRS_EPT_IGNORE_PAT_SHIFT 19
415#define PGM_PTATTRS_EPT_IGNORE_PAT_MASK RT_BIT_64(PGM_PTATTRS_EPT_IGNORE_PAT_SHIFT)
416/** Leaf paging entry (big or regular) - EPT only. */
417#define PGM_PTATTRS_EPT_LEAF_SHIFT 20
418#define PGM_PTATTRS_EPT_LEAF_MASK RT_BIT_64(PGM_PTATTRS_EPT_LEAF_SHIFT)
419/** Accessed bit - EPT only. */
420#define PGM_PTATTRS_EPT_A_SHIFT 21
421#define PGM_PTATTRS_EPT_A_MASK RT_BIT_64(PGM_PTATTRS_EPT_A_SHIFT)
422/** Dirty bit - EPT only. */
423#define PGM_PTATTRS_EPT_D_SHIFT 22
424#define PGM_PTATTRS_EPT_D_MASK RT_BIT_64(PGM_PTATTRS_EPT_D_SHIFT)
425/** Execute access for user-mode linear addresses - EPT only. */
426#define PGM_PTATTRS_EPT_X_USER_SHIFT 23
427#define PGM_PTATTRS_EPT_X_USER_MASK RT_BIT_64(PGM_PTATTRS_EPT_X_USER_SHIFT)
428/** Reserved (bits 29:24) - unused. */
429#define PGM_PTATTRS_RSVD_29_24_SHIFT 24
430#define PGM_PTATTRS_RSVD_29_24_MASK UINT64_C(0x000000003f000000)
431/** Verify Guest Paging - EPT only. */
432#define PGM_PTATTRS_EPT_VGP_SHIFT 30
433#define PGM_PTATTRS_EPT_VGP_MASK RT_BIT_64(PGM_PTATTRS_EPT_VGP_SHIFT)
434/** Paging-write - EPT only. */
435#define PGM_PTATTRS_EPT_PW_SHIFT 31
436#define PGM_PTATTRS_EPT_PW_MASK RT_BIT_64(PGM_PTATTRS_EPT_PW_SHIFT)
437/** Reserved (bit 32) - unused. */
438#define PGM_PTATTRS_RSVD_32_SHIFT 32
439#define PGM_PTATTRS_RSVD_32_MASK UINT64_C(0x0000000100000000)
440/** Supervisor shadow stack - EPT only. */
441#define PGM_PTATTRS_EPT_SSS_SHIFT 33
442#define PGM_PTATTRS_EPT_SSS_MASK RT_BIT_64(PGM_PTATTRS_EPT_SSS_SHIFT)
443/** Sub-page write permission - EPT only. */
444#define PGM_PTATTRS_EPT_SPP_SHIFT 34
445#define PGM_PTATTRS_EPT_SPP_MASK RT_BIT_64(PGM_PTATTRS_EPT_SPP_SHIFT)
446/** Reserved (bit 35) - unused. */
447#define PGM_PTATTRS_RSVD_35_SHIFT 35
448#define PGM_PTATTRS_RSVD_35_MASK UINT64_C(0x0000000800000000)
449/** Suppress \#VE exception - EPT only. */
450#define PGM_PTATTRS_EPT_SVE_SHIFT 36
451#define PGM_PTATTRS_EPT_SVE_MASK RT_BIT_64(PGM_PTATTRS_EPT_SVE_SHIFT)
452/** Reserved (bits 62:37) - unused. */
453#define PGM_PTATTRS_RSVD_62_37_SHIFT 37
454#define PGM_PTATTRS_RSVD_62_37_MASK UINT64_C(0x7fffffe000000000)
455/** No-execute bit. */
456#define PGM_PTATTRS_NX_SHIFT 63
457#define PGM_PTATTRS_NX_MASK RT_BIT_64(PGM_PTATTRS_NX_SHIFT)
458
459RT_BF_ASSERT_COMPILE_CHECKS(PGM_PTATTRS_, UINT64_C(0), UINT64_MAX,
460 (R, W, US, PWT, PCD, A, D, PAT, G, RSVD_12_9, EPT_R, EPT_W, EPT_X_SUPER, EPT_MEMTYPE, EPT_IGNORE_PAT,
461 EPT_LEAF, EPT_A, EPT_D, EPT_X_USER, RSVD_29_24, EPT_VGP, EPT_PW, RSVD_32, EPT_SSS, EPT_SPP,
462 RSVD_35, EPT_SVE, RSVD_62_37, NX));
463
464/** The bit position where the EPT specific attributes begin. */
465#define PGM_PTATTRS_EPT_SHIFT PGM_PTATTRS_EPT_R_SHIFT
466/** The mask of EPT bits (bits 36:ATTR_SHIFT). In the future we might choose to
467 * use higher unused bits for something else, in that case adjust this mask. */
468#define PGM_PTATTRS_EPT_MASK UINT64_C(0x0000001fffffe000)
469
470/** The mask of all PGM page attribute bits for regular page-tables. */
471#define PGM_PTATTRS_PT_VALID_MASK ( PGM_PTATTRS_R_MASK \
472 | PGM_PTATTRS_W_MASK \
473 | PGM_PTATTRS_US_MASK \
474 | PGM_PTATTRS_PWT_MASK \
475 | PGM_PTATTRS_PCD_MASK \
476 | PGM_PTATTRS_A_MASK \
477 | PGM_PTATTRS_D_MASK \
478 | PGM_PTATTRS_PAT_MASK \
479 | PGM_PTATTRS_G_MASK \
480 | PGM_PTATTRS_NX_MASK)
481
482/** The mask of all PGM page attribute bits for EPT. */
483#define PGM_PTATTRS_EPT_VALID_MASK ( PGM_PTATTRS_EPT_R_MASK \
484 | PGM_PTATTRS_EPT_W_MASK \
485 | PGM_PTATTRS_EPT_X_SUPER_MASK \
486 | PGM_PTATTRS_EPT_MEMTYPE_MASK \
487 | PGM_PTATTRS_EPT_IGNORE_PAT_MASK \
488 | PGM_PTATTRS_EPT_LEAF_MASK \
489 | PGM_PTATTRS_EPT_A_MASK \
490 | PGM_PTATTRS_EPT_D_MASK \
491 | PGM_PTATTRS_EPT_X_USER_MASK \
492 | PGM_PTATTRS_EPT_VGP_MASK \
493 | PGM_PTATTRS_EPT_PW_MASK \
494 | PGM_PTATTRS_EPT_SSS_MASK \
495 | PGM_PTATTRS_EPT_SPP_MASK \
496 | PGM_PTATTRS_EPT_SVE_MASK)
497
498/* The mask of all PGM page attribute bits (combined). */
499#define PGM_PTATTRS_VALID_MASK (PGM_PTATTRS_PT_VALID_MASK | PGM_PTATTRS_EPT_VALID_MASK)
500
501/* Verify bits match the regular PT bits. */
502AssertCompile(PGM_PTATTRS_W_SHIFT == X86_PTE_BIT_RW);
503AssertCompile(PGM_PTATTRS_US_SHIFT == X86_PTE_BIT_US);
504AssertCompile(PGM_PTATTRS_PWT_SHIFT == X86_PTE_BIT_PWT);
505AssertCompile(PGM_PTATTRS_PCD_SHIFT == X86_PTE_BIT_PCD);
506AssertCompile(PGM_PTATTRS_A_SHIFT == X86_PTE_BIT_A);
507AssertCompile(PGM_PTATTRS_D_SHIFT == X86_PTE_BIT_D);
508AssertCompile(PGM_PTATTRS_PAT_SHIFT == X86_PTE_BIT_PAT);
509AssertCompile(PGM_PTATTRS_G_SHIFT == X86_PTE_BIT_G);
510AssertCompile(PGM_PTATTRS_W_MASK == X86_PTE_RW);
511AssertCompile(PGM_PTATTRS_US_MASK == X86_PTE_US);
512AssertCompile(PGM_PTATTRS_PWT_MASK == X86_PTE_PWT);
513AssertCompile(PGM_PTATTRS_PCD_MASK == X86_PTE_PCD);
514AssertCompile(PGM_PTATTRS_A_MASK == X86_PTE_A);
515AssertCompile(PGM_PTATTRS_D_MASK == X86_PTE_D);
516AssertCompile(PGM_PTATTRS_PAT_MASK == X86_PTE_PAT);
517AssertCompile(PGM_PTATTRS_G_MASK == X86_PTE_G);
518AssertCompile(PGM_PTATTRS_NX_MASK == X86_PTE_PAE_NX);
519
520/* Verify those EPT bits that must map 1:1 (after shifting). */
521AssertCompile(PGM_PTATTRS_EPT_R_SHIFT - PGM_PTATTRS_EPT_SHIFT == EPT_E_BIT_READ);
522AssertCompile(PGM_PTATTRS_EPT_W_SHIFT - PGM_PTATTRS_EPT_SHIFT == EPT_E_BIT_WRITE);
523AssertCompile(PGM_PTATTRS_EPT_X_SUPER_SHIFT - PGM_PTATTRS_EPT_SHIFT == EPT_E_BIT_EXECUTE);
524AssertCompile(PGM_PTATTRS_EPT_IGNORE_PAT_SHIFT - PGM_PTATTRS_EPT_SHIFT == EPT_E_BIT_IGNORE_PAT);
525AssertCompile(PGM_PTATTRS_EPT_X_USER_SHIFT - PGM_PTATTRS_EPT_SHIFT == EPT_E_BIT_USER_EXECUTE);
526/** @} */
527
528
529/**
530 * Page table walk information.
531 *
532 * This provides extensive information regarding page faults (or EPT
533 * violations/misconfigurations) while traversing page tables.
534 */
535typedef struct PGMPTWALK
536{
537 /** The linear address that is being resolved (input). */
538 RTGCPTR GCPtr;
539
540 /** The second-level physical address (input/output).
541 * @remarks only valid if fIsSlat is set. */
542 RTGCPHYS GCPhysNested;
543
544 /** The physical address that is the result of the walk (output). */
545 RTGCPHYS GCPhys;
546
547 /** Set if the walk succeeded. */
548 bool fSucceeded;
549 /** Whether this is a second-level address translation. */
550 bool fIsSlat;
551 /** Whether the linear address (GCPtr) caused the second-level
552 * address translation. */
553 bool fIsLinearAddrValid;
554 /** The level problem arrised at.
555 * PTE is level 1, PDE is level 2, PDPE is level 3, PML4 is level 4, CR3 is
556 * level 8. This is 0 on success. */
557 uint8_t uLevel;
558 /** Set if the page isn't present. */
559 bool fNotPresent;
560 /** Encountered a bad physical address. */
561 bool fBadPhysAddr;
562 /** Set if there was reserved bit violations. */
563 bool fRsvdError;
564 /** Set if it involves a big page (2/4 MB). */
565 bool fBigPage;
566 /** Set if it involves a gigantic page (1 GB). */
567 bool fGigantPage;
568 bool afPadding[3];
569 /** Page-walk failure type, PGM_WALKFAIL_XXX. */
570 PGMWALKFAIL fFailed;
571
572 /** The effective page-table attributes, PGM_PTATTRS_XXX. */
573 PGMPTATTRS fEffective;
574} PGMPTWALK;
575/** Pointer to page walk information. */
576typedef PGMPTWALK *PPGMPTWALK;
577/** Pointer to const page walk information. */
578typedef PGMPTWALK const *PCPGMPTWALK;
579
580
581/** Macro for checking if the guest is using paging.
582 * @param enmMode PGMMODE_*.
583 * @remark ASSUMES certain order of the PGMMODE_* values.
584 */
585#define PGMMODE_WITH_PAGING(enmMode) ((enmMode) >= PGMMODE_32_BIT)
586
587/** Macro for checking if it's one of the long mode modes.
588 * @param enmMode PGMMODE_*.
589 */
590#define PGMMODE_IS_LONG_MODE(enmMode) ((enmMode) == PGMMODE_AMD64_NX || (enmMode) == PGMMODE_AMD64)
591
592/** Macro for checking if it's one of the AMD64 nested modes.
593 * @param enmMode PGMMODE_*.
594 */
595#define PGMMODE_IS_NESTED(enmMode) ( (enmMode) == PGMMODE_NESTED_32BIT \
596 || (enmMode) == PGMMODE_NESTED_PAE \
597 || (enmMode) == PGMMODE_NESTED_AMD64)
598
599/** Macro for checking if it's one of the PAE modes.
600 * @param enmMode PGMMODE_*.
601 */
602#define PGMMODE_IS_PAE(enmMode) ( (enmMode) == PGMMODE_PAE \
603 || (enmMode) == PGMMODE_PAE_NX)
604
605/**
606 * Is the ROM mapped (true) or is the shadow RAM mapped (false).
607 *
608 * @returns boolean.
609 * @param enmProt The PGMROMPROT value, must be valid.
610 */
611#define PGMROMPROT_IS_ROM(enmProt) \
612 ( (enmProt) == PGMROMPROT_READ_ROM_WRITE_IGNORE \
613 || (enmProt) == PGMROMPROT_READ_ROM_WRITE_RAM )
614
615
616VMMDECL(bool) PGMIsLockOwner(PVMCC pVM);
617
618VMMDECL(int) PGMRegisterStringFormatTypes(void);
619VMMDECL(void) PGMDeregisterStringFormatTypes(void);
620VMMDECL(RTHCPHYS) PGMGetHyperCR3(PVMCPU pVCpu);
621VMMDECL(int) PGMTrap0eHandler(PVMCPUCC pVCpu, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
622VMMDECL(int) PGMPrefetchPage(PVMCPUCC pVCpu, RTGCPTR GCPtrPage);
623VMMDECL(VBOXSTRICTRC) PGMInterpretInstruction(PVMCC pVM, PVMCPUCC pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
624VMMDECL(int) PGMShwGetPage(PVMCPUCC pVCpu, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
625VMMDECL(int) PGMShwMakePageReadonly(PVMCPUCC pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
626VMMDECL(int) PGMShwMakePageWritable(PVMCPUCC pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
627VMMDECL(int) PGMShwMakePageNotPresent(PVMCPUCC pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
628/** @name Flags for PGMShwMakePageReadonly, PGMShwMakePageWritable and
629 * PGMShwMakePageNotPresent
630 * @{ */
631/** The call is from an access handler for dealing with the a faulting write
632 * operation. The virtual address is within the same page. */
633#define PGM_MK_PG_IS_WRITE_FAULT RT_BIT(0)
634/** The page is an MMIO2. */
635#define PGM_MK_PG_IS_MMIO2 RT_BIT(1)
636/** @}*/
637VMMDECL(int) PGMGstGetPage(PVMCPUCC pVCpu, RTGCPTR GCPtr, PPGMPTWALK pWalk);
638VMMDECL(int) PGMGstModifyPage(PVMCPUCC pVCpu, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
639VMM_INT_DECL(bool) PGMGstArePaePdpesValid(PVMCPUCC pVCpu, PCX86PDPE paPaePdpes);
640VMM_INT_DECL(int) PGMGstMapPaePdpes(PVMCPUCC pVCpu, PCX86PDPE paPaePdpes);
641VMM_INT_DECL(int) PGMGstMapPaePdpesAtCr3(PVMCPUCC pVCpu, uint64_t cr3);
642
643VMMDECL(int) PGMInvalidatePage(PVMCPUCC pVCpu, RTGCPTR GCPtrPage);
644VMMDECL(int) PGMFlushTLB(PVMCPUCC pVCpu, uint64_t cr3, bool fGlobal);
645VMMDECL(int) PGMSyncCR3(PVMCPUCC pVCpu, uint64_t cr0, uint64_t cr3, uint64_t cr4, bool fGlobal);
646VMMDECL(int) PGMUpdateCR3(PVMCPUCC pVCpu, uint64_t cr3);
647VMMDECL(int) PGMChangeMode(PVMCPUCC pVCpu, uint64_t cr0, uint64_t cr4, uint64_t efer, bool fForce);
648VMM_INT_DECL(int) PGMHCChangeMode(PVMCC pVM, PVMCPUCC pVCpu, PGMMODE enmGuestMode, bool fForce);
649VMMDECL(void) PGMCr0WpEnabled(PVMCPUCC pVCpu);
650VMMDECL(PGMMODE) PGMGetGuestMode(PVMCPU pVCpu);
651VMMDECL(PGMMODE) PGMGetShadowMode(PVMCPU pVCpu);
652VMMDECL(PGMMODE) PGMGetHostMode(PVM pVM);
653VMMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
654#ifdef VBOX_WITH_NESTED_HWVIRT_VMX_EPT
655VMM_INT_DECL(const char *) PGMGetSlatModeName(PGMSLAT enmSlatMode);
656#endif
657VMM_INT_DECL(RTGCPHYS) PGMGetGuestCR3Phys(PVMCPU pVCpu);
658VMM_INT_DECL(void) PGMNotifyNxeChanged(PVMCPU pVCpu, bool fNxe);
659VMMDECL(bool) PGMHasDirtyPages(PVM pVM);
660VMM_INT_DECL(void) PGMSetGuestEptPtr(PVMCPUCC pVCpu, uint64_t uEptPtr);
661
662/** PGM physical access handler type registration handle (heap offset, valid
663 * cross contexts without needing fixing up). Callbacks and handler type is
664 * associated with this and it is shared by all handler registrations. */
665typedef uint64_t PGMPHYSHANDLERTYPE;
666/** Pointer to a PGM physical handler type registration handle. */
667typedef PGMPHYSHANDLERTYPE *PPGMPHYSHANDLERTYPE;
668/** NIL value for PGM physical access handler type handle. */
669#define NIL_PGMPHYSHANDLERTYPE UINT64_MAX
670VMMDECL(int) PGMHandlerPhysicalRegister(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast, PGMPHYSHANDLERTYPE hType,
671 uint64_t uUser, R3PTRTYPE(const char *) pszDesc);
672VMMDECL(int) PGMHandlerPhysicalModify(PVMCC pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
673VMMDECL(int) PGMHandlerPhysicalDeregister(PVMCC pVM, RTGCPHYS GCPhys);
674VMMDECL(int) PGMHandlerPhysicalChangeUserArg(PVMCC pVM, RTGCPHYS GCPhys, uint64_t uUser);
675VMMDECL(int) PGMHandlerPhysicalSplit(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
676VMMDECL(int) PGMHandlerPhysicalJoin(PVMCC pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
677VMMDECL(int) PGMHandlerPhysicalPageTempOff(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
678VMMDECL(int) PGMHandlerPhysicalPageAliasMmio2(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage,
679 PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS offMMio2PageRemap);
680VMMDECL(int) PGMHandlerPhysicalPageAliasHC(PVMCC pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTHCPHYS HCPhysPageRemap);
681VMMDECL(int) PGMHandlerPhysicalReset(PVMCC pVM, RTGCPHYS GCPhys);
682VMMDECL(bool) PGMHandlerPhysicalIsRegistered(PVMCC pVM, RTGCPHYS GCPhys);
683
684/** @name PGMPHYSHANDLER_F_XXX - flags for PGMR3HandlerPhysicalTypeRegister and PGMR0HandlerPhysicalTypeRegister
685 * @{ */
686/** Whether to hold the PGM lock while calling the handler or not.
687 * Mainly an optimization for PGM callers. */
688#define PGMPHYSHANDLER_F_KEEP_PGM_LOCK RT_BIT_32(0)
689/** The uUser value is a ring-0 device instance index that needs translating
690 * into a PDMDEVINS pointer before calling the handler. This is a hack to make
691 * it possible to use access handlers in devices. */
692#define PGMPHYSHANDLER_F_R0_DEVINS_IDX RT_BIT_32(1)
693/** Mask of valid bits. */
694#define PGMPHYSHANDLER_F_VALID_MASK UINT32_C(3)
695/** @} */
696
697
698/**
699 * Page type.
700 *
701 * @remarks This enum has to fit in a 3-bit field (see PGMPAGE::u3Type).
702 * @remarks This is used in the saved state, so changes to it requires bumping
703 * the saved state version.
704 * @todo So, convert to \#defines!
705 */
706typedef enum PGMPAGETYPE
707{
708 /** The usual invalid zero entry. */
709 PGMPAGETYPE_INVALID = 0,
710 /** RAM page. (RWX) */
711 PGMPAGETYPE_RAM,
712 /** MMIO2 page. (RWX) */
713 PGMPAGETYPE_MMIO2,
714 /** MMIO2 page aliased over an MMIO page. (RWX)
715 * See PGMHandlerPhysicalPageAlias(). */
716 PGMPAGETYPE_MMIO2_ALIAS_MMIO,
717 /** Special page aliased over an MMIO page. (RWX)
718 * See PGMHandlerPhysicalPageAliasHC(), but this is generally only used for
719 * VT-x's APIC access page at the moment. Treated as MMIO by everyone except
720 * the shadow paging code. */
721 PGMPAGETYPE_SPECIAL_ALIAS_MMIO,
722 /** Shadowed ROM. (RWX) */
723 PGMPAGETYPE_ROM_SHADOW,
724 /** ROM page. (R-X) */
725 PGMPAGETYPE_ROM,
726 /** MMIO page. (---) */
727 PGMPAGETYPE_MMIO,
728 /** End of valid entries. */
729 PGMPAGETYPE_END
730} PGMPAGETYPE;
731AssertCompile(PGMPAGETYPE_END == 8);
732
733/** @name PGM page type predicates.
734 * @{ */
735#define PGMPAGETYPE_IS_READABLE(a_enmType) ( (a_enmType) <= PGMPAGETYPE_ROM )
736#define PGMPAGETYPE_IS_WRITEABLE(a_enmType) ( (a_enmType) <= PGMPAGETYPE_ROM_SHADOW )
737#define PGMPAGETYPE_IS_RWX(a_enmType) ( (a_enmType) <= PGMPAGETYPE_ROM_SHADOW )
738#define PGMPAGETYPE_IS_ROX(a_enmType) ( (a_enmType) == PGMPAGETYPE_ROM )
739#define PGMPAGETYPE_IS_NP(a_enmType) ( (a_enmType) == PGMPAGETYPE_MMIO )
740/** @} */
741
742
743VMM_INT_DECL(PGMPAGETYPE) PGMPhysGetPageType(PVMCC pVM, RTGCPHYS GCPhys);
744
745VMM_INT_DECL(int) PGMPhysGCPhys2HCPhys(PVMCC pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
746VMM_INT_DECL(int) PGMPhysGCPtr2HCPhys(PVMCPUCC pVCpu, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
747VMM_INT_DECL(int) PGMPhysGCPhys2CCPtr(PVMCC pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
748VMM_INT_DECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVMCC pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
749VMM_INT_DECL(int) PGMPhysGCPtr2CCPtr(PVMCPU pVCpu, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
750VMM_INT_DECL(int) PGMPhysGCPtr2CCPtrReadOnly(PVMCPUCC pVCpu, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
751
752VMMDECL(bool) PGMPhysIsA20Enabled(PVMCPU pVCpu);
753VMMDECL(bool) PGMPhysIsGCPhysValid(PVMCC pVM, RTGCPHYS GCPhys);
754VMMDECL(bool) PGMPhysIsGCPhysNormal(PVMCC pVM, RTGCPHYS GCPhys);
755VMMDECL(int) PGMPhysGCPtr2GCPhys(PVMCPUCC pVCpu, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
756VMMDECL(void) PGMPhysReleasePageMappingLock(PVMCC pVM, PPGMPAGEMAPLOCK pLock);
757VMMDECL(void) PGMPhysBulkReleasePageMappingLocks(PVMCC pVM, uint32_t cPages, PPGMPAGEMAPLOCK paLock);
758
759/** @def PGM_PHYS_RW_IS_SUCCESS
760 * Check whether a PGMPhysRead, PGMPhysWrite, PGMPhysReadGCPtr or
761 * PGMPhysWriteGCPtr call completed the given task.
762 *
763 * @returns true if completed, false if not.
764 * @param a_rcStrict The status code.
765 * @sa IOM_SUCCESS
766 */
767#ifdef IN_RING3
768# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
769 ( (a_rcStrict) == VINF_SUCCESS \
770 || (a_rcStrict) == VINF_EM_DBG_STOP \
771 || (a_rcStrict) == VINF_EM_DBG_EVENT \
772 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
773 )
774#elif defined(IN_RING0)
775# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
776 ( (a_rcStrict) == VINF_SUCCESS \
777 || (a_rcStrict) == VINF_IOM_R3_MMIO_COMMIT_WRITE \
778 || (a_rcStrict) == VINF_EM_OFF \
779 || (a_rcStrict) == VINF_EM_SUSPEND \
780 || (a_rcStrict) == VINF_EM_RESET \
781 || (a_rcStrict) == VINF_EM_HALT \
782 || (a_rcStrict) == VINF_EM_DBG_STOP \
783 || (a_rcStrict) == VINF_EM_DBG_EVENT \
784 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
785 )
786#elif defined(IN_RC)
787# define PGM_PHYS_RW_IS_SUCCESS(a_rcStrict) \
788 ( (a_rcStrict) == VINF_SUCCESS \
789 || (a_rcStrict) == VINF_IOM_R3_MMIO_COMMIT_WRITE \
790 || (a_rcStrict) == VINF_EM_OFF \
791 || (a_rcStrict) == VINF_EM_SUSPEND \
792 || (a_rcStrict) == VINF_EM_RESET \
793 || (a_rcStrict) == VINF_EM_HALT \
794 || (a_rcStrict) == VINF_SELM_SYNC_GDT \
795 || (a_rcStrict) == VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT \
796 || (a_rcStrict) == VINF_EM_DBG_STOP \
797 || (a_rcStrict) == VINF_EM_DBG_EVENT \
798 || (a_rcStrict) == VINF_EM_DBG_BREAKPOINT \
799 )
800#endif
801/** @def PGM_PHYS_RW_DO_UPDATE_STRICT_RC
802 * Updates the return code with a new result.
803 *
804 * Both status codes must be successes according to PGM_PHYS_RW_IS_SUCCESS.
805 *
806 * @param a_rcStrict The current return code, to be updated.
807 * @param a_rcStrict2 The new return code to merge in.
808 */
809#ifdef IN_RING3
810# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
811 do { \
812 Assert(rcStrict == VINF_SUCCESS); \
813 Assert(rcStrict2 == VINF_SUCCESS); \
814 } while (0)
815#elif defined(IN_RING0)
816# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
817 do { \
818 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict)); \
819 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict2)); \
820 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_LAST); \
821 if ((a_rcStrict2) == VINF_SUCCESS || (a_rcStrict) == (a_rcStrict2)) \
822 { /* likely */ } \
823 else if ( (a_rcStrict) == VINF_SUCCESS \
824 || (a_rcStrict) > (a_rcStrict2)) \
825 (a_rcStrict) = (a_rcStrict2); \
826 } while (0)
827#elif defined(IN_RC)
828# define PGM_PHYS_RW_DO_UPDATE_STRICT_RC(a_rcStrict, a_rcStrict2) \
829 do { \
830 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict)); \
831 Assert(PGM_PHYS_RW_IS_SUCCESS(rcStrict2)); \
832 AssertCompile(VINF_SELM_SYNC_GDT > VINF_EM_LAST); \
833 AssertCompile(VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT > VINF_EM_LAST); \
834 AssertCompile(VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT < VINF_SELM_SYNC_GDT); \
835 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_LAST); \
836 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_SELM_SYNC_GDT); \
837 AssertCompile(VINF_IOM_R3_MMIO_COMMIT_WRITE > VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT); \
838 if ((a_rcStrict2) == VINF_SUCCESS || (a_rcStrict) == (a_rcStrict2)) \
839 { /* likely */ } \
840 else if ((a_rcStrict) == VINF_SUCCESS) \
841 (a_rcStrict) = (a_rcStrict2); \
842 else if ( ( (a_rcStrict) > (a_rcStrict2) \
843 && ( (a_rcStrict2) <= VINF_EM_RESET \
844 || (a_rcStrict) != VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT) ) \
845 || ( (a_rcStrict2) == VINF_EM_RAW_EMULATE_INSTR_GDT_FAULT \
846 && (a_rcStrict) > VINF_EM_RESET) ) \
847 (a_rcStrict) = (a_rcStrict2); \
848 } while (0)
849#endif
850
851VMMDECL(VBOXSTRICTRC) PGMPhysRead(PVMCC pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
852VMMDECL(VBOXSTRICTRC) PGMPhysWrite(PVMCC pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
853VMMDECL(VBOXSTRICTRC) PGMPhysReadGCPtr(PVMCPUCC pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, PGMACCESSORIGIN enmOrigin);
854VMMDECL(VBOXSTRICTRC) PGMPhysWriteGCPtr(PVMCPUCC pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb, PGMACCESSORIGIN enmOrigin);
855
856VMMDECL(int) PGMPhysSimpleReadGCPhys(PVMCC pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
857VMMDECL(int) PGMPhysSimpleWriteGCPhys(PVMCC pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
858VMMDECL(int) PGMPhysSimpleReadGCPtr(PVMCPUCC pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
859VMMDECL(int) PGMPhysSimpleWriteGCPtr(PVMCPUCC pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
860VMMDECL(int) PGMPhysSimpleDirtyWriteGCPtr(PVMCPUCC pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
861
862VMM_INT_DECL(int) PGMPhysIemGCPhys2Ptr(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers, void **ppv, PPGMPAGEMAPLOCK pLock);
863VMM_INT_DECL(int) PGMPhysIemQueryAccess(PVMCC pVM, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers);
864VMM_INT_DECL(int) PGMPhysIemGCPhys2PtrNoLock(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, uint64_t const volatile *puTlbPhysRev,
865#if defined(IN_RC)
866 R3PTRTYPE(uint8_t *) *ppb,
867#else
868 R3R0PTRTYPE(uint8_t *) *ppb,
869#endif
870 uint64_t *pfTlb);
871/** @name Flags returned by PGMPhysIemGCPhys2PtrNoLock
872 * @{ */
873#define PGMIEMGCPHYS2PTR_F_NO_WRITE RT_BIT_32(3) /**< Not writable (IEMTLBE_F_PG_NO_WRITE). */
874#define PGMIEMGCPHYS2PTR_F_NO_READ RT_BIT_32(4) /**< Not readable (IEMTLBE_F_PG_NO_READ). */
875#define PGMIEMGCPHYS2PTR_F_NO_MAPPINGR3 RT_BIT_32(7) /**< No ring-3 mapping (IEMTLBE_F_NO_MAPPINGR3). */
876#define PGMIEMGCPHYS2PTR_F_UNASSIGNED RT_BIT_32(8) /**< Unassgined memory (IEMTLBE_F_PG_UNASSIGNED). */
877/** @} */
878
879/** Information returned by PGMPhysNemQueryPageInfo. */
880typedef struct PGMPHYSNEMPAGEINFO
881{
882 /** The host physical address of the page, NIL_HCPHYS if invalid page. */
883 RTHCPHYS HCPhys;
884 /** The NEM access mode for the page, NEM_PAGE_PROT_XXX */
885 uint32_t fNemProt : 8;
886 /** The NEM state associated with the PAGE. */
887 uint32_t u2NemState : 2;
888 /** The NEM state associated with the PAGE before pgmPhysPageMakeWritable was called. */
889 uint32_t u2OldNemState : 2;
890 /** Set if the page has handler. */
891 uint32_t fHasHandlers : 1;
892 /** Set if is the zero page backing it. */
893 uint32_t fZeroPage : 1;
894 /** Set if the page has handler. */
895 PGMPAGETYPE enmType;
896} PGMPHYSNEMPAGEINFO;
897/** Pointer to page information for NEM. */
898typedef PGMPHYSNEMPAGEINFO *PPGMPHYSNEMPAGEINFO;
899/**
900 * Callback for checking that the page is in sync while under the PGM lock.
901 *
902 * NEM passes this callback to PGMPhysNemQueryPageInfo to check that the page is
903 * in-sync between PGM and the native hypervisor API in an atomic fashion.
904 *
905 * @returns VBox status code.
906 * @param pVM The cross context VM structure.
907 * @param pVCpu The cross context per virtual CPU structure. Optional,
908 * see PGMPhysNemQueryPageInfo.
909 * @param GCPhys The guest physical address (not A20 masked).
910 * @param pInfo The page info structure. This function updates the
911 * u2NemState memory and the caller will update the PGMPAGE
912 * copy accordingly.
913 * @param pvUser Callback user argument.
914 */
915typedef DECLCALLBACKTYPE(int, FNPGMPHYSNEMCHECKPAGE,(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, PPGMPHYSNEMPAGEINFO pInfo, void *pvUser));
916/** Pointer to a FNPGMPHYSNEMCHECKPAGE function. */
917typedef FNPGMPHYSNEMCHECKPAGE *PFNPGMPHYSNEMCHECKPAGE;
918
919VMM_INT_DECL(int) PGMPhysNemPageInfoChecker(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, bool fMakeWritable,
920 PPGMPHYSNEMPAGEINFO pInfo, PFNPGMPHYSNEMCHECKPAGE pfnChecker, void *pvUser);
921
922/**
923 * Callback for use with PGMPhysNemEnumPagesByState.
924 * @returns VBox status code.
925 * Failure status will stop enumeration immediately and return.
926 * @param pVM The cross context VM structure.
927 * @param pVCpu The cross context per virtual CPU structure. Optional,
928 * see PGMPhysNemEnumPagesByState.
929 * @param GCPhys The guest physical address (not A20 masked).
930 * @param pu2NemState Pointer to variable with the NEM state. This can be
931 * update.
932 * @param pvUser The user argument.
933 */
934typedef DECLCALLBACKTYPE(int, FNPGMPHYSNEMENUMCALLBACK,(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys,
935 uint8_t *pu2NemState, void *pvUser));
936/** Pointer to a FNPGMPHYSNEMENUMCALLBACK function. */
937typedef FNPGMPHYSNEMENUMCALLBACK *PFNPGMPHYSNEMENUMCALLBACK;
938VMM_INT_DECL(int) PGMPhysNemEnumPagesByState(PVMCC pVM, PVMCPUCC VCpu, uint8_t uMinState,
939 PFNPGMPHYSNEMENUMCALLBACK pfnCallback, void *pvUser);
940
941
942#ifdef VBOX_STRICT
943VMMDECL(unsigned) PGMAssertHandlerAndFlagsInSync(PVMCC pVM);
944VMMDECL(unsigned) PGMAssertNoMappingConflicts(PVM pVM);
945VMMDECL(unsigned) PGMAssertCR3(PVMCC pVM, PVMCPUCC pVCpu, uint64_t cr3, uint64_t cr4);
946#endif /* VBOX_STRICT */
947
948VMMDECL(int) PGMSetLargePageUsage(PVMCC pVM, bool fUseLargePages);
949
950/**
951 * Query large page usage state
952 *
953 * @returns 0 - disabled, 1 - enabled
954 * @param pVM The cross context VM structure.
955 */
956#define PGMIsUsingLargePages(pVM) ((pVM)->pgm.s.fUseLargePages)
957
958
959#ifdef IN_RING0
960/** @defgroup grp_pgm_r0 The PGM Host Context Ring-0 API
961 * @{
962 */
963VMMR0_INT_DECL(int) PGMR0InitPerVMData(PGVM pGVM, RTR0MEMOBJ hMemObj);
964VMMR0_INT_DECL(int) PGMR0InitVM(PGVM pGVM);
965VMMR0_INT_DECL(void) PGMR0DoneInitVM(PGVM pGVM);
966VMMR0_INT_DECL(void) PGMR0CleanupVM(PGVM pGVM);
967VMMR0_INT_DECL(int) PGMR0PhysAllocateHandyPages(PGVM pGVM, VMCPUID idCpu);
968VMMR0_INT_DECL(int) PGMR0PhysFlushHandyPages(PGVM pGVM, VMCPUID idCpu);
969VMMR0_INT_DECL(int) PGMR0PhysAllocateLargePage(PGVM pGVM, VMCPUID idCpu, RTGCPHYS GCPhys);
970VMMR0_INT_DECL(int) PGMR0PhysMMIO2MapKernel(PGVM pGVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2,
971 size_t offSub, size_t cbSub, void **ppvMapping);
972VMMR0_INT_DECL(int) PGMR0PhysSetupIoMmu(PGVM pGVM);
973VMMR0_INT_DECL(int) PGMR0PhysHandlerInitReqHandler(PGVM pGVM, uint32_t cEntries);
974VMMR0_INT_DECL(int) PGMR0HandlerPhysicalTypeSetUpContext(PGVM pGVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags,
975 PFNPGMPHYSHANDLER pfnHandler, PFNPGMRZPHYSPFHANDLER pfnPfHandler,
976 const char *pszDesc, PGMPHYSHANDLERTYPE hType);
977
978VMMR0DECL(int) PGMR0SharedModuleCheck(PVMCC pVM, PGVM pGVM, VMCPUID idCpu, PGMMSHAREDMODULE pModule,
979 PCRTGCPTR64 paRegionsGCPtrs);
980VMMR0DECL(int) PGMR0Trap0eHandlerNestedPaging(PGVM pGVM, PGVMCPU pGVCpu, PGMMODE enmShwPagingMode, RTGCUINT uErr,
981 PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault);
982VMMR0DECL(VBOXSTRICTRC) PGMR0Trap0eHandlerNPMisconfig(PGVM pGVM, PGVMCPU pGVCpu, PGMMODE enmShwPagingMode,
983 PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, uint32_t uErr);
984VMMR0_INT_DECL(int) PGMR0PoolGrow(PGVM pGVM, VMCPUID idCpu);
985
986# ifdef VBOX_WITH_NESTED_HWVIRT_VMX_EPT
987VMMR0DECL(VBOXSTRICTRC) PGMR0NestedTrap0eHandlerNestedPaging(PGVMCPU pGVCpu, PGMMODE enmShwPagingMode, RTGCUINT uErr,
988 PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysNestedFault,
989 bool fIsLinearAddrValid, RTGCPTR GCPtrNestedFault, PPGMPTWALK pWalk);
990# endif
991/** @} */
992#endif /* IN_RING0 */
993
994
995
996#ifdef IN_RING3
997/** @defgroup grp_pgm_r3 The PGM Host Context Ring-3 API
998 * @{
999 */
1000VMMR3_INT_DECL(void) PGMR3EnableNemMode(PVM pVM);
1001VMMR3_INT_DECL(bool) PGMR3IsNemModeEnabled(PVM pVM);
1002VMMR3DECL(int) PGMR3Init(PVM pVM);
1003VMMR3DECL(int) PGMR3InitFinalize(PVM pVM);
1004VMMR3_INT_DECL(int) PGMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
1005VMMR3DECL(void) PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
1006VMMR3DECL(void) PGMR3ResetCpu(PVM pVM, PVMCPU pVCpu);
1007VMMR3_INT_DECL(void) PGMR3Reset(PVM pVM);
1008VMMR3_INT_DECL(void) PGMR3ResetNoMorePhysWritesFlag(PVM pVM);
1009VMMR3_INT_DECL(void) PGMR3MemSetup(PVM pVM, bool fReset);
1010VMMR3DECL(int) PGMR3Term(PVM pVM);
1011
1012VMMR3DECL(int) PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
1013VMMR3DECL(int) PGMR3PhysChangeMemBalloon(PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage);
1014VMMR3DECL(int) PGMR3PhysWriteProtectRAM(PVM pVM);
1015VMMR3DECL(uint32_t) PGMR3PhysGetRamRangeCount(PVM pVM);
1016VMMR3DECL(int) PGMR3PhysGetRange(PVM pVM, uint32_t iRange, PRTGCPHYS pGCPhysStart, PRTGCPHYS pGCPhysLast,
1017 const char **ppszDesc, bool *pfIsMmio);
1018VMMR3DECL(int) PGMR3QueryMemoryStats(PUVM pUVM, uint64_t *pcbTotalMem, uint64_t *pcbPrivateMem, uint64_t *pcbSharedMem, uint64_t *pcbZeroMem);
1019VMMR3DECL(int) PGMR3QueryGlobalMemoryStats(PUVM pUVM, uint64_t *pcbAllocMem, uint64_t *pcbFreeMem, uint64_t *pcbBallonedMem, uint64_t *pcbSharedMem);
1020
1021VMMR3DECL(int) PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMPHYSHANDLERTYPE hType,
1022 uint64_t uUser, const char *pszDesc);
1023VMMR3DECL(int) PGMR3PhysMMIODeregister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb);
1024
1025/** @name PGMPHYS_MMIO2_FLAGS_XXX - MMIO2 registration flags.
1026 * @see PGMR3PhysMmio2Register, PDMDevHlpMmio2Create
1027 * @{ */
1028/** Track dirty pages.
1029 * @see PGMR3PhysMmio2QueryAndResetDirtyBitmap(), PGMR3PhysMmio2ControlDirtyPageTracking(). */
1030#define PGMPHYS_MMIO2_FLAGS_TRACK_DIRTY_PAGES RT_BIT_32(0)
1031/** Valid flags. */
1032#define PGMPHYS_MMIO2_FLAGS_VALID_MASK UINT32_C(0x00000001)
1033/** @} */
1034
1035VMMR3_INT_DECL(int) PGMR3PhysMmio2Register(PVM pVM, PPDMDEVINS pDevIns, uint32_t iSubDev, uint32_t iRegion, RTGCPHYS cb,
1036 uint32_t fFlags, const char *pszDesc, void **ppv, PGMMMIO2HANDLE *phRegion);
1037VMMR3_INT_DECL(int) PGMR3PhysMmio2Deregister(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2);
1038VMMR3_INT_DECL(int) PGMR3PhysMmio2Map(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS GCPhys);
1039VMMR3_INT_DECL(int) PGMR3PhysMmio2Unmap(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS GCPhys);
1040VMMR3_INT_DECL(int) PGMR3PhysMmio2Reduce(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, RTGCPHYS cbRegion);
1041VMMR3_INT_DECL(int) PGMR3PhysMmio2ValidateHandle(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2);
1042VMMR3_INT_DECL(RTGCPHYS) PGMR3PhysMmio2GetMappingAddress(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2);
1043VMMR3_INT_DECL(int) PGMR3PhysMmio2ChangeRegionNo(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, uint32_t iNewRegion);
1044VMMR3_INT_DECL(int) PGMR3PhysMmio2QueryAndResetDirtyBitmap(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2,
1045 void *pvBitmap, size_t cbBitmap);
1046VMMR3_INT_DECL(int) PGMR3PhysMmio2ControlDirtyPageTracking(PVM pVM, PPDMDEVINS pDevIns, PGMMMIO2HANDLE hMmio2, bool fEnabled);
1047
1048/** @name PGMPHYS_ROM_FLAGS_XXX - ROM registration flags.
1049 * @see PGMR3PhysRegisterRom, PDMDevHlpROMRegister
1050 * @{ */
1051/** Inidicates that ROM shadowing should be enabled. */
1052#define PGMPHYS_ROM_FLAGS_SHADOWED UINT8_C(0x01)
1053/** Indicates that what pvBinary points to won't go away
1054 * and can be used for strictness checks. */
1055#define PGMPHYS_ROM_FLAGS_PERMANENT_BINARY UINT8_C(0x02)
1056/** Indicates that the ROM is allowed to be missing from saved state.
1057 * @note This is a hack for EFI, see @bugref{6940} */
1058#define PGMPHYS_ROM_FLAGS_MAYBE_MISSING_FROM_STATE UINT8_C(0x04)
1059/** Valid flags. */
1060#define PGMPHYS_ROM_FLAGS_VALID_MASK UINT8_C(0x07)
1061/** @} */
1062
1063VMMR3DECL(int) PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
1064 const void *pvBinary, uint32_t cbBinary, uint8_t fFlags, const char *pszDesc);
1065VMMR3DECL(int) PGMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMROMPROT enmProt);
1066VMMDECL(void) PGMR3PhysSetA20(PVMCPU pVCpu, bool fEnable);
1067
1068VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags,
1069 PFNPGMPHYSHANDLER pfnHandlerR3, const char *pszDesc,
1070 PPGMPHYSHANDLERTYPE phType);
1071
1072VMMR3_INT_DECL(int) PGMR3PoolGrow(PVM pVM, PVMCPU pVCpu);
1073
1074VMMR3DECL(int) PGMR3PhysTlbGCPhys2Ptr(PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **ppv);
1075VMMR3DECL(uint8_t) PGMR3PhysReadU8(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
1076VMMR3DECL(uint16_t) PGMR3PhysReadU16(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
1077VMMR3DECL(uint32_t) PGMR3PhysReadU32(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
1078VMMR3DECL(uint64_t) PGMR3PhysReadU64(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
1079VMMR3DECL(void) PGMR3PhysWriteU8(PVM pVM, RTGCPHYS GCPhys, uint8_t Value, PGMACCESSORIGIN enmOrigin);
1080VMMR3DECL(void) PGMR3PhysWriteU16(PVM pVM, RTGCPHYS GCPhys, uint16_t Value, PGMACCESSORIGIN enmOrigin);
1081VMMR3DECL(void) PGMR3PhysWriteU32(PVM pVM, RTGCPHYS GCPhys, uint32_t Value, PGMACCESSORIGIN enmOrigin);
1082VMMR3DECL(void) PGMR3PhysWriteU64(PVM pVM, RTGCPHYS GCPhys, uint64_t Value, PGMACCESSORIGIN enmOrigin);
1083VMMR3DECL(int) PGMR3PhysReadExternal(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
1084VMMR3DECL(int) PGMR3PhysWriteExternal(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
1085VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrExternal(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
1086VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrReadOnlyExternal(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
1087VMMR3DECL(int) PGMR3PhysBulkGCPhys2CCPtrExternal(PVM pVM, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
1088 void **papvPages, PPGMPAGEMAPLOCK paLocks);
1089VMMR3DECL(int) PGMR3PhysBulkGCPhys2CCPtrReadOnlyExternal(PVM pVM, uint32_t cPages, PCRTGCPHYS paGCPhysPages,
1090 void const **papvPages, PPGMPAGEMAPLOCK paLocks);
1091VMMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM);
1092VMMR3DECL(int) PGMR3PhysAllocateHandyPages(PVM pVM);
1093
1094VMMR3DECL(int) PGMR3CheckIntegrity(PVM pVM);
1095
1096VMMR3DECL(int) PGMR3DbgR3Ptr2GCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTGCPHYS pGCPhys);
1097VMMR3DECL(int) PGMR3DbgR3Ptr2HCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTHCPHYS pHCPhys);
1098VMMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PUVM pUVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
1099VMMR3_INT_DECL(int) PGMR3DbgReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
1100VMMR3_INT_DECL(int) PGMR3DbgWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
1101VMMR3_INT_DECL(int) PGMR3DbgReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
1102VMMR3_INT_DECL(int) PGMR3DbgWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
1103VMMR3_INT_DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, RTGCPHYS GCPhysAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
1104VMMR3_INT_DECL(int) PGMR3DbgScanVirtual(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, RTGCPTR cbRange, RTGCPTR GCPtrAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
1105VMMR3_INT_DECL(int) PGMR3DumpHierarchyShw(PVM pVM, uint64_t cr3, uint32_t fFlags, uint64_t u64FirstAddr, uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
1106VMMR3_INT_DECL(int) PGMR3DumpHierarchyGst(PVM pVM, uint64_t cr3, uint32_t fFlags, RTGCPTR FirstAddr, RTGCPTR LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
1107
1108
1109/** @name Page sharing
1110 * @{ */
1111VMMR3DECL(int) PGMR3SharedModuleRegister(PVM pVM, VBOXOSFAMILY enmGuestOS, char *pszModuleName, char *pszVersion,
1112 RTGCPTR GCBaseAddr, uint32_t cbModule,
1113 uint32_t cRegions, VMMDEVSHAREDREGIONDESC const *paRegions);
1114VMMR3DECL(int) PGMR3SharedModuleUnregister(PVM pVM, char *pszModuleName, char *pszVersion,
1115 RTGCPTR GCBaseAddr, uint32_t cbModule);
1116VMMR3DECL(int) PGMR3SharedModuleCheckAll(PVM pVM);
1117VMMR3DECL(int) PGMR3SharedModuleGetPageState(PVM pVM, RTGCPTR GCPtrPage, bool *pfShared, uint64_t *pfPageFlags);
1118/** @} */
1119
1120/** @} */
1121#endif /* IN_RING3 */
1122
1123RT_C_DECLS_END
1124
1125/** @} */
1126#endif /* !VBOX_INCLUDED_vmm_pgm_h */
1127
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