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