VirtualBox

source: vbox/trunk/src/VBox/VMM/PGMHandler.cpp@ 6902

Last change on this file since 6902 was 6902, checked in by vboxsync, 17 years ago

Converted MM_RAM_FLAGS_PHYSICAL_HANDLER, _WRITE, _ALL and _TEMP_OFF into
a 2-bit state field (u2HandlerPhysStateX). I've tripple checked this change,
but if I overlooked something real odd stuff might happen...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 21.3 KB
Line 
1/* $Id: PGMHandler.cpp 6902 2008-02-11 16:51:52Z vboxsync $ */
2/** @file
3 * PGM - Page Manager / Monitor, Access Handlers.
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
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/dbgf.h>
24#include <VBox/pgm.h>
25#include <VBox/cpum.h>
26#include <VBox/iom.h>
27#include <VBox/sup.h>
28#include <VBox/mm.h>
29#include <VBox/em.h>
30#include <VBox/stam.h>
31#include <VBox/csam.h>
32#include <VBox/rem.h>
33#include <VBox/dbgf.h>
34#include <VBox/rem.h>
35#include <VBox/selm.h>
36#include <VBox/ssm.h>
37#include "PGMInternal.h"
38#include <VBox/vm.h>
39#include <VBox/dbg.h>
40
41#include <VBox/log.h>
42#include <iprt/assert.h>
43#include <iprt/alloc.h>
44#include <iprt/asm.h>
45#include <iprt/thread.h>
46#include <iprt/string.h>
47#include <VBox/param.h>
48#include <VBox/err.h>
49#include <VBox/hwaccm.h>
50
51
52/*******************************************************************************
53* Internal Functions *
54*******************************************************************************/
55static DECLCALLBACK(int) pgmR3HandlerPhysicalOneClear(PAVLROGCPHYSNODECORE pNode, void *pvUser);
56static DECLCALLBACK(int) pgmR3HandlerPhysicalOneSet(PAVLROGCPHYSNODECORE pNode, void *pvUser);
57static DECLCALLBACK(int) pgmR3InfoHandlersPhysicalOne(PAVLROGCPHYSNODECORE pNode, void *pvUser);
58static DECLCALLBACK(int) pgmR3InfoHandlersVirtualOne(PAVLROGCPTRNODECORE pNode, void *pvUser);
59
60
61
62/**
63 * Register a access handler for a physical range.
64 *
65 * @returns VBox status code.
66 * @param pVM VM handle.
67 * @param enmType Handler type. Any of the PGMPHYSHANDLERTYPE_PHYSICAL* enums.
68 * @param GCPhys Start physical address.
69 * @param GCPhysLast Last physical address. (inclusive)
70 * @param pfnHandlerR3 The R3 handler.
71 * @param pvUserR3 User argument to the R3 handler.
72 * @param pszModR0 The R0 handler module. NULL means the default R0 module.
73 * @param pszHandlerR0 The R0 handler symbol name.
74 * @param pvUserR0 User argument to the R0 handler.
75 * @param pszModGC The GC handler module. NULL means the default GC module.
76 * @param pszHandlerGC The GC handler symbol name.
77 * @param pvUserGC User argument to the GC handler.
78 * This must be a GC pointer because it will be relocated!
79 * @param pszDesc Pointer to description string. This must not be freed.
80 */
81PGMR3DECL(int) PGMR3HandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast,
82 PFNPGMR3PHYSHANDLER pfnHandlerR3, void *pvUserR3,
83 const char *pszModR0, const char *pszHandlerR0, RTR0PTR pvUserR0,
84 const char *pszModGC, const char *pszHandlerGC, RTGCPTR pvUserGC, const char *pszDesc)
85{
86 LogFlow(("PGMR3HandlerPhysicalRegister: enmType=%d GCPhys=%VGv GCPhysLast=%VGv pfnHandlerR3=%VHv pvUserHC=%VHv pszModGC=%p:{%s} pszHandlerGC=%p:{%s} pvUser=%VGv pszDesc=%s\n",
87 enmType, GCPhys, GCPhysLast, pfnHandlerR3, pvUserR3, pszModGC, pszModGC, pszHandlerGC, pszHandlerGC, pvUserGC, pszDesc));
88
89 /*
90 * Validate input.
91 */
92 if (!pszModGC)
93 pszModGC = VMMGC_MAIN_MODULE_NAME;
94
95 if (!pszModR0)
96 pszModR0 = VMMR0_MAIN_MODULE_NAME;
97
98 /*
99 * Resolve the R0 handler.
100 */
101 R0PTRTYPE(PFNPGMR0PHYSHANDLER) pfnHandlerR0 = NIL_RTR0PTR;
102 int rc = VINF_SUCCESS;
103 if (pszHandlerR0 && HWACCMR3IsAllowed(pVM))
104 rc = PDMR3GetSymbolR0Lazy(pVM, pszModR0, pszHandlerR0, &pfnHandlerR0);
105 if (VBOX_SUCCESS(rc))
106 {
107 /*
108 * Resolve the GC handler.
109 */
110 RTGCPTR pfnHandlerGC = NIL_RTGCPTR;
111 if (pszHandlerGC)
112 rc = PDMR3GetSymbolGCLazy(pVM, pszModGC, pszHandlerGC, &pfnHandlerGC);
113
114 if (VBOX_SUCCESS(rc))
115 return PGMHandlerPhysicalRegisterEx(pVM, enmType, GCPhys, GCPhysLast, pfnHandlerR3, pvUserR3,
116 pfnHandlerR0, pvUserR0, pfnHandlerGC, pvUserGC, pszDesc);
117
118 AssertMsgFailed(("Failed to resolve %s.%s, rc=%Vrc.\n", pszModGC, pszHandlerGC, rc));
119 }
120 else
121 AssertMsgFailed(("Failed to resolve %s.%s, rc=%Vrc.\n", pszModR0, pszHandlerR0, rc));
122
123 return rc;
124}
125
126
127/**
128 * Updates the physical page access handlers.
129 *
130 * @param pVM VM handle.
131 * @remark Only used when restoring a saved state.
132 */
133void pgmR3HandlerPhysicalUpdateAll(PVM pVM)
134{
135 LogFlow(("pgmHandlerPhysicalUpdateAll:\n"));
136
137 /*
138 * Clear and set.
139 * (the right -> left on the setting pass is just bird speculating on cache hits)
140 */
141 pgmLock(pVM);
142 RTAvlroGCPhysDoWithAll(&pVM->pgm.s.CTXSUFF(pTrees)->PhysHandlers, true, pgmR3HandlerPhysicalOneClear, pVM);
143 RTAvlroGCPhysDoWithAll(&pVM->pgm.s.CTXSUFF(pTrees)->PhysHandlers, false, pgmR3HandlerPhysicalOneSet, pVM);
144 pgmUnlock(pVM);
145}
146
147
148/**
149 * Clears all the page level flags for one physical handler range.
150 *
151 * @returns 0
152 * @param pNode Pointer to a PGMPHYSHANDLER.
153 * @param pvUser VM handle.
154 */
155static DECLCALLBACK(int) pgmR3HandlerPhysicalOneClear(PAVLROGCPHYSNODECORE pNode, void *pvUser)
156{
157 PPGMPHYSHANDLER pCur = (PPGMPHYSHANDLER)pNode;
158 PPGMRAMRANGE pRamHint = NULL;
159 RTGCPHYS GCPhys = pCur->Core.Key;
160 RTUINT cPages = pCur->cPages;
161 PPGM pPGM = &((PVM)pvUser)->pgm.s;
162 for (;;)
163 {
164 PPGMPAGE pPage;
165 int rc = pgmPhysGetPageWithHintEx(pPGM, GCPhys, &pPage, &pRamHint);
166 if (RT_SUCCESS(rc))
167 PGM_PAGE_SET_HNDL_PHYS_STATE(pPage, PGM_PAGE_HNDL_PHYS_STATE_NONE);
168 else
169 AssertRC(rc);
170
171 if (--cPages == 0)
172 return 0;
173 GCPhys += PAGE_SIZE;
174 }
175}
176
177
178/**
179 * Sets all the page level flags for one physical handler range.
180 *
181 * @returns 0
182 * @param pNode Pointer to a PGMPHYSHANDLER.
183 * @param pvUser VM handle.
184 */
185static DECLCALLBACK(int) pgmR3HandlerPhysicalOneSet(PAVLROGCPHYSNODECORE pNode, void *pvUser)
186{
187 PPGMPHYSHANDLER pCur = (PPGMPHYSHANDLER)pNode;
188 unsigned uState = pgmHandlerPhysicalCalcState(pCur);
189 PPGMRAMRANGE pRamHint = NULL;
190 RTGCPHYS GCPhys = pCur->Core.Key;
191 RTUINT cPages = pCur->cPages;
192 PPGM pPGM = &((PVM)pvUser)->pgm.s;
193 for (;;)
194 {
195 PPGMPAGE pPage;
196 int rc = pgmPhysGetPageWithHintEx(pPGM, GCPhys, &pPage, &pRamHint);
197 if (RT_SUCCESS(rc))
198 PGM_PAGE_SET_HNDL_PHYS_STATE(pPage, uState);
199 else
200 AssertRC(rc);
201
202 if (--cPages == 0)
203 return 0;
204 GCPhys += PAGE_SIZE;
205 }
206}
207
208
209
210/**
211 * Register a access handler for a virtual range.
212 *
213 * @returns VBox status code.
214 * @param pVM VM handle.
215 * @param enmType Handler type. Any of the PGMVIRTHANDLERTYPE_* enums.
216 * @param GCPtr Start address.
217 * @param GCPtrLast Last address (inclusive).
218 * @param pfnInvalidateHC The HC invalidate callback (can be 0)
219 * @param pfnHandlerHC The HC handler.
220 * @param pszHandlerGC The GC handler symbol name.
221 * @param pszModGC The GC handler module.
222 * @param pszDesc Pointer to description string. This must not be freed.
223 */
224/** @todo rename this function to PGMR3HandlerVirtualRegister */
225PGMR3DECL(int) PGMR3HandlerVirtualRegister(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
226 PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
227 PFNPGMHCVIRTHANDLER pfnHandlerHC,
228 const char *pszHandlerGC, const char *pszModGC,
229 const char *pszDesc)
230{
231 LogFlow(("PGMR3HandlerVirtualRegisterEx: enmType=%d GCPtr=%VGv GCPtrLast=%VGv pszHandlerGC=%p:{%s} pszModGC=%p:{%s} pszDesc=%s\n",
232 enmType, GCPtr, GCPtrLast, pszHandlerGC, pszHandlerGC, pszModGC, pszModGC, pszDesc));
233
234 /*
235 * Validate input.
236 */
237 if (!pszModGC)
238 pszModGC = VMMGC_MAIN_MODULE_NAME;
239 if (!pszModGC || !*pszModGC || !pszHandlerGC || !*pszHandlerGC)
240 {
241 AssertMsgFailed(("pfnHandlerGC or/and pszModGC is missing\n"));
242 return VERR_INVALID_PARAMETER;
243 }
244
245 /*
246 * Resolve the GC handler.
247 */
248 RTGCPTR pfnHandlerGC;
249 int rc = PDMR3GetSymbolGCLazy(pVM, pszModGC, pszHandlerGC, &pfnHandlerGC);
250 if (VBOX_SUCCESS(rc))
251 return PGMHandlerVirtualRegisterEx(pVM, enmType, GCPtr, GCPtrLast, pfnInvalidateHC, pfnHandlerHC, pfnHandlerGC, pszDesc);
252
253 AssertMsgFailed(("Failed to resolve %s.%s, rc=%Vrc.\n", pszModGC, pszHandlerGC, rc));
254 return rc;
255}
256
257
258/**
259 * Register an access handler for a virtual range.
260 *
261 * @returns VBox status code.
262 * @param pVM VM handle.
263 * @param enmType Handler type. Any of the PGMVIRTHANDLERTYPE_* enums.
264 * @param GCPtr Start address.
265 * @param GCPtrLast Last address (inclusive).
266 * @param pfnInvalidateHC The HC invalidate callback (can be 0)
267 * @param pfnHandlerHC The HC handler.
268 * @param pfnHandlerGC The GC handler.
269 * @param pszDesc Pointer to description string. This must not be freed.
270 */
271/** @todo rename this to PGMR3HandlerVirtualRegisterEx. */
272PGMDECL(int) PGMHandlerVirtualRegisterEx(PVM pVM, PGMVIRTHANDLERTYPE enmType, RTGCPTR GCPtr, RTGCPTR GCPtrLast,
273 PFNPGMHCVIRTINVALIDATE pfnInvalidateHC,
274 PFNPGMHCVIRTHANDLER pfnHandlerHC, RTGCPTR pfnHandlerGC,
275 R3PTRTYPE(const char *) pszDesc)
276{
277 Log(("PGMR3HandlerVirtualRegister: enmType=%d GCPtr=%RGv GCPtrLast=%RGv pfnHandlerGC=%RGv pszDesc=%s\n", enmType, GCPtr, GCPtrLast, pfnHandlerGC, pszDesc));
278
279 /*
280 * Validate input.
281 */
282 switch (enmType)
283 {
284 case PGMVIRTHANDLERTYPE_NORMAL:
285 case PGMVIRTHANDLERTYPE_ALL:
286 case PGMVIRTHANDLERTYPE_WRITE:
287 case PGMVIRTHANDLERTYPE_EIP:
288 if (!pfnHandlerHC)
289 {
290 AssertMsgFailed(("No HC handler specified!!\n"));
291 return VERR_INVALID_PARAMETER;
292 }
293 break;
294
295 case PGMVIRTHANDLERTYPE_HYPERVISOR:
296 if (pfnHandlerHC)
297 {
298 AssertMsgFailed(("HC handler specified for hypervisor range!?!\n"));
299 return VERR_INVALID_PARAMETER;
300 }
301 break;
302 default:
303 AssertMsgFailed(("Invalid enmType! enmType=%d\n", enmType));
304 return VERR_INVALID_PARAMETER;
305 }
306 if (GCPtrLast < GCPtr)
307 {
308 AssertMsgFailed(("GCPtrLast < GCPtr (%#x < %#x)\n", GCPtrLast, GCPtr));
309 return VERR_INVALID_PARAMETER;
310 }
311 if (!pfnHandlerGC)
312 {
313 AssertMsgFailed(("pfnHandlerGC is missing\n"));
314 return VERR_INVALID_PARAMETER;
315 }
316
317 /*
318 * Allocate and initialize a new entry.
319 */
320 unsigned cPages = (RT_ALIGN((RTGCUINTPTR)GCPtrLast + 1, PAGE_SIZE) - ((RTGCUINTPTR)GCPtr & PAGE_BASE_GC_MASK)) >> PAGE_SHIFT;
321 PPGMVIRTHANDLER pNew;
322 int rc = MMHyperAlloc(pVM, RT_OFFSETOF(PGMVIRTHANDLER, aPhysToVirt[cPages]), 0, MM_TAG_PGM_HANDLERS, (void **)&pNew); /** @todo r=bird: incorrect member name PhysToVirt? */
323 if (VBOX_FAILURE(rc))
324 return rc;
325
326 pNew->Core.Key = GCPtr;
327 pNew->Core.KeyLast = GCPtrLast;
328
329 pNew->enmType = enmType;
330 pNew->pfnInvalidateHC = pfnInvalidateHC;
331 pNew->pfnHandlerGC = pfnHandlerGC;
332 pNew->pfnHandlerHC = pfnHandlerHC;
333 pNew->pszDesc = pszDesc;
334 pNew->GCPtr = GCPtr;
335 pNew->GCPtrLast = GCPtrLast;
336 pNew->cb = GCPtrLast - GCPtr + 1;
337 pNew->cPages = cPages;
338 /* Will be synced at next guest execution attempt. */
339 while (cPages-- > 0)
340 {
341 pNew->aPhysToVirt[cPages].Core.Key = NIL_RTGCPHYS;
342 pNew->aPhysToVirt[cPages].Core.KeyLast = NIL_RTGCPHYS;
343 pNew->aPhysToVirt[cPages].offVirtHandler = -RT_OFFSETOF(PGMVIRTHANDLER, aPhysToVirt[cPages]);
344 pNew->aPhysToVirt[cPages].offNextAlias = 0;
345 }
346
347 /*
348 * Try to insert it into the tree.
349 *
350 * The current implementation doesn't allow multiple handlers for
351 * the same range this makes everything much simpler and faster.
352 */
353 pgmLock(pVM);
354 if (pVM->pgm.s.pTreesHC->VirtHandlers != 0)
355 {
356 PPGMVIRTHANDLER pCur = (PPGMVIRTHANDLER)RTAvlroGCPtrGetBestFit(&pVM->pgm.s.CTXSUFF(pTrees)->VirtHandlers, pNew->Core.Key, true);
357 if (!pCur || GCPtr > pCur->GCPtrLast || GCPtrLast < pCur->GCPtr)
358 pCur = (PPGMVIRTHANDLER)RTAvlroGCPtrGetBestFit(&pVM->pgm.s.CTXSUFF(pTrees)->VirtHandlers, pNew->Core.Key, false);
359 if (pCur && GCPtr <= pCur->GCPtrLast && GCPtrLast >= pCur->GCPtr)
360 {
361 /*
362 * The LDT sometimes conflicts with the IDT and LDT ranges while being
363 * updated on linux. So, we don't assert simply log it.
364 */
365 Log(("PGMR3HandlerVirtualRegister: Conflict with existing range %RGv-%RGv (%s), req. %RGv-%RGv (%s)\n",
366 pCur->GCPtr, pCur->GCPtrLast, pCur->pszDesc, GCPtr, GCPtrLast, pszDesc));
367 MMHyperFree(pVM, pNew);
368 pgmUnlock(pVM);
369 return VERR_PGM_HANDLER_VIRTUAL_CONFLICT;
370 }
371 }
372 if (RTAvlroGCPtrInsert(&pVM->pgm.s.CTXSUFF(pTrees)->VirtHandlers, &pNew->Core))
373 {
374 if (enmType != PGMVIRTHANDLERTYPE_HYPERVISOR)
375 {
376 pVM->pgm.s.fPhysCacheFlushPending = true;
377 pVM->pgm.s.fSyncFlags |= PGM_SYNC_UPDATE_PAGE_BIT_VIRTUAL | PGM_SYNC_CLEAR_PGM_POOL;
378 VM_FF_SET(pVM, VM_FF_PGM_SYNC_CR3);
379 }
380 pgmUnlock(pVM);
381
382#ifdef VBOX_WITH_STATISTICS
383 char szPath[256];
384 RTStrPrintf(szPath, sizeof(szPath), "/PGM/VirtHandler/Calls/%VGv-%VGv", pNew->GCPtr, pNew->GCPtrLast);
385 rc = STAMR3Register(pVM, &pNew->Stat, STAMTYPE_PROFILE, STAMVISIBILITY_USED, szPath, STAMUNIT_TICKS_PER_CALL, pszDesc);
386 AssertRC(rc);
387#endif
388 return VINF_SUCCESS;
389 }
390 pgmUnlock(pVM);
391 AssertFailed();
392 MMHyperFree(pVM, pNew);
393 return VERR_PGM_HANDLER_VIRTUAL_CONFLICT;
394}
395
396
397/**
398 * Modify the page invalidation callback handler for a registered virtual range
399 * (add more when needed)
400 *
401 * @returns VBox status code.
402 * @param pVM VM handle.
403 * @param GCPtr Start address.
404 * @param pfnInvalidateHC The HC invalidate callback (can be 0)
405 */
406PGMDECL(int) PGMHandlerVirtualChangeInvalidateCallback(PVM pVM, RTGCPTR GCPtr, PFNPGMHCVIRTINVALIDATE pfnInvalidateHC)
407{
408 pgmLock(pVM);
409 PPGMVIRTHANDLER pCur = (PPGMVIRTHANDLER)RTAvlroGCPtrGet(&pVM->pgm.s.pTreesHC->VirtHandlers, GCPtr);
410 if (pCur)
411 {
412 pCur->pfnInvalidateHC = pfnInvalidateHC;
413 pgmUnlock(pVM);
414 return VINF_SUCCESS;
415 }
416 pgmUnlock(pVM);
417 AssertMsgFailed(("Range %#x not found!\n", GCPtr));
418 return VERR_INVALID_PARAMETER;
419}
420
421
422/**
423 * Deregister an access handler for a virtual range.
424 *
425 * @returns VBox status code.
426 * @param pVM VM handle.
427 * @param GCPtr Start address.
428 */
429PGMDECL(int) PGMHandlerVirtualDeregister(PVM pVM, RTGCPTR GCPtr)
430{
431 /*
432 * Find the handler.
433 * We naturally assume GCPtr is a unique specification.
434 */
435 pgmLock(pVM);
436 PPGMVIRTHANDLER pCur = (PPGMVIRTHANDLER)RTAvlroGCPtrRemove(&pVM->pgm.s.CTXSUFF(pTrees)->VirtHandlers, GCPtr);
437 if (pCur)
438 {
439 Log(("PGMR3HandlerVirtualDeregister: Removing Virtual (%d) Range %#x-%#x %s\n", pCur->enmType,
440 pCur->GCPtr, pCur->GCPtrLast, pCur->pszDesc));
441
442 /*
443 * Reset the flags and remove phys2virt nodes.
444 */
445 PPGM pPGM = &pVM->pgm.s;
446 for (unsigned iPage = 0; iPage < pCur->cPages; iPage++)
447 if (pCur->aPhysToVirt[iPage].offNextAlias & PGMPHYS2VIRTHANDLER_IN_TREE)
448 pgmHandlerVirtualClearPage(pPGM, pCur, iPage);
449
450 /*
451 * Schedule CR3 sync (if required) and the memory.
452 */
453 STAM_DEREG(pVM, &pCur->Stat);
454 if (pCur->enmType != PGMVIRTHANDLERTYPE_HYPERVISOR)
455 {
456 pVM->pgm.s.fSyncFlags |= PGM_SYNC_UPDATE_PAGE_BIT_VIRTUAL | PGM_SYNC_CLEAR_PGM_POOL;
457 VM_FF_SET(pVM, VM_FF_PGM_SYNC_CR3);
458 }
459 MMHyperFree(pVM, pCur);
460 pgmUnlock(pVM);
461 return VINF_SUCCESS;
462 }
463 pgmUnlock(pVM);
464 AssertMsgFailed(("Range %#x not found!\n", GCPtr));
465 return VERR_INVALID_PARAMETER;
466}
467
468
469/**
470 * Arguments for pgmR3InfoHandlersPhysicalOne and pgmR3InfoHandlersVirtualOne.
471 */
472typedef struct PGMHANDLERINFOARG
473{
474 /** The output helpers.*/
475 PCDBGFINFOHLP pHlp;
476 /** Set if statistics should be dumped. */
477 bool fStats;
478} PGMHANDLERINFOARG, *PPGMHANDLERINFOARG;
479
480
481/**
482 * Info callback for 'pgmhandlers'.
483 *
484 * @param pHlp The output helpers.
485 * @param pszArgs The arguments. phys or virt.
486 */
487DECLCALLBACK(void) pgmR3InfoHandlers(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs)
488{
489 /*
490 * Test input.
491 */
492 PGMHANDLERINFOARG Args = { pHlp, true };
493 bool fPhysical = !pszArgs || !*pszArgs;
494 bool fVirtual = fPhysical;
495 if (!fPhysical)
496 {
497 fPhysical = strstr(pszArgs, "phys") != NULL;
498 fVirtual = strstr(pszArgs, "virt") != NULL;
499 Args.fStats = strstr(pszArgs, "nost") == NULL;
500 }
501
502 /*
503 * Dump the handlers.
504 */
505 if (fPhysical)
506 {
507 pHlp->pfnPrintf(pHlp,
508 "Physical handlers: (PhysHandlers=%d (%#x))\n"
509 "From - To (incl) HandlerHC UserHC HandlerGC UserGC Type Description\n",
510 pVM->pgm.s.pTreesHC->PhysHandlers, pVM->pgm.s.pTreesHC->PhysHandlers);
511 RTAvlroGCPhysDoWithAll(&pVM->pgm.s.pTreesHC->PhysHandlers, true, pgmR3InfoHandlersPhysicalOne, &Args);
512 }
513
514 if (fVirtual)
515 {
516 pHlp->pfnPrintf(pHlp,
517 "Virtual handlers:\n"
518 "From - To (excl) HandlerHC HandlerGC Type Description\n");
519 RTAvlroGCPtrDoWithAll(&pVM->pgm.s.pTreesHC->VirtHandlers, true, pgmR3InfoHandlersVirtualOne, &Args);
520 }
521}
522
523
524/**
525 * Displays one physical handler range.
526 *
527 * @returns 0
528 * @param pNode Pointer to a PGMPHYSHANDLER.
529 * @param pvUser Pointer to command helper functions.
530 */
531static DECLCALLBACK(int) pgmR3InfoHandlersPhysicalOne(PAVLROGCPHYSNODECORE pNode, void *pvUser)
532{
533 PPGMPHYSHANDLER pCur = (PPGMPHYSHANDLER)pNode;
534 PPGMHANDLERINFOARG pArgs= (PPGMHANDLERINFOARG)pvUser;
535 PCDBGFINFOHLP pHlp = pArgs->pHlp;
536 const char *pszType;
537 switch (pCur->enmType)
538 {
539 case PGMPHYSHANDLERTYPE_MMIO: pszType = "MMIO "; break;
540 case PGMPHYSHANDLERTYPE_PHYSICAL_WRITE: pszType = "Write "; break;
541 case PGMPHYSHANDLERTYPE_PHYSICAL_ALL: pszType = "All "; break;
542 default: pszType = "????"; break;
543 }
544 pHlp->pfnPrintf(pHlp,
545 "%VGp - %VGp %VHv %VHv %VGv %VGv %s %s\n",
546 pCur->Core.Key, pCur->Core.KeyLast, pCur->pfnHandlerR3, pCur->pvUserR3, pCur->pfnHandlerGC, pCur->pvUserGC, pszType, pCur->pszDesc);
547#ifdef VBOX_WITH_STATISTICS
548 if (pArgs->fStats)
549 pHlp->pfnPrintf(pHlp, " cPeriods: %9RU64 cTicks: %11RU64 Min: %11RU64 Avg: %11RU64 Max: %11RU64\n",
550 pCur->Stat.cPeriods, pCur->Stat.cTicks, pCur->Stat.cTicksMin,
551 pCur->Stat.cPeriods ? pCur->Stat.cTicks / pCur->Stat.cPeriods : 0, pCur->Stat.cTicksMax);
552#endif
553 return 0;
554}
555
556
557/**
558 * Displays one virtual handler range.
559 *
560 * @returns 0
561 * @param pNode Pointer to a PGMVIRTHANDLER.
562 * @param pvUser Pointer to command helper functions.
563 */
564static DECLCALLBACK(int) pgmR3InfoHandlersVirtualOne(PAVLROGCPTRNODECORE pNode, void *pvUser)
565{
566 PPGMVIRTHANDLER pCur = (PPGMVIRTHANDLER)pNode;
567 PPGMHANDLERINFOARG pArgs= (PPGMHANDLERINFOARG)pvUser;
568 PCDBGFINFOHLP pHlp = pArgs->pHlp;
569 const char *pszType;
570 switch (pCur->enmType)
571 {
572 case PGMVIRTHANDLERTYPE_NORMAL: pszType = "Natural"; break;
573 case PGMVIRTHANDLERTYPE_WRITE: pszType = "Write "; break;
574 case PGMVIRTHANDLERTYPE_ALL: pszType = "All "; break;
575 case PGMVIRTHANDLERTYPE_EIP: pszType = "EIP "; break;
576 case PGMVIRTHANDLERTYPE_HYPERVISOR: pszType = "WriteHyp "; break;
577 default: pszType = "????"; break;
578 }
579 pHlp->pfnPrintf(pHlp, "%08x - %08x %08x %08x %s %s\n",
580 pCur->GCPtr, pCur->GCPtrLast, pCur->pfnHandlerHC, pCur->pfnHandlerGC, pszType, pCur->pszDesc);
581#ifdef VBOX_WITH_STATISTICS
582 if (pArgs->fStats)
583 pHlp->pfnPrintf(pHlp, " cPeriods: %9RU64 cTicks: %11RU64 Min: %11RU64 Avg: %11RU64 Max: %11RU64\n",
584 pCur->Stat.cPeriods, pCur->Stat.cTicks, pCur->Stat.cTicksMin,
585 pCur->Stat.cPeriods ? pCur->Stat.cTicks / pCur->Stat.cPeriods : 0, pCur->Stat.cTicksMax);
586#endif
587 return 0;
588}
589
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette