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