1 | /* $Id: PGMDbg.cpp 85180 2020-07-10 13:19:43Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * PGM - Page Manager and Monitor - Debugger & Debugging APIs.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2020 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 |
|
---|
19 | /*********************************************************************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *********************************************************************************************************************************/
|
---|
22 | #define LOG_GROUP LOG_GROUP_PGM
|
---|
23 | #include <VBox/vmm/pgm.h>
|
---|
24 | #include <VBox/vmm/stam.h>
|
---|
25 | #include "PGMInternal.h"
|
---|
26 | #include <VBox/vmm/vm.h>
|
---|
27 | #include <VBox/vmm/uvm.h>
|
---|
28 | #include "PGMInline.h"
|
---|
29 | #include <iprt/assert.h>
|
---|
30 | #include <iprt/asm.h>
|
---|
31 | #include <iprt/string.h>
|
---|
32 | #include <VBox/log.h>
|
---|
33 | #include <VBox/param.h>
|
---|
34 | #include <VBox/err.h>
|
---|
35 |
|
---|
36 |
|
---|
37 | /*********************************************************************************************************************************
|
---|
38 | * Defined Constants And Macros *
|
---|
39 | *********************************************************************************************************************************/
|
---|
40 | /** The max needle size that we will bother searching for
|
---|
41 | * This must not be more than half a page! */
|
---|
42 | #define MAX_NEEDLE_SIZE 256
|
---|
43 |
|
---|
44 |
|
---|
45 | /*********************************************************************************************************************************
|
---|
46 | * Structures and Typedefs *
|
---|
47 | *********************************************************************************************************************************/
|
---|
48 | /**
|
---|
49 | * State structure for the paging hierarchy dumpers.
|
---|
50 | */
|
---|
51 | typedef struct PGMR3DUMPHIERARCHYSTATE
|
---|
52 | {
|
---|
53 | /** Pointer to the VM. */
|
---|
54 | PVM pVM;
|
---|
55 | /** Output helpers. */
|
---|
56 | PCDBGFINFOHLP pHlp;
|
---|
57 | /** Set if PSE, PAE or long mode is enabled. */
|
---|
58 | bool fPse;
|
---|
59 | /** Set if PAE or long mode is enabled. */
|
---|
60 | bool fPae;
|
---|
61 | /** Set if long mode is enabled. */
|
---|
62 | bool fLme;
|
---|
63 | /** Set if nested paging. */
|
---|
64 | bool fNp;
|
---|
65 | /** Set if EPT. */
|
---|
66 | bool fEpt;
|
---|
67 | /** Set if NXE is enabled. */
|
---|
68 | bool fNxe;
|
---|
69 | /** The number or chars the address needs. */
|
---|
70 | uint8_t cchAddress;
|
---|
71 | /** The last reserved bit. */
|
---|
72 | uint8_t uLastRsvdBit;
|
---|
73 | /** Dump the page info as well (shadow page summary / guest physical
|
---|
74 | * page summary). */
|
---|
75 | bool fDumpPageInfo;
|
---|
76 | /** Whether or not to print the header. */
|
---|
77 | bool fPrintHeader;
|
---|
78 | /** Whether to print the CR3 value */
|
---|
79 | bool fPrintCr3;
|
---|
80 | /** Padding*/
|
---|
81 | bool afReserved[5];
|
---|
82 | /** The current address. */
|
---|
83 | uint64_t u64Address;
|
---|
84 | /** The last address to dump structures for. */
|
---|
85 | uint64_t u64FirstAddress;
|
---|
86 | /** The last address to dump structures for. */
|
---|
87 | uint64_t u64LastAddress;
|
---|
88 | /** Mask with the high reserved bits set. */
|
---|
89 | uint64_t u64HighReservedBits;
|
---|
90 | /** The number of leaf entries that we've printed. */
|
---|
91 | uint64_t cLeaves;
|
---|
92 | } PGMR3DUMPHIERARCHYSTATE;
|
---|
93 | /** Pointer to the paging hierarchy dumper state. */
|
---|
94 | typedef PGMR3DUMPHIERARCHYSTATE *PPGMR3DUMPHIERARCHYSTATE;
|
---|
95 |
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * Assembly scanning function.
|
---|
99 | *
|
---|
100 | * @returns Pointer to possible match or NULL.
|
---|
101 | * @param pvHaystack Pointer to what we search in.
|
---|
102 | * @param cbHaystack Number of bytes to search.
|
---|
103 | * @param pvNeedle Pointer to what we search for.
|
---|
104 | * @param cbNeedle Size of what we're searching for.
|
---|
105 | */
|
---|
106 |
|
---|
107 | typedef DECLCALLBACKTYPE(uint8_t const *, FNPGMR3DBGFIXEDMEMSCAN,(void const *pvHaystack, uint32_t cbHaystack,
|
---|
108 | void const *pvNeedle, size_t cbNeedle));
|
---|
109 | /** Pointer to an fixed size and step assembly scanner function. */
|
---|
110 | typedef FNPGMR3DBGFIXEDMEMSCAN *PFNPGMR3DBGFIXEDMEMSCAN;
|
---|
111 |
|
---|
112 |
|
---|
113 | /*********************************************************************************************************************************
|
---|
114 | * Internal Functions *
|
---|
115 | *********************************************************************************************************************************/
|
---|
116 | DECLASM(uint8_t const *) pgmR3DbgFixedMemScan8Wide8Step(void const *, uint32_t, void const *, size_t cbNeedle);
|
---|
117 | DECLASM(uint8_t const *) pgmR3DbgFixedMemScan4Wide4Step(void const *, uint32_t, void const *, size_t cbNeedle);
|
---|
118 | DECLASM(uint8_t const *) pgmR3DbgFixedMemScan2Wide2Step(void const *, uint32_t, void const *, size_t cbNeedle);
|
---|
119 | DECLASM(uint8_t const *) pgmR3DbgFixedMemScan1Wide1Step(void const *, uint32_t, void const *, size_t cbNeedle);
|
---|
120 | DECLASM(uint8_t const *) pgmR3DbgFixedMemScan4Wide1Step(void const *, uint32_t, void const *, size_t cbNeedle);
|
---|
121 | DECLASM(uint8_t const *) pgmR3DbgFixedMemScan8Wide1Step(void const *, uint32_t, void const *, size_t cbNeedle);
|
---|
122 |
|
---|
123 |
|
---|
124 | /**
|
---|
125 | * Converts a R3 pointer to a GC physical address.
|
---|
126 | *
|
---|
127 | * Only for the debugger.
|
---|
128 | *
|
---|
129 | * @returns VBox status code.
|
---|
130 | * @retval VINF_SUCCESS on success, *pGCPhys is set.
|
---|
131 | * @retval VERR_INVALID_POINTER if the pointer is not within the GC physical memory.
|
---|
132 | *
|
---|
133 | * @param pUVM The user mode VM handle.
|
---|
134 | * @param R3Ptr The R3 pointer to convert.
|
---|
135 | * @param pGCPhys Where to store the GC physical address on success.
|
---|
136 | */
|
---|
137 | VMMR3DECL(int) PGMR3DbgR3Ptr2GCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTGCPHYS pGCPhys)
|
---|
138 | {
|
---|
139 | NOREF(pUVM); NOREF(R3Ptr);
|
---|
140 | *pGCPhys = NIL_RTGCPHYS;
|
---|
141 | return VERR_NOT_IMPLEMENTED;
|
---|
142 | }
|
---|
143 |
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * Converts a R3 pointer to a HC physical address.
|
---|
147 | *
|
---|
148 | * Only for the debugger.
|
---|
149 | *
|
---|
150 | * @returns VBox status code.
|
---|
151 | * @retval VINF_SUCCESS on success, *pHCPhys is set.
|
---|
152 | * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid GC physical page but has no physical backing.
|
---|
153 | * @retval VERR_INVALID_POINTER if the pointer is not within the GC physical memory.
|
---|
154 | *
|
---|
155 | * @param pUVM The user mode VM handle.
|
---|
156 | * @param R3Ptr The R3 pointer to convert.
|
---|
157 | * @param pHCPhys Where to store the HC physical address on success.
|
---|
158 | */
|
---|
159 | VMMR3DECL(int) PGMR3DbgR3Ptr2HCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTHCPHYS pHCPhys)
|
---|
160 | {
|
---|
161 | NOREF(pUVM); NOREF(R3Ptr);
|
---|
162 | *pHCPhys = NIL_RTHCPHYS;
|
---|
163 | return VERR_NOT_IMPLEMENTED;
|
---|
164 | }
|
---|
165 |
|
---|
166 |
|
---|
167 | /**
|
---|
168 | * Converts a HC physical address to a GC physical address.
|
---|
169 | *
|
---|
170 | * Only for the debugger.
|
---|
171 | *
|
---|
172 | * @returns VBox status code
|
---|
173 | * @retval VINF_SUCCESS on success, *pGCPhys is set.
|
---|
174 | * @retval VERR_INVALID_POINTER if the HC physical address is not within the GC physical memory.
|
---|
175 | *
|
---|
176 | * @param pUVM The user mode VM handle.
|
---|
177 | * @param HCPhys The HC physical address to convert.
|
---|
178 | * @param pGCPhys Where to store the GC physical address on success.
|
---|
179 | */
|
---|
180 | VMMR3DECL(int) PGMR3DbgHCPhys2GCPhys(PUVM pUVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys)
|
---|
181 | {
|
---|
182 | UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
|
---|
183 | VM_ASSERT_VALID_EXT_RETURN(pUVM->pVM, VERR_INVALID_VM_HANDLE);
|
---|
184 |
|
---|
185 | /*
|
---|
186 | * Validate and adjust the input a bit.
|
---|
187 | */
|
---|
188 | if (HCPhys == NIL_RTHCPHYS)
|
---|
189 | return VERR_INVALID_POINTER;
|
---|
190 | unsigned off = HCPhys & PAGE_OFFSET_MASK;
|
---|
191 | HCPhys &= X86_PTE_PAE_PG_MASK;
|
---|
192 | if (HCPhys == 0)
|
---|
193 | return VERR_INVALID_POINTER;
|
---|
194 |
|
---|
195 | for (PPGMRAMRANGE pRam = pUVM->pVM->pgm.s.CTX_SUFF(pRamRangesX);
|
---|
196 | pRam;
|
---|
197 | pRam = pRam->CTX_SUFF(pNext))
|
---|
198 | {
|
---|
199 | uint32_t iPage = pRam->cb >> PAGE_SHIFT;
|
---|
200 | while (iPage-- > 0)
|
---|
201 | if (PGM_PAGE_GET_HCPHYS(&pRam->aPages[iPage]) == HCPhys)
|
---|
202 | {
|
---|
203 | *pGCPhys = pRam->GCPhys + (iPage << PAGE_SHIFT) + off;
|
---|
204 | return VINF_SUCCESS;
|
---|
205 | }
|
---|
206 | }
|
---|
207 | return VERR_INVALID_POINTER;
|
---|
208 | }
|
---|
209 |
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * Read physical memory API for the debugger, similar to
|
---|
213 | * PGMPhysSimpleReadGCPhys.
|
---|
214 | *
|
---|
215 | * @returns VBox status code.
|
---|
216 | *
|
---|
217 | * @param pVM The cross context VM structure.
|
---|
218 | * @param pvDst Where to store what's read.
|
---|
219 | * @param GCPhysSrc Where to start reading from.
|
---|
220 | * @param cb The number of bytes to attempt reading.
|
---|
221 | * @param fFlags Flags, MBZ.
|
---|
222 | * @param pcbRead For store the actual number of bytes read, pass NULL if
|
---|
223 | * partial reads are unwanted.
|
---|
224 | * @todo Unused?
|
---|
225 | */
|
---|
226 | VMMR3_INT_DECL(int) PGMR3DbgReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb, uint32_t fFlags, size_t *pcbRead)
|
---|
227 | {
|
---|
228 | /* validate */
|
---|
229 | AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
|
---|
230 | AssertReturn(pVM, VERR_INVALID_PARAMETER);
|
---|
231 |
|
---|
232 | /* try simple first. */
|
---|
233 | int rc = PGMPhysSimpleReadGCPhys(pVM, pvDst, GCPhysSrc, cb);
|
---|
234 | if (RT_SUCCESS(rc) || !pcbRead)
|
---|
235 | return rc;
|
---|
236 |
|
---|
237 | /* partial read that failed, chop it up in pages. */
|
---|
238 | *pcbRead = 0;
|
---|
239 | rc = VINF_SUCCESS;
|
---|
240 | while (cb > 0)
|
---|
241 | {
|
---|
242 | size_t cbChunk = PAGE_SIZE;
|
---|
243 | cbChunk -= GCPhysSrc & PAGE_OFFSET_MASK;
|
---|
244 | if (cbChunk > cb)
|
---|
245 | cbChunk = cb;
|
---|
246 |
|
---|
247 | rc = PGMPhysSimpleReadGCPhys(pVM, pvDst, GCPhysSrc, cbChunk);
|
---|
248 |
|
---|
249 | /* advance */
|
---|
250 | if (RT_FAILURE(rc))
|
---|
251 | break;
|
---|
252 | *pcbRead += cbChunk;
|
---|
253 | cb -= cbChunk;
|
---|
254 | GCPhysSrc += cbChunk;
|
---|
255 | pvDst = (uint8_t *)pvDst + cbChunk;
|
---|
256 | }
|
---|
257 |
|
---|
258 | return *pcbRead && RT_FAILURE(rc) ? -rc : rc;
|
---|
259 | }
|
---|
260 |
|
---|
261 |
|
---|
262 | /**
|
---|
263 | * Write physical memory API for the debugger, similar to
|
---|
264 | * PGMPhysSimpleWriteGCPhys.
|
---|
265 | *
|
---|
266 | * @returns VBox status code.
|
---|
267 | *
|
---|
268 | * @param pVM The cross context VM structure.
|
---|
269 | * @param GCPhysDst Where to start writing.
|
---|
270 | * @param pvSrc What to write.
|
---|
271 | * @param cb The number of bytes to attempt writing.
|
---|
272 | * @param fFlags Flags, MBZ.
|
---|
273 | * @param pcbWritten For store the actual number of bytes written, pass NULL
|
---|
274 | * if partial writes are unwanted.
|
---|
275 | * @todo Unused?
|
---|
276 | */
|
---|
277 | VMMR3_INT_DECL(int) PGMR3DbgWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten)
|
---|
278 | {
|
---|
279 | /* validate */
|
---|
280 | AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
|
---|
281 | AssertReturn(pVM, VERR_INVALID_PARAMETER);
|
---|
282 |
|
---|
283 | /* try simple first. */
|
---|
284 | int rc = PGMPhysSimpleWriteGCPhys(pVM, GCPhysDst, pvSrc, cb);
|
---|
285 | if (RT_SUCCESS(rc) || !pcbWritten)
|
---|
286 | return rc;
|
---|
287 |
|
---|
288 | /* partial write that failed, chop it up in pages. */
|
---|
289 | *pcbWritten = 0;
|
---|
290 | rc = VINF_SUCCESS;
|
---|
291 | while (cb > 0)
|
---|
292 | {
|
---|
293 | size_t cbChunk = PAGE_SIZE;
|
---|
294 | cbChunk -= GCPhysDst & PAGE_OFFSET_MASK;
|
---|
295 | if (cbChunk > cb)
|
---|
296 | cbChunk = cb;
|
---|
297 |
|
---|
298 | rc = PGMPhysSimpleWriteGCPhys(pVM, GCPhysDst, pvSrc, cbChunk);
|
---|
299 |
|
---|
300 | /* advance */
|
---|
301 | if (RT_FAILURE(rc))
|
---|
302 | break;
|
---|
303 | *pcbWritten += cbChunk;
|
---|
304 | cb -= cbChunk;
|
---|
305 | GCPhysDst += cbChunk;
|
---|
306 | pvSrc = (uint8_t const *)pvSrc + cbChunk;
|
---|
307 | }
|
---|
308 |
|
---|
309 | return *pcbWritten && RT_FAILURE(rc) ? -rc : rc;
|
---|
310 |
|
---|
311 | }
|
---|
312 |
|
---|
313 |
|
---|
314 | /**
|
---|
315 | * Read virtual memory API for the debugger, similar to PGMPhysSimpleReadGCPtr.
|
---|
316 | *
|
---|
317 | * @returns VBox status code.
|
---|
318 | *
|
---|
319 | * @param pVM The cross context VM structure.
|
---|
320 | * @param pvDst Where to store what's read.
|
---|
321 | * @param GCPtrSrc Where to start reading from.
|
---|
322 | * @param cb The number of bytes to attempt reading.
|
---|
323 | * @param fFlags Flags, MBZ.
|
---|
324 | * @param pcbRead For store the actual number of bytes read, pass NULL if
|
---|
325 | * partial reads are unwanted.
|
---|
326 | * @todo Unused?
|
---|
327 | */
|
---|
328 | VMMR3_INT_DECL(int) PGMR3DbgReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, uint32_t fFlags, size_t *pcbRead)
|
---|
329 | {
|
---|
330 | /* validate */
|
---|
331 | AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
|
---|
332 | AssertReturn(pVM, VERR_INVALID_PARAMETER);
|
---|
333 |
|
---|
334 | /** @todo SMP support! */
|
---|
335 | PVMCPU pVCpu = pVM->apCpusR3[0];
|
---|
336 |
|
---|
337 | /** @todo deal with HMA */
|
---|
338 | /* try simple first. */
|
---|
339 | int rc = PGMPhysSimpleReadGCPtr(pVCpu, pvDst, GCPtrSrc, cb);
|
---|
340 | if (RT_SUCCESS(rc) || !pcbRead)
|
---|
341 | return rc;
|
---|
342 |
|
---|
343 | /* partial read that failed, chop it up in pages. */
|
---|
344 | *pcbRead = 0;
|
---|
345 | rc = VINF_SUCCESS;
|
---|
346 | while (cb > 0)
|
---|
347 | {
|
---|
348 | size_t cbChunk = PAGE_SIZE;
|
---|
349 | cbChunk -= GCPtrSrc & PAGE_OFFSET_MASK;
|
---|
350 | if (cbChunk > cb)
|
---|
351 | cbChunk = cb;
|
---|
352 |
|
---|
353 | rc = PGMPhysSimpleReadGCPtr(pVCpu, pvDst, GCPtrSrc, cbChunk);
|
---|
354 |
|
---|
355 | /* advance */
|
---|
356 | if (RT_FAILURE(rc))
|
---|
357 | break;
|
---|
358 | *pcbRead += cbChunk;
|
---|
359 | cb -= cbChunk;
|
---|
360 | GCPtrSrc += cbChunk;
|
---|
361 | pvDst = (uint8_t *)pvDst + cbChunk;
|
---|
362 | }
|
---|
363 |
|
---|
364 | return *pcbRead && RT_FAILURE(rc) ? -rc : rc;
|
---|
365 |
|
---|
366 | }
|
---|
367 |
|
---|
368 |
|
---|
369 | /**
|
---|
370 | * Write virtual memory API for the debugger, similar to
|
---|
371 | * PGMPhysSimpleWriteGCPtr.
|
---|
372 | *
|
---|
373 | * @returns VBox status code.
|
---|
374 | *
|
---|
375 | * @param pVM The cross context VM structure.
|
---|
376 | * @param GCPtrDst Where to start writing.
|
---|
377 | * @param pvSrc What to write.
|
---|
378 | * @param cb The number of bytes to attempt writing.
|
---|
379 | * @param fFlags Flags, MBZ.
|
---|
380 | * @param pcbWritten For store the actual number of bytes written, pass NULL
|
---|
381 | * if partial writes are unwanted.
|
---|
382 | * @todo Unused?
|
---|
383 | */
|
---|
384 | VMMR3_INT_DECL(int) PGMR3DbgWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten)
|
---|
385 | {
|
---|
386 | /* validate */
|
---|
387 | AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
|
---|
388 | AssertReturn(pVM, VERR_INVALID_PARAMETER);
|
---|
389 |
|
---|
390 | /** @todo SMP support! */
|
---|
391 | PVMCPU pVCpu = pVM->apCpusR3[0];
|
---|
392 |
|
---|
393 | /** @todo deal with HMA */
|
---|
394 | /* try simple first. */
|
---|
395 | int rc = PGMPhysSimpleWriteGCPtr(pVCpu, GCPtrDst, pvSrc, cb);
|
---|
396 | if (RT_SUCCESS(rc) || !pcbWritten)
|
---|
397 | return rc;
|
---|
398 |
|
---|
399 | /* partial write that failed, chop it up in pages. */
|
---|
400 | *pcbWritten = 0;
|
---|
401 | rc = VINF_SUCCESS;
|
---|
402 | while (cb > 0)
|
---|
403 | {
|
---|
404 | size_t cbChunk = PAGE_SIZE;
|
---|
405 | cbChunk -= GCPtrDst & PAGE_OFFSET_MASK;
|
---|
406 | if (cbChunk > cb)
|
---|
407 | cbChunk = cb;
|
---|
408 |
|
---|
409 | rc = PGMPhysSimpleWriteGCPtr(pVCpu, GCPtrDst, pvSrc, cbChunk);
|
---|
410 |
|
---|
411 | /* advance */
|
---|
412 | if (RT_FAILURE(rc))
|
---|
413 | break;
|
---|
414 | *pcbWritten += cbChunk;
|
---|
415 | cb -= cbChunk;
|
---|
416 | GCPtrDst += cbChunk;
|
---|
417 | pvSrc = (uint8_t const *)pvSrc + cbChunk;
|
---|
418 | }
|
---|
419 |
|
---|
420 | return *pcbWritten && RT_FAILURE(rc) ? -rc : rc;
|
---|
421 |
|
---|
422 | }
|
---|
423 |
|
---|
424 |
|
---|
425 | /**
|
---|
426 | * memchr() with alignment considerations.
|
---|
427 | *
|
---|
428 | * @returns Pointer to matching byte, NULL if none found.
|
---|
429 | * @param pb Where to search. Aligned.
|
---|
430 | * @param b What to search for.
|
---|
431 | * @param cb How much to search .
|
---|
432 | * @param uAlign The alignment restriction of the result.
|
---|
433 | */
|
---|
434 | static const uint8_t *pgmR3DbgAlignedMemChr(const uint8_t *pb, uint8_t b, size_t cb, uint32_t uAlign)
|
---|
435 | {
|
---|
436 | const uint8_t *pbRet;
|
---|
437 | if (uAlign <= 32)
|
---|
438 | {
|
---|
439 | pbRet = (const uint8_t *)memchr(pb, b, cb);
|
---|
440 | if ((uintptr_t)pbRet & (uAlign - 1))
|
---|
441 | {
|
---|
442 | do
|
---|
443 | {
|
---|
444 | pbRet++;
|
---|
445 | size_t cbLeft = cb - (pbRet - pb);
|
---|
446 | if (!cbLeft)
|
---|
447 | {
|
---|
448 | pbRet = NULL;
|
---|
449 | break;
|
---|
450 | }
|
---|
451 | pbRet = (const uint8_t *)memchr(pbRet, b, cbLeft);
|
---|
452 | } while ((uintptr_t)pbRet & (uAlign - 1));
|
---|
453 | }
|
---|
454 | }
|
---|
455 | else
|
---|
456 | {
|
---|
457 | pbRet = NULL;
|
---|
458 | if (cb)
|
---|
459 | {
|
---|
460 | for (;;)
|
---|
461 | {
|
---|
462 | if (*pb == b)
|
---|
463 | {
|
---|
464 | pbRet = pb;
|
---|
465 | break;
|
---|
466 | }
|
---|
467 | if (cb <= uAlign)
|
---|
468 | break;
|
---|
469 | cb -= uAlign;
|
---|
470 | pb += uAlign;
|
---|
471 | }
|
---|
472 | }
|
---|
473 | }
|
---|
474 | return pbRet;
|
---|
475 | }
|
---|
476 |
|
---|
477 |
|
---|
478 | /**
|
---|
479 | * Scans a page for a byte string, keeping track of potential
|
---|
480 | * cross page matches.
|
---|
481 | *
|
---|
482 | * @returns true and *poff on match.
|
---|
483 | * false on mismatch.
|
---|
484 | * @param pbPage Pointer to the current page.
|
---|
485 | * @param poff Input: The offset into the page (aligned).
|
---|
486 | * Output: The page offset of the match on success.
|
---|
487 | * @param cb The number of bytes to search, starting of *poff.
|
---|
488 | * @param uAlign The needle alignment. This is of course less than a page.
|
---|
489 | * @param pabNeedle The byte string to search for.
|
---|
490 | * @param cbNeedle The length of the byte string.
|
---|
491 | * @param pfnFixedMemScan Pointer to assembly scan function, if available for
|
---|
492 | * the given needle and alignment combination.
|
---|
493 | * @param pabPrev The buffer that keeps track of a partial match that we
|
---|
494 | * bring over from the previous page. This buffer must be
|
---|
495 | * at least cbNeedle - 1 big.
|
---|
496 | * @param pcbPrev Input: The number of partial matching bytes from the previous page.
|
---|
497 | * Output: The number of partial matching bytes from this page.
|
---|
498 | * Initialize to 0 before the first call to this function.
|
---|
499 | */
|
---|
500 | static bool pgmR3DbgScanPage(const uint8_t *pbPage, int32_t *poff, uint32_t cb, uint32_t uAlign,
|
---|
501 | const uint8_t *pabNeedle, size_t cbNeedle, PFNPGMR3DBGFIXEDMEMSCAN pfnFixedMemScan,
|
---|
502 | uint8_t *pabPrev, size_t *pcbPrev)
|
---|
503 | {
|
---|
504 | /*
|
---|
505 | * Try complete any partial match from the previous page.
|
---|
506 | */
|
---|
507 | if (*pcbPrev > 0)
|
---|
508 | {
|
---|
509 | size_t cbPrev = *pcbPrev;
|
---|
510 | Assert(!*poff);
|
---|
511 | Assert(cbPrev < cbNeedle);
|
---|
512 | if (!memcmp(pbPage, pabNeedle + cbPrev, cbNeedle - cbPrev))
|
---|
513 | {
|
---|
514 | if (cbNeedle - cbPrev > cb)
|
---|
515 | return false;
|
---|
516 | *poff = -(int32_t)cbPrev;
|
---|
517 | return true;
|
---|
518 | }
|
---|
519 |
|
---|
520 | /* check out the remainder of the previous page. */
|
---|
521 | const uint8_t *pb = pabPrev;
|
---|
522 | for (;;)
|
---|
523 | {
|
---|
524 | if (cbPrev <= uAlign)
|
---|
525 | break;
|
---|
526 | cbPrev -= uAlign;
|
---|
527 | pb = pgmR3DbgAlignedMemChr(pb + uAlign, *pabNeedle, cbPrev, uAlign);
|
---|
528 | if (!pb)
|
---|
529 | break;
|
---|
530 | cbPrev = *pcbPrev - (pb - pabPrev);
|
---|
531 | if ( !memcmp(pb + 1, &pabNeedle[1], cbPrev - 1)
|
---|
532 | && !memcmp(pbPage, pabNeedle + cbPrev, cbNeedle - cbPrev))
|
---|
533 | {
|
---|
534 | if (cbNeedle - cbPrev > cb)
|
---|
535 | return false;
|
---|
536 | *poff = -(int32_t)cbPrev;
|
---|
537 | return true;
|
---|
538 | }
|
---|
539 | }
|
---|
540 |
|
---|
541 | *pcbPrev = 0;
|
---|
542 | }
|
---|
543 |
|
---|
544 | /*
|
---|
545 | * Match the body of the page.
|
---|
546 | */
|
---|
547 | const uint8_t *pb = pbPage + *poff;
|
---|
548 | const uint8_t * const pbEnd = pb + cb;
|
---|
549 | for (;;)
|
---|
550 | {
|
---|
551 | AssertMsg(((uintptr_t)pb & (uAlign - 1)) == 0, ("%#p %#x\n", pb, uAlign));
|
---|
552 | if (pfnFixedMemScan)
|
---|
553 | pb = pfnFixedMemScan(pb, cb, pabNeedle, cbNeedle);
|
---|
554 | else
|
---|
555 | pb = pgmR3DbgAlignedMemChr(pb, *pabNeedle, cb, uAlign);
|
---|
556 | if (!pb)
|
---|
557 | break;
|
---|
558 | cb = pbEnd - pb;
|
---|
559 | if (cb >= cbNeedle)
|
---|
560 | {
|
---|
561 | /* match? */
|
---|
562 | if (!memcmp(pb + 1, &pabNeedle[1], cbNeedle - 1))
|
---|
563 | {
|
---|
564 | *poff = pb - pbPage;
|
---|
565 | return true;
|
---|
566 | }
|
---|
567 | }
|
---|
568 | else
|
---|
569 | {
|
---|
570 | /* partial match at the end of the page? */
|
---|
571 | if (!memcmp(pb + 1, &pabNeedle[1], cb - 1))
|
---|
572 | {
|
---|
573 | /* We're copying one byte more that we really need here, but wtf. */
|
---|
574 | memcpy(pabPrev, pb, cb);
|
---|
575 | *pcbPrev = cb;
|
---|
576 | return false;
|
---|
577 | }
|
---|
578 | }
|
---|
579 |
|
---|
580 | /* no match, skip ahead. */
|
---|
581 | if (cb <= uAlign)
|
---|
582 | break;
|
---|
583 | pb += uAlign;
|
---|
584 | cb -= uAlign;
|
---|
585 | }
|
---|
586 |
|
---|
587 | return false;
|
---|
588 | }
|
---|
589 |
|
---|
590 |
|
---|
591 | static PFNPGMR3DBGFIXEDMEMSCAN pgmR3DbgSelectMemScanFunction(uint32_t GCPhysAlign, size_t cbNeedle)
|
---|
592 | {
|
---|
593 | switch (GCPhysAlign)
|
---|
594 | {
|
---|
595 | case 1:
|
---|
596 | if (cbNeedle >= 8)
|
---|
597 | return pgmR3DbgFixedMemScan8Wide1Step;
|
---|
598 | if (cbNeedle >= 4)
|
---|
599 | return pgmR3DbgFixedMemScan4Wide1Step;
|
---|
600 | return pgmR3DbgFixedMemScan1Wide1Step;
|
---|
601 | case 2:
|
---|
602 | if (cbNeedle >= 2)
|
---|
603 | return pgmR3DbgFixedMemScan2Wide2Step;
|
---|
604 | break;
|
---|
605 | case 4:
|
---|
606 | if (cbNeedle >= 4)
|
---|
607 | return pgmR3DbgFixedMemScan4Wide4Step;
|
---|
608 | break;
|
---|
609 | case 8:
|
---|
610 | if (cbNeedle >= 8)
|
---|
611 | return pgmR3DbgFixedMemScan8Wide8Step;
|
---|
612 | break;
|
---|
613 | }
|
---|
614 | return NULL;
|
---|
615 | }
|
---|
616 |
|
---|
617 |
|
---|
618 |
|
---|
619 | /**
|
---|
620 | * Scans guest physical memory for a byte string.
|
---|
621 | *
|
---|
622 | * @returns VBox status codes:
|
---|
623 | * @retval VINF_SUCCESS and *pGCPtrHit on success.
|
---|
624 | * @retval VERR_DBGF_MEM_NOT_FOUND if not found.
|
---|
625 | * @retval VERR_INVALID_POINTER if any of the pointer arguments are invalid.
|
---|
626 | * @retval VERR_INVALID_ARGUMENT if any other arguments are invalid.
|
---|
627 | *
|
---|
628 | * @param pVM The cross context VM structure.
|
---|
629 | * @param GCPhys Where to start searching.
|
---|
630 | * @param cbRange The number of bytes to search.
|
---|
631 | * @param GCPhysAlign The alignment of the needle. Must be a power of two
|
---|
632 | * and less or equal to 4GB.
|
---|
633 | * @param pabNeedle The byte string to search for.
|
---|
634 | * @param cbNeedle The length of the byte string. Max 256 bytes.
|
---|
635 | * @param pGCPhysHit Where to store the address of the first occurrence on success.
|
---|
636 | */
|
---|
637 | VMMR3_INT_DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, RTGCPHYS GCPhysAlign,
|
---|
638 | const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit)
|
---|
639 | {
|
---|
640 | /*
|
---|
641 | * Validate and adjust the input a bit.
|
---|
642 | */
|
---|
643 | if (!VALID_PTR(pGCPhysHit))
|
---|
644 | return VERR_INVALID_POINTER;
|
---|
645 | *pGCPhysHit = NIL_RTGCPHYS;
|
---|
646 |
|
---|
647 | if ( !VALID_PTR(pabNeedle)
|
---|
648 | || GCPhys == NIL_RTGCPHYS)
|
---|
649 | return VERR_INVALID_POINTER;
|
---|
650 | if (!cbNeedle)
|
---|
651 | return VERR_INVALID_PARAMETER;
|
---|
652 | if (cbNeedle > MAX_NEEDLE_SIZE)
|
---|
653 | return VERR_INVALID_PARAMETER;
|
---|
654 |
|
---|
655 | if (!cbRange)
|
---|
656 | return VERR_DBGF_MEM_NOT_FOUND;
|
---|
657 | if (GCPhys + cbNeedle - 1 < GCPhys)
|
---|
658 | return VERR_DBGF_MEM_NOT_FOUND;
|
---|
659 |
|
---|
660 | if (!GCPhysAlign)
|
---|
661 | return VERR_INVALID_PARAMETER;
|
---|
662 | if (GCPhysAlign > UINT32_MAX)
|
---|
663 | return VERR_NOT_POWER_OF_TWO;
|
---|
664 | if (GCPhysAlign & (GCPhysAlign - 1))
|
---|
665 | return VERR_INVALID_PARAMETER;
|
---|
666 |
|
---|
667 | if (GCPhys & (GCPhysAlign - 1))
|
---|
668 | {
|
---|
669 | RTGCPHYS Adj = GCPhysAlign - (GCPhys & (GCPhysAlign - 1));
|
---|
670 | if ( cbRange <= Adj
|
---|
671 | || GCPhys + Adj < GCPhys)
|
---|
672 | return VERR_DBGF_MEM_NOT_FOUND;
|
---|
673 | GCPhys += Adj;
|
---|
674 | cbRange -= Adj;
|
---|
675 | }
|
---|
676 |
|
---|
677 | const bool fAllZero = ASMMemIsZero(pabNeedle, cbNeedle);
|
---|
678 | const uint32_t cIncPages = GCPhysAlign <= PAGE_SIZE
|
---|
679 | ? 1
|
---|
680 | : GCPhysAlign >> PAGE_SHIFT;
|
---|
681 | const RTGCPHYS GCPhysLast = GCPhys + cbRange - 1 >= GCPhys
|
---|
682 | ? GCPhys + cbRange - 1
|
---|
683 | : ~(RTGCPHYS)0;
|
---|
684 |
|
---|
685 | PFNPGMR3DBGFIXEDMEMSCAN pfnMemScan = pgmR3DbgSelectMemScanFunction((uint32_t)GCPhysAlign, cbNeedle);
|
---|
686 |
|
---|
687 | /*
|
---|
688 | * Search the memory - ignore MMIO and zero pages, also don't
|
---|
689 | * bother to match across ranges.
|
---|
690 | */
|
---|
691 | pgmLock(pVM);
|
---|
692 | for (PPGMRAMRANGE pRam = pVM->pgm.s.CTX_SUFF(pRamRangesX);
|
---|
693 | pRam;
|
---|
694 | pRam = pRam->CTX_SUFF(pNext))
|
---|
695 | {
|
---|
696 | /*
|
---|
697 | * If the search range starts prior to the current ram range record,
|
---|
698 | * adjust the search range and possibly conclude the search.
|
---|
699 | */
|
---|
700 | RTGCPHYS off;
|
---|
701 | if (GCPhys < pRam->GCPhys)
|
---|
702 | {
|
---|
703 | if (GCPhysLast < pRam->GCPhys)
|
---|
704 | break;
|
---|
705 | GCPhys = pRam->GCPhys;
|
---|
706 | off = 0;
|
---|
707 | }
|
---|
708 | else
|
---|
709 | off = GCPhys - pRam->GCPhys;
|
---|
710 | if (off < pRam->cb)
|
---|
711 | {
|
---|
712 | /*
|
---|
713 | * Iterate the relevant pages.
|
---|
714 | */
|
---|
715 | uint8_t abPrev[MAX_NEEDLE_SIZE];
|
---|
716 | size_t cbPrev = 0;
|
---|
717 | const uint32_t cPages = pRam->cb >> PAGE_SHIFT;
|
---|
718 | uint32_t iPage = off >> PAGE_SHIFT;
|
---|
719 | uint32_t offPage = GCPhys & PAGE_OFFSET_MASK;
|
---|
720 | GCPhys &= ~(RTGCPHYS)PAGE_OFFSET_MASK;
|
---|
721 | for (;; offPage = 0)
|
---|
722 | {
|
---|
723 | PPGMPAGE pPage = &pRam->aPages[iPage];
|
---|
724 | if ( ( !PGM_PAGE_IS_ZERO(pPage)
|
---|
725 | || fAllZero)
|
---|
726 | && !PGM_PAGE_IS_MMIO_OR_ALIAS(pPage)
|
---|
727 | && !PGM_PAGE_IS_BALLOONED(pPage))
|
---|
728 | {
|
---|
729 | void const *pvPage;
|
---|
730 | PGMPAGEMAPLOCK Lock;
|
---|
731 | int rc = PGMPhysGCPhys2CCPtrReadOnly(pVM, GCPhys, &pvPage, &Lock);
|
---|
732 | if (RT_SUCCESS(rc))
|
---|
733 | {
|
---|
734 | int32_t offHit = offPage;
|
---|
735 | bool fRc;
|
---|
736 | if (GCPhysAlign < PAGE_SIZE)
|
---|
737 | {
|
---|
738 | uint32_t cbSearch = (GCPhys ^ GCPhysLast) & ~(RTGCPHYS)PAGE_OFFSET_MASK
|
---|
739 | ? PAGE_SIZE - (uint32_t)offPage
|
---|
740 | : (GCPhysLast & PAGE_OFFSET_MASK) + 1 - (uint32_t)offPage;
|
---|
741 | fRc = pgmR3DbgScanPage((uint8_t const *)pvPage, &offHit, cbSearch, (uint32_t)GCPhysAlign,
|
---|
742 | pabNeedle, cbNeedle, pfnMemScan, &abPrev[0], &cbPrev);
|
---|
743 | }
|
---|
744 | else
|
---|
745 | fRc = memcmp(pvPage, pabNeedle, cbNeedle) == 0
|
---|
746 | && (GCPhysLast - GCPhys) >= cbNeedle;
|
---|
747 | PGMPhysReleasePageMappingLock(pVM, &Lock);
|
---|
748 | if (fRc)
|
---|
749 | {
|
---|
750 | *pGCPhysHit = GCPhys + offHit;
|
---|
751 | pgmUnlock(pVM);
|
---|
752 | return VINF_SUCCESS;
|
---|
753 | }
|
---|
754 | }
|
---|
755 | else
|
---|
756 | cbPrev = 0; /* ignore error. */
|
---|
757 | }
|
---|
758 | else
|
---|
759 | cbPrev = 0;
|
---|
760 |
|
---|
761 | /* advance to the next page. */
|
---|
762 | GCPhys += (RTGCPHYS)cIncPages << PAGE_SHIFT;
|
---|
763 | if (GCPhys >= GCPhysLast) /* (may not always hit, but we're run out of ranges.) */
|
---|
764 | {
|
---|
765 | pgmUnlock(pVM);
|
---|
766 | return VERR_DBGF_MEM_NOT_FOUND;
|
---|
767 | }
|
---|
768 | iPage += cIncPages;
|
---|
769 | if ( iPage < cIncPages
|
---|
770 | || iPage >= cPages)
|
---|
771 | break;
|
---|
772 | }
|
---|
773 | }
|
---|
774 | }
|
---|
775 | pgmUnlock(pVM);
|
---|
776 | return VERR_DBGF_MEM_NOT_FOUND;
|
---|
777 | }
|
---|
778 |
|
---|
779 |
|
---|
780 | /**
|
---|
781 | * Scans (guest) virtual memory for a byte string.
|
---|
782 | *
|
---|
783 | * @returns VBox status codes:
|
---|
784 | * @retval VINF_SUCCESS and *pGCPtrHit on success.
|
---|
785 | * @retval VERR_DBGF_MEM_NOT_FOUND if not found.
|
---|
786 | * @retval VERR_INVALID_POINTER if any of the pointer arguments are invalid.
|
---|
787 | * @retval VERR_INVALID_ARGUMENT if any other arguments are invalid.
|
---|
788 | *
|
---|
789 | * @param pVM The cross context VM structure.
|
---|
790 | * @param pVCpu The cross context virtual CPU structure of the CPU
|
---|
791 | * context to search from.
|
---|
792 | * @param GCPtr Where to start searching.
|
---|
793 | * @param GCPtrAlign The alignment of the needle. Must be a power of two
|
---|
794 | * and less or equal to 4GB.
|
---|
795 | * @param cbRange The number of bytes to search. Max 256 bytes.
|
---|
796 | * @param pabNeedle The byte string to search for.
|
---|
797 | * @param cbNeedle The length of the byte string.
|
---|
798 | * @param pGCPtrHit Where to store the address of the first occurrence on success.
|
---|
799 | */
|
---|
800 | VMMR3_INT_DECL(int) PGMR3DbgScanVirtual(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, RTGCPTR cbRange, RTGCPTR GCPtrAlign,
|
---|
801 | const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPtrHit)
|
---|
802 | {
|
---|
803 | VMCPU_ASSERT_EMT(pVCpu);
|
---|
804 |
|
---|
805 | /*
|
---|
806 | * Validate and adjust the input a bit.
|
---|
807 | */
|
---|
808 | if (!VALID_PTR(pGCPtrHit))
|
---|
809 | return VERR_INVALID_POINTER;
|
---|
810 | *pGCPtrHit = 0;
|
---|
811 |
|
---|
812 | if (!VALID_PTR(pabNeedle))
|
---|
813 | return VERR_INVALID_POINTER;
|
---|
814 | if (!cbNeedle)
|
---|
815 | return VERR_INVALID_PARAMETER;
|
---|
816 | if (cbNeedle > MAX_NEEDLE_SIZE)
|
---|
817 | return VERR_INVALID_PARAMETER;
|
---|
818 |
|
---|
819 | if (!cbRange)
|
---|
820 | return VERR_DBGF_MEM_NOT_FOUND;
|
---|
821 | if (GCPtr + cbNeedle - 1 < GCPtr)
|
---|
822 | return VERR_DBGF_MEM_NOT_FOUND;
|
---|
823 |
|
---|
824 | if (!GCPtrAlign)
|
---|
825 | return VERR_INVALID_PARAMETER;
|
---|
826 | if (GCPtrAlign > UINT32_MAX)
|
---|
827 | return VERR_NOT_POWER_OF_TWO;
|
---|
828 | if (GCPtrAlign & (GCPtrAlign - 1))
|
---|
829 | return VERR_INVALID_PARAMETER;
|
---|
830 |
|
---|
831 | if (GCPtr & (GCPtrAlign - 1))
|
---|
832 | {
|
---|
833 | RTGCPTR Adj = GCPtrAlign - (GCPtr & (GCPtrAlign - 1));
|
---|
834 | if ( cbRange <= Adj
|
---|
835 | || GCPtr + Adj < GCPtr)
|
---|
836 | return VERR_DBGF_MEM_NOT_FOUND;
|
---|
837 | GCPtr += Adj;
|
---|
838 | cbRange -= Adj;
|
---|
839 | }
|
---|
840 |
|
---|
841 | /* Only paged protected mode or long mode here, use the physical scan for
|
---|
842 | the other modes. */
|
---|
843 | PGMMODE enmMode = PGMGetGuestMode(pVCpu);
|
---|
844 | AssertReturn(PGMMODE_WITH_PAGING(enmMode), VERR_PGM_NOT_USED_IN_MODE);
|
---|
845 |
|
---|
846 | /*
|
---|
847 | * Search the memory - ignore MMIO, zero and not-present pages.
|
---|
848 | */
|
---|
849 | const bool fAllZero = ASMMemIsZero(pabNeedle, cbNeedle);
|
---|
850 | RTGCPTR GCPtrMask = PGMMODE_IS_LONG_MODE(enmMode) ? UINT64_MAX : UINT32_MAX;
|
---|
851 | uint8_t abPrev[MAX_NEEDLE_SIZE];
|
---|
852 | size_t cbPrev = 0;
|
---|
853 | const uint32_t cIncPages = GCPtrAlign <= PAGE_SIZE
|
---|
854 | ? 1
|
---|
855 | : GCPtrAlign >> PAGE_SHIFT;
|
---|
856 | const RTGCPTR GCPtrLast = GCPtr + cbRange - 1 >= GCPtr
|
---|
857 | ? (GCPtr + cbRange - 1) & GCPtrMask
|
---|
858 | : GCPtrMask;
|
---|
859 | RTGCPTR cPages = (((GCPtrLast - GCPtr) + (GCPtr & PAGE_OFFSET_MASK)) >> PAGE_SHIFT) + 1;
|
---|
860 | uint32_t offPage = GCPtr & PAGE_OFFSET_MASK;
|
---|
861 | GCPtr &= ~(RTGCPTR)PAGE_OFFSET_MASK;
|
---|
862 |
|
---|
863 | PFNPGMR3DBGFIXEDMEMSCAN pfnMemScan = pgmR3DbgSelectMemScanFunction((uint32_t)GCPtrAlign, cbNeedle);
|
---|
864 |
|
---|
865 | VMSTATE enmVMState = pVM->enmVMState;
|
---|
866 | uint32_t const cYieldCountDownReload = VMSTATE_IS_RUNNING(enmVMState) ? 4096 : 65536;
|
---|
867 | uint32_t cYieldCountDown = cYieldCountDownReload;
|
---|
868 | RTGCPHYS GCPhysPrev = NIL_RTGCPHYS;
|
---|
869 | bool fFullWalk = true;
|
---|
870 | PGMPTWALKGST Walk;
|
---|
871 | RT_ZERO(Walk);
|
---|
872 |
|
---|
873 | pgmLock(pVM);
|
---|
874 | for (;; offPage = 0)
|
---|
875 | {
|
---|
876 | int rc;
|
---|
877 | if (fFullWalk)
|
---|
878 | rc = pgmGstPtWalk(pVCpu, GCPtr, &Walk);
|
---|
879 | else
|
---|
880 | rc = pgmGstPtWalkNext(pVCpu, GCPtr, &Walk);
|
---|
881 | if (RT_SUCCESS(rc) && Walk.u.Core.fSucceeded)
|
---|
882 | {
|
---|
883 | fFullWalk = false;
|
---|
884 |
|
---|
885 | /* Skip if same page as previous one (W10 optimization). */
|
---|
886 | if ( Walk.u.Core.GCPhys != GCPhysPrev
|
---|
887 | || cbPrev != 0)
|
---|
888 | {
|
---|
889 | PPGMPAGE pPage = pgmPhysGetPage(pVM, Walk.u.Core.GCPhys);
|
---|
890 | if ( pPage
|
---|
891 | && ( !PGM_PAGE_IS_ZERO(pPage)
|
---|
892 | || fAllZero)
|
---|
893 | && !PGM_PAGE_IS_MMIO_OR_ALIAS(pPage)
|
---|
894 | && !PGM_PAGE_IS_BALLOONED(pPage))
|
---|
895 | {
|
---|
896 | GCPhysPrev = Walk.u.Core.GCPhys;
|
---|
897 | void const *pvPage;
|
---|
898 | PGMPAGEMAPLOCK Lock;
|
---|
899 | rc = PGMPhysGCPhys2CCPtrReadOnly(pVM, Walk.u.Core.GCPhys, &pvPage, &Lock);
|
---|
900 | if (RT_SUCCESS(rc))
|
---|
901 | {
|
---|
902 | int32_t offHit = offPage;
|
---|
903 | bool fRc;
|
---|
904 | if (GCPtrAlign < PAGE_SIZE)
|
---|
905 | {
|
---|
906 | uint32_t cbSearch = cPages > 0
|
---|
907 | ? PAGE_SIZE - (uint32_t)offPage
|
---|
908 | : (GCPtrLast & PAGE_OFFSET_MASK) + 1 - (uint32_t)offPage;
|
---|
909 | fRc = pgmR3DbgScanPage((uint8_t const *)pvPage, &offHit, cbSearch, (uint32_t)GCPtrAlign,
|
---|
910 | pabNeedle, cbNeedle, pfnMemScan, &abPrev[0], &cbPrev);
|
---|
911 | }
|
---|
912 | else
|
---|
913 | fRc = memcmp(pvPage, pabNeedle, cbNeedle) == 0
|
---|
914 | && (GCPtrLast - GCPtr) >= cbNeedle;
|
---|
915 | PGMPhysReleasePageMappingLock(pVM, &Lock);
|
---|
916 | if (fRc)
|
---|
917 | {
|
---|
918 | *pGCPtrHit = GCPtr + offHit;
|
---|
919 | pgmUnlock(pVM);
|
---|
920 | return VINF_SUCCESS;
|
---|
921 | }
|
---|
922 | }
|
---|
923 | else
|
---|
924 | cbPrev = 0; /* ignore error. */
|
---|
925 | }
|
---|
926 | else
|
---|
927 | cbPrev = 0;
|
---|
928 | }
|
---|
929 | else
|
---|
930 | cbPrev = 0;
|
---|
931 | }
|
---|
932 | else
|
---|
933 | {
|
---|
934 | Assert(Walk.enmType != PGMPTWALKGSTTYPE_INVALID);
|
---|
935 | Assert(!Walk.u.Core.fSucceeded);
|
---|
936 | cbPrev = 0; /* ignore error. */
|
---|
937 |
|
---|
938 | /*
|
---|
939 | * Try skip as much as possible. No need to figure out that a PDE
|
---|
940 | * is not present 512 times!
|
---|
941 | */
|
---|
942 | uint64_t cPagesCanSkip;
|
---|
943 | switch (Walk.u.Core.uLevel)
|
---|
944 | {
|
---|
945 | case 1:
|
---|
946 | /* page level, use cIncPages */
|
---|
947 | cPagesCanSkip = 1;
|
---|
948 | break;
|
---|
949 | case 2:
|
---|
950 | if (Walk.enmType == PGMPTWALKGSTTYPE_32BIT)
|
---|
951 | {
|
---|
952 | cPagesCanSkip = X86_PG_ENTRIES - ((GCPtr >> X86_PT_SHIFT) & X86_PT_MASK);
|
---|
953 | Assert(!((GCPtr + ((RTGCPTR)cPagesCanSkip << X86_PT_PAE_SHIFT)) & (RT_BIT_64(X86_PD_SHIFT) - 1)));
|
---|
954 | }
|
---|
955 | else
|
---|
956 | {
|
---|
957 | cPagesCanSkip = X86_PG_PAE_ENTRIES - ((GCPtr >> X86_PT_PAE_SHIFT) & X86_PT_PAE_MASK);
|
---|
958 | Assert(!((GCPtr + ((RTGCPTR)cPagesCanSkip << X86_PT_PAE_SHIFT)) & (RT_BIT_64(X86_PD_PAE_SHIFT) - 1)));
|
---|
959 | }
|
---|
960 | break;
|
---|
961 | case 3:
|
---|
962 | cPagesCanSkip = (X86_PG_PAE_ENTRIES - ((GCPtr >> X86_PD_PAE_SHIFT) & X86_PD_PAE_MASK)) * X86_PG_PAE_ENTRIES
|
---|
963 | - ((GCPtr >> X86_PT_PAE_SHIFT) & X86_PT_PAE_MASK);
|
---|
964 | Assert(!((GCPtr + ((RTGCPTR)cPagesCanSkip << X86_PT_PAE_SHIFT)) & (RT_BIT_64(X86_PDPT_SHIFT) - 1)));
|
---|
965 | break;
|
---|
966 | case 4:
|
---|
967 | cPagesCanSkip = (X86_PG_PAE_ENTRIES - ((GCPtr >> X86_PDPT_SHIFT) & X86_PDPT_MASK_AMD64))
|
---|
968 | * X86_PG_PAE_ENTRIES * X86_PG_PAE_ENTRIES
|
---|
969 | - ((((GCPtr >> X86_PD_PAE_SHIFT) & X86_PD_PAE_MASK)) * X86_PG_PAE_ENTRIES)
|
---|
970 | - (( GCPtr >> X86_PT_PAE_SHIFT) & X86_PT_PAE_MASK);
|
---|
971 | Assert(!((GCPtr + ((RTGCPTR)cPagesCanSkip << X86_PT_PAE_SHIFT)) & (RT_BIT_64(X86_PML4_SHIFT) - 1)));
|
---|
972 | break;
|
---|
973 | case 8:
|
---|
974 | /* The CR3 value is bad, forget the whole search. */
|
---|
975 | cPagesCanSkip = cPages;
|
---|
976 | break;
|
---|
977 | default:
|
---|
978 | AssertMsgFailed(("%d\n", Walk.u.Core.uLevel));
|
---|
979 | cPagesCanSkip = 0;
|
---|
980 | break;
|
---|
981 | }
|
---|
982 | if (cPages <= cPagesCanSkip)
|
---|
983 | break;
|
---|
984 | fFullWalk = true;
|
---|
985 | if (cPagesCanSkip >= cIncPages)
|
---|
986 | {
|
---|
987 | cPages -= cPagesCanSkip;
|
---|
988 | GCPtr += (RTGCPTR)cPagesCanSkip << X86_PT_PAE_SHIFT;
|
---|
989 | continue;
|
---|
990 | }
|
---|
991 | }
|
---|
992 |
|
---|
993 | /* advance to the next page. */
|
---|
994 | if (cPages <= cIncPages)
|
---|
995 | break;
|
---|
996 | cPages -= cIncPages;
|
---|
997 | GCPtr += (RTGCPTR)cIncPages << X86_PT_PAE_SHIFT;
|
---|
998 |
|
---|
999 | /* Yield the PGM lock every now and then. */
|
---|
1000 | if (!--cYieldCountDown)
|
---|
1001 | {
|
---|
1002 | fFullWalk = PDMR3CritSectYield(pVM, &pVM->pgm.s.CritSectX);
|
---|
1003 | cYieldCountDown = cYieldCountDownReload;
|
---|
1004 | }
|
---|
1005 | }
|
---|
1006 | pgmUnlock(pVM);
|
---|
1007 | return VERR_DBGF_MEM_NOT_FOUND;
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 |
|
---|
1011 | /**
|
---|
1012 | * Initializes the dumper state.
|
---|
1013 | *
|
---|
1014 | * @param pState The state to initialize.
|
---|
1015 | * @param pVM The cross context VM structure.
|
---|
1016 | * @param fFlags The flags.
|
---|
1017 | * @param u64FirstAddr The first address.
|
---|
1018 | * @param u64LastAddr The last address.
|
---|
1019 | * @param pHlp The output helpers.
|
---|
1020 | */
|
---|
1021 | static void pgmR3DumpHierarchyInitState(PPGMR3DUMPHIERARCHYSTATE pState, PVM pVM, uint32_t fFlags,
|
---|
1022 | uint64_t u64FirstAddr, uint64_t u64LastAddr, PCDBGFINFOHLP pHlp)
|
---|
1023 | {
|
---|
1024 | pState->pVM = pVM;
|
---|
1025 | pState->pHlp = pHlp ? pHlp : DBGFR3InfoLogHlp();
|
---|
1026 | pState->fPse = !!(fFlags & (DBGFPGDMP_FLAGS_PSE | DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_LME));
|
---|
1027 | pState->fPae = !!(fFlags & (DBGFPGDMP_FLAGS_PAE | DBGFPGDMP_FLAGS_LME));
|
---|
1028 | pState->fLme = !!(fFlags & DBGFPGDMP_FLAGS_LME);
|
---|
1029 | pState->fNp = !!(fFlags & DBGFPGDMP_FLAGS_NP);
|
---|
1030 | pState->fEpt = !!(fFlags & DBGFPGDMP_FLAGS_EPT);
|
---|
1031 | pState->fNxe = !!(fFlags & DBGFPGDMP_FLAGS_NXE);
|
---|
1032 | pState->cchAddress = pState->fLme ? 16 : 8;
|
---|
1033 | pState->uLastRsvdBit = pState->fNxe ? 62 : 63;
|
---|
1034 | pState->fDumpPageInfo = !!(fFlags & DBGFPGDMP_FLAGS_PAGE_INFO);
|
---|
1035 | pState->fPrintHeader = !!(fFlags & DBGFPGDMP_FLAGS_HEADER);
|
---|
1036 | pState->fPrintCr3 = !!(fFlags & DBGFPGDMP_FLAGS_PRINT_CR3);
|
---|
1037 | pState->afReserved[0] = false;
|
---|
1038 | pState->afReserved[1] = false;
|
---|
1039 | pState->afReserved[2] = false;
|
---|
1040 | pState->afReserved[3] = false;
|
---|
1041 | pState->afReserved[4] = false;
|
---|
1042 | pState->u64Address = u64FirstAddr;
|
---|
1043 | pState->u64FirstAddress = u64FirstAddr;
|
---|
1044 | pState->u64LastAddress = u64LastAddr;
|
---|
1045 | pState->u64HighReservedBits = pState->uLastRsvdBit == 62 ? UINT64_C(0x7ff) << 52 : UINT64_C(0xfff) << 52;
|
---|
1046 | pState->cLeaves = 0;
|
---|
1047 | }
|
---|
1048 |
|
---|
1049 |
|
---|
1050 | /**
|
---|
1051 | * The simple way out, too tired to think of a more elegant solution.
|
---|
1052 | *
|
---|
1053 | * @returns The base address of this page table/directory/whatever.
|
---|
1054 | * @param pState The state where we get the current address.
|
---|
1055 | * @param cShift The shift count for the table entries.
|
---|
1056 | * @param cEntries The number of table entries.
|
---|
1057 | * @param piFirst Where to return the table index of the first
|
---|
1058 | * entry to dump.
|
---|
1059 | * @param piLast Where to return the table index of the last
|
---|
1060 | * entry.
|
---|
1061 | */
|
---|
1062 | static uint64_t pgmR3DumpHierarchyCalcRange(PPGMR3DUMPHIERARCHYSTATE pState, uint32_t cShift, uint32_t cEntries,
|
---|
1063 | uint32_t *piFirst, uint32_t *piLast)
|
---|
1064 | {
|
---|
1065 | const uint64_t iBase = (pState->u64Address >> cShift) & ~(uint64_t)(cEntries - 1);
|
---|
1066 | const uint64_t iFirst = pState->u64FirstAddress >> cShift;
|
---|
1067 | const uint64_t iLast = pState->u64LastAddress >> cShift;
|
---|
1068 |
|
---|
1069 | if ( iBase >= iFirst
|
---|
1070 | && iBase + cEntries - 1 <= iLast)
|
---|
1071 | {
|
---|
1072 | /* full range. */
|
---|
1073 | *piFirst = 0;
|
---|
1074 | *piLast = cEntries - 1;
|
---|
1075 | }
|
---|
1076 | else if ( iBase + cEntries - 1 < iFirst
|
---|
1077 | || iBase > iLast)
|
---|
1078 | {
|
---|
1079 | /* no match */
|
---|
1080 | *piFirst = cEntries;
|
---|
1081 | *piLast = 0;
|
---|
1082 | }
|
---|
1083 | else
|
---|
1084 | {
|
---|
1085 | /* partial overlap */
|
---|
1086 | *piFirst = iBase <= iFirst
|
---|
1087 | ? iFirst - iBase
|
---|
1088 | : 0;
|
---|
1089 | *piLast = iBase + cEntries - 1 <= iLast
|
---|
1090 | ? cEntries - 1
|
---|
1091 | : iLast - iBase;
|
---|
1092 | }
|
---|
1093 |
|
---|
1094 | return iBase << cShift;
|
---|
1095 | }
|
---|
1096 |
|
---|
1097 |
|
---|
1098 | /**
|
---|
1099 | * Maps/finds the shadow page.
|
---|
1100 | *
|
---|
1101 | * @returns VBox status code.
|
---|
1102 | * @param pState The dumper state.
|
---|
1103 | * @param HCPhys The physical address of the shadow page.
|
---|
1104 | * @param pszDesc The description.
|
---|
1105 | * @param fIsMapping Set if it's a mapping.
|
---|
1106 | * @param ppv Where to return the pointer.
|
---|
1107 | */
|
---|
1108 | static int pgmR3DumpHierarchyShwMapPage(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS HCPhys, const char *pszDesc,
|
---|
1109 | bool fIsMapping, void const **ppv)
|
---|
1110 | {
|
---|
1111 | void *pvPage;
|
---|
1112 | if (!fIsMapping)
|
---|
1113 | {
|
---|
1114 | PPGMPOOLPAGE pPoolPage = pgmPoolQueryPageForDbg(pState->pVM->pgm.s.pPoolR3, HCPhys);
|
---|
1115 | if (pPoolPage)
|
---|
1116 | {
|
---|
1117 | pState->pHlp->pfnPrintf(pState->pHlp, "%0*llx error! %s at HCPhys=%RHp was not found in the page pool!\n",
|
---|
1118 | pState->cchAddress, pState->u64Address, pszDesc, HCPhys);
|
---|
1119 | return VERR_PGM_POOL_GET_PAGE_FAILED;
|
---|
1120 | }
|
---|
1121 | pvPage = (uint8_t *)pPoolPage->pvPageR3 + (HCPhys & PAGE_OFFSET_MASK);
|
---|
1122 | }
|
---|
1123 | else
|
---|
1124 | {
|
---|
1125 | pvPage = NULL;
|
---|
1126 | #ifndef PGM_WITHOUT_MAPPINGS
|
---|
1127 | for (PPGMMAPPING pMap = pState->pVM->pgm.s.pMappingsR3; pMap; pMap = pMap->pNextR3)
|
---|
1128 | {
|
---|
1129 | uint64_t off = pState->u64Address - pMap->GCPtr;
|
---|
1130 | if (off < pMap->cb)
|
---|
1131 | {
|
---|
1132 | const int iPDE = (uint32_t)(off >> X86_PD_SHIFT);
|
---|
1133 | const int iSub = (int)((off >> X86_PD_PAE_SHIFT) & 1); /* MSC is a pain sometimes */
|
---|
1134 | if ((iSub ? pMap->aPTs[iPDE].HCPhysPaePT1 : pMap->aPTs[iPDE].HCPhysPaePT0) != HCPhys)
|
---|
1135 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
1136 | "%0*llx error! Mapping error! PT %d has HCPhysPT=%RHp not %RHp is in the PD.\n",
|
---|
1137 | pState->cchAddress, pState->u64Address, iPDE,
|
---|
1138 | iSub ? pMap->aPTs[iPDE].HCPhysPaePT1 : pMap->aPTs[iPDE].HCPhysPaePT0, HCPhys);
|
---|
1139 | pvPage = &pMap->aPTs[iPDE].paPaePTsR3[iSub];
|
---|
1140 | break;
|
---|
1141 | }
|
---|
1142 | }
|
---|
1143 | #endif /* !PGM_WITHOUT_MAPPINGS */
|
---|
1144 | if (!pvPage)
|
---|
1145 | {
|
---|
1146 | pState->pHlp->pfnPrintf(pState->pHlp, "%0*llx error! PT mapping %s at HCPhys=%RHp was not found in the page pool!\n",
|
---|
1147 | pState->cchAddress, pState->u64Address, pszDesc, HCPhys);
|
---|
1148 | return VERR_INVALID_PARAMETER;
|
---|
1149 | }
|
---|
1150 | }
|
---|
1151 | *ppv = pvPage;
|
---|
1152 | return VINF_SUCCESS;
|
---|
1153 | }
|
---|
1154 |
|
---|
1155 |
|
---|
1156 | /**
|
---|
1157 | * Dumps the a shadow page summary or smth.
|
---|
1158 | *
|
---|
1159 | * @param pState The dumper state.
|
---|
1160 | * @param HCPhys The page address.
|
---|
1161 | */
|
---|
1162 | static void pgmR3DumpHierarchyShwTablePageInfo(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS HCPhys)
|
---|
1163 | {
|
---|
1164 | pgmLock(pState->pVM);
|
---|
1165 | char szPage[80];
|
---|
1166 | PPGMPOOLPAGE pPage = pgmPoolQueryPageForDbg(pState->pVM->pgm.s.CTX_SUFF(pPool), HCPhys);
|
---|
1167 | if (pPage)
|
---|
1168 | RTStrPrintf(szPage, sizeof(szPage), " idx=0i%u", pPage->idx);
|
---|
1169 | else
|
---|
1170 | {
|
---|
1171 | /* probably a mapping */
|
---|
1172 | strcpy(szPage, " not found");
|
---|
1173 | #ifndef PGM_WITHOUT_MAPPINGS
|
---|
1174 | for (PPGMMAPPING pMap = pState->pVM->pgm.s.pMappingsR3; pMap; pMap = pMap->pNextR3)
|
---|
1175 | {
|
---|
1176 | uint64_t off = pState->u64Address - pMap->GCPtr;
|
---|
1177 | if (off < pMap->cb)
|
---|
1178 | {
|
---|
1179 | const int iPDE = (uint32_t)(off >> X86_PD_SHIFT);
|
---|
1180 | if (pMap->aPTs[iPDE].HCPhysPT == HCPhys)
|
---|
1181 | RTStrPrintf(szPage, sizeof(szPage), " #%u: %s", iPDE, pMap->pszDesc);
|
---|
1182 | else if (pMap->aPTs[iPDE].HCPhysPaePT0 == HCPhys)
|
---|
1183 | RTStrPrintf(szPage, sizeof(szPage), " #%u/0: %s", iPDE, pMap->pszDesc);
|
---|
1184 | else if (pMap->aPTs[iPDE].HCPhysPaePT1 == HCPhys)
|
---|
1185 | RTStrPrintf(szPage, sizeof(szPage), " #%u/1: %s", iPDE, pMap->pszDesc);
|
---|
1186 | else
|
---|
1187 | continue;
|
---|
1188 | break;
|
---|
1189 | }
|
---|
1190 | }
|
---|
1191 | #endif /* !PGM_WITHOUT_MAPPINGS */
|
---|
1192 | }
|
---|
1193 | pgmUnlock(pState->pVM);
|
---|
1194 | pState->pHlp->pfnPrintf(pState->pHlp, "%s", szPage);
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 |
|
---|
1198 | /**
|
---|
1199 | * Figures out which guest page this is and dumps a summary.
|
---|
1200 | *
|
---|
1201 | * @param pState The dumper state.
|
---|
1202 | * @param HCPhys The page address.
|
---|
1203 | * @param cbPage The page size.
|
---|
1204 | */
|
---|
1205 | static void pgmR3DumpHierarchyShwGuestPageInfo(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS HCPhys, uint32_t cbPage)
|
---|
1206 | {
|
---|
1207 | char szPage[80];
|
---|
1208 | RTGCPHYS GCPhys;
|
---|
1209 | int rc = PGMR3DbgHCPhys2GCPhys(pState->pVM->pUVM, HCPhys, &GCPhys);
|
---|
1210 | if (RT_SUCCESS(rc))
|
---|
1211 | {
|
---|
1212 | pgmLock(pState->pVM);
|
---|
1213 | PCPGMPAGE pPage = pgmPhysGetPage(pState->pVM, GCPhys);
|
---|
1214 | if (pPage)
|
---|
1215 | RTStrPrintf(szPage, sizeof(szPage), "%R[pgmpage]", pPage);
|
---|
1216 | else
|
---|
1217 | strcpy(szPage, "not found");
|
---|
1218 | pgmUnlock(pState->pVM);
|
---|
1219 | pState->pHlp->pfnPrintf(pState->pHlp, " -> %RGp %s", GCPhys, szPage);
|
---|
1220 | }
|
---|
1221 | else
|
---|
1222 | {
|
---|
1223 | #ifndef PGM_WITHOUT_MAPPINGS
|
---|
1224 | /* check the heap */
|
---|
1225 | uint32_t cbAlloc;
|
---|
1226 | rc = MMR3HyperQueryInfoFromHCPhys(pState->pVM, HCPhys, szPage, sizeof(szPage), &cbAlloc);
|
---|
1227 | if (RT_SUCCESS(rc))
|
---|
1228 | pState->pHlp->pfnPrintf(pState->pHlp, " %s %#x bytes", szPage, cbAlloc);
|
---|
1229 | else
|
---|
1230 | #endif
|
---|
1231 | pState->pHlp->pfnPrintf(pState->pHlp, " not found");
|
---|
1232 | }
|
---|
1233 | NOREF(cbPage);
|
---|
1234 | }
|
---|
1235 |
|
---|
1236 |
|
---|
1237 | /**
|
---|
1238 | * Dumps a PAE shadow page table.
|
---|
1239 | *
|
---|
1240 | * @returns VBox status code (VINF_SUCCESS).
|
---|
1241 | * @param pState The dumper state.
|
---|
1242 | * @param HCPhys The page table address.
|
---|
1243 | * @param fIsMapping Whether it is a mapping.
|
---|
1244 | */
|
---|
1245 | static int pgmR3DumpHierarchyShwPaePT(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS HCPhys, bool fIsMapping)
|
---|
1246 | {
|
---|
1247 | PCPGMSHWPTPAE pPT;
|
---|
1248 | int rc = pgmR3DumpHierarchyShwMapPage(pState, HCPhys, "Page table", fIsMapping, (void const **)&pPT);
|
---|
1249 | if (RT_FAILURE(rc))
|
---|
1250 | return rc;
|
---|
1251 |
|
---|
1252 | uint32_t iFirst, iLast;
|
---|
1253 | uint64_t u64BaseAddress = pgmR3DumpHierarchyCalcRange(pState, X86_PT_PAE_SHIFT, X86_PG_PAE_ENTRIES, &iFirst, &iLast);
|
---|
1254 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
1255 | if (PGMSHWPTEPAE_GET_U(pPT->a[i]) & X86_PTE_P)
|
---|
1256 | {
|
---|
1257 | pState->u64Address = u64BaseAddress + ((uint64_t)i << X86_PT_PAE_SHIFT);
|
---|
1258 | if (PGMSHWPTEPAE_IS_P(pPT->a[i]))
|
---|
1259 | {
|
---|
1260 | X86PTEPAE Pte;
|
---|
1261 | Pte.u = PGMSHWPTEPAE_GET_U(pPT->a[i]);
|
---|
1262 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
1263 | pState->fLme /*P R S A D G WT CD AT NX 4M a p ? */
|
---|
1264 | ? "%016llx 3 | P %c %c %c %c %c %s %s %s %s 4K %c%c%c %016llx"
|
---|
1265 | : "%08llx 2 | P %c %c %c %c %c %s %s %s %s 4K %c%c%c %016llx",
|
---|
1266 | pState->u64Address,
|
---|
1267 | Pte.n.u1Write ? 'W' : 'R',
|
---|
1268 | Pte.n.u1User ? 'U' : 'S',
|
---|
1269 | Pte.n.u1Accessed ? 'A' : '-',
|
---|
1270 | Pte.n.u1Dirty ? 'D' : '-',
|
---|
1271 | Pte.n.u1Global ? 'G' : '-',
|
---|
1272 | Pte.n.u1WriteThru ? "WT" : "--",
|
---|
1273 | Pte.n.u1CacheDisable? "CD" : "--",
|
---|
1274 | Pte.n.u1PAT ? "AT" : "--",
|
---|
1275 | Pte.n.u1NoExecute ? "NX" : "--",
|
---|
1276 | Pte.u & PGM_PTFLAGS_TRACK_DIRTY ? 'd' : '-',
|
---|
1277 | Pte.u & RT_BIT(10) ? '1' : '0',
|
---|
1278 | Pte.u & PGM_PTFLAGS_CSAM_VALIDATED? 'v' : '-',
|
---|
1279 | Pte.u & X86_PTE_PAE_PG_MASK);
|
---|
1280 | if (pState->fDumpPageInfo)
|
---|
1281 | pgmR3DumpHierarchyShwGuestPageInfo(pState, Pte.u & X86_PTE_PAE_PG_MASK, _4K);
|
---|
1282 | if ((Pte.u >> 52) & 0x7ff)
|
---|
1283 | pState->pHlp->pfnPrintf(pState->pHlp, " 62:52=%03llx%s", (Pte.u >> 52) & 0x7ff, pState->fLme ? "" : "!");
|
---|
1284 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
1285 | }
|
---|
1286 | else if ( (PGMSHWPTEPAE_GET_U(pPT->a[i]) & (pState->pVM->pgm.s.HCPhysInvMmioPg | X86_PTE_PAE_MBZ_MASK_NO_NX))
|
---|
1287 | == (pState->pVM->pgm.s.HCPhysInvMmioPg | X86_PTE_PAE_MBZ_MASK_NO_NX))
|
---|
1288 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
1289 | pState->fLme
|
---|
1290 | ? "%016llx 3 | invalid / MMIO optimization\n"
|
---|
1291 | : "%08llx 2 | invalid / MMIO optimization\n",
|
---|
1292 | pState->u64Address);
|
---|
1293 | else
|
---|
1294 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
1295 | pState->fLme
|
---|
1296 | ? "%016llx 3 | invalid: %RX64\n"
|
---|
1297 | : "%08llx 2 | invalid: %RX64\n",
|
---|
1298 | pState->u64Address, PGMSHWPTEPAE_GET_U(pPT->a[i]));
|
---|
1299 | pState->cLeaves++;
|
---|
1300 | }
|
---|
1301 | return VINF_SUCCESS;
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 |
|
---|
1305 | /**
|
---|
1306 | * Dumps a PAE shadow page directory table.
|
---|
1307 | *
|
---|
1308 | * @returns VBox status code (VINF_SUCCESS).
|
---|
1309 | * @param pState The dumper state.
|
---|
1310 | * @param HCPhys The physical address of the page directory table.
|
---|
1311 | * @param cMaxDepth The maximum depth.
|
---|
1312 | */
|
---|
1313 | static int pgmR3DumpHierarchyShwPaePD(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS HCPhys, unsigned cMaxDepth)
|
---|
1314 | {
|
---|
1315 | PCX86PDPAE pPD;
|
---|
1316 | int rc = pgmR3DumpHierarchyShwMapPage(pState, HCPhys, "Page directory", false, (void const **)&pPD);
|
---|
1317 | if (RT_FAILURE(rc))
|
---|
1318 | return rc;
|
---|
1319 |
|
---|
1320 | Assert(cMaxDepth > 0);
|
---|
1321 | cMaxDepth--;
|
---|
1322 |
|
---|
1323 | uint32_t iFirst, iLast;
|
---|
1324 | uint64_t u64BaseAddress = pgmR3DumpHierarchyCalcRange(pState, X86_PD_PAE_SHIFT, X86_PG_PAE_ENTRIES, &iFirst, &iLast);
|
---|
1325 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
1326 | {
|
---|
1327 | X86PDEPAE Pde = pPD->a[i];
|
---|
1328 | if (Pde.n.u1Present)
|
---|
1329 | {
|
---|
1330 | pState->u64Address = u64BaseAddress + ((uint64_t)i << X86_PD_PAE_SHIFT);
|
---|
1331 | if (Pde.b.u1Size)
|
---|
1332 | {
|
---|
1333 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
1334 | pState->fLme /*P R S A D G WT CD AT NX 2M a p ? phys*/
|
---|
1335 | ? "%016llx 2 | P %c %c %c %c %c %s %s %s %s 2M %c%c%c %016llx"
|
---|
1336 | : "%08llx 1 | P %c %c %c %c %c %s %s %s %s 2M %c%c%c %016llx",
|
---|
1337 | pState->u64Address,
|
---|
1338 | Pde.b.u1Write ? 'W' : 'R',
|
---|
1339 | Pde.b.u1User ? 'U' : 'S',
|
---|
1340 | Pde.b.u1Accessed ? 'A' : '-',
|
---|
1341 | Pde.b.u1Dirty ? 'D' : '-',
|
---|
1342 | Pde.b.u1Global ? 'G' : '-',
|
---|
1343 | Pde.b.u1WriteThru ? "WT" : "--",
|
---|
1344 | Pde.b.u1CacheDisable? "CD" : "--",
|
---|
1345 | Pde.b.u1PAT ? "AT" : "--",
|
---|
1346 | Pde.b.u1NoExecute ? "NX" : "--",
|
---|
1347 | Pde.u & PGM_PDFLAGS_BIG_PAGE ? 'b' : '-',
|
---|
1348 | Pde.u & PGM_PDFLAGS_MAPPING ? 'm' : '-',
|
---|
1349 | Pde.u & PGM_PDFLAGS_TRACK_DIRTY ? 'd' : '-',
|
---|
1350 | Pde.u & X86_PDE2M_PAE_PG_MASK);
|
---|
1351 | if (pState->fDumpPageInfo)
|
---|
1352 | pgmR3DumpHierarchyShwGuestPageInfo(pState, Pde.u & X86_PDE2M_PAE_PG_MASK, _2M);
|
---|
1353 | if ((Pde.u >> 52) & 0x7ff)
|
---|
1354 | pState->pHlp->pfnPrintf(pState->pHlp, " 62:52=%03llx%s", (Pde.u >> 52) & 0x7ff, pState->fLme ? "" : "!");
|
---|
1355 | if ((Pde.u >> 13) & 0xff)
|
---|
1356 | pState->pHlp->pfnPrintf(pState->pHlp, " 20:13=%02llx%s", (Pde.u >> 13) & 0x0ff, pState->fLme ? "" : "!");
|
---|
1357 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
1358 |
|
---|
1359 | pState->cLeaves++;
|
---|
1360 | }
|
---|
1361 | else
|
---|
1362 | {
|
---|
1363 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
1364 | pState->fLme /*P R S A D G WT CD AT NX 4M a p ? phys */
|
---|
1365 | ? "%016llx 2 | P %c %c %c %c %c %s %s .. %s .. %c%c%c %016llx"
|
---|
1366 | : "%08llx 1 | P %c %c %c %c %c %s %s .. %s .. %c%c%c %016llx",
|
---|
1367 | pState->u64Address,
|
---|
1368 | Pde.n.u1Write ? 'W' : 'R',
|
---|
1369 | Pde.n.u1User ? 'U' : 'S',
|
---|
1370 | Pde.n.u1Accessed ? 'A' : '-',
|
---|
1371 | Pde.n.u1Reserved0 ? '?' : '.', /* ignored */
|
---|
1372 | Pde.n.u1Reserved1 ? '?' : '.', /* ignored */
|
---|
1373 | Pde.n.u1WriteThru ? "WT" : "--",
|
---|
1374 | Pde.n.u1CacheDisable? "CD" : "--",
|
---|
1375 | Pde.n.u1NoExecute ? "NX" : "--",
|
---|
1376 | Pde.u & PGM_PDFLAGS_BIG_PAGE ? 'b' : '-',
|
---|
1377 | Pde.u & PGM_PDFLAGS_MAPPING ? 'm' : '-',
|
---|
1378 | Pde.u & PGM_PDFLAGS_TRACK_DIRTY ? 'd' : '-',
|
---|
1379 | Pde.u & X86_PDE_PAE_PG_MASK);
|
---|
1380 | if (pState->fDumpPageInfo)
|
---|
1381 | pgmR3DumpHierarchyShwTablePageInfo(pState, Pde.u & X86_PDE_PAE_PG_MASK);
|
---|
1382 | if ((Pde.u >> 52) & 0x7ff)
|
---|
1383 | pState->pHlp->pfnPrintf(pState->pHlp, " 62:52=%03llx!", (Pde.u >> 52) & 0x7ff);
|
---|
1384 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
1385 |
|
---|
1386 | if (cMaxDepth)
|
---|
1387 | {
|
---|
1388 | int rc2 = pgmR3DumpHierarchyShwPaePT(pState, Pde.u & X86_PDE_PAE_PG_MASK, !!(Pde.u & PGM_PDFLAGS_MAPPING));
|
---|
1389 | if (rc2 < rc && RT_SUCCESS(rc))
|
---|
1390 | rc = rc2;
|
---|
1391 | }
|
---|
1392 | else
|
---|
1393 | pState->cLeaves++;
|
---|
1394 | }
|
---|
1395 | }
|
---|
1396 | }
|
---|
1397 | return rc;
|
---|
1398 | }
|
---|
1399 |
|
---|
1400 |
|
---|
1401 | /**
|
---|
1402 | * Dumps a PAE shadow page directory pointer table.
|
---|
1403 | *
|
---|
1404 | * @returns VBox status code (VINF_SUCCESS).
|
---|
1405 | * @param pState The dumper state.
|
---|
1406 | * @param HCPhys The physical address of the page directory pointer table.
|
---|
1407 | * @param cMaxDepth The maximum depth.
|
---|
1408 | */
|
---|
1409 | static int pgmR3DumpHierarchyShwPaePDPT(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS HCPhys, unsigned cMaxDepth)
|
---|
1410 | {
|
---|
1411 | /* Fend of addresses that are out of range in PAE mode - simplifies the code below. */
|
---|
1412 | if (!pState->fLme && pState->u64Address >= _4G)
|
---|
1413 | return VINF_SUCCESS;
|
---|
1414 |
|
---|
1415 | PCX86PDPT pPDPT;
|
---|
1416 | int rc = pgmR3DumpHierarchyShwMapPage(pState, HCPhys, "Page directory pointer table", false, (void const **)&pPDPT);
|
---|
1417 | if (RT_FAILURE(rc))
|
---|
1418 | return rc;
|
---|
1419 |
|
---|
1420 | Assert(cMaxDepth > 0);
|
---|
1421 | cMaxDepth--;
|
---|
1422 |
|
---|
1423 | uint32_t iFirst, iLast;
|
---|
1424 | uint64_t u64BaseAddress = pgmR3DumpHierarchyCalcRange(pState, X86_PDPT_SHIFT,
|
---|
1425 | pState->fLme ? X86_PG_AMD64_PDPE_ENTRIES : X86_PG_PAE_PDPE_ENTRIES,
|
---|
1426 | &iFirst, &iLast);
|
---|
1427 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
1428 | {
|
---|
1429 | X86PDPE Pdpe = pPDPT->a[i];
|
---|
1430 | if (Pdpe.n.u1Present)
|
---|
1431 | {
|
---|
1432 | pState->u64Address = u64BaseAddress + ((uint64_t)i << X86_PDPT_SHIFT);
|
---|
1433 | if (pState->fLme)
|
---|
1434 | {
|
---|
1435 | pState->pHlp->pfnPrintf(pState->pHlp, /*P R S A D G WT CD AT NX .. a p ? */
|
---|
1436 | "%016llx 1 | P %c %c %c %c %c %s %s %s %s .. %c%c%c %016llx",
|
---|
1437 | pState->u64Address,
|
---|
1438 | Pdpe.lm.u1Write ? 'W' : 'R',
|
---|
1439 | Pdpe.lm.u1User ? 'U' : 'S',
|
---|
1440 | Pdpe.lm.u1Accessed ? 'A' : '-',
|
---|
1441 | Pdpe.lm.u3Reserved & 1? '?' : '.', /* ignored */
|
---|
1442 | Pdpe.lm.u3Reserved & 4? '!' : '.', /* mbz */
|
---|
1443 | Pdpe.lm.u1WriteThru ? "WT" : "--",
|
---|
1444 | Pdpe.lm.u1CacheDisable? "CD" : "--",
|
---|
1445 | Pdpe.lm.u3Reserved & 2? "!" : "..",/* mbz */
|
---|
1446 | Pdpe.lm.u1NoExecute ? "NX" : "--",
|
---|
1447 | Pdpe.u & RT_BIT(9) ? '1' : '0',
|
---|
1448 | Pdpe.u & PGM_PLXFLAGS_PERMANENT ? 'p' : '-',
|
---|
1449 | Pdpe.u & RT_BIT(11) ? '1' : '0',
|
---|
1450 | Pdpe.u & X86_PDPE_PG_MASK);
|
---|
1451 | if (pState->fDumpPageInfo)
|
---|
1452 | pgmR3DumpHierarchyShwTablePageInfo(pState, Pdpe.u & X86_PDPE_PG_MASK);
|
---|
1453 | if ((Pdpe.u >> 52) & 0x7ff)
|
---|
1454 | pState->pHlp->pfnPrintf(pState->pHlp, " 62:52=%03llx", (Pdpe.u >> 52) & 0x7ff);
|
---|
1455 | }
|
---|
1456 | else
|
---|
1457 | {
|
---|
1458 | pState->pHlp->pfnPrintf(pState->pHlp,/*P R S A D G WT CD AT NX .. a p ? */
|
---|
1459 | "%08llx 0 | P %c %c %c %c %c %s %s %s %s .. %c%c%c %016llx",
|
---|
1460 | pState->u64Address,
|
---|
1461 | Pdpe.n.u2Reserved & 1? '!' : '.', /* mbz */
|
---|
1462 | Pdpe.n.u2Reserved & 2? '!' : '.', /* mbz */
|
---|
1463 | Pdpe.n.u4Reserved & 1? '!' : '.', /* mbz */
|
---|
1464 | Pdpe.n.u4Reserved & 2? '!' : '.', /* mbz */
|
---|
1465 | Pdpe.n.u4Reserved & 8? '!' : '.', /* mbz */
|
---|
1466 | Pdpe.n.u1WriteThru ? "WT" : "--",
|
---|
1467 | Pdpe.n.u1CacheDisable? "CD" : "--",
|
---|
1468 | Pdpe.n.u4Reserved & 2? "!" : "..",/* mbz */
|
---|
1469 | Pdpe.lm.u1NoExecute ? "!!" : "..",/* mbz */
|
---|
1470 | Pdpe.u & RT_BIT(9) ? '1' : '0',
|
---|
1471 | Pdpe.u & PGM_PLXFLAGS_PERMANENT ? 'p' : '-',
|
---|
1472 | Pdpe.u & RT_BIT(11) ? '1' : '0',
|
---|
1473 | Pdpe.u & X86_PDPE_PG_MASK);
|
---|
1474 | if (pState->fDumpPageInfo)
|
---|
1475 | pgmR3DumpHierarchyShwTablePageInfo(pState, Pdpe.u & X86_PDPE_PG_MASK);
|
---|
1476 | if ((Pdpe.u >> 52) & 0xfff)
|
---|
1477 | pState->pHlp->pfnPrintf(pState->pHlp, " 63:52=%03llx!", (Pdpe.u >> 52) & 0xfff);
|
---|
1478 | }
|
---|
1479 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
1480 |
|
---|
1481 | if (cMaxDepth)
|
---|
1482 | {
|
---|
1483 | int rc2 = pgmR3DumpHierarchyShwPaePD(pState, Pdpe.u & X86_PDPE_PG_MASK, cMaxDepth);
|
---|
1484 | if (rc2 < rc && RT_SUCCESS(rc))
|
---|
1485 | rc = rc2;
|
---|
1486 | }
|
---|
1487 | else
|
---|
1488 | pState->cLeaves++;
|
---|
1489 | }
|
---|
1490 | }
|
---|
1491 | return rc;
|
---|
1492 | }
|
---|
1493 |
|
---|
1494 |
|
---|
1495 | /**
|
---|
1496 | * Dumps a 32-bit shadow page table.
|
---|
1497 | *
|
---|
1498 | * @returns VBox status code (VINF_SUCCESS).
|
---|
1499 | * @param pState The dumper state.
|
---|
1500 | * @param HCPhys The physical address of the table.
|
---|
1501 | * @param cMaxDepth The maximum depth.
|
---|
1502 | */
|
---|
1503 | static int pgmR3DumpHierarchyShwPaePML4(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS HCPhys, unsigned cMaxDepth)
|
---|
1504 | {
|
---|
1505 | PCX86PML4 pPML4;
|
---|
1506 | int rc = pgmR3DumpHierarchyShwMapPage(pState, HCPhys, "Page map level 4", false, (void const **)&pPML4);
|
---|
1507 | if (RT_FAILURE(rc))
|
---|
1508 | return rc;
|
---|
1509 |
|
---|
1510 | Assert(cMaxDepth);
|
---|
1511 | cMaxDepth--;
|
---|
1512 |
|
---|
1513 | /*
|
---|
1514 | * This is a bit tricky as we're working on unsigned addresses while the
|
---|
1515 | * AMD64 spec uses signed tricks.
|
---|
1516 | */
|
---|
1517 | uint32_t iFirst = (pState->u64FirstAddress >> X86_PML4_SHIFT) & X86_PML4_MASK;
|
---|
1518 | uint32_t iLast = (pState->u64LastAddress >> X86_PML4_SHIFT) & X86_PML4_MASK;
|
---|
1519 | if ( pState->u64LastAddress <= UINT64_C(0x00007fffffffffff)
|
---|
1520 | || pState->u64FirstAddress >= UINT64_C(0xffff800000000000))
|
---|
1521 | { /* Simple, nothing to adjust */ }
|
---|
1522 | else if (pState->u64FirstAddress <= UINT64_C(0x00007fffffffffff))
|
---|
1523 | iLast = X86_PG_AMD64_ENTRIES / 2 - 1;
|
---|
1524 | else if (pState->u64LastAddress >= UINT64_C(0xffff800000000000))
|
---|
1525 | iFirst = X86_PG_AMD64_ENTRIES / 2;
|
---|
1526 | else
|
---|
1527 | iFirst = X86_PG_AMD64_ENTRIES; /* neither address is canonical */
|
---|
1528 |
|
---|
1529 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
1530 | {
|
---|
1531 | X86PML4E Pml4e = pPML4->a[i];
|
---|
1532 | if (Pml4e.n.u1Present)
|
---|
1533 | {
|
---|
1534 | pState->u64Address = ((uint64_t)i << X86_PML4_SHIFT)
|
---|
1535 | | (i >= RT_ELEMENTS(pPML4->a) / 2 ? UINT64_C(0xffff000000000000) : 0);
|
---|
1536 | pState->pHlp->pfnPrintf(pState->pHlp, /*P R S A D G WT CD AT NX 4M a p ? */
|
---|
1537 | "%016llx 0 | P %c %c %c %c %c %s %s %s %s .. %c%c%c %016llx",
|
---|
1538 | pState->u64Address,
|
---|
1539 | Pml4e.n.u1Write ? 'W' : 'R',
|
---|
1540 | Pml4e.n.u1User ? 'U' : 'S',
|
---|
1541 | Pml4e.n.u1Accessed ? 'A' : '-',
|
---|
1542 | Pml4e.n.u3Reserved & 1? '?' : '.', /* ignored */
|
---|
1543 | Pml4e.n.u3Reserved & 4? '!' : '.', /* mbz */
|
---|
1544 | Pml4e.n.u1WriteThru ? "WT" : "--",
|
---|
1545 | Pml4e.n.u1CacheDisable? "CD" : "--",
|
---|
1546 | Pml4e.n.u3Reserved & 2? "!" : "..",/* mbz */
|
---|
1547 | Pml4e.n.u1NoExecute ? "NX" : "--",
|
---|
1548 | Pml4e.u & RT_BIT(9) ? '1' : '0',
|
---|
1549 | Pml4e.u & PGM_PLXFLAGS_PERMANENT ? 'p' : '-',
|
---|
1550 | Pml4e.u & RT_BIT(11) ? '1' : '0',
|
---|
1551 | Pml4e.u & X86_PML4E_PG_MASK);
|
---|
1552 | if (pState->fDumpPageInfo)
|
---|
1553 | pgmR3DumpHierarchyShwTablePageInfo(pState, Pml4e.u & X86_PML4E_PG_MASK);
|
---|
1554 | if ((Pml4e.u >> 52) & 0x7ff)
|
---|
1555 | pState->pHlp->pfnPrintf(pState->pHlp, " 62:52=%03llx!", (Pml4e.u >> 52) & 0x7ff);
|
---|
1556 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
1557 |
|
---|
1558 | if (cMaxDepth)
|
---|
1559 | {
|
---|
1560 | int rc2 = pgmR3DumpHierarchyShwPaePDPT(pState, Pml4e.u & X86_PML4E_PG_MASK, cMaxDepth);
|
---|
1561 | if (rc2 < rc && RT_SUCCESS(rc))
|
---|
1562 | rc = rc2;
|
---|
1563 | }
|
---|
1564 | else
|
---|
1565 | pState->cLeaves++;
|
---|
1566 | }
|
---|
1567 | }
|
---|
1568 | return rc;
|
---|
1569 | }
|
---|
1570 |
|
---|
1571 |
|
---|
1572 | /**
|
---|
1573 | * Dumps a 32-bit shadow page table.
|
---|
1574 | *
|
---|
1575 | * @returns VBox status code (VINF_SUCCESS).
|
---|
1576 | * @param pState The dumper state.
|
---|
1577 | * @param HCPhys The physical address of the table.
|
---|
1578 | * @param fMapping Set if it's a guest mapping.
|
---|
1579 | */
|
---|
1580 | static int pgmR3DumpHierarchyShw32BitPT(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS HCPhys, bool fMapping)
|
---|
1581 | {
|
---|
1582 | PCX86PT pPT;
|
---|
1583 | int rc = pgmR3DumpHierarchyShwMapPage(pState, HCPhys, "Page table", fMapping, (void const **)&pPT);
|
---|
1584 | if (RT_FAILURE(rc))
|
---|
1585 | return rc;
|
---|
1586 |
|
---|
1587 | uint32_t iFirst, iLast;
|
---|
1588 | uint64_t u64BaseAddress = pgmR3DumpHierarchyCalcRange(pState, X86_PT_SHIFT, X86_PG_ENTRIES, &iFirst, &iLast);
|
---|
1589 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
1590 | {
|
---|
1591 | X86PTE Pte = pPT->a[i];
|
---|
1592 | if (Pte.n.u1Present)
|
---|
1593 | {
|
---|
1594 | pState->u64Address = u64BaseAddress + (i << X86_PT_SHIFT);
|
---|
1595 | pState->pHlp->pfnPrintf(pState->pHlp,/*P R S A D G WT CD AT NX 4M a m d */
|
---|
1596 | "%08llx 1 | P %c %c %c %c %c %s %s %s .. 4K %c%c%c %08x",
|
---|
1597 | pState->u64Address,
|
---|
1598 | Pte.n.u1Write ? 'W' : 'R',
|
---|
1599 | Pte.n.u1User ? 'U' : 'S',
|
---|
1600 | Pte.n.u1Accessed ? 'A' : '-',
|
---|
1601 | Pte.n.u1Dirty ? 'D' : '-',
|
---|
1602 | Pte.n.u1Global ? 'G' : '-',
|
---|
1603 | Pte.n.u1WriteThru ? "WT" : "--",
|
---|
1604 | Pte.n.u1CacheDisable? "CD" : "--",
|
---|
1605 | Pte.n.u1PAT ? "AT" : "--",
|
---|
1606 | Pte.u & PGM_PTFLAGS_TRACK_DIRTY ? 'd' : '-',
|
---|
1607 | Pte.u & RT_BIT(10) ? '1' : '0',
|
---|
1608 | Pte.u & PGM_PTFLAGS_CSAM_VALIDATED ? 'v' : '-',
|
---|
1609 | Pte.u & X86_PDE_PG_MASK);
|
---|
1610 | if (pState->fDumpPageInfo)
|
---|
1611 | pgmR3DumpHierarchyShwGuestPageInfo(pState, Pte.u & X86_PDE_PG_MASK, _4K);
|
---|
1612 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
1613 | }
|
---|
1614 | }
|
---|
1615 | return VINF_SUCCESS;
|
---|
1616 | }
|
---|
1617 |
|
---|
1618 |
|
---|
1619 | /**
|
---|
1620 | * Dumps a 32-bit shadow page directory and page tables.
|
---|
1621 | *
|
---|
1622 | * @returns VBox status code (VINF_SUCCESS).
|
---|
1623 | * @param pState The dumper state.
|
---|
1624 | * @param HCPhys The physical address of the table.
|
---|
1625 | * @param cMaxDepth The maximum depth.
|
---|
1626 | */
|
---|
1627 | static int pgmR3DumpHierarchyShw32BitPD(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS HCPhys, unsigned cMaxDepth)
|
---|
1628 | {
|
---|
1629 | if (pState->u64Address >= _4G)
|
---|
1630 | return VINF_SUCCESS;
|
---|
1631 |
|
---|
1632 | PCX86PD pPD;
|
---|
1633 | int rc = pgmR3DumpHierarchyShwMapPage(pState, HCPhys, "Page directory", false, (void const **)&pPD);
|
---|
1634 | if (RT_FAILURE(rc))
|
---|
1635 | return rc;
|
---|
1636 |
|
---|
1637 | Assert(cMaxDepth > 0);
|
---|
1638 | cMaxDepth--;
|
---|
1639 |
|
---|
1640 | uint32_t iFirst, iLast;
|
---|
1641 | pgmR3DumpHierarchyCalcRange(pState, X86_PD_SHIFT, X86_PG_ENTRIES, &iFirst, &iLast);
|
---|
1642 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
1643 | {
|
---|
1644 | X86PDE Pde = pPD->a[i];
|
---|
1645 | if (Pde.n.u1Present)
|
---|
1646 | {
|
---|
1647 | pState->u64Address = (uint32_t)i << X86_PD_SHIFT;
|
---|
1648 | if (Pde.b.u1Size && pState->fPse)
|
---|
1649 | {
|
---|
1650 | uint64_t u64Phys = ((uint64_t)(Pde.u & X86_PDE4M_PG_HIGH_MASK) << X86_PDE4M_PG_HIGH_SHIFT)
|
---|
1651 | | (Pde.u & X86_PDE4M_PG_MASK);
|
---|
1652 | pState->pHlp->pfnPrintf(pState->pHlp,/*P R S A D G WT CD AT NX 4M a m d phys */
|
---|
1653 | "%08llx 0 | P %c %c %c %c %c %s %s %s .. 4M %c%c%c %08llx",
|
---|
1654 | pState->u64Address,
|
---|
1655 | Pde.b.u1Write ? 'W' : 'R',
|
---|
1656 | Pde.b.u1User ? 'U' : 'S',
|
---|
1657 | Pde.b.u1Accessed ? 'A' : '-',
|
---|
1658 | Pde.b.u1Dirty ? 'D' : '-',
|
---|
1659 | Pde.b.u1Global ? 'G' : '-',
|
---|
1660 | Pde.b.u1WriteThru ? "WT" : "--",
|
---|
1661 | Pde.b.u1CacheDisable? "CD" : "--",
|
---|
1662 | Pde.b.u1PAT ? "AT" : "--",
|
---|
1663 | Pde.u & PGM_PDFLAGS_BIG_PAGE ? 'b' : '-',
|
---|
1664 | Pde.u & PGM_PDFLAGS_MAPPING ? 'm' : '-',
|
---|
1665 | Pde.u & PGM_PDFLAGS_TRACK_DIRTY ? 'd' : '-',
|
---|
1666 | u64Phys);
|
---|
1667 | if (pState->fDumpPageInfo)
|
---|
1668 | pgmR3DumpHierarchyShwGuestPageInfo(pState, u64Phys, _4M);
|
---|
1669 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
1670 | pState->cLeaves++;
|
---|
1671 | }
|
---|
1672 | else
|
---|
1673 | {
|
---|
1674 | pState->pHlp->pfnPrintf(pState->pHlp,/*P R S A D G WT CD AT NX 4M a m d phys */
|
---|
1675 | "%08llx 0 | P %c %c %c %c %c %s %s .. .. 4K %c%c%c %08x",
|
---|
1676 | pState->u64Address,
|
---|
1677 | Pde.n.u1Write ? 'W' : 'R',
|
---|
1678 | Pde.n.u1User ? 'U' : 'S',
|
---|
1679 | Pde.n.u1Accessed ? 'A' : '-',
|
---|
1680 | Pde.n.u1Reserved0 ? '?' : '.', /* ignored */
|
---|
1681 | Pde.n.u1Reserved1 ? '?' : '.', /* ignored */
|
---|
1682 | Pde.n.u1WriteThru ? "WT" : "--",
|
---|
1683 | Pde.n.u1CacheDisable? "CD" : "--",
|
---|
1684 | Pde.u & PGM_PDFLAGS_BIG_PAGE ? 'b' : '-',
|
---|
1685 | Pde.u & PGM_PDFLAGS_MAPPING ? 'm' : '-',
|
---|
1686 | Pde.u & PGM_PDFLAGS_TRACK_DIRTY ? 'd' : '-',
|
---|
1687 | Pde.u & X86_PDE_PG_MASK);
|
---|
1688 | if (pState->fDumpPageInfo)
|
---|
1689 | pgmR3DumpHierarchyShwTablePageInfo(pState, Pde.u & X86_PDE_PG_MASK);
|
---|
1690 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
1691 |
|
---|
1692 | if (cMaxDepth)
|
---|
1693 | {
|
---|
1694 | int rc2 = pgmR3DumpHierarchyShw32BitPT(pState, Pde.u & X86_PDE_PG_MASK, !!(Pde.u & PGM_PDFLAGS_MAPPING));
|
---|
1695 | if (rc2 < rc && RT_SUCCESS(rc))
|
---|
1696 | rc = rc2;
|
---|
1697 | }
|
---|
1698 | else
|
---|
1699 | pState->cLeaves++;
|
---|
1700 | }
|
---|
1701 | }
|
---|
1702 | }
|
---|
1703 |
|
---|
1704 | return rc;
|
---|
1705 | }
|
---|
1706 |
|
---|
1707 |
|
---|
1708 | /**
|
---|
1709 | * Internal worker that initiates the actual dump.
|
---|
1710 | *
|
---|
1711 | * @returns VBox status code.
|
---|
1712 | * @param pState The dumper state.
|
---|
1713 | * @param cr3 The CR3 value.
|
---|
1714 | * @param cMaxDepth The max depth.
|
---|
1715 | */
|
---|
1716 | static int pgmR3DumpHierarchyShwDoIt(PPGMR3DUMPHIERARCHYSTATE pState, uint64_t cr3, unsigned cMaxDepth)
|
---|
1717 | {
|
---|
1718 | int rc;
|
---|
1719 | unsigned const cch = pState->cchAddress;
|
---|
1720 | uint64_t const cr3Mask = pState->fEpt ? X86_CR3_AMD64_PAGE_MASK
|
---|
1721 | : pState->fLme ? X86_CR3_AMD64_PAGE_MASK
|
---|
1722 | : pState->fPae ? X86_CR3_PAE_PAGE_MASK
|
---|
1723 | : X86_CR3_PAGE_MASK;
|
---|
1724 | if (pState->fPrintCr3)
|
---|
1725 | {
|
---|
1726 | const char * const pszMode = pState->fEpt ? "Extended Page Tables"
|
---|
1727 | : pState->fLme ? "Long Mode"
|
---|
1728 | : pState->fPae ? "PAE Mode"
|
---|
1729 | : pState->fPse ? "32-bit w/ PSE"
|
---|
1730 | : "32-bit";
|
---|
1731 | pState->pHlp->pfnPrintf(pState->pHlp, "cr3=%0*llx", cch, cr3);
|
---|
1732 | if (pState->fDumpPageInfo)
|
---|
1733 | pgmR3DumpHierarchyShwTablePageInfo(pState, cr3 & X86_CR3_AMD64_PAGE_MASK);
|
---|
1734 | pState->pHlp->pfnPrintf(pState->pHlp, " %s%s%s\n",
|
---|
1735 | pszMode,
|
---|
1736 | pState->fNp ? " + Nested Paging" : "",
|
---|
1737 | pState->fNxe ? " + NX" : "");
|
---|
1738 | }
|
---|
1739 |
|
---|
1740 |
|
---|
1741 | if (pState->fEpt)
|
---|
1742 | {
|
---|
1743 | if (pState->fPrintHeader)
|
---|
1744 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
1745 | "%-*s R - Readable\n"
|
---|
1746 | "%-*s | W - Writeable\n"
|
---|
1747 | "%-*s | | X - Executable\n"
|
---|
1748 | "%-*s | | | EMT - EPT memory type\n"
|
---|
1749 | "%-*s | | | | PAT - Ignored PAT?\n"
|
---|
1750 | "%-*s | | | | | AVL1 - 4 available bits\n"
|
---|
1751 | "%-*s | | | | | | AVL2 - 12 available bits\n"
|
---|
1752 | "%-*s Level | | | | | | | page \n"
|
---|
1753 | /* xxxx n **** R W X EMT PAT AVL1 AVL2 xxxxxxxxxxxxx
|
---|
1754 | R W X 7 0 f fff 0123456701234567 */
|
---|
1755 | ,
|
---|
1756 | cch, "", cch, "", cch, "", cch, "", cch, "", cch, "", cch, "", cch, "Address");
|
---|
1757 |
|
---|
1758 | pState->pHlp->pfnPrintf(pState->pHlp, "EPT dumping is not yet implemented, sorry.\n");
|
---|
1759 | /** @todo implemented EPT dumping. */
|
---|
1760 | rc = VERR_NOT_IMPLEMENTED;
|
---|
1761 | }
|
---|
1762 | else
|
---|
1763 | {
|
---|
1764 | if (pState->fPrintHeader)
|
---|
1765 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
1766 | "%-*s P - Present\n"
|
---|
1767 | "%-*s | R/W - Read (0) / Write (1)\n"
|
---|
1768 | "%-*s | | U/S - User (1) / Supervisor (0)\n"
|
---|
1769 | "%-*s | | | A - Accessed\n"
|
---|
1770 | "%-*s | | | | D - Dirty\n"
|
---|
1771 | "%-*s | | | | | G - Global\n"
|
---|
1772 | "%-*s | | | | | | WT - Write thru\n"
|
---|
1773 | "%-*s | | | | | | | CD - Cache disable\n"
|
---|
1774 | "%-*s | | | | | | | | AT - Attribute table (PAT)\n"
|
---|
1775 | "%-*s | | | | | | | | | NX - No execute (K8)\n"
|
---|
1776 | "%-*s | | | | | | | | | | 4K/4M/2M - Page size.\n"
|
---|
1777 | "%-*s | | | | | | | | | | | AVL - a=allocated; m=mapping; d=track dirty;\n"
|
---|
1778 | "%-*s | | | | | | | | | | | | p=permanent; v=validated;\n"
|
---|
1779 | "%-*s Level | | | | | | | | | | | | Page\n"
|
---|
1780 | /* xxxx n **** P R S A D G WT CD AT NX 4M AVL xxxxxxxxxxxxx
|
---|
1781 | - W U - - - -- -- -- -- -- 010 */
|
---|
1782 | ,
|
---|
1783 | cch, "", cch, "", cch, "", cch, "", cch, "", cch, "", cch, "",
|
---|
1784 | cch, "", cch, "", cch, "", cch, "", cch, "", cch, "", cch, "Address");
|
---|
1785 | if (pState->fLme)
|
---|
1786 | rc = pgmR3DumpHierarchyShwPaePML4(pState, cr3 & cr3Mask, cMaxDepth);
|
---|
1787 | else if (pState->fPae)
|
---|
1788 | rc = pgmR3DumpHierarchyShwPaePDPT(pState, cr3 & cr3Mask, cMaxDepth);
|
---|
1789 | else
|
---|
1790 | rc = pgmR3DumpHierarchyShw32BitPD(pState, cr3 & cr3Mask, cMaxDepth);
|
---|
1791 | }
|
---|
1792 |
|
---|
1793 | if (!pState->cLeaves)
|
---|
1794 | pState->pHlp->pfnPrintf(pState->pHlp, "not present\n");
|
---|
1795 | return rc;
|
---|
1796 | }
|
---|
1797 |
|
---|
1798 |
|
---|
1799 | /**
|
---|
1800 | * dbgfR3PagingDumpEx worker.
|
---|
1801 | *
|
---|
1802 | * @returns VBox status code.
|
---|
1803 | * @param pVM The cross context VM structure.
|
---|
1804 | * @param cr3 The CR3 register value.
|
---|
1805 | * @param fFlags The flags, DBGFPGDMP_FLAGS_XXX.
|
---|
1806 | * @param u64FirstAddr The start address.
|
---|
1807 | * @param u64LastAddr The address to stop after.
|
---|
1808 | * @param cMaxDepth The max depth.
|
---|
1809 | * @param pHlp The output callbacks. Defaults to log if NULL.
|
---|
1810 | *
|
---|
1811 | * @internal
|
---|
1812 | */
|
---|
1813 | VMMR3_INT_DECL(int) PGMR3DumpHierarchyShw(PVM pVM, uint64_t cr3, uint32_t fFlags, uint64_t u64FirstAddr, uint64_t u64LastAddr,
|
---|
1814 | uint32_t cMaxDepth, PCDBGFINFOHLP pHlp)
|
---|
1815 | {
|
---|
1816 | /* Minimal validation as we're only supposed to service DBGF. */
|
---|
1817 | AssertReturn(~(fFlags & ~DBGFPGDMP_FLAGS_VALID_MASK), VERR_INVALID_PARAMETER);
|
---|
1818 | AssertReturn(!(fFlags & (DBGFPGDMP_FLAGS_CURRENT_MODE | DBGFPGDMP_FLAGS_CURRENT_CR3)), VERR_INVALID_PARAMETER);
|
---|
1819 | AssertReturn(fFlags & DBGFPGDMP_FLAGS_SHADOW, VERR_INVALID_PARAMETER);
|
---|
1820 |
|
---|
1821 | PGMR3DUMPHIERARCHYSTATE State;
|
---|
1822 | pgmR3DumpHierarchyInitState(&State, pVM, fFlags, u64FirstAddr, u64LastAddr, pHlp);
|
---|
1823 | return pgmR3DumpHierarchyShwDoIt(&State, cr3, cMaxDepth);
|
---|
1824 | }
|
---|
1825 |
|
---|
1826 |
|
---|
1827 | /**
|
---|
1828 | * Dumps a page table hierarchy use only physical addresses and cr4/lm flags.
|
---|
1829 | *
|
---|
1830 | * @returns VBox status code (VINF_SUCCESS).
|
---|
1831 | * @param pVM The cross context VM structure.
|
---|
1832 | * @param cr3 The root of the hierarchy.
|
---|
1833 | * @param cr4 The cr4, only PAE and PSE is currently used.
|
---|
1834 | * @param fLongMode Set if long mode, false if not long mode.
|
---|
1835 | * @param cMaxDepth Number of levels to dump.
|
---|
1836 | * @param pHlp Pointer to the output functions.
|
---|
1837 | *
|
---|
1838 | * @deprecated Use DBGFR3PagingDumpEx.
|
---|
1839 | */
|
---|
1840 | VMMR3DECL(int) PGMR3DumpHierarchyHC(PVM pVM, uint64_t cr3, uint64_t cr4, bool fLongMode, unsigned cMaxDepth, PCDBGFINFOHLP pHlp)
|
---|
1841 | {
|
---|
1842 | if (!cMaxDepth)
|
---|
1843 | return VINF_SUCCESS;
|
---|
1844 |
|
---|
1845 | PVMCPU pVCpu = VMMGetCpu(pVM);
|
---|
1846 | if (!pVCpu)
|
---|
1847 | pVCpu = pVM->apCpusR3[0];
|
---|
1848 |
|
---|
1849 | uint32_t fFlags = DBGFPGDMP_FLAGS_HEADER | DBGFPGDMP_FLAGS_PRINT_CR3 | DBGFPGDMP_FLAGS_PAGE_INFO | DBGFPGDMP_FLAGS_SHADOW;
|
---|
1850 | fFlags |= cr4 & (X86_CR4_PAE | X86_CR4_PSE);
|
---|
1851 | if (fLongMode)
|
---|
1852 | fFlags |= DBGFPGDMP_FLAGS_LME;
|
---|
1853 |
|
---|
1854 | return DBGFR3PagingDumpEx(pVM->pUVM, pVCpu->idCpu, fFlags, cr3, 0, fLongMode ? UINT64_MAX : UINT32_MAX, cMaxDepth, pHlp);
|
---|
1855 | }
|
---|
1856 |
|
---|
1857 |
|
---|
1858 | /**
|
---|
1859 | * Maps the guest page.
|
---|
1860 | *
|
---|
1861 | * @returns VBox status code.
|
---|
1862 | * @param pState The dumper state.
|
---|
1863 | * @param GCPhys The physical address of the guest page.
|
---|
1864 | * @param pszDesc The description.
|
---|
1865 | * @param ppv Where to return the pointer.
|
---|
1866 | * @param pLock Where to return the mapping lock. Hand this to
|
---|
1867 | * PGMPhysReleasePageMappingLock when done.
|
---|
1868 | */
|
---|
1869 | static int pgmR3DumpHierarchyGstMapPage(PPGMR3DUMPHIERARCHYSTATE pState, RTGCPHYS GCPhys, const char *pszDesc,
|
---|
1870 | void const **ppv, PPGMPAGEMAPLOCK pLock)
|
---|
1871 | {
|
---|
1872 | int rc = PGMPhysGCPhys2CCPtrReadOnly(pState->pVM, GCPhys, ppv, pLock);
|
---|
1873 | if (RT_FAILURE(rc))
|
---|
1874 | {
|
---|
1875 | pState->pHlp->pfnPrintf(pState->pHlp, "%0*llx error! Failed to map %s at GCPhys=%RGp: %Rrc!\n",
|
---|
1876 | pState->cchAddress, pState->u64Address, pszDesc, GCPhys, rc);
|
---|
1877 | return rc;
|
---|
1878 | }
|
---|
1879 | return VINF_SUCCESS;
|
---|
1880 | }
|
---|
1881 |
|
---|
1882 |
|
---|
1883 | /**
|
---|
1884 | * Figures out which guest page this is and dumps a summary.
|
---|
1885 | *
|
---|
1886 | * @param pState The dumper state.
|
---|
1887 | * @param GCPhys The page address.
|
---|
1888 | * @param cbPage The page size.
|
---|
1889 | */
|
---|
1890 | static void pgmR3DumpHierarchyGstPageInfo(PPGMR3DUMPHIERARCHYSTATE pState, RTGCPHYS GCPhys, uint32_t cbPage)
|
---|
1891 | {
|
---|
1892 | char szPage[80];
|
---|
1893 | pgmLock(pState->pVM);
|
---|
1894 | PCPGMPAGE pPage = pgmPhysGetPage(pState->pVM, GCPhys);
|
---|
1895 | if (pPage)
|
---|
1896 | RTStrPrintf(szPage, sizeof(szPage), " %R[pgmpage]", pPage);
|
---|
1897 | else
|
---|
1898 | strcpy(szPage, " not found");
|
---|
1899 | pgmUnlock(pState->pVM);
|
---|
1900 | pState->pHlp->pfnPrintf(pState->pHlp, "%s", szPage);
|
---|
1901 | NOREF(cbPage);
|
---|
1902 | }
|
---|
1903 |
|
---|
1904 |
|
---|
1905 | /**
|
---|
1906 | * Checks the entry for reserved bits.
|
---|
1907 | *
|
---|
1908 | * @param pState The dumper state.
|
---|
1909 | * @param u64Entry The entry to check.
|
---|
1910 | */
|
---|
1911 | static void pgmR3DumpHierarchyGstCheckReservedHighBits(PPGMR3DUMPHIERARCHYSTATE pState, uint64_t u64Entry)
|
---|
1912 | {
|
---|
1913 | uint32_t uRsvd = (u64Entry & pState->u64HighReservedBits) >> 52;
|
---|
1914 | if (uRsvd)
|
---|
1915 | pState->pHlp->pfnPrintf(pState->pHlp, " %u:52=%03x%s",
|
---|
1916 | pState->uLastRsvdBit, uRsvd, pState->fLme ? "" : "!");
|
---|
1917 | /** @todo check the valid physical bits as well. */
|
---|
1918 | }
|
---|
1919 |
|
---|
1920 |
|
---|
1921 | /**
|
---|
1922 | * Dumps a PAE shadow page table.
|
---|
1923 | *
|
---|
1924 | * @returns VBox status code (VINF_SUCCESS).
|
---|
1925 | * @param pState The dumper state.
|
---|
1926 | * @param GCPhys The page table address.
|
---|
1927 | */
|
---|
1928 | static int pgmR3DumpHierarchyGstPaePT(PPGMR3DUMPHIERARCHYSTATE pState, RTGCPHYS GCPhys)
|
---|
1929 | {
|
---|
1930 | PCX86PTPAE pPT;
|
---|
1931 | PGMPAGEMAPLOCK Lock;
|
---|
1932 | int rc = pgmR3DumpHierarchyGstMapPage(pState, GCPhys, "Page table", (void const **)&pPT, &Lock);
|
---|
1933 | if (RT_FAILURE(rc))
|
---|
1934 | return rc;
|
---|
1935 |
|
---|
1936 | uint32_t iFirst, iLast;
|
---|
1937 | uint64_t u64BaseAddress = pgmR3DumpHierarchyCalcRange(pState, X86_PT_PAE_SHIFT, X86_PG_PAE_ENTRIES, &iFirst, &iLast);
|
---|
1938 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
1939 | {
|
---|
1940 | X86PTEPAE Pte = pPT->a[i];
|
---|
1941 | if (Pte.n.u1Present)
|
---|
1942 | {
|
---|
1943 | pState->u64Address = u64BaseAddress + ((uint64_t)i << X86_PT_PAE_SHIFT);
|
---|
1944 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
1945 | pState->fLme /*P R S A D G WT CD AT NX 4M a p ? */
|
---|
1946 | ? "%016llx 3 | P %c %c %c %c %c %s %s %s %s 4K %c%c%c %016llx"
|
---|
1947 | : "%08llx 2 | P %c %c %c %c %c %s %s %s %s 4K %c%c%c %016llx",
|
---|
1948 | pState->u64Address,
|
---|
1949 | Pte.n.u1Write ? 'W' : 'R',
|
---|
1950 | Pte.n.u1User ? 'U' : 'S',
|
---|
1951 | Pte.n.u1Accessed ? 'A' : '-',
|
---|
1952 | Pte.n.u1Dirty ? 'D' : '-',
|
---|
1953 | Pte.n.u1Global ? 'G' : '-',
|
---|
1954 | Pte.n.u1WriteThru ? "WT" : "--",
|
---|
1955 | Pte.n.u1CacheDisable? "CD" : "--",
|
---|
1956 | Pte.n.u1PAT ? "AT" : "--",
|
---|
1957 | Pte.n.u1NoExecute ? "NX" : "--",
|
---|
1958 | Pte.u & RT_BIT(9) ? '1' : '0',
|
---|
1959 | Pte.u & RT_BIT(10) ? '1' : '0',
|
---|
1960 | Pte.u & RT_BIT(11) ? '1' : '0',
|
---|
1961 | Pte.u & X86_PTE_PAE_PG_MASK);
|
---|
1962 | if (pState->fDumpPageInfo)
|
---|
1963 | pgmR3DumpHierarchyGstPageInfo(pState, Pte.u & X86_PTE_PAE_PG_MASK, _4K);
|
---|
1964 | pgmR3DumpHierarchyGstCheckReservedHighBits(pState, Pte.u);
|
---|
1965 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
1966 | pState->cLeaves++;
|
---|
1967 | }
|
---|
1968 | }
|
---|
1969 |
|
---|
1970 | PGMPhysReleasePageMappingLock(pState->pVM, &Lock);
|
---|
1971 | return VINF_SUCCESS;
|
---|
1972 | }
|
---|
1973 |
|
---|
1974 |
|
---|
1975 | /**
|
---|
1976 | * Dumps a PAE shadow page directory table.
|
---|
1977 | *
|
---|
1978 | * @returns VBox status code (VINF_SUCCESS).
|
---|
1979 | * @param pState The dumper state.
|
---|
1980 | * @param GCPhys The physical address of the table.
|
---|
1981 | * @param cMaxDepth The maximum depth.
|
---|
1982 | */
|
---|
1983 | static int pgmR3DumpHierarchyGstPaePD(PPGMR3DUMPHIERARCHYSTATE pState, RTGCPHYS GCPhys, unsigned cMaxDepth)
|
---|
1984 | {
|
---|
1985 | PCX86PDPAE pPD;
|
---|
1986 | PGMPAGEMAPLOCK Lock;
|
---|
1987 | int rc = pgmR3DumpHierarchyGstMapPage(pState, GCPhys, "Page directory", (void const **)&pPD, &Lock);
|
---|
1988 | if (RT_FAILURE(rc))
|
---|
1989 | return rc;
|
---|
1990 |
|
---|
1991 | Assert(cMaxDepth > 0);
|
---|
1992 | cMaxDepth--;
|
---|
1993 |
|
---|
1994 | uint32_t iFirst, iLast;
|
---|
1995 | uint64_t u64BaseAddress = pgmR3DumpHierarchyCalcRange(pState, X86_PD_PAE_SHIFT, X86_PG_PAE_ENTRIES, &iFirst, &iLast);
|
---|
1996 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
1997 | {
|
---|
1998 | X86PDEPAE Pde = pPD->a[i];
|
---|
1999 | if (Pde.n.u1Present)
|
---|
2000 | {
|
---|
2001 | pState->u64Address = u64BaseAddress + ((uint64_t)i << X86_PD_PAE_SHIFT);
|
---|
2002 | if (Pde.b.u1Size)
|
---|
2003 | {
|
---|
2004 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
2005 | pState->fLme /*P R S A D G WT CD AT NX 2M a p ? phys*/
|
---|
2006 | ? "%016llx 2 | P %c %c %c %c %c %s %s %s %s 2M %c%c%c %016llx"
|
---|
2007 | : "%08llx 1 | P %c %c %c %c %c %s %s %s %s 2M %c%c%c %016llx",
|
---|
2008 | pState->u64Address,
|
---|
2009 | Pde.b.u1Write ? 'W' : 'R',
|
---|
2010 | Pde.b.u1User ? 'U' : 'S',
|
---|
2011 | Pde.b.u1Accessed ? 'A' : '-',
|
---|
2012 | Pde.b.u1Dirty ? 'D' : '-',
|
---|
2013 | Pde.b.u1Global ? 'G' : '-',
|
---|
2014 | Pde.b.u1WriteThru ? "WT" : "--",
|
---|
2015 | Pde.b.u1CacheDisable ? "CD" : "--",
|
---|
2016 | Pde.b.u1PAT ? "AT" : "--",
|
---|
2017 | Pde.b.u1NoExecute ? "NX" : "--",
|
---|
2018 | Pde.u & RT_BIT_64(9) ? '1' : '0',
|
---|
2019 | Pde.u & RT_BIT_64(10) ? '1' : '0',
|
---|
2020 | Pde.u & RT_BIT_64(11) ? '1' : '0',
|
---|
2021 | Pde.u & X86_PDE2M_PAE_PG_MASK);
|
---|
2022 | if (pState->fDumpPageInfo)
|
---|
2023 | pgmR3DumpHierarchyGstPageInfo(pState, Pde.u & X86_PDE2M_PAE_PG_MASK, _2M);
|
---|
2024 | pgmR3DumpHierarchyGstCheckReservedHighBits(pState, Pde.u);
|
---|
2025 | if ((Pde.u >> 13) & 0xff)
|
---|
2026 | pState->pHlp->pfnPrintf(pState->pHlp, " 20:13=%02llx%s", (Pde.u >> 13) & 0x0ff, pState->fLme ? "" : "!");
|
---|
2027 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
2028 |
|
---|
2029 | pState->cLeaves++;
|
---|
2030 | }
|
---|
2031 | else
|
---|
2032 | {
|
---|
2033 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
2034 | pState->fLme /*P R S A D G WT CD AT NX 4M a p ? phys */
|
---|
2035 | ? "%016llx 2 | P %c %c %c %c %c %s %s .. %s .. %c%c%c %016llx"
|
---|
2036 | : "%08llx 1 | P %c %c %c %c %c %s %s .. %s .. %c%c%c %016llx",
|
---|
2037 | pState->u64Address,
|
---|
2038 | Pde.n.u1Write ? 'W' : 'R',
|
---|
2039 | Pde.n.u1User ? 'U' : 'S',
|
---|
2040 | Pde.n.u1Accessed ? 'A' : '-',
|
---|
2041 | Pde.n.u1Reserved0 ? '?' : '.', /* ignored */
|
---|
2042 | Pde.n.u1Reserved1 ? '?' : '.', /* ignored */
|
---|
2043 | Pde.n.u1WriteThru ? "WT" : "--",
|
---|
2044 | Pde.n.u1CacheDisable ? "CD" : "--",
|
---|
2045 | Pde.n.u1NoExecute ? "NX" : "--",
|
---|
2046 | Pde.u & RT_BIT_64(9) ? '1' : '0',
|
---|
2047 | Pde.u & RT_BIT_64(10) ? '1' : '0',
|
---|
2048 | Pde.u & RT_BIT_64(11) ? '1' : '0',
|
---|
2049 | Pde.u & X86_PDE_PAE_PG_MASK);
|
---|
2050 | if (pState->fDumpPageInfo)
|
---|
2051 | pgmR3DumpHierarchyGstPageInfo(pState, Pde.u & X86_PDE_PAE_PG_MASK, _4K);
|
---|
2052 | pgmR3DumpHierarchyGstCheckReservedHighBits(pState, Pde.u);
|
---|
2053 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
2054 |
|
---|
2055 | if (cMaxDepth)
|
---|
2056 | {
|
---|
2057 | int rc2 = pgmR3DumpHierarchyGstPaePT(pState, Pde.u & X86_PDE_PAE_PG_MASK);
|
---|
2058 | if (rc2 < rc && RT_SUCCESS(rc))
|
---|
2059 | rc = rc2;
|
---|
2060 | }
|
---|
2061 | else
|
---|
2062 | pState->cLeaves++;
|
---|
2063 | }
|
---|
2064 | }
|
---|
2065 | }
|
---|
2066 |
|
---|
2067 | PGMPhysReleasePageMappingLock(pState->pVM, &Lock);
|
---|
2068 | return rc;
|
---|
2069 | }
|
---|
2070 |
|
---|
2071 |
|
---|
2072 | /**
|
---|
2073 | * Dumps a PAE shadow page directory pointer table.
|
---|
2074 | *
|
---|
2075 | * @returns VBox status code (VINF_SUCCESS).
|
---|
2076 | * @param pState The dumper state.
|
---|
2077 | * @param GCPhys The physical address of the table.
|
---|
2078 | * @param cMaxDepth The maximum depth.
|
---|
2079 | */
|
---|
2080 | static int pgmR3DumpHierarchyGstPaePDPT(PPGMR3DUMPHIERARCHYSTATE pState, RTGCPHYS GCPhys, unsigned cMaxDepth)
|
---|
2081 | {
|
---|
2082 | /* Fend of addresses that are out of range in PAE mode - simplifies the code below. */
|
---|
2083 | if (!pState->fLme && pState->u64Address >= _4G)
|
---|
2084 | return VINF_SUCCESS;
|
---|
2085 |
|
---|
2086 | PCX86PDPT pPDPT;
|
---|
2087 | PGMPAGEMAPLOCK Lock;
|
---|
2088 | int rc = pgmR3DumpHierarchyGstMapPage(pState, GCPhys, "Page directory pointer table", (void const **)&pPDPT, &Lock);
|
---|
2089 | if (RT_FAILURE(rc))
|
---|
2090 | return rc;
|
---|
2091 |
|
---|
2092 | Assert(cMaxDepth > 0);
|
---|
2093 | cMaxDepth--;
|
---|
2094 |
|
---|
2095 | uint32_t iFirst, iLast;
|
---|
2096 | uint64_t u64BaseAddress = pgmR3DumpHierarchyCalcRange(pState, X86_PDPT_SHIFT,
|
---|
2097 | pState->fLme ? X86_PG_AMD64_PDPE_ENTRIES : X86_PG_PAE_PDPE_ENTRIES,
|
---|
2098 | &iFirst, &iLast);
|
---|
2099 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
2100 | {
|
---|
2101 | X86PDPE Pdpe = pPDPT->a[i];
|
---|
2102 | if (Pdpe.n.u1Present)
|
---|
2103 | {
|
---|
2104 | pState->u64Address = u64BaseAddress + ((uint64_t)i << X86_PDPT_SHIFT);
|
---|
2105 | if (pState->fLme)
|
---|
2106 | {
|
---|
2107 | /** @todo Do 1G pages. */
|
---|
2108 | pState->pHlp->pfnPrintf(pState->pHlp, /*P R S A D G WT CD AT NX .. a p ? */
|
---|
2109 | "%016llx 1 | P %c %c %c %c %c %s %s %s %s .. %c%c%c %016llx",
|
---|
2110 | pState->u64Address,
|
---|
2111 | Pdpe.lm.u1Write ? 'W' : 'R',
|
---|
2112 | Pdpe.lm.u1User ? 'U' : 'S',
|
---|
2113 | Pdpe.lm.u1Accessed ? 'A' : '-',
|
---|
2114 | Pdpe.lm.u3Reserved & 1 ? '?' : '.', /* ignored */
|
---|
2115 | Pdpe.lm.u3Reserved & 4 ? '!' : '.', /* mbz */
|
---|
2116 | Pdpe.lm.u1WriteThru ? "WT" : "--",
|
---|
2117 | Pdpe.lm.u1CacheDisable ? "CD" : "--",
|
---|
2118 | Pdpe.lm.u3Reserved & 2 ? "!" : "..",/* mbz */
|
---|
2119 | Pdpe.lm.u1NoExecute ? "NX" : "--",
|
---|
2120 | Pdpe.u & RT_BIT_64(9) ? '1' : '0',
|
---|
2121 | Pdpe.u & RT_BIT_64(10) ? '1' : '0',
|
---|
2122 | Pdpe.u & RT_BIT_64(11) ? '1' : '0',
|
---|
2123 | Pdpe.u & X86_PDPE_PG_MASK);
|
---|
2124 | if (pState->fDumpPageInfo)
|
---|
2125 | pgmR3DumpHierarchyGstPageInfo(pState, Pdpe.u & X86_PDPE_PG_MASK, _4K);
|
---|
2126 | pgmR3DumpHierarchyGstCheckReservedHighBits(pState, Pdpe.u);
|
---|
2127 | }
|
---|
2128 | else
|
---|
2129 | {
|
---|
2130 | pState->pHlp->pfnPrintf(pState->pHlp,/*P R S A D G WT CD AT NX .. a p ? */
|
---|
2131 | "%08llx 0 | P %c %c %c %c %c %s %s %s %s .. %c%c%c %016llx",
|
---|
2132 | pState->u64Address,
|
---|
2133 | Pdpe.n.u2Reserved & 1 ? '!' : '.', /* mbz */
|
---|
2134 | Pdpe.n.u2Reserved & 2 ? '!' : '.', /* mbz */
|
---|
2135 | Pdpe.n.u4Reserved & 1 ? '!' : '.', /* mbz */
|
---|
2136 | Pdpe.n.u4Reserved & 2 ? '!' : '.', /* mbz */
|
---|
2137 | Pdpe.n.u4Reserved & 8 ? '!' : '.', /* mbz */
|
---|
2138 | Pdpe.n.u1WriteThru ? "WT" : "--",
|
---|
2139 | Pdpe.n.u1CacheDisable ? "CD" : "--",
|
---|
2140 | Pdpe.n.u4Reserved & 2 ? "!" : "..", /* mbz */
|
---|
2141 | Pdpe.lm.u1NoExecute ? "!!" : "..",/* mbz */
|
---|
2142 | Pdpe.u & RT_BIT_64(9) ? '1' : '0',
|
---|
2143 | Pdpe.u & RT_BIT_64(10) ? '1' : '0',
|
---|
2144 | Pdpe.u & RT_BIT_64(11) ? '1' : '0',
|
---|
2145 | Pdpe.u & X86_PDPE_PG_MASK);
|
---|
2146 | if (pState->fDumpPageInfo)
|
---|
2147 | pgmR3DumpHierarchyGstPageInfo(pState, Pdpe.u & X86_PDPE_PG_MASK, _4K);
|
---|
2148 | pgmR3DumpHierarchyGstCheckReservedHighBits(pState, Pdpe.u);
|
---|
2149 | }
|
---|
2150 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
2151 |
|
---|
2152 | if (cMaxDepth)
|
---|
2153 | {
|
---|
2154 | int rc2 = pgmR3DumpHierarchyGstPaePD(pState, Pdpe.u & X86_PDPE_PG_MASK, cMaxDepth);
|
---|
2155 | if (rc2 < rc && RT_SUCCESS(rc))
|
---|
2156 | rc = rc2;
|
---|
2157 | }
|
---|
2158 | else
|
---|
2159 | pState->cLeaves++;
|
---|
2160 | }
|
---|
2161 | }
|
---|
2162 |
|
---|
2163 | PGMPhysReleasePageMappingLock(pState->pVM, &Lock);
|
---|
2164 | return rc;
|
---|
2165 | }
|
---|
2166 |
|
---|
2167 |
|
---|
2168 | /**
|
---|
2169 | * Dumps a 32-bit shadow page table.
|
---|
2170 | *
|
---|
2171 | * @returns VBox status code (VINF_SUCCESS).
|
---|
2172 | * @param pState The dumper state.
|
---|
2173 | * @param GCPhys The physical address of the table.
|
---|
2174 | * @param cMaxDepth The maximum depth.
|
---|
2175 | */
|
---|
2176 | static int pgmR3DumpHierarchyGstPaePML4(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS GCPhys, unsigned cMaxDepth)
|
---|
2177 | {
|
---|
2178 | PCX86PML4 pPML4;
|
---|
2179 | PGMPAGEMAPLOCK Lock;
|
---|
2180 | int rc = pgmR3DumpHierarchyGstMapPage(pState, GCPhys, "Page map level 4", (void const **)&pPML4, &Lock);
|
---|
2181 | if (RT_FAILURE(rc))
|
---|
2182 | return rc;
|
---|
2183 |
|
---|
2184 | Assert(cMaxDepth);
|
---|
2185 | cMaxDepth--;
|
---|
2186 |
|
---|
2187 | /*
|
---|
2188 | * This is a bit tricky as we're working on unsigned addresses while the
|
---|
2189 | * AMD64 spec uses signed tricks.
|
---|
2190 | */
|
---|
2191 | uint32_t iFirst = (pState->u64FirstAddress >> X86_PML4_SHIFT) & X86_PML4_MASK;
|
---|
2192 | uint32_t iLast = (pState->u64LastAddress >> X86_PML4_SHIFT) & X86_PML4_MASK;
|
---|
2193 | if ( pState->u64LastAddress <= UINT64_C(0x00007fffffffffff)
|
---|
2194 | || pState->u64FirstAddress >= UINT64_C(0xffff800000000000))
|
---|
2195 | { /* Simple, nothing to adjust */ }
|
---|
2196 | else if (pState->u64FirstAddress <= UINT64_C(0x00007fffffffffff))
|
---|
2197 | iLast = X86_PG_AMD64_ENTRIES / 2 - 1;
|
---|
2198 | else if (pState->u64LastAddress >= UINT64_C(0xffff800000000000))
|
---|
2199 | iFirst = X86_PG_AMD64_ENTRIES / 2;
|
---|
2200 | else
|
---|
2201 | iFirst = X86_PG_AMD64_ENTRIES; /* neither address is canonical */
|
---|
2202 |
|
---|
2203 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
2204 | {
|
---|
2205 | X86PML4E Pml4e = pPML4->a[i];
|
---|
2206 | if (Pml4e.n.u1Present)
|
---|
2207 | {
|
---|
2208 | pState->u64Address = ((uint64_t)i << X86_PML4_SHIFT)
|
---|
2209 | | (i >= RT_ELEMENTS(pPML4->a) / 2 ? UINT64_C(0xffff000000000000) : 0);
|
---|
2210 | pState->pHlp->pfnPrintf(pState->pHlp, /*P R S A D G WT CD AT NX 4M a p ? */
|
---|
2211 | "%016llx 0 | P %c %c %c %c %c %s %s %s %s .. %c%c%c %016llx",
|
---|
2212 | pState->u64Address,
|
---|
2213 | Pml4e.n.u1Write ? 'W' : 'R',
|
---|
2214 | Pml4e.n.u1User ? 'U' : 'S',
|
---|
2215 | Pml4e.n.u1Accessed ? 'A' : '-',
|
---|
2216 | Pml4e.n.u3Reserved & 1 ? '?' : '.', /* ignored */
|
---|
2217 | Pml4e.n.u3Reserved & 4 ? '!' : '.', /* mbz */
|
---|
2218 | Pml4e.n.u1WriteThru ? "WT" : "--",
|
---|
2219 | Pml4e.n.u1CacheDisable ? "CD" : "--",
|
---|
2220 | Pml4e.n.u3Reserved & 2 ? "!" : "..",/* mbz */
|
---|
2221 | Pml4e.n.u1NoExecute ? "NX" : "--",
|
---|
2222 | Pml4e.u & RT_BIT_64(9) ? '1' : '0',
|
---|
2223 | Pml4e.u & RT_BIT_64(10) ? '1' : '0',
|
---|
2224 | Pml4e.u & RT_BIT_64(11) ? '1' : '0',
|
---|
2225 | Pml4e.u & X86_PML4E_PG_MASK);
|
---|
2226 | if (pState->fDumpPageInfo)
|
---|
2227 | pgmR3DumpHierarchyGstPageInfo(pState, Pml4e.u & X86_PML4E_PG_MASK, _4K);
|
---|
2228 | pgmR3DumpHierarchyGstCheckReservedHighBits(pState, Pml4e.u);
|
---|
2229 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
2230 |
|
---|
2231 | if (cMaxDepth)
|
---|
2232 | {
|
---|
2233 | int rc2 = pgmR3DumpHierarchyGstPaePDPT(pState, Pml4e.u & X86_PML4E_PG_MASK, cMaxDepth);
|
---|
2234 | if (rc2 < rc && RT_SUCCESS(rc))
|
---|
2235 | rc = rc2;
|
---|
2236 | }
|
---|
2237 | else
|
---|
2238 | pState->cLeaves++;
|
---|
2239 | }
|
---|
2240 | }
|
---|
2241 |
|
---|
2242 | PGMPhysReleasePageMappingLock(pState->pVM, &Lock);
|
---|
2243 | return rc;
|
---|
2244 | }
|
---|
2245 |
|
---|
2246 |
|
---|
2247 | /**
|
---|
2248 | * Dumps a 32-bit shadow page table.
|
---|
2249 | *
|
---|
2250 | * @returns VBox status code (VINF_SUCCESS).
|
---|
2251 | * @param pState The dumper state.
|
---|
2252 | * @param GCPhys The physical address of the table.
|
---|
2253 | */
|
---|
2254 | static int pgmR3DumpHierarchyGst32BitPT(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS GCPhys)
|
---|
2255 | {
|
---|
2256 | PCX86PT pPT;
|
---|
2257 | PGMPAGEMAPLOCK Lock;
|
---|
2258 | int rc = pgmR3DumpHierarchyGstMapPage(pState, GCPhys, "Page table", (void const **)&pPT, &Lock);
|
---|
2259 | if (RT_FAILURE(rc))
|
---|
2260 | return rc;
|
---|
2261 |
|
---|
2262 | uint32_t iFirst, iLast;
|
---|
2263 | uint64_t u64BaseAddress = pgmR3DumpHierarchyCalcRange(pState, X86_PT_SHIFT, X86_PG_ENTRIES, &iFirst, &iLast);
|
---|
2264 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
2265 | {
|
---|
2266 | X86PTE Pte = pPT->a[i];
|
---|
2267 | if (Pte.n.u1Present)
|
---|
2268 | {
|
---|
2269 | pState->u64Address = u64BaseAddress + (i << X86_PT_SHIFT);
|
---|
2270 | pState->pHlp->pfnPrintf(pState->pHlp,/*P R S A D G WT CD AT NX 4M a m d */
|
---|
2271 | "%08llx 1 | P %c %c %c %c %c %s %s %s .. 4K %c%c%c %08x",
|
---|
2272 | pState->u64Address,
|
---|
2273 | Pte.n.u1Write ? 'W' : 'R',
|
---|
2274 | Pte.n.u1User ? 'U' : 'S',
|
---|
2275 | Pte.n.u1Accessed ? 'A' : '-',
|
---|
2276 | Pte.n.u1Dirty ? 'D' : '-',
|
---|
2277 | Pte.n.u1Global ? 'G' : '-',
|
---|
2278 | Pte.n.u1WriteThru ? "WT" : "--",
|
---|
2279 | Pte.n.u1CacheDisable ? "CD" : "--",
|
---|
2280 | Pte.n.u1PAT ? "AT" : "--",
|
---|
2281 | Pte.u & RT_BIT_32(9) ? '1' : '0',
|
---|
2282 | Pte.u & RT_BIT_32(10) ? '1' : '0',
|
---|
2283 | Pte.u & RT_BIT_32(11) ? '1' : '0',
|
---|
2284 | Pte.u & X86_PDE_PG_MASK);
|
---|
2285 | if (pState->fDumpPageInfo)
|
---|
2286 | pgmR3DumpHierarchyGstPageInfo(pState, Pte.u & X86_PDE_PG_MASK, _4K);
|
---|
2287 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
2288 | }
|
---|
2289 | }
|
---|
2290 |
|
---|
2291 | PGMPhysReleasePageMappingLock(pState->pVM, &Lock);
|
---|
2292 | return VINF_SUCCESS;
|
---|
2293 | }
|
---|
2294 |
|
---|
2295 |
|
---|
2296 | /**
|
---|
2297 | * Dumps a 32-bit shadow page directory and page tables.
|
---|
2298 | *
|
---|
2299 | * @returns VBox status code (VINF_SUCCESS).
|
---|
2300 | * @param pState The dumper state.
|
---|
2301 | * @param GCPhys The physical address of the table.
|
---|
2302 | * @param cMaxDepth The maximum depth.
|
---|
2303 | */
|
---|
2304 | static int pgmR3DumpHierarchyGst32BitPD(PPGMR3DUMPHIERARCHYSTATE pState, RTHCPHYS GCPhys, unsigned cMaxDepth)
|
---|
2305 | {
|
---|
2306 | if (pState->u64Address >= _4G)
|
---|
2307 | return VINF_SUCCESS;
|
---|
2308 |
|
---|
2309 | PCX86PD pPD;
|
---|
2310 | PGMPAGEMAPLOCK Lock;
|
---|
2311 | int rc = pgmR3DumpHierarchyGstMapPage(pState, GCPhys, "Page directory", (void const **)&pPD, &Lock);
|
---|
2312 | if (RT_FAILURE(rc))
|
---|
2313 | return rc;
|
---|
2314 |
|
---|
2315 | Assert(cMaxDepth > 0);
|
---|
2316 | cMaxDepth--;
|
---|
2317 |
|
---|
2318 | uint32_t iFirst, iLast;
|
---|
2319 | pgmR3DumpHierarchyCalcRange(pState, X86_PD_SHIFT, X86_PG_ENTRIES, &iFirst, &iLast);
|
---|
2320 | for (uint32_t i = iFirst; i <= iLast; i++)
|
---|
2321 | {
|
---|
2322 | X86PDE Pde = pPD->a[i];
|
---|
2323 | if (Pde.n.u1Present)
|
---|
2324 | {
|
---|
2325 | pState->u64Address = (uint32_t)i << X86_PD_SHIFT;
|
---|
2326 | if (Pde.b.u1Size && pState->fPse)
|
---|
2327 | {
|
---|
2328 | uint64_t u64Phys = ((uint64_t)(Pde.u & X86_PDE4M_PG_HIGH_MASK) << X86_PDE4M_PG_HIGH_SHIFT)
|
---|
2329 | | (Pde.u & X86_PDE4M_PG_MASK);
|
---|
2330 | pState->pHlp->pfnPrintf(pState->pHlp,/*P R S A D G WT CD AT NX 4M a m d phys */
|
---|
2331 | "%08llx 0 | P %c %c %c %c %c %s %s %s .. 4M %c%c%c %08llx",
|
---|
2332 | pState->u64Address,
|
---|
2333 | Pde.b.u1Write ? 'W' : 'R',
|
---|
2334 | Pde.b.u1User ? 'U' : 'S',
|
---|
2335 | Pde.b.u1Accessed ? 'A' : '-',
|
---|
2336 | Pde.b.u1Dirty ? 'D' : '-',
|
---|
2337 | Pde.b.u1Global ? 'G' : '-',
|
---|
2338 | Pde.b.u1WriteThru ? "WT" : "--",
|
---|
2339 | Pde.b.u1CacheDisable ? "CD" : "--",
|
---|
2340 | Pde.b.u1PAT ? "AT" : "--",
|
---|
2341 | Pde.u & RT_BIT_32(9) ? '1' : '0',
|
---|
2342 | Pde.u & RT_BIT_32(10) ? '1' : '0',
|
---|
2343 | Pde.u & RT_BIT_32(11) ? '1' : '0',
|
---|
2344 | u64Phys);
|
---|
2345 | if (pState->fDumpPageInfo)
|
---|
2346 | pgmR3DumpHierarchyGstPageInfo(pState, u64Phys, _4M);
|
---|
2347 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
2348 | pState->cLeaves++;
|
---|
2349 | }
|
---|
2350 | else
|
---|
2351 | {
|
---|
2352 | pState->pHlp->pfnPrintf(pState->pHlp,/*P R S A D G WT CD AT NX 4M a m d phys */
|
---|
2353 | "%08llx 0 | P %c %c %c %c %c %s %s .. .. .. %c%c%c %08x",
|
---|
2354 | pState->u64Address,
|
---|
2355 | Pde.n.u1Write ? 'W' : 'R',
|
---|
2356 | Pde.n.u1User ? 'U' : 'S',
|
---|
2357 | Pde.n.u1Accessed ? 'A' : '-',
|
---|
2358 | Pde.n.u1Reserved0 ? '?' : '.', /* ignored */
|
---|
2359 | Pde.n.u1Reserved1 ? '?' : '.', /* ignored */
|
---|
2360 | Pde.n.u1WriteThru ? "WT" : "--",
|
---|
2361 | Pde.n.u1CacheDisable ? "CD" : "--",
|
---|
2362 | Pde.u & RT_BIT_32(9) ? '1' : '0',
|
---|
2363 | Pde.u & RT_BIT_32(10) ? '1' : '0',
|
---|
2364 | Pde.u & RT_BIT_32(11) ? '1' : '0',
|
---|
2365 | Pde.u & X86_PDE_PG_MASK);
|
---|
2366 | if (pState->fDumpPageInfo)
|
---|
2367 | pgmR3DumpHierarchyGstPageInfo(pState, Pde.u & X86_PDE_PG_MASK, _4K);
|
---|
2368 | pState->pHlp->pfnPrintf(pState->pHlp, "\n");
|
---|
2369 |
|
---|
2370 | if (cMaxDepth)
|
---|
2371 | {
|
---|
2372 | int rc2 = pgmR3DumpHierarchyGst32BitPT(pState, Pde.u & X86_PDE_PG_MASK);
|
---|
2373 | if (rc2 < rc && RT_SUCCESS(rc))
|
---|
2374 | rc = rc2;
|
---|
2375 | }
|
---|
2376 | else
|
---|
2377 | pState->cLeaves++;
|
---|
2378 | }
|
---|
2379 | }
|
---|
2380 | }
|
---|
2381 |
|
---|
2382 | PGMPhysReleasePageMappingLock(pState->pVM, &Lock);
|
---|
2383 | return rc;
|
---|
2384 | }
|
---|
2385 |
|
---|
2386 |
|
---|
2387 | /**
|
---|
2388 | * Internal worker that initiates the actual dump.
|
---|
2389 | *
|
---|
2390 | * @returns VBox status code.
|
---|
2391 | * @param pState The dumper state.
|
---|
2392 | * @param cr3 The CR3 value.
|
---|
2393 | * @param cMaxDepth The max depth.
|
---|
2394 | */
|
---|
2395 | static int pgmR3DumpHierarchyGstDoIt(PPGMR3DUMPHIERARCHYSTATE pState, uint64_t cr3, unsigned cMaxDepth)
|
---|
2396 | {
|
---|
2397 | int rc;
|
---|
2398 | unsigned const cch = pState->cchAddress;
|
---|
2399 | uint64_t const cr3Mask = pState->fEpt ? X86_CR3_AMD64_PAGE_MASK
|
---|
2400 | : pState->fLme ? X86_CR3_AMD64_PAGE_MASK
|
---|
2401 | : pState->fPae ? X86_CR3_PAE_PAGE_MASK
|
---|
2402 | : X86_CR3_PAGE_MASK;
|
---|
2403 | if (pState->fPrintCr3)
|
---|
2404 | {
|
---|
2405 | const char * const pszMode = pState->fEpt ? "Extended Page Tables"
|
---|
2406 | : pState->fLme ? "Long Mode"
|
---|
2407 | : pState->fPae ? "PAE Mode"
|
---|
2408 | : pState->fPse ? "32-bit w/ PSE"
|
---|
2409 | : "32-bit";
|
---|
2410 | pState->pHlp->pfnPrintf(pState->pHlp, "cr3=%0*llx", cch, cr3);
|
---|
2411 | if (pState->fDumpPageInfo)
|
---|
2412 | pgmR3DumpHierarchyGstPageInfo(pState, cr3 & X86_CR3_AMD64_PAGE_MASK, _4K);
|
---|
2413 | pState->pHlp->pfnPrintf(pState->pHlp, " %s%s%s\n",
|
---|
2414 | pszMode,
|
---|
2415 | pState->fNp ? " + Nested Paging" : "",
|
---|
2416 | pState->fNxe ? " + NX" : "");
|
---|
2417 | }
|
---|
2418 |
|
---|
2419 |
|
---|
2420 | if (pState->fEpt)
|
---|
2421 | {
|
---|
2422 | if (pState->fPrintHeader)
|
---|
2423 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
2424 | "%-*s R - Readable\n"
|
---|
2425 | "%-*s | W - Writeable\n"
|
---|
2426 | "%-*s | | X - Executable\n"
|
---|
2427 | "%-*s | | | EMT - EPT memory type\n"
|
---|
2428 | "%-*s | | | | PAT - Ignored PAT?\n"
|
---|
2429 | "%-*s | | | | | AVL1 - 4 available bits\n"
|
---|
2430 | "%-*s | | | | | | AVL2 - 12 available bits\n"
|
---|
2431 | "%-*s Level | | | | | | | page \n"
|
---|
2432 | /* xxxx n **** R W X EMT PAT AVL1 AVL2 xxxxxxxxxxxxx
|
---|
2433 | R W X 7 0 f fff 0123456701234567 */
|
---|
2434 | ,
|
---|
2435 | cch, "", cch, "", cch, "", cch, "", cch, "", cch, "", cch, "", cch, "Address");
|
---|
2436 |
|
---|
2437 | pState->pHlp->pfnPrintf(pState->pHlp, "EPT dumping is not yet implemented, sorry.\n");
|
---|
2438 | /** @todo implemented EPT dumping. */
|
---|
2439 | rc = VERR_NOT_IMPLEMENTED;
|
---|
2440 | }
|
---|
2441 | else
|
---|
2442 | {
|
---|
2443 | if (pState->fPrintHeader)
|
---|
2444 | pState->pHlp->pfnPrintf(pState->pHlp,
|
---|
2445 | "%-*s P - Present\n"
|
---|
2446 | "%-*s | R/W - Read (0) / Write (1)\n"
|
---|
2447 | "%-*s | | U/S - User (1) / Supervisor (0)\n"
|
---|
2448 | "%-*s | | | A - Accessed\n"
|
---|
2449 | "%-*s | | | | D - Dirty\n"
|
---|
2450 | "%-*s | | | | | G - Global\n"
|
---|
2451 | "%-*s | | | | | | WT - Write thru\n"
|
---|
2452 | "%-*s | | | | | | | CD - Cache disable\n"
|
---|
2453 | "%-*s | | | | | | | | AT - Attribute table (PAT)\n"
|
---|
2454 | "%-*s | | | | | | | | | NX - No execute (K8)\n"
|
---|
2455 | "%-*s | | | | | | | | | | 4K/4M/2M - Page size.\n"
|
---|
2456 | "%-*s | | | | | | | | | | | AVL - 3 available bits.\n"
|
---|
2457 | "%-*s Level | | | | | | | | | | | | Page\n"
|
---|
2458 | /* xxxx n **** P R S A D G WT CD AT NX 4M AVL xxxxxxxxxxxxx
|
---|
2459 | - W U - - - -- -- -- -- -- 010 */
|
---|
2460 | ,
|
---|
2461 | cch, "", cch, "", cch, "", cch, "", cch, "", cch, "", cch, "",
|
---|
2462 | cch, "", cch, "", cch, "", cch, "", cch, "", cch, "Address");
|
---|
2463 | if (pState->fLme)
|
---|
2464 | rc = pgmR3DumpHierarchyGstPaePML4(pState, cr3 & cr3Mask, cMaxDepth);
|
---|
2465 | else if (pState->fPae)
|
---|
2466 | rc = pgmR3DumpHierarchyGstPaePDPT(pState, cr3 & cr3Mask, cMaxDepth);
|
---|
2467 | else
|
---|
2468 | rc = pgmR3DumpHierarchyGst32BitPD(pState, cr3 & cr3Mask, cMaxDepth);
|
---|
2469 | }
|
---|
2470 |
|
---|
2471 | if (!pState->cLeaves)
|
---|
2472 | pState->pHlp->pfnPrintf(pState->pHlp, "not present\n");
|
---|
2473 | return rc;
|
---|
2474 | }
|
---|
2475 |
|
---|
2476 |
|
---|
2477 | /**
|
---|
2478 | * dbgfR3PagingDumpEx worker.
|
---|
2479 | *
|
---|
2480 | * @returns VBox status code.
|
---|
2481 | * @param pVM The cross context VM structure.
|
---|
2482 | * @param cr3 The CR3 register value.
|
---|
2483 | * @param fFlags The flags, DBGFPGDMP_FLAGS_XXX.
|
---|
2484 | * @param FirstAddr The start address.
|
---|
2485 | * @param LastAddr The address to stop after.
|
---|
2486 | * @param cMaxDepth The max depth.
|
---|
2487 | * @param pHlp The output callbacks. Defaults to log if NULL.
|
---|
2488 | *
|
---|
2489 | * @internal
|
---|
2490 | */
|
---|
2491 | VMMR3_INT_DECL(int) PGMR3DumpHierarchyGst(PVM pVM, uint64_t cr3, uint32_t fFlags, RTGCPTR FirstAddr, RTGCPTR LastAddr,
|
---|
2492 | uint32_t cMaxDepth, PCDBGFINFOHLP pHlp)
|
---|
2493 | {
|
---|
2494 | /* Minimal validation as we're only supposed to service DBGF. */
|
---|
2495 | AssertReturn(~(fFlags & ~DBGFPGDMP_FLAGS_VALID_MASK), VERR_INVALID_PARAMETER);
|
---|
2496 | AssertReturn(!(fFlags & (DBGFPGDMP_FLAGS_CURRENT_MODE | DBGFPGDMP_FLAGS_CURRENT_CR3)), VERR_INVALID_PARAMETER);
|
---|
2497 | AssertReturn(fFlags & DBGFPGDMP_FLAGS_GUEST, VERR_INVALID_PARAMETER);
|
---|
2498 |
|
---|
2499 | PGMR3DUMPHIERARCHYSTATE State;
|
---|
2500 | pgmR3DumpHierarchyInitState(&State, pVM, fFlags, FirstAddr, LastAddr, pHlp);
|
---|
2501 | return pgmR3DumpHierarchyGstDoIt(&State, cr3, cMaxDepth);
|
---|
2502 | }
|
---|
2503 |
|
---|
2504 |
|
---|
2505 | /**
|
---|
2506 | * For aiding with reset problems and similar.
|
---|
2507 | *
|
---|
2508 | * @param pVM The cross context VM handle.
|
---|
2509 | */
|
---|
2510 | void pgmLogState(PVM pVM)
|
---|
2511 | {
|
---|
2512 | #if 0
|
---|
2513 | RTLogRelPrintf("\npgmLogState pgmLogState pgmLogState pgmLogState pgmLogState\n");
|
---|
2514 |
|
---|
2515 | /*
|
---|
2516 | * Per CPU stuff.
|
---|
2517 | */
|
---|
2518 | for (VMCPUID iCpu = 0; iCpu < pVM->cCpus; iCpu++)
|
---|
2519 | {
|
---|
2520 | PPGMCPU pPgmCpu = &pVM->aCpus[iCpu].pgm.s;
|
---|
2521 | RTLogRelPrintf("pgmLogState: CPU #%u\n", iCpu);
|
---|
2522 | # define LOG_PGMCPU_MEMBER(aFmt, aMember) RTLogRelPrintf(" %32s: %" aFmt "\n", #aMember, pPgmCpu->aMember)
|
---|
2523 | LOG_PGMCPU_MEMBER("#RX32", offVM);
|
---|
2524 | LOG_PGMCPU_MEMBER("#RX32", offVCpu);
|
---|
2525 | LOG_PGMCPU_MEMBER("#RX32", offPGM);
|
---|
2526 | LOG_PGMCPU_MEMBER("RGp", GCPhysA20Mask);
|
---|
2527 | LOG_PGMCPU_MEMBER("RTbool", fA20Enabled);
|
---|
2528 | LOG_PGMCPU_MEMBER("RTbool", fNoExecuteEnabled);
|
---|
2529 | LOG_PGMCPU_MEMBER("#RX32", fSyncFlags);
|
---|
2530 | LOG_PGMCPU_MEMBER("d", enmShadowMode);
|
---|
2531 | LOG_PGMCPU_MEMBER("d", enmGuestMode);
|
---|
2532 | LOG_PGMCPU_MEMBER("RGp", GCPhysCR3);
|
---|
2533 |
|
---|
2534 | LOG_PGMCPU_MEMBER("p", pGst32BitPdR3);
|
---|
2535 | # ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
|
---|
2536 | LOG_PGMCPU_MEMBER("p", pGst32BitPdR0);
|
---|
2537 | # endif
|
---|
2538 | LOG_PGMCPU_MEMBER("RRv", pGst32BitPdRC);
|
---|
2539 | LOG_PGMCPU_MEMBER("#RX32", fGst32BitMbzBigPdeMask);
|
---|
2540 | LOG_PGMCPU_MEMBER("RTbool", fGst32BitPageSizeExtension);
|
---|
2541 |
|
---|
2542 | LOG_PGMCPU_MEMBER("p", pGstPaePdptR3);
|
---|
2543 | # ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
|
---|
2544 | LOG_PGMCPU_MEMBER("p", pGstPaePdptR0);
|
---|
2545 | # endif
|
---|
2546 | LOG_PGMCPU_MEMBER("RRv", pGstPaePdptRC);
|
---|
2547 | LOG_PGMCPU_MEMBER("p", apGstPaePDsR3[0]);
|
---|
2548 | LOG_PGMCPU_MEMBER("p", apGstPaePDsR3[1]);
|
---|
2549 | LOG_PGMCPU_MEMBER("p", apGstPaePDsR3[2]);
|
---|
2550 | LOG_PGMCPU_MEMBER("p", apGstPaePDsR3[3]);
|
---|
2551 | # ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
|
---|
2552 | LOG_PGMCPU_MEMBER("p", apGstPaePDsR0[0]);
|
---|
2553 | LOG_PGMCPU_MEMBER("p", apGstPaePDsR0[1]);
|
---|
2554 | LOG_PGMCPU_MEMBER("p", apGstPaePDsR0[2]);
|
---|
2555 | LOG_PGMCPU_MEMBER("p", apGstPaePDsR0[3]);
|
---|
2556 | # endif
|
---|
2557 | LOG_PGMCPU_MEMBER("RRv", apGstPaePDsR0[0]);
|
---|
2558 | LOG_PGMCPU_MEMBER("RRv", apGstPaePDsR0[1]);
|
---|
2559 | LOG_PGMCPU_MEMBER("RRv", apGstPaePDsR0[2]);
|
---|
2560 | LOG_PGMCPU_MEMBER("RRv", apGstPaePDsR0[3]);
|
---|
2561 | LOG_PGMCPU_MEMBER("RGp", aGCPhysGstPaePDs[0]);
|
---|
2562 | LOG_PGMCPU_MEMBER("RGp", aGCPhysGstPaePDs[1]);
|
---|
2563 | LOG_PGMCPU_MEMBER("RGp", aGCPhysGstPaePDs[2]);
|
---|
2564 | LOG_PGMCPU_MEMBER("RGp", aGCPhysGstPaePDs[3]);
|
---|
2565 | LOG_PGMCPU_MEMBER("#RX64", aGstPaePdpeRegs[0].u);
|
---|
2566 | LOG_PGMCPU_MEMBER("#RX64", aGstPaePdpeRegs[1].u);
|
---|
2567 | LOG_PGMCPU_MEMBER("#RX64", aGstPaePdpeRegs[2].u);
|
---|
2568 | LOG_PGMCPU_MEMBER("#RX64", aGstPaePdpeRegs[3].u);
|
---|
2569 | LOG_PGMCPU_MEMBER("RGp", aGCPhysGstPaePDsMonitored[0]);
|
---|
2570 | LOG_PGMCPU_MEMBER("RGp", aGCPhysGstPaePDsMonitored[1]);
|
---|
2571 | LOG_PGMCPU_MEMBER("RGp", aGCPhysGstPaePDsMonitored[2]);
|
---|
2572 | LOG_PGMCPU_MEMBER("RGp", aGCPhysGstPaePDsMonitored[3]);
|
---|
2573 | LOG_PGMCPU_MEMBER("#RX64", fGstPaeMbzPteMask);
|
---|
2574 | LOG_PGMCPU_MEMBER("#RX64", fGstPaeMbzPdeMask);
|
---|
2575 | LOG_PGMCPU_MEMBER("#RX64", fGstPaeMbzBigPdeMask);
|
---|
2576 | LOG_PGMCPU_MEMBER("#RX64", fGstPaeMbzBigPdeMask);
|
---|
2577 | LOG_PGMCPU_MEMBER("#RX64", fGstPaeMbzPdpeMask);
|
---|
2578 |
|
---|
2579 | LOG_PGMCPU_MEMBER("p", pGstAmd64Pml4R3);
|
---|
2580 | # ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
|
---|
2581 | LOG_PGMCPU_MEMBER("p", pGstAmd64Pml4R0);
|
---|
2582 | # endif
|
---|
2583 | LOG_PGMCPU_MEMBER("#RX64", fGstAmd64MbzPteMask);
|
---|
2584 | LOG_PGMCPU_MEMBER("#RX64", fGstAmd64MbzPdeMask);
|
---|
2585 | LOG_PGMCPU_MEMBER("#RX64", fGstAmd64MbzBigPdeMask);
|
---|
2586 | LOG_PGMCPU_MEMBER("#RX64", fGstAmd64MbzPdpeMask);
|
---|
2587 | LOG_PGMCPU_MEMBER("#RX64", fGstAmd64MbzBigPdpeMask);
|
---|
2588 | LOG_PGMCPU_MEMBER("#RX64", fGstAmd64MbzPml4eMask);
|
---|
2589 | LOG_PGMCPU_MEMBER("#RX64", fGstAmd64ShadowedPdpeMask);
|
---|
2590 | LOG_PGMCPU_MEMBER("#RX64", fGstAmd64ShadowedPml4eMask);
|
---|
2591 | LOG_PGMCPU_MEMBER("#RX64", fGst64ShadowedPteMask);
|
---|
2592 | LOG_PGMCPU_MEMBER("#RX64", fGst64ShadowedPdeMask);
|
---|
2593 | LOG_PGMCPU_MEMBER("#RX64", fGst64ShadowedBigPdeMask);
|
---|
2594 | LOG_PGMCPU_MEMBER("#RX64", fGst64ShadowedBigPde4PteMask);
|
---|
2595 |
|
---|
2596 | LOG_PGMCPU_MEMBER("p", pShwPageCR3R3);
|
---|
2597 | LOG_PGMCPU_MEMBER("p", pShwPageCR3R0);
|
---|
2598 | LOG_PGMCPU_MEMBER("RRv", pShwPageCR3RC);
|
---|
2599 |
|
---|
2600 | LOG_PGMCPU_MEMBER("p", pfnR3ShwRelocate);
|
---|
2601 | LOG_PGMCPU_MEMBER("p", pfnR3ShwExit);
|
---|
2602 | LOG_PGMCPU_MEMBER("p", pfnR3ShwGetPage);
|
---|
2603 | LOG_PGMCPU_MEMBER("p", pfnR3ShwModifyPage);
|
---|
2604 | LOG_PGMCPU_MEMBER("p", pfnR0ShwGetPage);
|
---|
2605 | LOG_PGMCPU_MEMBER("p", pfnR0ShwModifyPage);
|
---|
2606 | LOG_PGMCPU_MEMBER("p", pfnR3GstRelocate);
|
---|
2607 | LOG_PGMCPU_MEMBER("p", pfnR3GstExit);
|
---|
2608 | LOG_PGMCPU_MEMBER("p", pfnR3GstGetPage);
|
---|
2609 | LOG_PGMCPU_MEMBER("p", pfnR3GstModifyPage);
|
---|
2610 | LOG_PGMCPU_MEMBER("p", pfnR0GstGetPage);
|
---|
2611 | LOG_PGMCPU_MEMBER("p", pfnR0GstModifyPage);
|
---|
2612 | LOG_PGMCPU_MEMBER("p", pfnR3BthRelocate);
|
---|
2613 | LOG_PGMCPU_MEMBER("p", pfnR3BthInvalidatePage);
|
---|
2614 | LOG_PGMCPU_MEMBER("p", pfnR3BthSyncCR3);
|
---|
2615 | LOG_PGMCPU_MEMBER("p", pfnR3BthPrefetchPage);
|
---|
2616 | LOG_PGMCPU_MEMBER("p", pfnR3BthMapCR3);
|
---|
2617 | LOG_PGMCPU_MEMBER("p", pfnR3BthUnmapCR3);
|
---|
2618 | LOG_PGMCPU_MEMBER("p", pfnR0BthMapCR3);
|
---|
2619 | LOG_PGMCPU_MEMBER("p", pfnR0BthUnmapCR3);
|
---|
2620 | LOG_PGMCPU_MEMBER("#RX64", cNetwareWp0Hacks);
|
---|
2621 | LOG_PGMCPU_MEMBER("#RX64", cPoolAccessHandler);
|
---|
2622 |
|
---|
2623 | }
|
---|
2624 |
|
---|
2625 | /*
|
---|
2626 | * PGM globals.
|
---|
2627 | */
|
---|
2628 | RTLogRelPrintf("PGM globals\n");
|
---|
2629 | PPGM pPgm = &pVM->pgm.s;
|
---|
2630 | # define LOG_PGM_MEMBER(aFmt, aMember) RTLogRelPrintf(" %32s: %" aFmt "\n", #aMember, pPgm->aMember)
|
---|
2631 | LOG_PGM_MEMBER("#RX32", offVM);
|
---|
2632 | LOG_PGM_MEMBER("#RX32", offVCpuPGM);
|
---|
2633 | LOG_PGM_MEMBER("RTbool", fRamPreAlloc);
|
---|
2634 | LOG_PGM_MEMBER("RTbool", fPhysWriteMonitoringEngaged);
|
---|
2635 | LOG_PGM_MEMBER("RTbool", fLessThan52PhysicalAddressBits);
|
---|
2636 | LOG_PGM_MEMBER("RTbool", fNestedPaging);
|
---|
2637 | LOG_PGM_MEMBER("d", enmHostMode);
|
---|
2638 | LOG_PGM_MEMBER("RTbool", fNoMorePhysWrites);
|
---|
2639 | LOG_PGM_MEMBER("RTbool", fPageFusionAllowed);
|
---|
2640 | LOG_PGM_MEMBER("RTbool", fPciPassthrough);
|
---|
2641 | LOG_PGM_MEMBER("#x", cMmio2Regions);
|
---|
2642 | LOG_PGM_MEMBER("RTbool", fRestoreRomPagesOnReset);
|
---|
2643 | LOG_PGM_MEMBER("RTbool", fZeroRamPagesOnReset);
|
---|
2644 | LOG_PGM_MEMBER("RTbool", fFinalizedMappings);
|
---|
2645 | LOG_PGM_MEMBER("RTbool", fMappingsFixed);
|
---|
2646 | LOG_PGM_MEMBER("RTbool", fMappingsFixedRestored);
|
---|
2647 | LOG_PGM_MEMBER("%#x", cbMappingFixed);
|
---|
2648 | LOG_PGM_MEMBER("%#x", idRamRangesGen);
|
---|
2649 | LOG_PGM_MEMBER("#RGv", GCPtrMappingFixed);
|
---|
2650 | LOG_PGM_MEMBER("#RGv", GCPtrPrevRamRangeMapping);
|
---|
2651 | LOG_PGM_MEMBER("%#x", hRomPhysHandlerType);
|
---|
2652 | LOG_PGM_MEMBER("#RGp", GCPhys4MBPSEMask);
|
---|
2653 | LOG_PGM_MEMBER("#RGp", GCPhysInvAddrMask);
|
---|
2654 | LOG_PGM_MEMBER("p", apRamRangesTlbR3[0]);
|
---|
2655 | LOG_PGM_MEMBER("p", apRamRangesTlbR3[1]);
|
---|
2656 | LOG_PGM_MEMBER("p", apRamRangesTlbR3[2]);
|
---|
2657 | LOG_PGM_MEMBER("p", apRamRangesTlbR3[3]);
|
---|
2658 | LOG_PGM_MEMBER("p", apRamRangesTlbR3[4]);
|
---|
2659 | LOG_PGM_MEMBER("p", apRamRangesTlbR3[5]);
|
---|
2660 | LOG_PGM_MEMBER("p", apRamRangesTlbR3[6]);
|
---|
2661 | LOG_PGM_MEMBER("p", apRamRangesTlbR3[7]);
|
---|
2662 | LOG_PGM_MEMBER("p", pRamRangesXR3);
|
---|
2663 | LOG_PGM_MEMBER("p", pRamRangeTreeR3);
|
---|
2664 | LOG_PGM_MEMBER("p", pTreesR3);
|
---|
2665 | LOG_PGM_MEMBER("p", pLastPhysHandlerR3);
|
---|
2666 | LOG_PGM_MEMBER("p", pPoolR3);
|
---|
2667 | LOG_PGM_MEMBER("p", pMappingsR3);
|
---|
2668 | LOG_PGM_MEMBER("p", pRomRangesR3);
|
---|
2669 | LOG_PGM_MEMBER("p", pRegMmioRangesR3);
|
---|
2670 | LOG_PGM_MEMBER("p", paModeData);
|
---|
2671 | LOG_PGM_MEMBER("p", apMmio2RangesR3[0]);
|
---|
2672 | LOG_PGM_MEMBER("p", apMmio2RangesR3[1]);
|
---|
2673 | LOG_PGM_MEMBER("p", apMmio2RangesR3[2]);
|
---|
2674 | LOG_PGM_MEMBER("p", apMmio2RangesR3[3]);
|
---|
2675 | LOG_PGM_MEMBER("p", apMmio2RangesR3[4]);
|
---|
2676 | LOG_PGM_MEMBER("p", apMmio2RangesR3[5]);
|
---|
2677 | LOG_PGM_MEMBER("p", apRamRangesTlbR0[0]);
|
---|
2678 | LOG_PGM_MEMBER("p", apRamRangesTlbR0[1]);
|
---|
2679 | LOG_PGM_MEMBER("p", apRamRangesTlbR0[2]);
|
---|
2680 | LOG_PGM_MEMBER("p", apRamRangesTlbR0[3]);
|
---|
2681 | LOG_PGM_MEMBER("p", apRamRangesTlbR0[4]);
|
---|
2682 | LOG_PGM_MEMBER("p", apRamRangesTlbR0[5]);
|
---|
2683 | LOG_PGM_MEMBER("p", apRamRangesTlbR0[6]);
|
---|
2684 | LOG_PGM_MEMBER("p", apRamRangesTlbR0[7]);
|
---|
2685 | LOG_PGM_MEMBER("p", pRamRangesXR0);
|
---|
2686 | LOG_PGM_MEMBER("p", pRamRangeTreeR0);
|
---|
2687 | LOG_PGM_MEMBER("p", pTreesR0);
|
---|
2688 | LOG_PGM_MEMBER("p", pLastPhysHandlerR0);
|
---|
2689 | LOG_PGM_MEMBER("p", pPoolR0);
|
---|
2690 | LOG_PGM_MEMBER("p", pMappingsR0);
|
---|
2691 | LOG_PGM_MEMBER("p", pRomRangesR0);
|
---|
2692 | LOG_PGM_MEMBER("p", apMmio2RangesR0[0]);
|
---|
2693 | LOG_PGM_MEMBER("p", apMmio2RangesR0[1]);
|
---|
2694 | LOG_PGM_MEMBER("p", apMmio2RangesR0[2]);
|
---|
2695 | LOG_PGM_MEMBER("p", apMmio2RangesR0[3]);
|
---|
2696 | LOG_PGM_MEMBER("p", apMmio2RangesR0[4]);
|
---|
2697 | LOG_PGM_MEMBER("p", apMmio2RangesR0[5]);
|
---|
2698 | LOG_PGM_MEMBER("RRv", apRamRangesTlbRC[0]);
|
---|
2699 | LOG_PGM_MEMBER("RRv", apRamRangesTlbRC[1]);
|
---|
2700 | LOG_PGM_MEMBER("RRv", apRamRangesTlbRC[2]);
|
---|
2701 | LOG_PGM_MEMBER("RRv", apRamRangesTlbRC[3]);
|
---|
2702 | LOG_PGM_MEMBER("RRv", apRamRangesTlbRC[4]);
|
---|
2703 | LOG_PGM_MEMBER("RRv", apRamRangesTlbRC[5]);
|
---|
2704 | LOG_PGM_MEMBER("RRv", apRamRangesTlbRC[6]);
|
---|
2705 | LOG_PGM_MEMBER("RRv", apRamRangesTlbRC[7]);
|
---|
2706 | LOG_PGM_MEMBER("RRv", pRamRangesXRC);
|
---|
2707 | LOG_PGM_MEMBER("RRv", pRamRangeTreeRC);
|
---|
2708 | LOG_PGM_MEMBER("RRv", pTreesRC);
|
---|
2709 | LOG_PGM_MEMBER("RRv", pLastPhysHandlerRC);
|
---|
2710 | LOG_PGM_MEMBER("RRv", pPoolRC);
|
---|
2711 | LOG_PGM_MEMBER("RRv", pMappingsRC);
|
---|
2712 | LOG_PGM_MEMBER("RRv", pRomRangesRC);
|
---|
2713 | LOG_PGM_MEMBER("RRv", paDynPageMap32BitPTEsGC);
|
---|
2714 | LOG_PGM_MEMBER("RRv", paDynPageMapPaePTEsGC);
|
---|
2715 |
|
---|
2716 | LOG_PGM_MEMBER("#RGv", GCPtrCR3Mapping);
|
---|
2717 | LOG_PGM_MEMBER("p", pInterPD);
|
---|
2718 | LOG_PGM_MEMBER("p", apInterPTs[0]);
|
---|
2719 | LOG_PGM_MEMBER("p", apInterPTs[1]);
|
---|
2720 | LOG_PGM_MEMBER("p", apInterPaePTs[0]);
|
---|
2721 | LOG_PGM_MEMBER("p", apInterPaePTs[1]);
|
---|
2722 | LOG_PGM_MEMBER("p", apInterPaePDs[0]);
|
---|
2723 | LOG_PGM_MEMBER("p", apInterPaePDs[1]);
|
---|
2724 | LOG_PGM_MEMBER("p", apInterPaePDs[2]);
|
---|
2725 | LOG_PGM_MEMBER("p", apInterPaePDs[3]);
|
---|
2726 | LOG_PGM_MEMBER("p", pInterPaePDPT);
|
---|
2727 | LOG_PGM_MEMBER("p", pInterPaePML4);
|
---|
2728 | LOG_PGM_MEMBER("p", pInterPaePDPT64);
|
---|
2729 | LOG_PGM_MEMBER("#RHp", HCPhysInterPD);
|
---|
2730 | LOG_PGM_MEMBER("#RHp", HCPhysInterPaePDPT);
|
---|
2731 | LOG_PGM_MEMBER("#RHp", HCPhysInterPaePML4);
|
---|
2732 | LOG_PGM_MEMBER("RRv", pbDynPageMapBaseGC);
|
---|
2733 | LOG_PGM_MEMBER("RRv", pRCDynMap);
|
---|
2734 | LOG_PGM_MEMBER("p", pvR0DynMapUsed);
|
---|
2735 | LOG_PGM_MEMBER("%#x", cDeprecatedPageLocks);
|
---|
2736 |
|
---|
2737 | /**
|
---|
2738 | * Data associated with managing the ring-3 mappings of the allocation chunks.
|
---|
2739 | */
|
---|
2740 | LOG_PGM_MEMBER("p", ChunkR3Map.pTree);
|
---|
2741 | //LOG_PGM_MEMBER(PGMCHUNKR3MAPTLB ChunkR3Map.Tlb);
|
---|
2742 | LOG_PGM_MEMBER("%#x", ChunkR3Map.c);
|
---|
2743 | LOG_PGM_MEMBER("%#x", ChunkR3Map.cMax);
|
---|
2744 | LOG_PGM_MEMBER("%#x", ChunkR3Map.iNow);
|
---|
2745 | //LOG_PGM_MEMBER(PGMPAGER3MAPTLB PhysTlbHC);
|
---|
2746 |
|
---|
2747 | LOG_PGM_MEMBER("#RHp", HCPhysZeroPg);
|
---|
2748 | LOG_PGM_MEMBER("p", pvZeroPgR3);
|
---|
2749 | LOG_PGM_MEMBER("p", pvZeroPgR0);
|
---|
2750 | LOG_PGM_MEMBER("RRv", pvZeroPgRC);
|
---|
2751 | LOG_PGM_MEMBER("#RHp", HCPhysMmioPg);
|
---|
2752 | LOG_PGM_MEMBER("#RHp", HCPhysInvMmioPg);
|
---|
2753 | LOG_PGM_MEMBER("p", pvMmioPgR3);
|
---|
2754 | LOG_PGM_MEMBER("RTbool", fErrInjHandyPages);
|
---|
2755 |
|
---|
2756 | /*
|
---|
2757 | * PGM page pool.
|
---|
2758 | */
|
---|
2759 | PPGMPOOL pPool = pVM->pgm.s.pPoolR3;
|
---|
2760 | RTLogRelPrintf("PGM Page Pool\n");
|
---|
2761 | # define LOG_PGMPOOL_MEMBER(aFmt, aMember) RTLogRelPrintf(" %32s: %" aFmt "\n", #aMember, pPool->aMember)
|
---|
2762 | LOG_PGMPOOL_MEMBER("p", pVMR3);
|
---|
2763 | LOG_PGMPOOL_MEMBER("p", pVMR0);
|
---|
2764 | LOG_PGMPOOL_MEMBER("RRv", pVMRC);
|
---|
2765 | LOG_PGMPOOL_MEMBER("#x", cMaxPages);
|
---|
2766 | LOG_PGMPOOL_MEMBER("#x", cCurPages);
|
---|
2767 | LOG_PGMPOOL_MEMBER("#x", iFreeHead);
|
---|
2768 | LOG_PGMPOOL_MEMBER("#x", u16Padding);
|
---|
2769 | LOG_PGMPOOL_MEMBER("#x", iUserFreeHead);
|
---|
2770 | LOG_PGMPOOL_MEMBER("#x", cMaxUsers);
|
---|
2771 | LOG_PGMPOOL_MEMBER("#x", cPresent);
|
---|
2772 | LOG_PGMPOOL_MEMBER("RRv", paUsersRC);
|
---|
2773 | LOG_PGMPOOL_MEMBER("p", paUsersR3);
|
---|
2774 | LOG_PGMPOOL_MEMBER("p", paUsersR0);
|
---|
2775 | LOG_PGMPOOL_MEMBER("#x", iPhysExtFreeHead);
|
---|
2776 | LOG_PGMPOOL_MEMBER("#x", cMaxPhysExts);
|
---|
2777 | LOG_PGMPOOL_MEMBER("RRv", paPhysExtsRC);
|
---|
2778 | LOG_PGMPOOL_MEMBER("p", paPhysExtsR3);
|
---|
2779 | LOG_PGMPOOL_MEMBER("p", paPhysExtsR0);
|
---|
2780 | for (uint32_t i = 0; i < RT_ELEMENTS(pPool->aiHash); i++)
|
---|
2781 | RTLogRelPrintf(" aiHash[%u]: %#x\n", i, pPool->aiHash[i]);
|
---|
2782 | LOG_PGMPOOL_MEMBER("#x", iAgeHead);
|
---|
2783 | LOG_PGMPOOL_MEMBER("#x", iAgeTail);
|
---|
2784 | LOG_PGMPOOL_MEMBER("RTbool", fCacheEnabled);
|
---|
2785 | LOG_PGMPOOL_MEMBER("RTbool", afPadding1[0]);
|
---|
2786 | LOG_PGMPOOL_MEMBER("RTbool", afPadding1[1]);
|
---|
2787 | LOG_PGMPOOL_MEMBER("RTbool", afPadding1[2]);
|
---|
2788 | LOG_PGMPOOL_MEMBER("#x", iModifiedHead);
|
---|
2789 | LOG_PGMPOOL_MEMBER("#x", cModifiedPages);
|
---|
2790 | LOG_PGMPOOL_MEMBER("#x", hAccessHandlerType);
|
---|
2791 | LOG_PGMPOOL_MEMBER("#x", idxFreeDirtyPage);
|
---|
2792 | LOG_PGMPOOL_MEMBER("#x", cDirtyPages);
|
---|
2793 | for (uint32_t i = 0; i < RT_ELEMENTS(pPool->aDirtyPages); i++)
|
---|
2794 | RTLogRelPrintf(" aDirtyPages[%u].uIdx: %#x\n", i, pPool->aDirtyPages[i].uIdx);
|
---|
2795 | LOG_PGMPOOL_MEMBER("#x", cUsedPages);
|
---|
2796 | LOG_PGMPOOL_MEMBER("#x", HCPhysTree);
|
---|
2797 | for (uint32_t i = 0; i < pPool->cCurPages; i++)
|
---|
2798 | {
|
---|
2799 | PPGMPOOLPAGE pPage = &pPool->aPages[i];
|
---|
2800 | # define LOG_PAGE_MEMBER(aFmt, aMember) RTLogRelPrintf(" %3u:%-32s: %" aFmt "\n", i, #aMember, pPage->aMember)
|
---|
2801 | RTLogRelPrintf("%3u:%-32s: %p\n", i, "", pPage);
|
---|
2802 | LOG_PAGE_MEMBER("RHp", Core.Key);
|
---|
2803 | LOG_PAGE_MEMBER("p", pvPageR3);
|
---|
2804 | LOG_PAGE_MEMBER("RGp", GCPhys);
|
---|
2805 | LOG_PAGE_MEMBER("d", enmKind);
|
---|
2806 | LOG_PAGE_MEMBER("d", enmAccess);
|
---|
2807 | LOG_PAGE_MEMBER("RTbool", fA20Enabled);
|
---|
2808 | LOG_PAGE_MEMBER("RTbool", fZeroed);
|
---|
2809 | LOG_PAGE_MEMBER("RTbool", fSeenNonGlobal);
|
---|
2810 | LOG_PAGE_MEMBER("RTbool", fMonitored);
|
---|
2811 | LOG_PAGE_MEMBER("RTbool", fCached);
|
---|
2812 | LOG_PAGE_MEMBER("RTbool", fReusedFlushPending);
|
---|
2813 | LOG_PAGE_MEMBER("RTbool", fDirty);
|
---|
2814 | LOG_PAGE_MEMBER("RTbool", fPadding1);
|
---|
2815 | LOG_PAGE_MEMBER("RTbool", fPadding2);
|
---|
2816 | LOG_PAGE_MEMBER("#x", idx);
|
---|
2817 | LOG_PAGE_MEMBER("#x", iNext);
|
---|
2818 | LOG_PAGE_MEMBER("#x", iUserHead);
|
---|
2819 | LOG_PAGE_MEMBER("#x", cPresent);
|
---|
2820 | LOG_PAGE_MEMBER("#x", iFirstPresent);
|
---|
2821 | LOG_PAGE_MEMBER("#x", cModifications);
|
---|
2822 | LOG_PAGE_MEMBER("#x", iModifiedNext);
|
---|
2823 | LOG_PAGE_MEMBER("#x", iModifiedPrev);
|
---|
2824 | LOG_PAGE_MEMBER("#x", iMonitoredNext);
|
---|
2825 | LOG_PAGE_MEMBER("#x", iMonitoredPrev);
|
---|
2826 | LOG_PAGE_MEMBER("#x", iAgeNext);
|
---|
2827 | LOG_PAGE_MEMBER("#x", iAgePrev);
|
---|
2828 | LOG_PAGE_MEMBER("#x", idxDirtyEntry);
|
---|
2829 | LOG_PAGE_MEMBER("RGv", GCPtrLastAccessHandlerRip);
|
---|
2830 | LOG_PAGE_MEMBER("RGv", GCPtrLastAccessHandlerFault);
|
---|
2831 | LOG_PAGE_MEMBER("#RX64", cLastAccessHandler);
|
---|
2832 | LOG_PAGE_MEMBER("#RX32", cLocked);
|
---|
2833 | # ifdef VBOX_STRICT
|
---|
2834 | LOG_PAGE_MEMBER("RGv", GCPtrDirtyFault);
|
---|
2835 | # endif
|
---|
2836 | if ( pPage->enmKind == PGMPOOLKIND_32BIT_PT_FOR_32BIT_PT
|
---|
2837 | || pPage->enmKind == PGMPOOLKIND_32BIT_PT_FOR_32BIT_4MB
|
---|
2838 | || pPage->enmKind == PGMPOOLKIND_32BIT_PD
|
---|
2839 | || pPage->enmKind == PGMPOOLKIND_32BIT_PD_PHYS)
|
---|
2840 | {
|
---|
2841 | uint32_t const *pu32Page = (uint32_t const *)pPage->pvPageR3;
|
---|
2842 | for (uint32_t i = 0; i < 1024/2; i += 4)
|
---|
2843 | RTLogRelPrintf(" %#05x: %RX32 %RX32 %RX32 %RX32\n", i, pu32Page[i], pu32Page[i+1], pu32Page[i+2], pu32Page[i+3]);
|
---|
2844 | }
|
---|
2845 | else if ( pPage->enmKind != PGMPOOLKIND_FREE
|
---|
2846 | && pPage->enmKind != PGMPOOLKIND_INVALID)
|
---|
2847 | {
|
---|
2848 | uint64_t const *pu64Page = (uint64_t const *)pPage->pvPageR3;
|
---|
2849 | for (uint32_t i = 0; i < 512/2; i += 2)
|
---|
2850 | RTLogRelPrintf(" %#05x: %RX64 %RX64\n", i, pu64Page[i], pu64Page[i+1]);
|
---|
2851 | }
|
---|
2852 | }
|
---|
2853 |
|
---|
2854 | RTLogRelPrintf("pgmLogState pgmLogState pgmLogState pgmLogState pgmLogState\n\n");
|
---|
2855 | #else
|
---|
2856 | RT_NOREF(pVM);
|
---|
2857 | #endif
|
---|
2858 | }
|
---|
2859 |
|
---|