1 | /** @file
|
---|
2 | * PGM - Page Monitor/Monitor.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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_pgm_h
|
---|
27 | #define ___VBox_pgm_h
|
---|
28 |
|
---|
29 | #include <VBox/cdefs.h>
|
---|
30 | #include <VBox/types.h>
|
---|
31 | #include <VBox/sup.h>
|
---|
32 | #include <VBox/cpum.h>
|
---|
33 | #include <VBox/vmapi.h>
|
---|
34 |
|
---|
35 | __BEGIN_DECLS
|
---|
36 |
|
---|
37 | /** @defgroup grp_pgm The Page Monitor/Manager API
|
---|
38 | * @{
|
---|
39 | */
|
---|
40 |
|
---|
41 | /** Enable dynamic allocation of guest physical RAM. */
|
---|
42 | #define PGM_DYNAMIC_RAM_ALLOC
|
---|
43 |
|
---|
44 | /** Chunk size for dynamically allocated physical memory. */
|
---|
45 | #define PGM_DYNAMIC_CHUNK_SIZE (1*1024*1024)
|
---|
46 | /** Shift GC physical address by 20 bits to get the offset into the pvHCChunkHC array. */
|
---|
47 | #define PGM_DYNAMIC_CHUNK_SHIFT 20
|
---|
48 | /** Dynamic chunk offset mask. */
|
---|
49 | #define PGM_DYNAMIC_CHUNK_OFFSET_MASK 0xfffff
|
---|
50 | /** Dynamic chunk base mask. */
|
---|
51 | #define PGM_DYNAMIC_CHUNK_BASE_MASK (~(RTGCPHYS)PGM_DYNAMIC_CHUNK_OFFSET_MASK)
|
---|
52 |
|
---|
53 |
|
---|
54 | /** Page flags used for PGMHyperSetPageFlags
|
---|
55 | * @deprecated
|
---|
56 | * @{ */
|
---|
57 | #define PGMPAGE_READ 1
|
---|
58 | #define PGMPAGE_WRITE 2
|
---|
59 | #define PGMPAGE_USER 4
|
---|
60 | #define PGMPAGE_SYSTEM 8
|
---|
61 | #define PGMPAGE_NOTPRESENT 16
|
---|
62 | /** @} */
|
---|
63 |
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * FNPGMRELOCATE callback mode.
|
---|
67 | */
|
---|
68 | typedef enum PGMRELOCATECALL
|
---|
69 | {
|
---|
70 | /** The callback is for checking if the suggested address is suitable. */
|
---|
71 | PGMRELOCATECALL_SUGGEST = 1,
|
---|
72 | /** The callback is for executing the relocation. */
|
---|
73 | PGMRELOCATECALL_RELOCATE
|
---|
74 | } PGMRELOCATECALL;
|
---|
75 |
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * Callback function which will be called when PGM is trying to find
|
---|
79 | * a new location for the mapping.
|
---|
80 | *
|
---|
81 | * The callback is called in two modes, 1) the check mode and 2) the relocate mode.
|
---|
82 | * In 1) the callback should say if it objects to a suggested new location. If it
|
---|
83 | * accepts the new location, it is called again for doing it's relocation.
|
---|
84 | *
|
---|
85 | *
|
---|
86 | * @returns true if the location is ok.
|
---|
87 | * @returns false if another location should be found.
|
---|
88 | * @param GCPtrOld The old virtual address.
|
---|
89 | * @param GCPtrNew The new virtual address.
|
---|
90 | * @param enmMode Used to indicate the callback mode.
|
---|
91 | * @param pvUser User argument.
|
---|
92 | * @remark The return value is no a failure indicator, it's an acceptance
|
---|
93 | * indicator. Relocation can not fail!
|
---|
94 | */
|
---|
95 | typedef DECLCALLBACK(bool) FNPGMRELOCATE(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser);
|
---|
96 | /** Pointer to a relocation callback function. */
|
---|
97 | typedef FNPGMRELOCATE *PFNPGMRELOCATE;
|
---|
98 |
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * Physical page access handler type.
|
---|
102 | */
|
---|
103 | typedef enum PGMPHYSHANDLERTYPE
|
---|
104 | {
|
---|
105 | /** MMIO range. Pages are not present, all access is done in interpreter or recompiler. */
|
---|
106 | PGMPHYSHANDLERTYPE_MMIO = 1,
|
---|
107 | /** Handle all normal page faults for a physical page range. */
|
---|
108 | PGMPHYSHANDLERTYPE_PHYSICAL,
|
---|
109 | /** Handler all write access to a physical page range. */
|
---|
110 | PGMPHYSHANDLERTYPE_PHYSICAL_WRITE,
|
---|
111 | /** Handler all access to a physical page range. */
|
---|
112 | PGMPHYSHANDLERTYPE_PHYSICAL_ALL
|
---|
113 |
|
---|
114 | } PGMPHYSHANDLERTYPE;
|
---|
115 |
|
---|
116 | /**
|
---|
117 | * \#PF Handler callback for physical access handler ranges (MMIO among others) in GC.
|
---|
118 | *
|
---|
119 | * @returns VBox status code (appropriate for GC return).
|
---|
120 | * @param pVM VM Handle.
|
---|
121 | * @param uErrorCode CPU Error code.
|
---|
122 | * @param pRegFrame Trap register frame.
|
---|
123 | * NULL on DMA and other non CPU access.
|
---|
124 | * @param pvFault The fault address (cr2).
|
---|
125 | * @param GCPhysFault The GC physical address corresponding to pvFault.
|
---|
126 | * @param pvUser User argument.
|
---|
127 | */
|
---|
128 | typedef DECLCALLBACK(int) FNPGMGCPHYSHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
|
---|
129 | /** Pointer to PGM access callback. */
|
---|
130 | typedef FNPGMGCPHYSHANDLER *PFNPGMGCPHYSHANDLER;
|
---|
131 |
|
---|
132 | /**
|
---|
133 | * \#PF Handler callback for physical access handler ranges (MMIO among others) in R0.
|
---|
134 | *
|
---|
135 | * @returns VBox status code (appropriate for GC return).
|
---|
136 | * @param pVM VM Handle.
|
---|
137 | * @param uErrorCode CPU Error code.
|
---|
138 | * @param pRegFrame Trap register frame.
|
---|
139 | * NULL on DMA and other non CPU access.
|
---|
140 | * @param pvFault The fault address (cr2).
|
---|
141 | * @param GCPhysFault The GC physical address corresponding to pvFault.
|
---|
142 | * @param pvUser User argument.
|
---|
143 | */
|
---|
144 | typedef DECLCALLBACK(int) FNPGMR0PHYSHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
|
---|
145 | /** Pointer to PGM access callback. */
|
---|
146 | typedef FNPGMR0PHYSHANDLER *PFNPGMR0PHYSHANDLER;
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * Guest Access type
|
---|
150 | */
|
---|
151 | typedef enum PGMACCESSTYPE
|
---|
152 | {
|
---|
153 | /** Read access. */
|
---|
154 | PGMACCESSTYPE_READ = 1,
|
---|
155 | /** Write access. */
|
---|
156 | PGMACCESSTYPE_WRITE
|
---|
157 | } PGMACCESSTYPE;
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * \#PF Handler callback for physical access handler ranges (MMIO among others) in HC.
|
---|
161 | *
|
---|
162 | * The handler can not raise any faults, it's mainly for monitoring write access
|
---|
163 | * to certain pages.
|
---|
164 | *
|
---|
165 | * @returns VINF_SUCCESS if the handler have carried out the operation.
|
---|
166 | * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
|
---|
167 | * @param pVM VM Handle.
|
---|
168 | * @param GCPhys The physical address the guest is writing to.
|
---|
169 | * @param pvPhys The HC mapping of that address.
|
---|
170 | * @param pvBuf What the guest is reading/writing.
|
---|
171 | * @param cbBuf How much it's reading/writing.
|
---|
172 | * @param enmAccessType The access type.
|
---|
173 | * @param pvUser User argument.
|
---|
174 | */
|
---|
175 | typedef DECLCALLBACK(int) FNPGMR3PHYSHANDLER(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
|
---|
176 | /** Pointer to PGM access callback. */
|
---|
177 | typedef FNPGMR3PHYSHANDLER *PFNPGMR3PHYSHANDLER;
|
---|
178 |
|
---|
179 |
|
---|
180 | /**
|
---|
181 | * Virtual access handler type.
|
---|
182 | */
|
---|
183 | typedef enum PGMVIRTHANDLERTYPE
|
---|
184 | {
|
---|
185 | /** Natural traps only. */
|
---|
186 | PGMVIRTHANDLERTYPE_NORMAL = 1,
|
---|
187 | /** Write access handled. */
|
---|
188 | PGMVIRTHANDLERTYPE_WRITE,
|
---|
189 | /** All access handled. */
|
---|
190 | PGMVIRTHANDLERTYPE_ALL,
|
---|
191 | /** By eip - Natural traps only. */
|
---|
192 | PGMVIRTHANDLERTYPE_EIP,
|
---|
193 | /** Hypervisor write access handled.
|
---|
194 | * This is used to catch the guest trying to write to LDT, TSS and any other
|
---|
195 | * system structure which the brain dead intel guys let unprivilegde code find. */
|
---|
196 | PGMVIRTHANDLERTYPE_HYPERVISOR
|
---|
197 |
|
---|
198 | } PGMVIRTHANDLERTYPE;
|
---|
199 |
|
---|
200 | /**
|
---|
201 | * \#PF Handler callback for virtual access handler ranges.
|
---|
202 | *
|
---|
203 | * Important to realize that a physical page in a range can have aliases, and
|
---|
204 | * for ALL and WRITE handlers these will also trigger.
|
---|
205 | *
|
---|
206 | * @returns VBox status code (appropriate for GC return).
|
---|
207 | * @param pVM VM Handle.
|
---|
208 | * @param uErrorCode CPU Error code.
|
---|
209 | * @param pRegFrame Trap register frame.
|
---|
210 | * @param pvFault The fault address (cr2).
|
---|
211 | * @param pvRange The base address of the handled virtual range.
|
---|
212 | * @param offRange The offset of the access into this range.
|
---|
213 | * (If it's a EIP range this's the EIP, if not it's pvFault.)
|
---|
214 | */
|
---|
215 | typedef DECLCALLBACK(int) FNPGMGCVIRTHANDLER(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange);
|
---|
216 | /** Pointer to PGM access callback. */
|
---|
217 | typedef FNPGMGCVIRTHANDLER *PFNPGMGCVIRTHANDLER;
|
---|
218 |
|
---|
219 | /**
|
---|
220 | * \#PF Handler callback for virtual access handler ranges.
|
---|
221 | *
|
---|
222 | * Important to realize that a physical page in a range can have aliases, and
|
---|
223 | * for ALL and WRITE handlers these will also trigger.
|
---|
224 | *
|
---|
225 | * @returns VINF_SUCCESS if the handler have carried out the operation.
|
---|
226 | * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
|
---|
227 | * @param pVM VM Handle.
|
---|
228 | * @param GCPtr The virtual address the guest is writing to. (not correct if it's an alias!)
|
---|
229 | * @param pvPtr The HC mapping of that address.
|
---|
230 | * @param pvBuf What the guest is reading/writing.
|
---|
231 | * @param cbBuf How much it's reading/writing.
|
---|
232 | * @param enmAccessType The access type.
|
---|
233 | * @param pvUser User argument.
|
---|
234 | */
|
---|
235 | typedef DECLCALLBACK(int) FNPGMHCVIRTHANDLER(PVM pVM, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
|
---|
236 | /** Pointer to PGM access callback. */
|
---|
237 | typedef FNPGMHCVIRTHANDLER *PFNPGMHCVIRTHANDLER;
|
---|
238 |
|
---|
239 |
|
---|
240 | /**
|
---|
241 | * \#PF Handler callback for invalidation of virtual access handler ranges.
|
---|
242 | *
|
---|
243 | * @param pVM VM Handle.
|
---|
244 | * @param GCPtr The virtual address the guest has changed.
|
---|
245 | */
|
---|
246 | typedef DECLCALLBACK(int) FNPGMHCVIRTINVALIDATE(PVM pVM, RTGCPTR GCPtr);
|
---|
247 | /** Pointer to PGM invalidation callback. */
|
---|
248 | typedef FNPGMHCVIRTINVALIDATE *PFNPGMHCVIRTINVALIDATE;
|
---|
249 |
|
---|
250 | /**
|
---|
251 | * Paging mode.
|
---|
252 | */
|
---|
253 | typedef enum PGMMODE
|
---|
254 | {
|
---|
255 | /** The usual invalid value. */
|
---|
256 | PGMMODE_INVALID = 0,
|
---|
257 | /** Real mode. */
|
---|
258 | PGMMODE_REAL,
|
---|
259 | /** Protected mode, no paging. */
|
---|
260 | PGMMODE_PROTECTED,
|
---|
261 | /** 32-bit paging. */
|
---|
262 | PGMMODE_32_BIT,
|
---|
263 | /** PAE paging. */
|
---|
264 | PGMMODE_PAE,
|
---|
265 | /** PAE paging with NX enabled. */
|
---|
266 | PGMMODE_PAE_NX,
|
---|
267 | /** 64-bit AMD paging (long mode). */
|
---|
268 | PGMMODE_AMD64,
|
---|
269 | /** 64-bit AMD paging (long mode) with NX enabled. */
|
---|
270 | PGMMODE_AMD64_NX,
|
---|
271 | /** The max number of modes */
|
---|
272 | PGMMODE_MAX,
|
---|
273 | /** 32bit hackishness. */
|
---|
274 | PGMMODE_32BIT_HACK = 0x7fffffff
|
---|
275 | } PGMMODE;
|
---|
276 |
|
---|
277 |
|
---|
278 | /**
|
---|
279 | * Gets the current CR3 register value for the shadow memory context.
|
---|
280 | * @returns CR3 value.
|
---|
281 | * @param pVM The VM handle.
|
---|
282 | */
|
---|
283 | PGMDECL(uint32_t) PGMGetHyperCR3(PVM pVM);
|
---|
284 |
|
---|
285 | /**
|
---|
286 | * Gets the CR3 register value for the 32-Bit shadow memory context.
|
---|
287 | * @returns CR3 value.
|
---|
288 | * @param pVM The VM handle.
|
---|
289 | */
|
---|
290 | PGMDECL(uint32_t) PGMGetHyper32BitCR3(PVM pVM);
|
---|
291 |
|
---|
292 | /**
|
---|
293 | * Gets the CR3 register value for the PAE shadow memory context.
|
---|
294 | * @returns CR3 value.
|
---|
295 | * @param pVM The VM handle.
|
---|
296 | */
|
---|
297 | PGMDECL(uint32_t) PGMGetHyperPaeCR3(PVM pVM);
|
---|
298 |
|
---|
299 | /**
|
---|
300 | * Gets the CR3 register value for the AMD64 shadow memory context.
|
---|
301 | * @returns CR3 value.
|
---|
302 | * @param pVM The VM handle.
|
---|
303 | */
|
---|
304 | PGMDECL(uint32_t) PGMGetHyperAmd64CR3(PVM pVM);
|
---|
305 |
|
---|
306 | /**
|
---|
307 | * Gets the current CR3 register value for the HC intermediate memory context.
|
---|
308 | * @returns CR3 value.
|
---|
309 | * @param pVM The VM handle.
|
---|
310 | */
|
---|
311 | PGMDECL(uint32_t) PGMGetInterHCCR3(PVM pVM);
|
---|
312 |
|
---|
313 | /**
|
---|
314 | * Gets the current CR3 register value for the GC intermediate memory context.
|
---|
315 | * @returns CR3 value.
|
---|
316 | * @param pVM The VM handle.
|
---|
317 | */
|
---|
318 | PGMDECL(uint32_t) PGMGetInterGCCR3(PVM pVM);
|
---|
319 |
|
---|
320 | /**
|
---|
321 | * Gets the CR3 register value for the 32-Bit intermediate memory context.
|
---|
322 | * @returns CR3 value.
|
---|
323 | * @param pVM The VM handle.
|
---|
324 | */
|
---|
325 | PGMDECL(uint32_t) PGMGetInter32BitCR3(PVM pVM);
|
---|
326 |
|
---|
327 | /**
|
---|
328 | * Gets the CR3 register value for the PAE intermediate memory context.
|
---|
329 | * @returns CR3 value.
|
---|
330 | * @param pVM The VM handle.
|
---|
331 | */
|
---|
332 | PGMDECL(uint32_t) PGMGetInterPaeCR3(PVM pVM);
|
---|
333 |
|
---|
334 | /**
|
---|
335 | * Gets the CR3 register value for the AMD64 intermediate memory context.
|
---|
336 | * @returns CR3 value.
|
---|
337 | * @param pVM The VM handle.
|
---|
338 | */
|
---|
339 | PGMDECL(uint32_t) PGMGetInterAmd64CR3(PVM pVM);
|
---|
340 |
|
---|
341 | /**
|
---|
342 | * \#PF Handler.
|
---|
343 | *
|
---|
344 | * @returns VBox status code (appropriate for GC return).
|
---|
345 | * @param pVM VM Handle.
|
---|
346 | * @param uErr The trap error code.
|
---|
347 | * @param pRegFrame Trap register frame.
|
---|
348 | * @param pvFault The fault address.
|
---|
349 | */
|
---|
350 | PGMDECL(int) PGMTrap0eHandler(PVM pVM, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
|
---|
351 |
|
---|
352 | /**
|
---|
353 | * Prefetch a page/set of pages.
|
---|
354 | *
|
---|
355 | * Typically used to sync commonly used pages before entering raw mode
|
---|
356 | * after a CR3 reload.
|
---|
357 | *
|
---|
358 | * @returns VBox status code suitable for scheduling.
|
---|
359 | * @retval VINF_SUCCESS on success.
|
---|
360 | * @retval VINF_PGM_SYNC_CR3 if we're out of shadow pages or something like that.
|
---|
361 | * @param pVM VM handle.
|
---|
362 | * @param GCPtrPage Page to prefetch.
|
---|
363 | */
|
---|
364 | PGMDECL(int) PGMPrefetchPage(PVM pVM, RTGCPTR GCPtrPage);
|
---|
365 |
|
---|
366 | /**
|
---|
367 | * Verifies a range of pages for read or write access.
|
---|
368 | *
|
---|
369 | * Supports handling of pages marked for dirty bit tracking and CSAM.
|
---|
370 | *
|
---|
371 | * @returns VBox status code.
|
---|
372 | * @param pVM VM handle.
|
---|
373 | * @param Addr Guest virtual address to check.
|
---|
374 | * @param cbSize Access size.
|
---|
375 | * @param fAccess Access type (r/w, user/supervisor (X86_PTE_*).
|
---|
376 | */
|
---|
377 | PGMDECL(int) PGMVerifyAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
|
---|
378 |
|
---|
379 | /**
|
---|
380 | * Verifies a range of pages for read or write access
|
---|
381 | *
|
---|
382 | * Only checks the guest's page tables
|
---|
383 | *
|
---|
384 | * @returns VBox status code.
|
---|
385 | * @param pVM VM handle.
|
---|
386 | * @param Addr Guest virtual address to check
|
---|
387 | * @param cbSize Access size
|
---|
388 | * @param fAccess Access type (r/w, user/supervisor (X86_PTE_*))
|
---|
389 | */
|
---|
390 | PGMDECL(int) PGMIsValidAccess(PVM pVM, RTGCUINTPTR Addr, uint32_t cbSize, uint32_t fAccess);
|
---|
391 |
|
---|
392 | /**
|
---|
393 | * Executes an instruction using the interpreter.
|
---|
394 | *
|
---|
395 | * @returns VBox status code (appropriate for trap handling and GC return).
|
---|
396 | * @param pVM VM handle.
|
---|
397 | * @param pRegFrame Register frame.
|
---|
398 | * @param pvFault Fault address.
|
---|
399 | */
|
---|
400 | PGMDECL(int) PGMInterpretInstruction(PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
|
---|
401 |
|
---|
402 | /**
|
---|
403 | * Maps a range of physical pages at a given virtual address
|
---|
404 | * in the guest context.
|
---|
405 | *
|
---|
406 | * The GC virtual address range must be within an existing mapping.
|
---|
407 | *
|
---|
408 | * @returns VBox status code.
|
---|
409 | * @param pVM The virtual machine.
|
---|
410 | * @param GCPtr Where to map the page(s). Must be page aligned.
|
---|
411 | * @param HCPhys Start of the range of physical pages. Must be page aligned.
|
---|
412 | * @param cbPages Number of bytes to map. Must be page aligned.
|
---|
413 | * @param fFlags Page flags (X86_PTE_*).
|
---|
414 | */
|
---|
415 | PGMDECL(int) PGMMap(PVM pVM, RTGCUINTPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags);
|
---|
416 |
|
---|
417 | /**
|
---|
418 | * Sets (replaces) the page flags for a range of pages in a mapping.
|
---|
419 | *
|
---|
420 | * The pages must be mapped pages, it's not possible to change the flags of
|
---|
421 | * Guest OS pages.
|
---|
422 | *
|
---|
423 | * @returns VBox status.
|
---|
424 | * @param pVM VM handle.
|
---|
425 | * @param GCPtr Virtual address of the first page in the range.
|
---|
426 | * @param cb Size (in bytes) of the range to apply the modification to.
|
---|
427 | * @param fFlags Page flags X86_PTE_*, excluding the page mask of course.
|
---|
428 | */
|
---|
429 | PGMDECL(int) PGMMapSetPage(PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags);
|
---|
430 |
|
---|
431 | /**
|
---|
432 | * Modify page flags for a range of pages in a mapping.
|
---|
433 | *
|
---|
434 | * The existing flags are ANDed with the fMask and ORed with the fFlags.
|
---|
435 | *
|
---|
436 | * @returns VBox status code.
|
---|
437 | * @param pVM VM handle.
|
---|
438 | * @param GCPtr Virtual address of the first page in the range.
|
---|
439 | * @param cb Size (in bytes) of the range to apply the modification to.
|
---|
440 | * @param fFlags The OR mask - page flags X86_PTE_*, excluding the page mask of course.
|
---|
441 | * @param fMask The AND mask - page flags X86_PTE_*.
|
---|
442 | * Be very CAREFUL when ~'ing constants which could be 32-bit!
|
---|
443 | */
|
---|
444 | PGMDECL(int) PGMMapModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
|
---|
445 |
|
---|
446 | /**
|
---|
447 | * Gets effective page information (from the VMM page directory).
|
---|
448 | *
|
---|
449 | * @returns VBox status.
|
---|
450 | * @param pVM VM Handle.
|
---|
451 | * @param GCPtr Guest Context virtual address of the page.
|
---|
452 | * @param pfFlags Where to store the flags. These are X86_PTE_*.
|
---|
453 | * @param pHCPhys Where to store the HC physical address of the page.
|
---|
454 | * This is page aligned.
|
---|
455 | * @remark You should use PGMMapGetPage() for pages in a mapping.
|
---|
456 | */
|
---|
457 | PGMDECL(int) PGMShwGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Sets (replaces) the page flags for a range of pages in the shadow context.
|
---|
461 | *
|
---|
462 | * @returns VBox status.
|
---|
463 | * @param pVM VM handle.
|
---|
464 | * @param GCPtr The address of the first page.
|
---|
465 | * @param cb The size of the range in bytes.
|
---|
466 | * @param fFlags Page flags X86_PTE_*, excluding the page mask of course.
|
---|
467 | * @remark You must use PGMMapSetPage() for pages in a mapping.
|
---|
468 | */
|
---|
469 | PGMDECL(int) PGMShwSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
|
---|
470 |
|
---|
471 | /**
|
---|
472 | * Modify page flags for a range of pages in the shadow context.
|
---|
473 | *
|
---|
474 | * The existing flags are ANDed with the fMask and ORed with the fFlags.
|
---|
475 | *
|
---|
476 | * @returns VBox status code.
|
---|
477 | * @param pVM VM handle.
|
---|
478 | * @param GCPtr Virtual address of the first page in the range.
|
---|
479 | * @param cb Size (in bytes) of the range to apply the modification to.
|
---|
480 | * @param fFlags The OR mask - page flags X86_PTE_*, excluding the page mask of course.
|
---|
481 | * @param fMask The AND mask - page flags X86_PTE_*.
|
---|
482 | * Be very CAREFUL when ~'ing constants which could be 32-bit!
|
---|
483 | * @remark You must use PGMMapModifyPage() for pages in a mapping.
|
---|
484 | */
|
---|
485 | PGMDECL(int) PGMShwModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
|
---|
486 |
|
---|
487 | /**
|
---|
488 | * Gets effective Guest OS page information.
|
---|
489 | *
|
---|
490 | * When GCPtr is in a big page, the function will return as if it was a normal
|
---|
491 | * 4KB page. If the need for distinguishing between big and normal page becomes
|
---|
492 | * necessary at a later point, a PGMGstGetPageEx() will be created for that
|
---|
493 | * purpose.
|
---|
494 | *
|
---|
495 | * @returns VBox status.
|
---|
496 | * @param pVM VM Handle.
|
---|
497 | * @param GCPtr Guest Context virtual address of the page.
|
---|
498 | * @param pfFlags Where to store the flags. These are X86_PTE_*, even for big pages.
|
---|
499 | * @param pGCPhys Where to store the GC physical address of the page.
|
---|
500 | * This is page aligned. The fact that the
|
---|
501 | */
|
---|
502 | PGMDECL(int) PGMGstGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTGCPHYS pGCPhys);
|
---|
503 |
|
---|
504 | /**
|
---|
505 | * Checks if the page is present.
|
---|
506 | *
|
---|
507 | * @returns true if the page is present.
|
---|
508 | * @returns false if the page is not present.
|
---|
509 | * @param pVM The VM handle.
|
---|
510 | * @param GCPtr Address within the page.
|
---|
511 | */
|
---|
512 | PGMDECL(bool) PGMGstIsPagePresent(PVM pVM, RTGCPTR GCPtr);
|
---|
513 |
|
---|
514 | /**
|
---|
515 | * Sets (replaces) the page flags for a range of pages in the guest's tables.
|
---|
516 | *
|
---|
517 | * @returns VBox status.
|
---|
518 | * @param pVM VM handle.
|
---|
519 | * @param GCPtr The address of the first page.
|
---|
520 | * @param cb The size of the range in bytes.
|
---|
521 | * @param fFlags Page flags X86_PTE_*, excluding the page mask of course.
|
---|
522 | */
|
---|
523 | PGMDECL(int) PGMGstSetPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags);
|
---|
524 |
|
---|
525 | /**
|
---|
526 | * Modify page flags for a range of pages in the guest's tables
|
---|
527 | *
|
---|
528 | * The existing flags are ANDed with the fMask and ORed with the fFlags.
|
---|
529 | *
|
---|
530 | * @returns VBox status code.
|
---|
531 | * @param pVM VM handle.
|
---|
532 | * @param GCPtr Virtual address of the first page in the range.
|
---|
533 | * @param cb Size (in bytes) of the range to apply the modification to.
|
---|
534 | * @param fFlags The OR mask - page flags X86_PTE_*, excluding the page mask of course.
|
---|
535 | * @param fMask The AND mask - page flags X86_PTE_*, excluding the page mask of course.
|
---|
536 | * Be very CAREFUL when ~'ing constants which could be 32-bit!
|
---|
537 | */
|
---|
538 | PGMDECL(int) PGMGstModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
|
---|
539 |
|
---|
540 | /**
|
---|
541 | * Performs and schedules necessary updates following a CR3 load or reload.
|
---|
542 | *
|
---|
543 | * This will normally involve mapping the guest PD or nPDPTR
|
---|
544 | *
|
---|
545 | * @returns VBox status code.
|
---|
546 | * @retval VINF_PGM_SYNC_CR3 if monitoring requires a CR3 sync. This can
|
---|
547 | * safely be ignored and overridden since the FF will be set too then.
|
---|
548 | * @param pVM VM handle.
|
---|
549 | * @param cr3 The new cr3.
|
---|
550 | * @param fGlobal Indicates whether this is a global flush or not.
|
---|
551 | */
|
---|
552 | PGMDECL(int) PGMFlushTLB(PVM pVM, uint32_t cr3, bool fGlobal);
|
---|
553 |
|
---|
554 | /**
|
---|
555 | * Synchronize the paging structures.
|
---|
556 | *
|
---|
557 | * This function is called in response to the VM_FF_PGM_SYNC_CR3 and
|
---|
558 | * VM_FF_PGM_SYNC_CR3_NONGLOBAL. Those two force action flags are set
|
---|
559 | * in several places, most importantly whenever the CR3 is loaded.
|
---|
560 | *
|
---|
561 | * @returns VBox status code.
|
---|
562 | * @param pVM The virtual machine.
|
---|
563 | * @param cr0 Guest context CR0 register
|
---|
564 | * @param cr3 Guest context CR3 register
|
---|
565 | * @param cr4 Guest context CR4 register
|
---|
566 | * @param fGlobal Including global page directories or not
|
---|
567 | */
|
---|
568 | PGMDECL(int) PGMSyncCR3(PVM pVM, uint32_t cr0, uint32_t cr3, uint32_t cr4, bool fGlobal);
|
---|
569 |
|
---|
570 | /**
|
---|
571 | * Called whenever CR0 or CR4 in a way which may change
|
---|
572 | * the paging mode.
|
---|
573 | *
|
---|
574 | * @returns VBox status code fit for scheduling in GC and R0.
|
---|
575 | * @retval VINF_SUCCESS if the was no change, or it was successfully dealt with.
|
---|
576 | * @retval VINF_PGM_CHANGE_MODE if we're in GC or R0 and the mode changes.
|
---|
577 | * @param pVM VM handle.
|
---|
578 | * @param cr0 The new cr0.
|
---|
579 | * @param cr4 The new cr4.
|
---|
580 | * @param efer The new extended feature enable register.
|
---|
581 | */
|
---|
582 | PGMDECL(int) PGMChangeMode(PVM pVM, uint32_t cr0, uint32_t cr4, uint64_t efer);
|
---|
583 |
|
---|
584 | /**
|
---|
585 | * Gets the current guest paging mode.
|
---|
586 | *
|
---|
587 | * If you just need the CPU mode (real/protected/long), use CPUMGetGuestMode().
|
---|
588 | *
|
---|
589 | * @returns The current paging mode.
|
---|
590 | * @param pVM The VM handle.
|
---|
591 | */
|
---|
592 | PGMDECL(PGMMODE) PGMGetGuestMode(PVM pVM);
|
---|
593 |
|
---|
594 | /**
|
---|
595 | * Gets the current shadow paging mode.
|
---|
596 | *
|
---|
597 | * @returns The current paging mode.
|
---|
598 | * @param pVM The VM handle.
|
---|
599 | */
|
---|
600 | PGMDECL(PGMMODE) PGMGetShadowMode(PVM pVM);
|
---|
601 |
|
---|
602 | /**
|
---|
603 | * Get mode name.
|
---|
604 | *
|
---|
605 | * @returns read-only name string.
|
---|
606 | * @param enmMode The mode which name is desired.
|
---|
607 | */
|
---|
608 | PGMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
|
---|
609 |
|
---|
610 | /**
|
---|
611 | * Register a access handler for a physical range.
|
---|
612 | *
|
---|
613 | * @returns VBox status code.
|
---|
614 | * @param pVM VM Handle.
|
---|
615 | * @param enmType Handler type. Any of the PGMPHYSHANDLERTYPE_PHYSICAL* enums.
|
---|
616 | * @param GCPhys Start physical address.
|
---|
617 | * @param GCPhysLast Last physical address. (inclusive)
|
---|
618 | * @param pfnHandlerR3 The R3 handler.
|
---|
619 | * @param pvUserR3 User argument to the R3 handler.
|
---|
620 | * @param pfnHandlerR0 The R0 handler.
|
---|
621 | * @param pvUserR0 User argument to the R0 handler.
|
---|
622 | * @param pfnHandlerGC The GC handler.
|
---|
623 | * @param pvUserGC User argument to the GC handler.
|
---|
624 | * This must be a GC pointer because it will be relocated!
|
---|
625 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
626 | */
|
---|
627 | PGMDECL(int) PGMHandlerPhysicalRegisterEx(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
|
---|
628 | R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
|
---|
629 | R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
|
---|
630 | GCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RTGCPTR pvUserGC,
|
---|
631 | R3PTRTYPE(const char *) pszDesc);
|
---|
632 |
|
---|
633 | /**
|
---|
634 | * Modify a physical page access handler.
|
---|
635 | *
|
---|
636 | * Modification can only be done to the range it self, not the type or anything else.
|
---|
637 | *
|
---|
638 | * @returns VBox status code.
|
---|
639 | * For all return codes other than VERR_PGM_HANDLER_NOT_FOUND and VINF_SUCCESS the range is deregistered
|
---|
640 | * and a new registration must be performed!
|
---|
641 | * @param pVM VM handle.
|
---|
642 | * @param GCPhysCurrent Current location.
|
---|
643 | * @param GCPhys New location.
|
---|
644 | * @param GCPhysLast New last location.
|
---|
645 | */
|
---|
646 | PGMDECL(int) PGMHandlerPhysicalModify(PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
|
---|
647 |
|
---|
648 | /**
|
---|
649 | * Register a physical page access handler.
|
---|
650 | *
|
---|
651 | * @returns VBox status code.
|
---|
652 | * @param pVM VM Handle.
|
---|
653 | * @param GCPhys Start physical address earlier passed to PGMR3HandlerPhysicalRegister().
|
---|
654 | */
|
---|
655 | PGMDECL(int) PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys);
|
---|
656 |
|
---|
657 | /**
|
---|
658 | * Changes the callbacks associated with a physical access handler.
|
---|
659 | *
|
---|
660 | * @returns VBox status code.
|
---|
661 | * @param pVM VM Handle.
|
---|
662 | * @param GCPhys Start physical address.
|
---|
663 | * @param pfnHandlerR3 The R3 handler.
|
---|
664 | * @param pvUserR3 User argument to the R3 handler.
|
---|
665 | * @param pfnHandlerR0 The R0 handler.
|
---|
666 | * @param pvUserR0 User argument to the R0 handler.
|
---|
667 | * @param pfnHandlerGC The GC handler.
|
---|
668 | * @param pvUserGC User argument to the GC handler.
|
---|
669 | * This must be a GC pointer because it will be relocated!
|
---|
670 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
671 | */
|
---|
672 | PGMDECL(int) PGMHandlerPhysicalChangeCallbacks(PVM pVM, RTGCPHYS GCPhys,
|
---|
673 | R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
|
---|
674 | R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0, RTR0PTR pvUserR0,
|
---|
675 | GCPTRTYPE(PFNPGMGCPHYSHANDLER) pfnHandlerGC, RTGCPTR pvUserGC,
|
---|
676 | R3PTRTYPE(const char *) pszDesc);
|
---|
677 |
|
---|
678 | /**
|
---|
679 | * Splitts a physical access handler in two.
|
---|
680 | *
|
---|
681 | * @returns VBox status code.
|
---|
682 | * @param pVM VM Handle.
|
---|
683 | * @param GCPhys Start physical address of the handler.
|
---|
684 | * @param GCPhysSplit The split address.
|
---|
685 | */
|
---|
686 | PGMDECL(int) PGMHandlerPhysicalSplit(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
|
---|
687 |
|
---|
688 | /**
|
---|
689 | * Joins up two adjacent physical access handlers which has the same callbacks.
|
---|
690 | *
|
---|
691 | * @returns VBox status code.
|
---|
692 | * @param pVM VM Handle.
|
---|
693 | * @param GCPhys1 Start physical address of the first handler.
|
---|
694 | * @param GCPhys2 Start physical address of the second handler.
|
---|
695 | */
|
---|
696 | PGMDECL(int) PGMHandlerPhysicalJoin(PVM pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
|
---|
697 |
|
---|
698 | /**
|
---|
699 | * Temporarily turns off the access monitoring of a page within a monitored
|
---|
700 | * physical write/all page access handler region.
|
---|
701 | *
|
---|
702 | * Use this when no further #PFs are required for that page. Be aware that
|
---|
703 | * a page directory sync might reset the flags, and turn on access monitoring
|
---|
704 | * for the page.
|
---|
705 | *
|
---|
706 | * The caller must do required page table modifications.
|
---|
707 | *
|
---|
708 | * @returns VBox status code.
|
---|
709 | * @param pVM VM Handle
|
---|
710 | * @param GCPhys Start physical address earlier passed to PGMR3HandlerPhysicalRegister().
|
---|
711 | * @param GCPhysPage Physical address of the page to turn off access monitoring for.
|
---|
712 | */
|
---|
713 | PGMDECL(int) PGMHandlerPhysicalPageTempOff(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
|
---|
714 |
|
---|
715 |
|
---|
716 | /**
|
---|
717 | * Resets any modifications to individual pages in a physical
|
---|
718 | * page access handler region.
|
---|
719 | *
|
---|
720 | * This is used in pair with PGMHandlerPhysicalModify().
|
---|
721 | *
|
---|
722 | * @returns VBox status code.
|
---|
723 | * @param pVM VM Handle
|
---|
724 | * @param GCPhys Start physical address earlier passed to PGMR3HandlerPhysicalRegister().
|
---|
725 | */
|
---|
726 | PGMDECL(int) PGMHandlerPhysicalReset(PVM pVM, RTGCPHYS GCPhys);
|
---|
727 |
|
---|
728 | /**
|
---|
729 | * Turns access monitoring of a page within a monitored
|
---|
730 | * physical write/all page access handler region back on.
|
---|
731 | *
|
---|
732 | * The caller must do required page table modifications.
|
---|
733 | *
|
---|
734 | * @returns VBox status code.
|
---|
735 | * @param pVM VM Handle
|
---|
736 | * @param GCPhys Start physical address earlier passed to PGMR3HandlerPhysicalRegister().
|
---|
737 | * @param GCPhysPage Physical address of the page to turn on access monitoring for.
|
---|
738 | */
|
---|
739 | PGMDECL(int) PGMHandlerPhysicalPageReset(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
|
---|
740 |
|
---|
741 | /**
|
---|
742 | * Checks if a physical range is handled
|
---|
743 | *
|
---|
744 | * @returns boolean.
|
---|
745 | * @param pVM VM Handle
|
---|
746 | * @param GCPhys Start physical address earlier passed to PGMR3HandlerPhysicalRegister().
|
---|
747 | */
|
---|
748 | PGMDECL(bool) PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys);
|
---|
749 |
|
---|
750 | /**
|
---|
751 | * Checks if Address Gate 20 is enabled or not.
|
---|
752 | *
|
---|
753 | * @returns true if enabled.
|
---|
754 | * @returns false if disabled.
|
---|
755 | * @param pVM VM handle.
|
---|
756 | */
|
---|
757 | PGMDECL(bool) PGMPhysIsA20Enabled(PVM pVM);
|
---|
758 |
|
---|
759 | /**
|
---|
760 | * Validates a GC physical address.
|
---|
761 | *
|
---|
762 | * @returns true if valid.
|
---|
763 | * @returns false if invalid.
|
---|
764 | * @param pVM The VM handle.
|
---|
765 | * @param GCPhys The physical address to validate.
|
---|
766 | */
|
---|
767 | PGMDECL(bool) PGMPhysIsGCPhysValid(PVM pVM, RTGCPHYS GCPhys);
|
---|
768 |
|
---|
769 | /**
|
---|
770 | * Checks if a GC physical address is a normal page,
|
---|
771 | * i.e. not ROM, MMIO or reserved.
|
---|
772 | *
|
---|
773 | * @returns true if normal.
|
---|
774 | * @returns false if invalid, ROM, MMIO or reserved page.
|
---|
775 | * @param pVM The VM handle.
|
---|
776 | * @param GCPhys The physical address to check.
|
---|
777 | */
|
---|
778 | PGMDECL(bool) PGMPhysIsGCPhysNormal(PVM pVM, RTGCPHYS GCPhys);
|
---|
779 |
|
---|
780 | /**
|
---|
781 | * Converts a GC physical address to a HC physical address.
|
---|
782 | *
|
---|
783 | * @returns VINF_SUCCESS on success.
|
---|
784 | * @returns VERR_PGM_PHYS_PAGE_RESERVED it it's a valid GC physical
|
---|
785 | * page but has no physical backing.
|
---|
786 | * @returns VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid
|
---|
787 | * GC physical address.
|
---|
788 | * @param pVM The VM handle.
|
---|
789 | * @param GCPhys The GC physical address to convert.
|
---|
790 | * @param pHCPhys Where to store the HC physical address on success.
|
---|
791 | */
|
---|
792 | PGMDECL(int) PGMPhysGCPhys2HCPhys(PVM pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
|
---|
793 |
|
---|
794 | /**
|
---|
795 | * Converts a guest pointer to a GC physical address.
|
---|
796 | *
|
---|
797 | * This uses the current CR3/CR0/CR4 of the guest.
|
---|
798 | *
|
---|
799 | * @returns VBox status code.
|
---|
800 | * @param pVM The VM Handle
|
---|
801 | * @param GCPtr The guest pointer to convert.
|
---|
802 | * @param pGCPhys Where to store the GC physical address.
|
---|
803 | */
|
---|
804 | PGMDECL(int) PGMPhysGCPtr2GCPhys(PVM pVM, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
|
---|
805 |
|
---|
806 | /**
|
---|
807 | * Converts a guest pointer to a HC physical address.
|
---|
808 | *
|
---|
809 | * This uses the current CR3/CR0/CR4 of the guest.
|
---|
810 | *
|
---|
811 | * @returns VBox status code.
|
---|
812 | * @param pVM The VM Handle
|
---|
813 | * @param GCPtr The guest pointer to convert.
|
---|
814 | * @param pHCPhys Where to store the HC physical address.
|
---|
815 | */
|
---|
816 | PGMDECL(int) PGMPhysGCPtr2HCPhys(PVM pVM, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
|
---|
817 |
|
---|
818 |
|
---|
819 | /**
|
---|
820 | * Invalidates the GC page mapping TLB.
|
---|
821 | *
|
---|
822 | * @param pVM The VM handle.
|
---|
823 | */
|
---|
824 | PDMDECL(void) PGMPhysInvalidatePageGCMapTLB(PVM pVM);
|
---|
825 |
|
---|
826 | /**
|
---|
827 | * Invalidates the ring-0 page mapping TLB.
|
---|
828 | *
|
---|
829 | * @param pVM The VM handle.
|
---|
830 | */
|
---|
831 | PDMDECL(void) PGMPhysInvalidatePageR0MapTLB(PVM pVM);
|
---|
832 |
|
---|
833 | /**
|
---|
834 | * Invalidates the ring-3 page mapping TLB.
|
---|
835 | *
|
---|
836 | * @param pVM The VM handle.
|
---|
837 | */
|
---|
838 | PDMDECL(void) PGMPhysInvalidatePageR3MapTLB(PVM pVM);
|
---|
839 |
|
---|
840 | /**
|
---|
841 | * Page mapping lock.
|
---|
842 | *
|
---|
843 | * @remarks This doesn't work in structures shared between
|
---|
844 | * ring-3, ring-0 and/or GC.
|
---|
845 | */
|
---|
846 | typedef struct PGMPAGEMAPLOCK
|
---|
847 | {
|
---|
848 | /** @todo see PGMPhysIsPageMappingLockValid for possibly incorrect assumptions */
|
---|
849 | #ifdef IN_GC
|
---|
850 | /** Just a dummy for the time being. */
|
---|
851 | uint32_t u32Dummy;
|
---|
852 | #else
|
---|
853 | /** Pointer to the PGMPAGE. */
|
---|
854 | void *pvPage;
|
---|
855 | /** Pointer to the PGMCHUNKR3MAP. */
|
---|
856 | void *pvMap;
|
---|
857 | #endif
|
---|
858 | } PGMPAGEMAPLOCK;
|
---|
859 | /** Pointer to a page mapping lock. */
|
---|
860 | typedef PGMPAGEMAPLOCK *PPGMPAGEMAPLOCK;
|
---|
861 |
|
---|
862 | /**
|
---|
863 | * Requests the mapping of a guest page into the current context.
|
---|
864 | *
|
---|
865 | * This API should only be used for very short term, as it will consume
|
---|
866 | * scarse resources (R0 and GC) in the mapping cache. When you're done
|
---|
867 | * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
|
---|
868 | *
|
---|
869 | * This API will assume your intention is to write to the page, and will
|
---|
870 | * therefore replace shared and zero pages. If you do not intend to modify
|
---|
871 | * the page, use the PGMPhysGCPhys2CCPtrReadOnly() API.
|
---|
872 | *
|
---|
873 | * @returns VBox status code.
|
---|
874 | * @retval VINF_SUCCESS on success.
|
---|
875 | * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
|
---|
876 | * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
|
---|
877 | *
|
---|
878 | * @param pVM The VM handle.
|
---|
879 | * @param GCPhys The guest physical address of the page that should be mapped.
|
---|
880 | * @param ppv Where to store the address corresponding to GCPhys.
|
---|
881 | * @param pLock Where to store the lock information that PGMPhysReleasePageMappingLock needs.
|
---|
882 | *
|
---|
883 | * @remark Avoid calling this API from within critical sections (other than
|
---|
884 | * the PGM one) because of the deadlock risk.
|
---|
885 | * @thread Any thread.
|
---|
886 | */
|
---|
887 | PGMDECL(int) PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
|
---|
888 |
|
---|
889 | /**
|
---|
890 | * Requests the mapping of a guest page into the current context.
|
---|
891 | *
|
---|
892 | * This API should only be used for very short term, as it will consume
|
---|
893 | * scarse resources (R0 and GC) in the mapping cache. When you're done
|
---|
894 | * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
|
---|
895 | *
|
---|
896 | * @returns VBox status code.
|
---|
897 | * @retval VINF_SUCCESS on success.
|
---|
898 | * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
|
---|
899 | * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
|
---|
900 | *
|
---|
901 | * @param pVM The VM handle.
|
---|
902 | * @param GCPhys The guest physical address of the page that should be mapped.
|
---|
903 | * @param ppv Where to store the address corresponding to GCPhys.
|
---|
904 | * @param pLock Where to store the lock information that PGMPhysReleasePageMappingLock needs.
|
---|
905 | *
|
---|
906 | * @remark Avoid calling this API from within critical sections (other than
|
---|
907 | * the PGM one) because of the deadlock risk.
|
---|
908 | * @thread Any thread.
|
---|
909 | */
|
---|
910 | PGMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
|
---|
911 |
|
---|
912 | /**
|
---|
913 | * Requests the mapping of a guest page given by virtual address into the current context.
|
---|
914 | *
|
---|
915 | * This API should only be used for very short term, as it will consume
|
---|
916 | * scarse resources (R0 and GC) in the mapping cache. When you're done
|
---|
917 | * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
|
---|
918 | *
|
---|
919 | * This API will assume your intention is to write to the page, and will
|
---|
920 | * therefore replace shared and zero pages. If you do not intend to modify
|
---|
921 | * the page, use the PGMPhysGCPtr2CCPtrReadOnly() API.
|
---|
922 | *
|
---|
923 | * @returns VBox status code.
|
---|
924 | * @retval VINF_SUCCESS on success.
|
---|
925 | * @retval VERR_PAGE_TABLE_NOT_PRESENT if the page directory for the virtual address isn't present.
|
---|
926 | * @retval VERR_PAGE_NOT_PRESENT if the page at the virtual address isn't present.
|
---|
927 | * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
|
---|
928 | * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
|
---|
929 | *
|
---|
930 | * @param pVM The VM handle.
|
---|
931 | * @param GCPhys The guest physical address of the page that should be mapped.
|
---|
932 | * @param ppv Where to store the address corresponding to GCPhys.
|
---|
933 | * @param pLock Where to store the lock information that PGMPhysReleasePageMappingLock needs.
|
---|
934 | *
|
---|
935 | * @remark Avoid calling this API from within critical sections (other than
|
---|
936 | * the PGM one) because of the deadlock risk.
|
---|
937 | * @thread EMT
|
---|
938 | */
|
---|
939 | PGMDECL(int) PGMPhysGCPtr2CCPtr(PVM pVM, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
|
---|
940 |
|
---|
941 | /**
|
---|
942 | * Requests the mapping of a guest page given by virtual address into the current context.
|
---|
943 | *
|
---|
944 | * This API should only be used for very short term, as it will consume
|
---|
945 | * scarse resources (R0 and GC) in the mapping cache. When you're done
|
---|
946 | * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
|
---|
947 | *
|
---|
948 | * @returns VBox status code.
|
---|
949 | * @retval VINF_SUCCESS on success.
|
---|
950 | * @retval VERR_PAGE_TABLE_NOT_PRESENT if the page directory for the virtual address isn't present.
|
---|
951 | * @retval VERR_PAGE_NOT_PRESENT if the page at the virtual address isn't present.
|
---|
952 | * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
|
---|
953 | * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
|
---|
954 | *
|
---|
955 | * @param pVM The VM handle.
|
---|
956 | * @param GCPhys The guest physical address of the page that should be mapped.
|
---|
957 | * @param ppv Where to store the address corresponding to GCPhys.
|
---|
958 | * @param pLock Where to store the lock information that PGMPhysReleasePageMappingLock needs.
|
---|
959 | *
|
---|
960 | * @remark Avoid calling this API from within critical sections (other than
|
---|
961 | * the PGM one) because of the deadlock risk.
|
---|
962 | * @thread EMT
|
---|
963 | */
|
---|
964 | PGMDECL(int) PGMPhysGCPtr2CCPtrReadOnly(PVM pVM, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
|
---|
965 |
|
---|
966 | /**
|
---|
967 | * Release the mapping of a guest page.
|
---|
968 | *
|
---|
969 | * This is the counter part of PGMPhysGCPhys2CCPtr, PGMPhysGCPhys2CCPtrReadOnly
|
---|
970 | * PGMPhysGCPtr2CCPtr and PGMPhysGCPtr2CCPtrReadOnly.
|
---|
971 | *
|
---|
972 | * @param pVM The VM handle.
|
---|
973 | * @param pLock The lock structure initialized by the mapping function.
|
---|
974 | */
|
---|
975 | PGMDECL(void) PGMPhysReleasePageMappingLock(PVM pVM, PPGMPAGEMAPLOCK pLock);
|
---|
976 |
|
---|
977 |
|
---|
978 | /**
|
---|
979 | * Checks if the lock structure is valid
|
---|
980 | *
|
---|
981 | * @param pVM The VM handle.
|
---|
982 | * @param pLock The lock structure initialized by the mapping function.
|
---|
983 | */
|
---|
984 | DECLINLINE(bool) PGMPhysIsPageMappingLockValid(PVM pVM, PPGMPAGEMAPLOCK pLock)
|
---|
985 | {
|
---|
986 | /** @todo -> complete/change this */
|
---|
987 | #ifdef IN_GC
|
---|
988 | return !!(pLock->u32Dummy);
|
---|
989 | #else
|
---|
990 | return !!(pLock->pvPage);
|
---|
991 | #endif
|
---|
992 | }
|
---|
993 |
|
---|
994 | /**
|
---|
995 | * Converts a GC physical address to a HC pointer.
|
---|
996 | *
|
---|
997 | * @returns VINF_SUCCESS on success.
|
---|
998 | * @returns VERR_PGM_PHYS_PAGE_RESERVED it it's a valid GC physical
|
---|
999 | * page but has no physical backing.
|
---|
1000 | * @returns VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid
|
---|
1001 | * GC physical address.
|
---|
1002 | * @param pVM The VM handle.
|
---|
1003 | * @param GCPhys The GC physical address to convert.
|
---|
1004 | * @param cbRange Physical range
|
---|
1005 | * @param pHCPtr Where to store the HC pointer on success.
|
---|
1006 | *
|
---|
1007 | * @remark Do *not* assume this mapping will be around forever!
|
---|
1008 | */
|
---|
1009 | PGMDECL(int) PGMPhysGCPhys2HCPtr(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR pHCPtr);
|
---|
1010 |
|
---|
1011 | /**
|
---|
1012 | * Converts a guest pointer to a HC pointer.
|
---|
1013 | *
|
---|
1014 | * This uses the current CR3/CR0/CR4 of the guest.
|
---|
1015 | *
|
---|
1016 | * @returns VBox status code.
|
---|
1017 | * @param pVM The VM Handle
|
---|
1018 | * @param GCPtr The guest pointer to convert.
|
---|
1019 | * @param pHCPtr Where to store the HC virtual address.
|
---|
1020 | *
|
---|
1021 | * @remark Do *not* assume this mapping will be around forever!
|
---|
1022 | */
|
---|
1023 | PGMDECL(int) PGMPhysGCPtr2HCPtr(PVM pVM, RTGCPTR GCPtr, PRTHCPTR pHCPtr);
|
---|
1024 |
|
---|
1025 | /**
|
---|
1026 | * Converts a guest virtual address to a HC pointer by specfied CR3 and flags.
|
---|
1027 | *
|
---|
1028 | * @returns VBox status code.
|
---|
1029 | * @param pVM The VM Handle
|
---|
1030 | * @param GCPtr The guest pointer to convert.
|
---|
1031 | * @param cr3 The guest CR3.
|
---|
1032 | * @param fFlags Flags used for interpreting the PD correctly: X86_CR4_PSE and X86_CR4_PAE
|
---|
1033 | * @param pHCPtr Where to store the HC pointer.
|
---|
1034 | *
|
---|
1035 | * @remark Do *not* assume this mapping will be around forever!
|
---|
1036 | * @remark This function is used by the REM at a time where PGM could
|
---|
1037 | * potentially not be in sync. It could also be used by a
|
---|
1038 | * future DBGF API to cpu state independent conversions.
|
---|
1039 | */
|
---|
1040 | PGMDECL(int) PGMPhysGCPtr2HCPtrByGstCR3(PVM pVM, RTGCPTR GCPtr, uint32_t cr3, unsigned fFlags, PRTHCPTR pHCPtr);
|
---|
1041 |
|
---|
1042 | /**
|
---|
1043 | * Read physical memory.
|
---|
1044 | *
|
---|
1045 | * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
|
---|
1046 | * want to ignore those.
|
---|
1047 | *
|
---|
1048 | * @param pVM VM Handle.
|
---|
1049 | * @param GCPhys Physical address start reading from.
|
---|
1050 | * @param pvBuf Where to put the read bits.
|
---|
1051 | * @param cbRead How many bytes to read.
|
---|
1052 | */
|
---|
1053 | PGMDECL(void) PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
|
---|
1054 |
|
---|
1055 | /**
|
---|
1056 | * Write to physical memory.
|
---|
1057 | *
|
---|
1058 | * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
|
---|
1059 | * want to ignore those.
|
---|
1060 | *
|
---|
1061 | * @param pVM VM Handle.
|
---|
1062 | * @param GCPhys Physical address to write to.
|
---|
1063 | * @param pvBuf What to write.
|
---|
1064 | * @param cbWrite How many bytes to write.
|
---|
1065 | */
|
---|
1066 | PGMDECL(void) PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
|
---|
1067 |
|
---|
1068 |
|
---|
1069 | #ifndef IN_GC /* Only ring 0 & 3. */
|
---|
1070 |
|
---|
1071 | /**
|
---|
1072 | * Read from guest physical memory by GC physical address, bypassing
|
---|
1073 | * MMIO and access handlers.
|
---|
1074 | *
|
---|
1075 | * @returns VBox status.
|
---|
1076 | * @param pVM VM handle.
|
---|
1077 | * @param pvDst The destination address.
|
---|
1078 | * @param GCPhysSrc The source address (GC physical address).
|
---|
1079 | * @param cb The number of bytes to read.
|
---|
1080 | */
|
---|
1081 | PGMDECL(int) PGMPhysReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
|
---|
1082 |
|
---|
1083 | /**
|
---|
1084 | * Write to guest physical memory referenced by GC pointer.
|
---|
1085 | * Write memory to GC physical address in guest physical memory.
|
---|
1086 | *
|
---|
1087 | * This will bypass MMIO and access handlers.
|
---|
1088 | *
|
---|
1089 | * @returns VBox status.
|
---|
1090 | * @param pVM VM handle.
|
---|
1091 | * @param GCPhysDst The GC physical address of the destination.
|
---|
1092 | * @param pvSrc The source buffer.
|
---|
1093 | * @param cb The number of bytes to write.
|
---|
1094 | */
|
---|
1095 | PGMDECL(int) PGMPhysWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
|
---|
1096 |
|
---|
1097 | /**
|
---|
1098 | * Read from guest physical memory referenced by GC pointer.
|
---|
1099 | *
|
---|
1100 | * This function uses the current CR3/CR0/CR4 of the guest and will
|
---|
1101 | * bypass access handlers and not set any accessed bits.
|
---|
1102 | *
|
---|
1103 | * @returns VBox status.
|
---|
1104 | * @param pVM VM handle.
|
---|
1105 | * @param pvDst The destination address.
|
---|
1106 | * @param GCPtrSrc The source address (GC pointer).
|
---|
1107 | * @param cb The number of bytes to read.
|
---|
1108 | */
|
---|
1109 | PGMDECL(int) PGMPhysReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
|
---|
1110 |
|
---|
1111 | /**
|
---|
1112 | * Write to guest physical memory referenced by GC pointer.
|
---|
1113 | *
|
---|
1114 | * This function uses the current CR3/CR0/CR4 of the guest and will
|
---|
1115 | * bypass access handlers and not set dirty or accessed bits.
|
---|
1116 | *
|
---|
1117 | * @returns VBox status.
|
---|
1118 | * @param pVM VM handle.
|
---|
1119 | * @param GCPtrDst The destination address (GC pointer).
|
---|
1120 | * @param pvSrc The source address.
|
---|
1121 | * @param cb The number of bytes to write.
|
---|
1122 | */
|
---|
1123 | PGMDECL(int) PGMPhysWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
|
---|
1124 |
|
---|
1125 | /**
|
---|
1126 | * Read from guest physical memory referenced by GC pointer.
|
---|
1127 | *
|
---|
1128 | * This function uses the current CR3/CR0/CR4 of the guest and will
|
---|
1129 | * respect access handlers and set accessed bits.
|
---|
1130 | *
|
---|
1131 | * @returns VBox status.
|
---|
1132 | * @param pVM VM handle.
|
---|
1133 | * @param pvDst The destination address.
|
---|
1134 | * @param GCPtrSrc The source address (GC pointer).
|
---|
1135 | * @param cb The number of bytes to read.
|
---|
1136 | */
|
---|
1137 | PGMDECL(int) PGMPhysReadGCPtrSafe(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
|
---|
1138 |
|
---|
1139 | /**
|
---|
1140 | * Write to guest physical memory referenced by GC pointer.
|
---|
1141 | *
|
---|
1142 | * This function uses the current CR3/CR0/CR4 of the guest and will
|
---|
1143 | * respect access handlers and set dirty and accessed bits.
|
---|
1144 | *
|
---|
1145 | * @returns VBox status.
|
---|
1146 | * @param pVM VM handle.
|
---|
1147 | * @param GCPtrDst The destination address (GC pointer).
|
---|
1148 | * @param pvSrc The source address.
|
---|
1149 | * @param cb The number of bytes to write.
|
---|
1150 | */
|
---|
1151 | PGMDECL(int) PGMPhysWriteGCPtrSafe(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
|
---|
1152 |
|
---|
1153 | /**
|
---|
1154 | * Write to guest physical memory referenced by GC pointer and update the PTE.
|
---|
1155 | *
|
---|
1156 | * This function uses the current CR3/CR0/CR4 of the guest and will
|
---|
1157 | * bypass access handlers and set any dirty and accessed bits in the PTE.
|
---|
1158 | *
|
---|
1159 | * If you don't want to set the dirty bit, use PGMR3PhysWriteGCPtr().
|
---|
1160 | *
|
---|
1161 | * @returns VBox status.
|
---|
1162 | * @param pVM VM handle.
|
---|
1163 | * @param GCPtrDst The destination address (GC pointer).
|
---|
1164 | * @param pvSrc The source address.
|
---|
1165 | * @param cb The number of bytes to write.
|
---|
1166 | */
|
---|
1167 | PGMDECL(int) PGMPhysWriteGCPtrDirty(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
|
---|
1168 |
|
---|
1169 | /**
|
---|
1170 | * Emulation of the invlpg instruction (HC only actually).
|
---|
1171 | *
|
---|
1172 | * @returns VBox status code.
|
---|
1173 | * @param pVM VM handle.
|
---|
1174 | * @param GCPtrPage Page to invalidate.
|
---|
1175 | * @remark ASSUMES the page table entry or page directory is
|
---|
1176 | * valid. Fairly safe, but there could be edge cases!
|
---|
1177 | * @todo Flush page or page directory only if necessary!
|
---|
1178 | */
|
---|
1179 | PGMDECL(int) PGMInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
|
---|
1180 |
|
---|
1181 | #endif /* !IN_GC */
|
---|
1182 |
|
---|
1183 | /**
|
---|
1184 | * Performs a read of guest virtual memory for instruction emulation.
|
---|
1185 | *
|
---|
1186 | * This will check permissions, raise exceptions and update the access bits.
|
---|
1187 | *
|
---|
1188 | * The current implementation will bypass all access handlers. It may later be
|
---|
1189 | * changed to at least respect MMIO.
|
---|
1190 | *
|
---|
1191 | *
|
---|
1192 | * @returns VBox status code suitable to scheduling.
|
---|
1193 | * @retval VINF_SUCCESS if the read was performed successfully.
|
---|
1194 | * @retval VINF_EM_RAW_GUEST_TRAP if an exception was raised but not dispatched yet.
|
---|
1195 | * @retval VINF_TRPM_XCPT_DISPATCHED if an exception was raised and dispatched.
|
---|
1196 | *
|
---|
1197 | * @param pVM The VM handle.
|
---|
1198 | * @param pCtxCore The context core.
|
---|
1199 | * @param pvDst Where to put the bytes we've read.
|
---|
1200 | * @param GCPtrSrc The source address.
|
---|
1201 | * @param cb The number of bytes to read. Not more than a page.
|
---|
1202 | *
|
---|
1203 | * @remark This function will dynamically map physical pages in GC. This may unmap
|
---|
1204 | * mappings done by the caller. Be careful!
|
---|
1205 | */
|
---|
1206 | PGMDECL(int) PGMPhysInterpretedRead(PVM pVM, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb);
|
---|
1207 |
|
---|
1208 | #ifdef VBOX_STRICT
|
---|
1209 | /**
|
---|
1210 | * Asserts that the handlers+guest-page-tables == ramrange-flags and
|
---|
1211 | * that the physical addresses associated with virtual handlers are correct.
|
---|
1212 | *
|
---|
1213 | * @returns Number of mismatches.
|
---|
1214 | * @param pVM The VM handle.
|
---|
1215 | */
|
---|
1216 | PGMDECL(unsigned) PGMAssertHandlerAndFlagsInSync(PVM pVM);
|
---|
1217 |
|
---|
1218 | /**
|
---|
1219 | * Asserts that there are no mapping conflicts.
|
---|
1220 | *
|
---|
1221 | * @returns Number of conflicts.
|
---|
1222 | * @param pVM The VM Handle.
|
---|
1223 | */
|
---|
1224 | PGMDECL(unsigned) PGMAssertNoMappingConflicts(PVM pVM);
|
---|
1225 |
|
---|
1226 | /**
|
---|
1227 | * Asserts that everything related to the guest CR3 is correctly shadowed.
|
---|
1228 | *
|
---|
1229 | * This will call PGMAssertNoMappingConflicts() and PGMAssertHandlerAndFlagsInSync(),
|
---|
1230 | * and assert the correctness of the guest CR3 mapping before asserting that the
|
---|
1231 | * shadow page tables is in sync with the guest page tables.
|
---|
1232 | *
|
---|
1233 | * @returns Number of conflicts.
|
---|
1234 | * @param pVM The VM Handle.
|
---|
1235 | * @param cr3 The current guest CR3 register value.
|
---|
1236 | * @param cr4 The current guest CR4 register value.
|
---|
1237 | */
|
---|
1238 | PGMDECL(unsigned) PGMAssertCR3(PVM pVM, uint32_t cr3, uint32_t cr4);
|
---|
1239 | #endif /* VBOX_STRICT */
|
---|
1240 |
|
---|
1241 |
|
---|
1242 | #ifdef IN_GC
|
---|
1243 |
|
---|
1244 | /** @defgroup grp_pgm_gc The PGM Guest Context API
|
---|
1245 | * @ingroup grp_pgm
|
---|
1246 | * @{
|
---|
1247 | */
|
---|
1248 |
|
---|
1249 | /**
|
---|
1250 | * Temporarily maps one guest page specified by GC physical address.
|
---|
1251 | * These pages must have a physical mapping in HC, i.e. they cannot be MMIO pages.
|
---|
1252 | *
|
---|
1253 | * Be WARNED that the dynamic page mapping area is small, 8 pages, thus the space is
|
---|
1254 | * reused after 8 mappings (or perhaps a few more if you score with the cache).
|
---|
1255 | *
|
---|
1256 | * @returns VBox status.
|
---|
1257 | * @param pVM VM handle.
|
---|
1258 | * @param GCPhys GC Physical address of the page.
|
---|
1259 | * @param ppv Where to store the address of the mapping.
|
---|
1260 | */
|
---|
1261 | PGMGCDECL(int) PGMGCDynMapGCPage(PVM pVM, RTGCPHYS GCPhys, void **ppv);
|
---|
1262 |
|
---|
1263 | /**
|
---|
1264 | * Temporarily maps one guest page specified by unaligned GC physical address.
|
---|
1265 | * These pages must have a physical mapping in HC, i.e. they cannot be MMIO pages.
|
---|
1266 | *
|
---|
1267 | * Be WARNED that the dynamic page mapping area is small, 8 pages, thus the space is
|
---|
1268 | * reused after 8 mappings (or perhaps a few more if you score with the cache).
|
---|
1269 | *
|
---|
1270 | * The caller is aware that only the speicifed page is mapped and that really bad things
|
---|
1271 | * will happen if writing beyond the page!
|
---|
1272 | *
|
---|
1273 | * @returns VBox status.
|
---|
1274 | * @param pVM VM handle.
|
---|
1275 | * @param GCPhys GC Physical address within the page to be mapped.
|
---|
1276 | * @param ppv Where to store the address of the mapping address corresponding to GCPhys.
|
---|
1277 | */
|
---|
1278 | PGMGCDECL(int) PGMGCDynMapGCPageEx(PVM pVM, RTGCPHYS GCPhys, void **ppv);
|
---|
1279 |
|
---|
1280 | /**
|
---|
1281 | * Temporarily maps one host page specified by HC physical address.
|
---|
1282 | *
|
---|
1283 | * Be WARNED that the dynamic page mapping area is small, 8 pages, thus the space is
|
---|
1284 | * reused after 8 mappings (or perhaps a few more if you score with the cache).
|
---|
1285 | *
|
---|
1286 | * @returns VBox status.
|
---|
1287 | * @param pVM VM handle.
|
---|
1288 | * @param HCPhys HC Physical address of the page.
|
---|
1289 | * @param ppv Where to store the address of the mapping.
|
---|
1290 | */
|
---|
1291 | PGMGCDECL(int) PGMGCDynMapHCPage(PVM pVM, RTHCPHYS HCPhys, void **ppv);
|
---|
1292 |
|
---|
1293 | /**
|
---|
1294 | * Syncs a guest os page table.
|
---|
1295 | *
|
---|
1296 | * @returns VBox status code.
|
---|
1297 | * @param pVM VM handle.
|
---|
1298 | * @param iPD Page directory index.
|
---|
1299 | * @param pPDSrc Source page directory (i.e. Guest OS page directory).
|
---|
1300 | * Assume this is a temporary mapping.
|
---|
1301 | */
|
---|
1302 | PGMGCDECL(int) PGMGCSyncPT(PVM pVM, unsigned iPD, PVBOXPD pPDSrc);
|
---|
1303 |
|
---|
1304 | /**
|
---|
1305 | * Emulation of the invlpg instruction.
|
---|
1306 | *
|
---|
1307 | * @returns VBox status code.
|
---|
1308 | * @param pVM VM handle.
|
---|
1309 | * @param GCPtrPage Page to invalidate.
|
---|
1310 | */
|
---|
1311 | PGMGCDECL(int) PGMGCInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
|
---|
1312 |
|
---|
1313 | /** @} */
|
---|
1314 | #endif
|
---|
1315 |
|
---|
1316 |
|
---|
1317 | #ifdef IN_RING0
|
---|
1318 | /** @defgroup grp_pgm_r0 The PGM Host Context Ring-0 API
|
---|
1319 | * @ingroup grp_pgm
|
---|
1320 | * @{
|
---|
1321 | */
|
---|
1322 | /**
|
---|
1323 | * Worker function for PGMR3PhysAllocateHandyPages and pgmPhysEnsureHandyPage.
|
---|
1324 | *
|
---|
1325 | * @returns The following VBox status codes.
|
---|
1326 | * @retval VINF_SUCCESS on success. FF cleared.
|
---|
1327 | * @retval VINF_EM_NO_MEMORY if we're out of memory. The FF is set in this case.
|
---|
1328 | *
|
---|
1329 | * @param pVM The VM handle.
|
---|
1330 | *
|
---|
1331 | * @remarks Must be called from within the PGM critical section.
|
---|
1332 | */
|
---|
1333 | PGMR0DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM);
|
---|
1334 |
|
---|
1335 | /** @} */
|
---|
1336 | #endif
|
---|
1337 |
|
---|
1338 |
|
---|
1339 |
|
---|
1340 | #ifdef IN_RING3
|
---|
1341 | /** @defgroup grp_pgm_r3 The PGM Host Context Ring-3 API
|
---|
1342 | * @ingroup grp_pgm
|
---|
1343 | * @{
|
---|
1344 | */
|
---|
1345 | /**
|
---|
1346 | * Initiates the paging of VM.
|
---|
1347 | *
|
---|
1348 | * @returns VBox status code.
|
---|
1349 | * @param pVM Pointer to VM structure.
|
---|
1350 | */
|
---|
1351 | PGMR3DECL(int) PGMR3Init(PVM pVM);
|
---|
1352 |
|
---|
1353 | /**
|
---|
1354 | * Init the PGM bits that rely on VMMR0 and MM to be fully initialized.
|
---|
1355 | *
|
---|
1356 | * The dynamic mapping area will also be allocated and initialized at this
|
---|
1357 | * time. We could allocate it during PGMR3Init of course, but the mapping
|
---|
1358 | * wouldn't be allocated at that time preventing us from setting up the
|
---|
1359 | * page table entries with the dummy page.
|
---|
1360 | *
|
---|
1361 | * @returns VBox status code.
|
---|
1362 | * @param pVM VM handle.
|
---|
1363 | */
|
---|
1364 | PGMR3DECL(int) PGMR3InitDynMap(PVM pVM);
|
---|
1365 |
|
---|
1366 | /**
|
---|
1367 | * Ring-3 init finalizing.
|
---|
1368 | *
|
---|
1369 | * @returns VBox status code.
|
---|
1370 | * @param pVM The VM handle.
|
---|
1371 | */
|
---|
1372 | PGMR3DECL(int) PGMR3InitFinalize(PVM pVM);
|
---|
1373 |
|
---|
1374 | /**
|
---|
1375 | * Applies relocations to data and code managed by this
|
---|
1376 | * component. This function will be called at init and
|
---|
1377 | * whenever the VMM need to relocate it self inside the GC.
|
---|
1378 | *
|
---|
1379 | * @param pVM The VM.
|
---|
1380 | * @param offDelta Relocation delta relative to old location.
|
---|
1381 | */
|
---|
1382 | PGMR3DECL(void) PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
1383 |
|
---|
1384 | /**
|
---|
1385 | * The VM is being reset.
|
---|
1386 | *
|
---|
1387 | * For the PGM component this means that any PD write monitors
|
---|
1388 | * needs to be removed.
|
---|
1389 | *
|
---|
1390 | * @param pVM VM handle.
|
---|
1391 | */
|
---|
1392 | PGMR3DECL(void) PGMR3Reset(PVM pVM);
|
---|
1393 |
|
---|
1394 | /**
|
---|
1395 | * Terminates the PGM.
|
---|
1396 | *
|
---|
1397 | * @returns VBox status code.
|
---|
1398 | * @param pVM Pointer to VM structure.
|
---|
1399 | */
|
---|
1400 | PGMR3DECL(int) PGMR3Term(PVM pVM);
|
---|
1401 |
|
---|
1402 | /**
|
---|
1403 | * Serivce a VMMCALLHOST_PGM_LOCK call.
|
---|
1404 | *
|
---|
1405 | * @returns VBox status code.
|
---|
1406 | * @param pVM The VM handle.
|
---|
1407 | */
|
---|
1408 | PDMR3DECL(int) PGMR3LockCall(PVM pVM);
|
---|
1409 |
|
---|
1410 | /**
|
---|
1411 | * Inform PGM if we want all mappings to be put into the shadow page table. (necessary for e.g. VMX)
|
---|
1412 | *
|
---|
1413 | * @returns VBox status code.
|
---|
1414 | * @param pVM VM handle.
|
---|
1415 | * @param fEnable Enable or disable shadow mappings
|
---|
1416 | */
|
---|
1417 | PGMR3DECL(int) PGMR3ChangeShwPDMappings(PVM pVM, bool fEnable);
|
---|
1418 |
|
---|
1419 | /**
|
---|
1420 | * Allocate missing physical pages for an existing guest RAM range.
|
---|
1421 | *
|
---|
1422 | * @returns VBox status.
|
---|
1423 | * @param pVM The VM handle.
|
---|
1424 | * @param GCPhys GC physical address of the RAM range. (page aligned)
|
---|
1425 | */
|
---|
1426 | PGMR3DECL(int) PGM3PhysGrowRange(PVM pVM, RTGCPHYS GCPhys);
|
---|
1427 |
|
---|
1428 | /**
|
---|
1429 | * Interface that the MMR3RamRegister(), MMR3RomRegister() and MMIO handler
|
---|
1430 | * registration APIs calls to inform PGM about memory registrations.
|
---|
1431 | *
|
---|
1432 | * It registers the physical memory range with PGM. MM is responsible
|
---|
1433 | * for the toplevel things - allocation and locking - while PGM is taking
|
---|
1434 | * care of all the details and implements the physical address space virtualization.
|
---|
1435 | *
|
---|
1436 | * @returns VBox status.
|
---|
1437 | * @param pVM The VM handle.
|
---|
1438 | * @param pvRam HC virtual address of the RAM range. (page aligned)
|
---|
1439 | * @param GCPhys GC physical address of the RAM range. (page aligned)
|
---|
1440 | * @param cb Size of the RAM range. (page aligned)
|
---|
1441 | * @param fFlags Flags, MM_RAM_*.
|
---|
1442 | * @param paPages Pointer an array of physical page descriptors.
|
---|
1443 | * @param pszDesc Description string.
|
---|
1444 | */
|
---|
1445 | PGMR3DECL(int) PGMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
|
---|
1446 |
|
---|
1447 | /**
|
---|
1448 | * Register a chunk of a the physical memory range with PGM. MM is responsible
|
---|
1449 | * for the toplevel things - allocation and locking - while PGM is taking
|
---|
1450 | * care of all the details and implements the physical address space virtualization.
|
---|
1451 | *
|
---|
1452 | * @returns VBox status.
|
---|
1453 | * @param pVM The VM handle.
|
---|
1454 | * @param pvRam HC virtual address of the RAM range. (page aligned)
|
---|
1455 | * @param GCPhys GC physical address of the RAM range. (page aligned)
|
---|
1456 | * @param cb Size of the RAM range. (page aligned)
|
---|
1457 | * @param fFlags Flags, MM_RAM_*.
|
---|
1458 | * @param paPages Pointer an array of physical page descriptors.
|
---|
1459 | * @param pszDesc Description string.
|
---|
1460 | */
|
---|
1461 | PGMR3DECL(int) PGMR3PhysRegisterChunk(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
|
---|
1462 |
|
---|
1463 | /**
|
---|
1464 | * Interface MMIO handler relocation calls.
|
---|
1465 | *
|
---|
1466 | * It relocates an existing physical memory range with PGM.
|
---|
1467 | *
|
---|
1468 | * @returns VBox status.
|
---|
1469 | * @param pVM The VM handle.
|
---|
1470 | * @param GCPhysOld Previous GC physical address of the RAM range. (page aligned)
|
---|
1471 | * @param GCPhysNew New GC physical address of the RAM range. (page aligned)
|
---|
1472 | * @param cb Size of the RAM range. (page aligned)
|
---|
1473 | */
|
---|
1474 | PGMR3DECL(int) PGMR3PhysRelocate(PVM pVM, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, size_t cb);
|
---|
1475 |
|
---|
1476 | /**
|
---|
1477 | * Interface MMR3RomRegister() and MMR3PhysReserve calls to update the
|
---|
1478 | * flags of existing RAM ranges.
|
---|
1479 | *
|
---|
1480 | * @returns VBox status.
|
---|
1481 | * @param pVM The VM handle.
|
---|
1482 | * @param GCPhys GC physical address of the RAM range. (page aligned)
|
---|
1483 | * @param cb Size of the RAM range. (page aligned)
|
---|
1484 | * @param fFlags The Or flags, MM_RAM_* #defines.
|
---|
1485 | * @param fMask The and mask for the flags.
|
---|
1486 | */
|
---|
1487 | PGMR3DECL(int) PGMR3PhysSetFlags(PVM pVM, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, unsigned fMask);
|
---|
1488 |
|
---|
1489 | /**
|
---|
1490 | * Sets the Address Gate 20 state.
|
---|
1491 | *
|
---|
1492 | * @param pVM VM handle.
|
---|
1493 | * @param fEnable True if the gate should be enabled.
|
---|
1494 | * False if the gate should be disabled.
|
---|
1495 | */
|
---|
1496 | PGMDECL(void) PGMR3PhysSetA20(PVM pVM, bool fEnable);
|
---|
1497 |
|
---|
1498 | /**
|
---|
1499 | * Creates a page table based mapping in GC.
|
---|
1500 | *
|
---|
1501 | * @returns VBox status code.
|
---|
1502 | * @param pVM VM Handle.
|
---|
1503 | * @param GCPtr Virtual Address. (Page table aligned!)
|
---|
1504 | * @param cb Size of the range. Must be a 4MB aligned!
|
---|
1505 | * @param pfnRelocate Relocation callback function.
|
---|
1506 | * @param pvUser User argument to the callback.
|
---|
1507 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
1508 | */
|
---|
1509 | PGMR3DECL(int) PGMR3MapPT(PVM pVM, RTGCPTR GCPtr, size_t cb, PFNPGMRELOCATE pfnRelocate, void *pvUser, const char *pszDesc);
|
---|
1510 |
|
---|
1511 | /**
|
---|
1512 | * Removes a page table based mapping.
|
---|
1513 | *
|
---|
1514 | * @returns VBox status code.
|
---|
1515 | * @param pVM VM Handle.
|
---|
1516 | * @param GCPtr Virtual Address. (Page table aligned!)
|
---|
1517 | */
|
---|
1518 | PGMR3DECL(int) PGMR3UnmapPT(PVM pVM, RTGCPTR GCPtr);
|
---|
1519 |
|
---|
1520 | /**
|
---|
1521 | * Gets the size of the current guest mappings if they were to be
|
---|
1522 | * put next to oneanother.
|
---|
1523 | *
|
---|
1524 | * @returns VBox status code.
|
---|
1525 | * @param pVM The VM.
|
---|
1526 | * @param pcb Where to store the size.
|
---|
1527 | */
|
---|
1528 | PGMR3DECL(int) PGMR3MappingsSize(PVM pVM, size_t *pcb);
|
---|
1529 |
|
---|
1530 | /**
|
---|
1531 | * Fixes the guest context mappings in a range reserved from the Guest OS.
|
---|
1532 | *
|
---|
1533 | * @returns VBox status code.
|
---|
1534 | * @param pVM The VM.
|
---|
1535 | * @param GCPtrBase The address of the reserved range of guest memory.
|
---|
1536 | * @param cb The size of the range starting at GCPtrBase.
|
---|
1537 | */
|
---|
1538 | PGMR3DECL(int) PGMR3MappingsFix(PVM pVM, RTGCPTR GCPtrBase, size_t cb);
|
---|
1539 |
|
---|
1540 | /**
|
---|
1541 | * Unfixes the mappings.
|
---|
1542 | * After calling this function mapping conflict detection will be enabled.
|
---|
1543 | *
|
---|
1544 | * @returns VBox status code.
|
---|
1545 | * @param pVM The VM.
|
---|
1546 | */
|
---|
1547 | PGMR3DECL(int) PGMR3MappingsUnfix(PVM pVM);
|
---|
1548 |
|
---|
1549 | /**
|
---|
1550 | * Map pages into the intermediate context (switcher code).
|
---|
1551 | * These pages are mapped at both the give virtual address and at
|
---|
1552 | * the physical address (for identity mapping).
|
---|
1553 | *
|
---|
1554 | * @returns VBox status code.
|
---|
1555 | * @param pVM The virtual machine.
|
---|
1556 | * @param Addr Intermediate context address of the mapping.
|
---|
1557 | * @param HCPhys Start of the range of physical pages. This must be entriely below 4GB!
|
---|
1558 | * @param cbPages Number of bytes to map.
|
---|
1559 | *
|
---|
1560 | * @remark This API shall not be used to anything but mapping the switcher code.
|
---|
1561 | */
|
---|
1562 | PGMR3DECL(int) PGMR3MapIntermediate(PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
|
---|
1563 |
|
---|
1564 | /**
|
---|
1565 | * Checks guest PD for conflicts with VMM GC mappings.
|
---|
1566 | *
|
---|
1567 | * @returns true if conflict detected.
|
---|
1568 | * @returns false if not.
|
---|
1569 | * @param pVM The virtual machine.
|
---|
1570 | * @param cr3 Guest context CR3 register.
|
---|
1571 | * @param fRawR0 Whether RawR0 is enabled or not.
|
---|
1572 | */
|
---|
1573 | PGMR3DECL(bool) PGMR3MapHasConflicts(PVM pVM, uint32_t cr3, bool fRawR0);
|
---|
1574 |
|
---|
1575 | /**
|
---|
1576 | * Read memory from the guest mappings.
|
---|
1577 | *
|
---|
1578 | * This will use the page tables associated with the mappings to
|
---|
1579 | * read the memory. This means that not all kind of memory is readable
|
---|
1580 | * since we don't necessarily know how to convert that physical address
|
---|
1581 | * to a HC virtual one.
|
---|
1582 | *
|
---|
1583 | * @returns VBox status.
|
---|
1584 | * @param pVM VM handle.
|
---|
1585 | * @param pvDst The destination address (HC of course).
|
---|
1586 | * @param GCPtrSrc The source address (GC virtual address).
|
---|
1587 | * @param cb Number of bytes to read.
|
---|
1588 | */
|
---|
1589 | PGMR3DECL(int) PGMR3MapRead(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
|
---|
1590 |
|
---|
1591 | /**
|
---|
1592 | * Register a access handler for a physical range.
|
---|
1593 | *
|
---|
1594 | * @returns VBox status code.
|
---|
1595 | * @param pVM VM handle.
|
---|
1596 | * @param enmType Handler type. Any of the PGMPHYSHANDLERTYPE_PHYSICAL* enums.
|
---|
1597 | * @param GCPhys Start physical address.
|
---|
1598 | * @param GCPhysLast Last physical address. (inclusive)
|
---|
1599 | * @param pfnHandlerR3 The R3 handler.
|
---|
1600 | * @param pvUserR3 User argument to the R3 handler.
|
---|
1601 | * @param pszModR0 The R0 handler module. NULL means default R0 module.
|
---|
1602 | * @param pszHandlerR0 The R0 handler symbol name.
|
---|
1603 | * @param pvUserR0 User argument to the R0 handler.
|
---|
1604 | * @param pszModGC The GC handler module. NULL means default GC module.
|
---|
1605 | * @param pszHandlerGC The GC handler symbol name.
|
---|
1606 | * @param pvUserGC User argument to the GC handler.
|
---|
1607 | * This must be a GC pointer because it will be relocated!
|
---|
1608 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
1609 | */
|
---|
1610 | PGMR3DECL(int) PGMR3HandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
|
---|
1611 | PFNPGMR3PHYSHANDLER pfnHandlerR3, void *pvUserR3,
|
---|
1612 | const char *pszModR0, const char *pszHandlerR0, RTR0PTR pvUserR0,
|
---|
1613 | const char *pszModGC, const char *pszHandlerGC, RTGCPTR pvUserGC, const char *pszDesc);
|
---|
1614 |
|
---|
1615 | /**
|
---|
1616 | * Register an access handler for a virtual range.
|
---|
1617 | *
|
---|
1618 | * @returns VBox status code.
|
---|
1619 | * @param pVM VM handle.
|
---|
1620 | * @param enmType Handler type. Any of the PGMVIRTHANDLERTYPE_* enums.
|
---|
1621 | * @param GCPtr Start address.
|
---|
1622 | * @param GCPtrLast Last address. (inclusive)
|
---|
1623 | * @param pfnInvalidateHC The HC invalidate callback (can be 0)
|
---|
1624 | * @param pfnHandlerHC The HC handler.
|
---|
1625 | * @param pfnHandlerGC The GC handler.
|
---|
1626 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
1627 | */
|
---|
1628 | PGMDECL(int) PGMHandlerVirtualRegisterEx(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
|
---|
1629 | PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
|
---|
1630 | PFNPGMHCVIRTHANDLER pfnHandlerHC, RTGCPTR pfnHandlerGC,
|
---|
1631 | R3PTRTYPE(const char *) pszDesc);
|
---|
1632 |
|
---|
1633 | /**
|
---|
1634 | * Register a access handler for a virtual range.
|
---|
1635 | *
|
---|
1636 | * @returns VBox status code.
|
---|
1637 | * @param pVM VM handle.
|
---|
1638 | * @param enmType Handler type. Any of the PGMVIRTHANDLERTYPE_* enums.
|
---|
1639 | * @param GCPtr Start address.
|
---|
1640 | * @param GCPtrLast Last address. (inclusive)
|
---|
1641 | * @param pfnInvalidateHC The HC invalidate callback (can be 0)
|
---|
1642 | * @param pfnHandlerHC The HC handler.
|
---|
1643 | * @param pszHandlerGC The GC handler symbol name.
|
---|
1644 | * @param pszModGC The GC handler module.
|
---|
1645 | * @param pszDesc Pointer to description string. This must not be freed.
|
---|
1646 | */
|
---|
1647 | PGMR3DECL(int) PGMR3HandlerVirtualRegister(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
|
---|
1648 | PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
|
---|
1649 | PFNPGMHCVIRTHANDLER pfnHandlerHC,
|
---|
1650 | const char *pszHandlerGC, const char *pszModGC, const char *pszDesc);
|
---|
1651 |
|
---|
1652 | /**
|
---|
1653 | * Modify the page invalidation callback handler for a registered virtual range
|
---|
1654 | * (add more when needed)
|
---|
1655 | *
|
---|
1656 | * @returns VBox status code.
|
---|
1657 | * @param pVM VM handle.
|
---|
1658 | * @param GCPtr Start address.
|
---|
1659 | * @param pfnInvalidateHC The HC invalidate callback (can be 0)
|
---|
1660 | */
|
---|
1661 | PGMDECL(int) PGMHandlerVirtualChangeInvalidateCallback(PVM pVM, RTGCPTR GCPtr, PFNPGMHCVIRTINVALIDATE pfnInvalidateHC);
|
---|
1662 |
|
---|
1663 |
|
---|
1664 | /**
|
---|
1665 | * Deregister an access handler for a virtual range.
|
---|
1666 | *
|
---|
1667 | * @returns VBox status code.
|
---|
1668 | * @param pVM VM handle.
|
---|
1669 | * @param GCPtr Start address.
|
---|
1670 | */
|
---|
1671 | PGMDECL(int) PGMHandlerVirtualDeregister(PVM pVM, RTGCPTR GCPtr);
|
---|
1672 |
|
---|
1673 | /**
|
---|
1674 | * Grows the shadow page pool.
|
---|
1675 | *
|
---|
1676 | * I.e. adds more pages to it, assuming that hasn't reached cMaxPages yet.
|
---|
1677 | *
|
---|
1678 | * @returns VBox status code.
|
---|
1679 | * @param pVM The VM handle.
|
---|
1680 | */
|
---|
1681 | PDMR3DECL(int) PGMR3PoolGrow(PVM pVM);
|
---|
1682 |
|
---|
1683 | #ifdef ___VBox_dbgf_h /** @todo fix this! */
|
---|
1684 | /**
|
---|
1685 | * Dumps a page table hierarchy use only physical addresses and cr4/lm flags.
|
---|
1686 | *
|
---|
1687 | * @returns VBox status code (VINF_SUCCESS).
|
---|
1688 | * @param pVM The VM handle.
|
---|
1689 | * @param cr3 The root of the hierarchy.
|
---|
1690 | * @param cr4 The cr4, only PAE and PSE is currently used.
|
---|
1691 | * @param fLongMode Set if long mode, false if not long mode.
|
---|
1692 | * @param cMaxDepth Number of levels to dump.
|
---|
1693 | * @param pHlp Pointer to the output functions.
|
---|
1694 | */
|
---|
1695 | PGMR3DECL(int) PGMR3DumpHierarchyHC(PVM pVM, uint32_t cr3, uint32_t cr4, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp);
|
---|
1696 | #endif
|
---|
1697 |
|
---|
1698 | /**
|
---|
1699 | * Dumps a 32-bit guest page directory and page tables.
|
---|
1700 | *
|
---|
1701 | * @returns VBox status code (VINF_SUCCESS).
|
---|
1702 | * @param pVM The VM handle.
|
---|
1703 | * @param cr3 The root of the hierarchy.
|
---|
1704 | * @param cr4 The CR4, PSE is currently used.
|
---|
1705 | * @param PhysSearch Address to search for.
|
---|
1706 | */
|
---|
1707 | PGMR3DECL(int) PGMR3DumpHierarchyGC(PVM pVM, uint32_t cr3, uint32_t cr4, RTGCPHYS PhysSearch);
|
---|
1708 |
|
---|
1709 | /**
|
---|
1710 | * Debug helper - Dumps the supplied page directory.
|
---|
1711 | *
|
---|
1712 | * @internal
|
---|
1713 | */
|
---|
1714 | PGMR3DECL(void) PGMR3DumpPD(PVM pVM, PVBOXPD pPD);
|
---|
1715 |
|
---|
1716 | /**
|
---|
1717 | * Dumps the the PGM mappings..
|
---|
1718 | *
|
---|
1719 | * @param pVM VM handle.
|
---|
1720 | */
|
---|
1721 | PGMR3DECL(void) PGMR3DumpMappings(PVM pVM);
|
---|
1722 |
|
---|
1723 | /** @todo r=bird: s/Byte/U8/ s/Word/U16/ s/Dword/U32/ to match other functions names and returned types. */
|
---|
1724 | /**
|
---|
1725 | * Read physical memory. (one byte)
|
---|
1726 | *
|
---|
1727 | * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
|
---|
1728 | * want to ignore those.
|
---|
1729 | *
|
---|
1730 | * @param pVM VM Handle.
|
---|
1731 | * @param GCPhys Physical address start reading from.
|
---|
1732 | */
|
---|
1733 | PGMR3DECL(uint8_t) PGMR3PhysReadByte(PVM pVM, RTGCPHYS GCPhys);
|
---|
1734 |
|
---|
1735 | /**
|
---|
1736 | * Read physical memory. (one word)
|
---|
1737 | *
|
---|
1738 | * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
|
---|
1739 | * want to ignore those.
|
---|
1740 | *
|
---|
1741 | * @param pVM VM Handle.
|
---|
1742 | * @param GCPhys Physical address start reading from.
|
---|
1743 | */
|
---|
1744 | PGMR3DECL(uint16_t) PGMR3PhysReadWord(PVM pVM, RTGCPHYS GCPhys);
|
---|
1745 |
|
---|
1746 | /**
|
---|
1747 | * Read physical memory. (one dword)
|
---|
1748 | *
|
---|
1749 | * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
|
---|
1750 | * want to ignore those.
|
---|
1751 | *
|
---|
1752 | * @param pVM VM Handle.
|
---|
1753 | * @param GCPhys Physical address start reading from.
|
---|
1754 | */
|
---|
1755 | PGMR3DECL(uint32_t) PGMR3PhysReadDword(PVM pVM, RTGCPHYS GCPhys);
|
---|
1756 |
|
---|
1757 | /**
|
---|
1758 | * Write to physical memory. (one byte)
|
---|
1759 | *
|
---|
1760 | * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
|
---|
1761 | * want to ignore those.
|
---|
1762 | *
|
---|
1763 | * @param pVM VM Handle.
|
---|
1764 | * @param GCPhys Physical address to write to.
|
---|
1765 | * @param val What to write.
|
---|
1766 | */
|
---|
1767 | PGMR3DECL(void) PGMR3PhysWriteByte(PVM pVM, RTGCPHYS GCPhys, uint8_t val);
|
---|
1768 |
|
---|
1769 | /**
|
---|
1770 | * Write to physical memory. (one word)
|
---|
1771 | *
|
---|
1772 | * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
|
---|
1773 | * want to ignore those.
|
---|
1774 | *
|
---|
1775 | * @param pVM VM Handle.
|
---|
1776 | * @param GCPhys Physical address to write to.
|
---|
1777 | * @param val What to write.
|
---|
1778 | */
|
---|
1779 | PGMR3DECL(void) PGMR3PhysWriteWord(PVM pVM, RTGCPHYS GCPhys, uint16_t val);
|
---|
1780 |
|
---|
1781 | /**
|
---|
1782 | * Write to physical memory. (one dword)
|
---|
1783 | *
|
---|
1784 | * This API respects access handlers and MMIO. Use PGMPhysReadGCPhys() if you
|
---|
1785 | * want to ignore those.
|
---|
1786 | *
|
---|
1787 | * @param pVM VM Handle.
|
---|
1788 | * @param GCPhys Physical address to write to.
|
---|
1789 | * @param val What to write.
|
---|
1790 | */
|
---|
1791 | PGMR3DECL(void) PGMR3PhysWriteDword(PVM pVM, RTGCPHYS GCPhys, uint32_t val);
|
---|
1792 |
|
---|
1793 | /**
|
---|
1794 | * For VMMCALLHOST_PGM_MAP_CHUNK, considered internal.
|
---|
1795 | *
|
---|
1796 | * @returns see pgmR3PhysChunkMap.
|
---|
1797 | * @param pVM The VM handle.
|
---|
1798 | * @param idChunk The chunk to map.
|
---|
1799 | */
|
---|
1800 | PDMR3DECL(int) PGMR3PhysChunkMap(PVM pVM, uint32_t idChunk);
|
---|
1801 |
|
---|
1802 | /**
|
---|
1803 | * Invalidates the TLB for the ring-3 mapping cache.
|
---|
1804 | *
|
---|
1805 | * @param pVM The VM handle.
|
---|
1806 | */
|
---|
1807 | PGMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM);
|
---|
1808 |
|
---|
1809 | /**
|
---|
1810 | * Response to VM_FF_PGM_NEED_HANDY_PAGES and VMMCALLHOST_PGM_ALLOCATE_HANDY_PAGES.
|
---|
1811 | *
|
---|
1812 | * @returns VBox status code.
|
---|
1813 | * @retval VINF_SUCCESS on success. FF cleared.
|
---|
1814 | * @retval VINF_EM_NO_MEMORY if we're out of memory. The FF is not cleared in this case.
|
---|
1815 | *
|
---|
1816 | * @param pVM The VM handle.
|
---|
1817 | */
|
---|
1818 | PDMR3DECL(int) PGMR3PhysAllocateHandyPages(PVM pVM);
|
---|
1819 |
|
---|
1820 | /**
|
---|
1821 | * Perform an integrity check on the PGM component.
|
---|
1822 | *
|
---|
1823 | * @returns VINF_SUCCESS if everything is fine.
|
---|
1824 | * @returns VBox error status after asserting on integrity breach.
|
---|
1825 | * @param pVM The VM handle.
|
---|
1826 | */
|
---|
1827 | PDMR3DECL(int) PGMR3CheckIntegrity(PVM pVM);
|
---|
1828 |
|
---|
1829 | /**
|
---|
1830 | * Converts a HC pointer to a GC physical address.
|
---|
1831 | *
|
---|
1832 | * Only for the debugger.
|
---|
1833 | *
|
---|
1834 | * @returns VBox status code.
|
---|
1835 | * @retval VINF_SUCCESS on success, *pGCPhys is set.
|
---|
1836 | * @retval VERR_INVALID_POINTER if the pointer is not within the GC physical memory.
|
---|
1837 | *
|
---|
1838 | * @param pVM The VM handle.
|
---|
1839 | * @param HCPtr The HC pointer to convert.
|
---|
1840 | * @param pGCPhys Where to store the GC physical address on success.
|
---|
1841 | */
|
---|
1842 | PGMR3DECL(int) PGMR3DbgHCPtr2GCPhys(PVM pVM, RTHCPTR HCPtr, PRTGCPHYS pGCPhys);
|
---|
1843 |
|
---|
1844 | /**
|
---|
1845 | * Converts a HC pointer to a GC physical address.
|
---|
1846 | *
|
---|
1847 | * @returns VBox status code.
|
---|
1848 | * @retval VINF_SUCCESS on success, *pHCPhys is set.
|
---|
1849 | * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid GC physical page but has no physical backing.
|
---|
1850 | * @retval VERR_INVALID_POINTER if the pointer is not within the GC physical memory.
|
---|
1851 | *
|
---|
1852 | * @param pVM The VM handle.
|
---|
1853 | * @param HCPtr The HC pointer to convert.
|
---|
1854 | * @param pHCPhys Where to store the HC physical address on success.
|
---|
1855 | */
|
---|
1856 | PGMR3DECL(int) PGMR3DbgHCPtr2HCPhys(PVM pVM, RTHCPTR HCPtr, PRTHCPHYS pHCPhys);
|
---|
1857 |
|
---|
1858 | /**
|
---|
1859 | * Converts a HC physical address to a GC physical address.
|
---|
1860 | *
|
---|
1861 | * Only for the debugger.
|
---|
1862 | *
|
---|
1863 | * @returns VBox status code
|
---|
1864 | * @retval VINF_SUCCESS on success, *pGCPhys is set.
|
---|
1865 | * @retval VERR_INVALID_POINTER if the HC physical address is not within the GC physical memory.
|
---|
1866 | *
|
---|
1867 | * @param pVM The VM handle.
|
---|
1868 | * @param HCPhys The HC physical address to convert.
|
---|
1869 | * @param pGCPhys Where to store the GC physical address on success.
|
---|
1870 | */
|
---|
1871 | PGMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PVM pVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
|
---|
1872 |
|
---|
1873 | /**
|
---|
1874 | * Scans guest physical memory for a byte string.
|
---|
1875 | *
|
---|
1876 | * Only for the debugger.
|
---|
1877 | *
|
---|
1878 | * @returns VBox status codes:
|
---|
1879 | * @retval VINF_SUCCESS and *pGCPtrHit on success.
|
---|
1880 | * @retval VERR_DBGF_MEM_NOT_FOUND if not found.
|
---|
1881 | * @retval VERR_INVALID_POINTER if any of the pointer arguments are invalid.
|
---|
1882 | * @retval VERR_INVALID_ARGUMENT if any other arguments are invalid.
|
---|
1883 | *
|
---|
1884 | * @param pVM Pointer to the shared VM structure.
|
---|
1885 | * @param GCPhys Where to start searching.
|
---|
1886 | * @param cbRange The number of bytes to search. Max 256 bytes.
|
---|
1887 | * @param pabNeedle The byte string to search for.
|
---|
1888 | * @param cbNeedle The length of the byte string.
|
---|
1889 | * @param pGCPhysHit Where to store the address of the first occurence on success.
|
---|
1890 | */
|
---|
1891 | PDMR3DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
|
---|
1892 |
|
---|
1893 | /**
|
---|
1894 | * Scans virtual memory for a byte string.
|
---|
1895 | *
|
---|
1896 | * Only for the debugger.
|
---|
1897 | *
|
---|
1898 | * @returns VBox status codes:
|
---|
1899 | * @retval VINF_SUCCESS and *pGCPtrHit on success.
|
---|
1900 | * @retval VERR_DBGF_MEM_NOT_FOUND if not found.
|
---|
1901 | * @retval VERR_INVALID_POINTER if any of the pointer arguments are invalid.
|
---|
1902 | * @retval VERR_INVALID_ARGUMENT if any other arguments are invalid.
|
---|
1903 | *
|
---|
1904 | * @param pVM Pointer to the shared VM structure.
|
---|
1905 | * @param GCPtr Where to start searching.
|
---|
1906 | * @param cbRange The number of bytes to search. Max 256 bytes.
|
---|
1907 | * @param pabNeedle The byte string to search for.
|
---|
1908 | * @param cbNeedle The length of the byte string.
|
---|
1909 | * @param pGCPtrHit Where to store the address of the first occurence on success.
|
---|
1910 | */
|
---|
1911 | PDMR3DECL(int) PGMR3DbgScanVirtual(PVM pVM, RTGCUINTPTR GCPtr, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
|
---|
1912 |
|
---|
1913 | /** @} */
|
---|
1914 |
|
---|
1915 | #endif /* IN_RING3 */
|
---|
1916 |
|
---|
1917 | __END_DECLS
|
---|
1918 |
|
---|
1919 | /** @} */
|
---|
1920 | #endif
|
---|
1921 |
|
---|