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