VirtualBox

source: vbox/trunk/src/VBox/VMM/MMHyper.cpp@ 11219

Last change on this file since 11219 was 11164, checked in by vboxsync, 16 years ago

#1865: VGA. Changed PDMDevHlpMMHyperMapMMIO2/MMHyperMapMMIO2 to return a RC pointer instead of a GC one.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 39.0 KB
Line 
1/* $Id: MMHyper.cpp 11164 2008-08-06 00:15:58Z vboxsync $ */
2/** @file
3 * MM - Memory Monitor(/Manager) - Hypervisor Memory Area.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23
24
25/*******************************************************************************
26* Header Files *
27*******************************************************************************/
28#define LOG_GROUP LOG_GROUP_MM_HYPER
29#include <VBox/pgm.h>
30#include <VBox/mm.h>
31#include <VBox/dbgf.h>
32#include "MMInternal.h"
33#include <VBox/vm.h>
34#include <VBox/err.h>
35#include <VBox/param.h>
36#include <VBox/log.h>
37#include <iprt/alloc.h>
38#include <iprt/assert.h>
39#include <iprt/string.h>
40
41
42/*******************************************************************************
43* Internal Functions *
44*******************************************************************************/
45static DECLCALLBACK(bool) mmR3HyperRelocateCallback(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser);
46static int mmR3HyperMap(PVM pVM, const size_t cb, const char *pszDesc, PRTGCPTR pGCPtr, PMMLOOKUPHYPER *ppLookup);
47static int mmR3HyperHeapCreate(PVM pVM, const size_t cb, PMMHYPERHEAP *ppHeap);
48static int mmR3HyperHeapMap(PVM pVM, PMMHYPERHEAP pHeap, PRTGCPTR ppHeapGC);
49static DECLCALLBACK(void) mmR3HyperInfoHma(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
50
51
52/**
53 * Initializes the hypvervisor related MM stuff without
54 * calling down to PGM.
55 *
56 * PGM is not initialized at this point, PGM relies on
57 * the heap to initialize.
58 *
59 * @returns VBox status.
60 */
61int mmR3HyperInit(PVM pVM)
62{
63 LogFlow(("mmR3HyperInit:\n"));
64
65 /*
66 * Decide Hypervisor mapping in the guest context
67 * And setup various hypervisor area and heap parameters.
68 */
69 pVM->mm.s.pvHyperAreaGC = (RTGCPTR)MM_HYPER_AREA_ADDRESS;
70 pVM->mm.s.cbHyperArea = MM_HYPER_AREA_MAX_SIZE;
71 AssertRelease(RT_ALIGN_T(pVM->mm.s.pvHyperAreaGC, 1 << X86_PD_SHIFT, RTGCPTR) == pVM->mm.s.pvHyperAreaGC);
72 Assert(pVM->mm.s.pvHyperAreaGC < 0xff000000);
73
74 uint32_t cbHyperHeap;
75 int rc = CFGMR3QueryU32(CFGMR3GetChild(CFGMR3GetRoot(pVM), "MM"), "cbHyperHeap", &cbHyperHeap);
76 if (rc == VERR_CFGM_NO_PARENT || rc == VERR_CFGM_VALUE_NOT_FOUND)
77 cbHyperHeap = 1280*_1K;
78 else if (VBOX_FAILURE(rc))
79 {
80 LogRel(("MM/cbHyperHeap query -> %Vrc\n", rc));
81 AssertRCReturn(rc, rc);
82 }
83 cbHyperHeap = RT_ALIGN_32(cbHyperHeap, PAGE_SIZE);
84
85 /*
86 * Allocate the hypervisor heap.
87 *
88 * (This must be done before we start adding memory to the
89 * hypervisor static area because lookup records are allocated from it.)
90 */
91 rc = mmR3HyperHeapCreate(pVM, cbHyperHeap, &pVM->mm.s.pHyperHeapHC);
92 if (VBOX_SUCCESS(rc))
93 {
94 /*
95 * Make a small head fence to fend of accidental sequential access.
96 */
97 MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
98
99 /*
100 * Map the VM structure into the hypervisor space.
101 */
102 RTGCPTR GCPtr;
103 rc = MMR3HyperMapPages(pVM, pVM, pVM->pVMR0, RT_ALIGN_Z(sizeof(VM), PAGE_SIZE) >> PAGE_SHIFT, pVM->paVMPagesR3, "VM", &GCPtr);
104 if (VBOX_SUCCESS(rc))
105 {
106 pVM->pVMGC = (RTGCPTR32)GCPtr;
107
108 /* Reserve a page for fencing. */
109 MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
110
111 /*
112 * Map the heap into the hypervisor space.
113 */
114 rc = mmR3HyperHeapMap(pVM, pVM->mm.s.pHyperHeapHC, &GCPtr);
115 if (VBOX_SUCCESS(rc))
116 {
117 pVM->mm.s.pHyperHeapGC = (RTGCPTR32)GCPtr;
118
119 /*
120 * Register info handlers.
121 */
122 DBGFR3InfoRegisterInternal(pVM, "hma", "Show the layout of the Hypervisor Memory Area.", mmR3HyperInfoHma);
123
124 LogFlow(("mmR3HyperInit: returns VINF_SUCCESS\n"));
125 return VINF_SUCCESS;
126 }
127 /* Caller will do proper cleanup. */
128 }
129 }
130
131 LogFlow(("mmR3HyperInit: returns %Vrc\n", rc));
132 return rc;
133}
134
135
136/**
137 * Finalizes the HMA mapping.
138 *
139 * This is called later during init, most (all) HMA allocations should be done
140 * by the time this function is called.
141 *
142 * @returns VBox status.
143 */
144MMR3DECL(int) MMR3HyperInitFinalize(PVM pVM)
145{
146 LogFlow(("MMR3HyperInitFinalize:\n"));
147
148 /*
149 * Adjust and create the HMA mapping.
150 */
151 while ((RTINT)pVM->mm.s.offHyperNextStatic + 64*_1K < (RTINT)pVM->mm.s.cbHyperArea - _4M)
152 pVM->mm.s.cbHyperArea -= _4M;
153 int rc = PGMR3MapPT(pVM, pVM->mm.s.pvHyperAreaGC, pVM->mm.s.cbHyperArea,
154 mmR3HyperRelocateCallback, NULL, "Hypervisor Memory Area");
155 if (VBOX_FAILURE(rc))
156 return rc;
157 pVM->mm.s.fPGMInitialized = true;
158
159 /*
160 * Do all the delayed mappings.
161 */
162 PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((uintptr_t)pVM->mm.s.pHyperHeapHC + pVM->mm.s.offLookupHyper);
163 for (;;)
164 {
165 RTGCPTR GCPtr = pVM->mm.s.pvHyperAreaGC + pLookup->off;
166 unsigned cPages = pLookup->cb >> PAGE_SHIFT;
167 switch (pLookup->enmType)
168 {
169 case MMLOOKUPHYPERTYPE_LOCKED:
170 rc = mmR3MapLocked(pVM, pLookup->u.Locked.pLockedMem, GCPtr, 0, cPages, 0);
171 break;
172
173 case MMLOOKUPHYPERTYPE_HCPHYS:
174 rc = PGMMap(pVM, GCPtr, pLookup->u.HCPhys.HCPhys, pLookup->cb, 0);
175 break;
176
177 case MMLOOKUPHYPERTYPE_GCPHYS:
178 {
179 const RTGCPHYS GCPhys = pLookup->u.GCPhys.GCPhys;
180 const size_t cb = pLookup->cb;
181 for (unsigned off = 0; off < cb; off += PAGE_SIZE)
182 {
183 RTHCPHYS HCPhys;
184 rc = PGMPhysGCPhys2HCPhys(pVM, GCPhys + off, &HCPhys);
185 if (VBOX_FAILURE(rc))
186 break;
187 rc = PGMMap(pVM, GCPtr + off, HCPhys, PAGE_SIZE, 0);
188 if (VBOX_FAILURE(rc))
189 break;
190 }
191 break;
192 }
193
194 case MMLOOKUPHYPERTYPE_MMIO2:
195 {
196 const RTGCPHYS offEnd = pLookup->u.MMIO2.off + pLookup->cb;
197 for (RTGCPHYS offCur = pLookup->u.MMIO2.off; offCur < offEnd; offCur += PAGE_SIZE)
198 {
199 RTHCPHYS HCPhys;
200 rc = PGMR3PhysMMIO2GetHCPhys(pVM, pLookup->u.MMIO2.pDevIns, pLookup->u.MMIO2.iRegion, offCur, &HCPhys);
201 if (RT_FAILURE(rc))
202 break;
203 rc = PGMMap(pVM, GCPtr + (offCur - pLookup->u.MMIO2.off), HCPhys, PAGE_SIZE, 0);
204 if (RT_FAILURE(rc))
205 break;
206 }
207 break;
208 }
209
210 case MMLOOKUPHYPERTYPE_DYNAMIC:
211 /* do nothing here since these are either fences or managed by someone else using PGM. */
212 break;
213
214 default:
215 AssertMsgFailed(("enmType=%d\n", pLookup->enmType));
216 break;
217 }
218
219 if (VBOX_FAILURE(rc))
220 {
221 AssertMsgFailed(("rc=%Vrc cb=%d GCPtr=%VGv enmType=%d pszDesc=%s\n",
222 rc, pLookup->cb, pLookup->enmType, pLookup->pszDesc));
223 return rc;
224 }
225
226 /* next */
227 if (pLookup->offNext == (int32_t)NIL_OFFSET)
228 break;
229 pLookup = (PMMLOOKUPHYPER)((uintptr_t)pLookup + pLookup->offNext);
230 }
231
232 LogFlow(("MMR3HyperInitFinalize: returns VINF_SUCCESS\n"));
233 return VINF_SUCCESS;
234}
235
236
237/**
238 * Callback function which will be called when PGM is trying to find
239 * a new location for the mapping.
240 *
241 * The callback is called in two modes, 1) the check mode and 2) the relocate mode.
242 * In 1) the callback should say if it objects to a suggested new location. If it
243 * accepts the new location, it is called again for doing it's relocation.
244 *
245 *
246 * @returns true if the location is ok.
247 * @returns false if another location should be found.
248 * @param pVM The VM handle.
249 * @param GCPtrOld The old virtual address.
250 * @param GCPtrNew The new virtual address.
251 * @param enmMode Used to indicate the callback mode.
252 * @param pvUser User argument. Ignored.
253 * @remark The return value is no a failure indicator, it's an acceptance
254 * indicator. Relocation can not fail!
255 */
256static DECLCALLBACK(bool) mmR3HyperRelocateCallback(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser)
257{
258 switch (enmMode)
259 {
260 /*
261 * Verify location - all locations are good for us.
262 */
263 case PGMRELOCATECALL_SUGGEST:
264 return true;
265
266 /*
267 * Execute the relocation.
268 */
269 case PGMRELOCATECALL_RELOCATE:
270 {
271 /*
272 * Accepted!
273 */
274 AssertMsg(GCPtrOld == pVM->mm.s.pvHyperAreaGC, ("GCPtrOld=%VGv pVM->mm.s.pvHyperAreaGC=%VGv\n", GCPtrOld, pVM->mm.s.pvHyperAreaGC));
275 Log(("Relocating the hypervisor from %VGv to %VGv\n", GCPtrOld, GCPtrNew));
276
277 /* relocate our selves and the VM structure. */
278 RTGCINTPTR offDelta = GCPtrNew - GCPtrOld;
279 pVM->pVMGC += offDelta;
280 pVM->mm.s.pvHyperAreaGC += offDelta;
281 pVM->mm.s.pHyperHeapGC += offDelta;
282 pVM->mm.s.pHyperHeapHC->pbHeapGC += offDelta;
283 pVM->mm.s.pHyperHeapHC->pVMGC += pVM->pVMGC;
284
285 /* relocate the rest. */
286 VMR3Relocate(pVM, offDelta);
287 return true;
288 }
289
290 default:
291 AssertMsgFailed(("Invalid relocation mode %d\n", enmMode));
292 }
293
294 return false;
295}
296
297
298/**
299 * Maps contiguous HC physical memory into the hypervisor region in the GC.
300 *
301 * @return VBox status code.
302 *
303 * @param pVM VM handle.
304 * @param pvHC Host context address of the memory. Must be page aligned!
305 * @param HCPhys Host context physical address of the memory to be mapped. Must be page aligned!
306 * @param cb Size of the memory. Will be rounded up to nearest page.
307 * @param pszDesc Description.
308 * @param pGCPtr Where to store the GC address.
309 */
310MMR3DECL(int) MMR3HyperMapHCPhys(PVM pVM, void *pvHC, RTHCPHYS HCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr)
311{
312 LogFlow(("MMR3HyperMapHCPhys: pvHc=%p HCPhys=%VHp cb=%d pszDesc=%p:{%s} pGCPtr=%p\n", pvHC, HCPhys, (int)cb, pszDesc, pszDesc, pGCPtr));
313
314 /*
315 * Validate input.
316 */
317 AssertReturn(RT_ALIGN_P(pvHC, PAGE_SIZE) == pvHC, VERR_INVALID_PARAMETER);
318 AssertReturn(RT_ALIGN_T(HCPhys, PAGE_SIZE, RTHCPHYS) == HCPhys, VERR_INVALID_PARAMETER);
319 AssertReturn(pszDesc && *pszDesc, VERR_INVALID_PARAMETER);
320
321 /*
322 * Add the memory to the hypervisor area.
323 */
324 uint32_t cbAligned = RT_ALIGN_32(cb, PAGE_SIZE);
325 AssertReturn(cbAligned >= cb, VERR_INVALID_PARAMETER);
326 RTGCPTR GCPtr;
327 PMMLOOKUPHYPER pLookup;
328 int rc = mmR3HyperMap(pVM, cbAligned, pszDesc, &GCPtr, &pLookup);
329 if (VBOX_SUCCESS(rc))
330 {
331 pLookup->enmType = MMLOOKUPHYPERTYPE_HCPHYS;
332 pLookup->u.HCPhys.pvHC = pvHC;
333 pLookup->u.HCPhys.HCPhys = HCPhys;
334
335 /*
336 * Update the page table.
337 */
338 if (pVM->mm.s.fPGMInitialized)
339 rc = PGMMap(pVM, GCPtr, HCPhys, cbAligned, 0);
340 if (VBOX_SUCCESS(rc))
341 *pGCPtr = GCPtr;
342 }
343 return rc;
344}
345
346
347/**
348 * Maps contiguous GC physical memory into the hypervisor region in the GC.
349 *
350 * @return VBox status code.
351 *
352 * @param pVM VM handle.
353 * @param GCPhys Guest context physical address of the memory to be mapped. Must be page aligned!
354 * @param cb Size of the memory. Will be rounded up to nearest page.
355 * @param pszDesc Mapping description.
356 * @param pGCPtr Where to store the GC address.
357 */
358MMR3DECL(int) MMR3HyperMapGCPhys(PVM pVM, RTGCPHYS GCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr)
359{
360 LogFlow(("MMR3HyperMapGCPhys: GCPhys=%VGp cb=%d pszDesc=%p:{%s} pGCPtr=%p\n", GCPhys, (int)cb, pszDesc, pszDesc, pGCPtr));
361
362 /*
363 * Validate input.
364 */
365 AssertReturn(RT_ALIGN_T(GCPhys, PAGE_SIZE, RTGCPHYS) == GCPhys, VERR_INVALID_PARAMETER);
366 AssertReturn(pszDesc && *pszDesc, VERR_INVALID_PARAMETER);
367
368 /*
369 * Add the memory to the hypervisor area.
370 */
371 cb = RT_ALIGN_Z(cb, PAGE_SIZE);
372 RTGCPTR GCPtr;
373 PMMLOOKUPHYPER pLookup;
374 int rc = mmR3HyperMap(pVM, cb, pszDesc, &GCPtr, &pLookup);
375 if (VBOX_SUCCESS(rc))
376 {
377 pLookup->enmType = MMLOOKUPHYPERTYPE_GCPHYS;
378 pLookup->u.GCPhys.GCPhys = GCPhys;
379
380 /*
381 * Update the page table.
382 */
383 for (unsigned off = 0; off < cb; off += PAGE_SIZE)
384 {
385 RTHCPHYS HCPhys;
386 rc = PGMPhysGCPhys2HCPhys(pVM, GCPhys + off, &HCPhys);
387 AssertRC(rc);
388 if (VBOX_FAILURE(rc))
389 {
390 AssertMsgFailed(("rc=%Vrc GCPhys=%VGv off=%#x %s\n", rc, GCPhys, off, pszDesc));
391 break;
392 }
393 if (pVM->mm.s.fPGMInitialized)
394 {
395 rc = PGMMap(pVM, GCPtr + off, HCPhys, PAGE_SIZE, 0);
396 AssertRC(rc);
397 if (VBOX_FAILURE(rc))
398 {
399 AssertMsgFailed(("rc=%Vrc GCPhys=%VGv off=%#x %s\n", rc, GCPhys, off, pszDesc));
400 break;
401 }
402 }
403 }
404
405 if (VBOX_SUCCESS(rc) && pGCPtr)
406 *pGCPtr = GCPtr;
407 }
408 return rc;
409}
410
411
412/**
413 * Maps a portion of an MMIO2 region into the hypervisor region.
414 *
415 * Callers of this API must never deregister the MMIO2 region before the
416 * VM is powered off. If this becomes a requirement MMR3HyperUnmapMMIO2
417 * API will be needed to perform cleanups.
418 *
419 * @return VBox status code.
420 *
421 * @param pVM Pointer to the shared VM structure.
422 * @param pDevIns The device owning the MMIO2 memory.
423 * @param iRegion The region.
424 * @param off The offset into the region. Will be rounded down to closest page boundrary.
425 * @param cb The number of bytes to map. Will be rounded up to the closest page boundrary.
426 * @param pszDesc Mapping description.
427 * @param pRCPtr Where to store the RC address.
428 */
429MMR3DECL(int) MMR3HyperMapMMIO2(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb,
430 const char *pszDesc, PRTRCPTR pRCPtr)
431{
432 LogFlow(("MMR3HyperMapMMIO2: pDevIns=%p iRegion=%#x off=%VGp cb=%VGp pszDesc=%p:{%s} pRCPtr=%p\n",
433 pDevIns, iRegion, off, cb, pszDesc, pszDesc, pRCPtr));
434 int rc;
435
436 /*
437 * Validate input.
438 */
439 AssertReturn(pszDesc && *pszDesc, VERR_INVALID_PARAMETER);
440 AssertReturn(off + cb > off, VERR_INVALID_PARAMETER);
441 uint32_t const offPage = off & PAGE_OFFSET_MASK;
442 off &= ~(RTGCPHYS)PAGE_OFFSET_MASK;
443 cb += offPage;
444 cb = RT_ALIGN_Z(cb, PAGE_SIZE);
445 const RTGCPHYS offEnd = off + cb;
446 AssertReturn(offEnd > off, VERR_INVALID_PARAMETER);
447 for (RTGCPHYS offCur = off; offCur < offEnd; offCur += PAGE_SIZE)
448 {
449 RTHCPHYS HCPhys;
450 rc = PGMR3PhysMMIO2GetHCPhys(pVM, pDevIns, iRegion, offCur, &HCPhys);
451 AssertMsgRCReturn(rc, ("rc=%Rrc - iRegion=%d off=%RGp\n", rc, iRegion, off), rc);
452 }
453
454 /*
455 * Add the memory to the hypervisor area.
456 */
457 RTGCPTR GCPtr;
458 PMMLOOKUPHYPER pLookup;
459 rc = mmR3HyperMap(pVM, cb, pszDesc, &GCPtr, &pLookup);
460 if (VBOX_SUCCESS(rc))
461 {
462 pLookup->enmType = MMLOOKUPHYPERTYPE_MMIO2;
463 pLookup->u.MMIO2.pDevIns = pDevIns;
464 pLookup->u.MMIO2.iRegion = iRegion;
465 pLookup->u.MMIO2.off = off;
466
467 /*
468 * Update the page table.
469 */
470 if (pVM->mm.s.fPGMInitialized)
471 {
472 for (RTGCPHYS offCur = off; offCur < offEnd; offCur += PAGE_SIZE)
473 {
474 RTHCPHYS HCPhys;
475 rc = PGMR3PhysMMIO2GetHCPhys(pVM, pDevIns, iRegion, offCur, &HCPhys);
476 AssertRCReturn(rc, VERR_INTERNAL_ERROR);
477 rc = PGMMap(pVM, GCPtr + (offCur - off), HCPhys, PAGE_SIZE, 0);
478 if (VBOX_FAILURE(rc))
479 {
480 AssertMsgFailed(("rc=%Vrc offCur=%RGp %s\n", rc, offCur, pszDesc));
481 break;
482 }
483 }
484 }
485
486 if (VBOX_SUCCESS(rc))
487 {
488 GCPtr |= offPage;
489 *pRCPtr = GCPtr;
490 AssertLogRelReturn(*pRCPtr == GCPtr, VERR_INTERNAL_ERROR);
491 }
492 }
493 return rc;
494}
495
496
497
498
499/**
500 * Locks and Maps HC virtual memory into the hypervisor region in the GC.
501 *
502 * @return VBox status code.
503 *
504 * @param pVM VM handle.
505 * @param pvHC Host context address of the memory (may be not page aligned).
506 * @param cb Size of the memory. Will be rounded up to nearest page.
507 * @param fFree Set this if MM is responsible for freeing the memory using SUPPageFree.
508 * @param pszDesc Mapping description.
509 * @param pGCPtr Where to store the GC address corresponding to pvHC.
510 */
511MMR3DECL(int) MMR3HyperMapHCRam(PVM pVM, void *pvHC, size_t cb, bool fFree, const char *pszDesc, PRTGCPTR pGCPtr)
512{
513 LogFlow(("MMR3HyperMapHCRam: pvHc=%p cb=%d fFree=%d pszDesc=%p:{%s} pGCPtr=%p\n", pvHC, (int)cb, fFree, pszDesc, pszDesc, pGCPtr));
514
515 /*
516 * Validate input.
517 */
518 if ( !pvHC
519 || cb <= 0
520 || !pszDesc
521 || !*pszDesc)
522 {
523 AssertMsgFailed(("Invalid parameter\n"));
524 return VERR_INVALID_PARAMETER;
525 }
526
527 /*
528 * Page align address and size.
529 */
530 void *pvHCPage = (void *)((uintptr_t)pvHC & PAGE_BASE_HC_MASK);
531 cb += (uintptr_t)pvHC & PAGE_OFFSET_MASK;
532 cb = RT_ALIGN_Z(cb, PAGE_SIZE);
533
534 /*
535 * Add the memory to the hypervisor area.
536 */
537 RTGCPTR GCPtr;
538 PMMLOOKUPHYPER pLookup;
539 int rc = mmR3HyperMap(pVM, cb, pszDesc, &GCPtr, &pLookup);
540 if (VBOX_SUCCESS(rc))
541 {
542 /*
543 * Lock the heap memory and tell PGM about the locked pages.
544 */
545 PMMLOCKEDMEM pLockedMem;
546 rc = mmR3LockMem(pVM, pvHCPage, cb, fFree ? MM_LOCKED_TYPE_HYPER : MM_LOCKED_TYPE_HYPER_NOFREE, &pLockedMem, false /* fSilentFailure */);
547 if (VBOX_SUCCESS(rc))
548 {
549 /* map the stuff into guest address space. */
550 if (pVM->mm.s.fPGMInitialized)
551 rc = mmR3MapLocked(pVM, pLockedMem, GCPtr, 0, ~(size_t)0, 0);
552 if (VBOX_SUCCESS(rc))
553 {
554 pLookup->enmType = MMLOOKUPHYPERTYPE_LOCKED;
555 pLookup->u.Locked.pvHC = pvHC;
556 pLookup->u.Locked.pvR0 = NIL_RTR0PTR;
557 pLookup->u.Locked.pLockedMem = pLockedMem;
558
559 /* done. */
560 GCPtr |= (uintptr_t)pvHC & PAGE_OFFSET_MASK;
561 *pGCPtr = GCPtr;
562 return rc;
563 }
564 /* Don't care about failure clean, we're screwed if this fails anyway. */
565 }
566 }
567
568 return rc;
569}
570
571
572/**
573 * Maps locked R3 virtual memory into the hypervisor region in the GC.
574 *
575 * @return VBox status code.
576 *
577 * @param pVM VM handle.
578 * @param pvR3 The ring-3 address of the memory, must be page aligned.
579 * @param pvR0 The ring-0 address of the memory, must be page aligned. (optional)
580 * @param cPages The number of pages.
581 * @param paPages The page descriptors.
582 * @param pszDesc Mapping description.
583 * @param pGCPtr Where to store the GC address corresponding to pvHC.
584 */
585MMR3DECL(int) MMR3HyperMapPages(PVM pVM, void *pvR3, RTR0PTR pvR0, size_t cPages, PCSUPPAGE paPages, const char *pszDesc, PRTGCPTR pGCPtr)
586{
587 LogFlow(("MMR3HyperMapPages: pvR3=%p pvR0=%p cPages=%zu paPages=%p pszDesc=%p:{%s} pGCPtr=%p\n",
588 pvR3, pvR0, cPages, paPages, pszDesc, pszDesc, pGCPtr));
589
590 /*
591 * Validate input.
592 */
593 AssertPtrReturn(pvR3, VERR_INVALID_POINTER);
594 AssertPtrReturn(paPages, VERR_INVALID_POINTER);
595 AssertReturn(cPages > 0, VERR_INVALID_PARAMETER);
596 AssertReturn(cPages < 1024, VERR_INVALID_PARAMETER);
597 AssertPtrReturn(pszDesc, VERR_INVALID_POINTER);
598 AssertReturn(*pszDesc, VERR_INVALID_PARAMETER);
599 AssertPtrReturn(pGCPtr, VERR_INVALID_PARAMETER);
600
601 /*
602 * Add the memory to the hypervisor area.
603 */
604 RTGCPTR GCPtr;
605 PMMLOOKUPHYPER pLookup;
606 int rc = mmR3HyperMap(pVM, cPages << PAGE_SHIFT, pszDesc, &GCPtr, &pLookup);
607 if (VBOX_SUCCESS(rc))
608 {
609 /*
610 * Create a locked memory record and tell PGM about this.
611 */
612 PMMLOCKEDMEM pLockedMem = (PMMLOCKEDMEM)MMR3HeapAlloc(pVM, MM_TAG_MM, RT_OFFSETOF(MMLOCKEDMEM, aPhysPages[cPages]));
613 if (pLockedMem)
614 {
615 pLockedMem->pv = pvR3;
616 pLockedMem->cb = cPages << PAGE_SHIFT;
617 pLockedMem->eType = MM_LOCKED_TYPE_HYPER_PAGES;
618 memset(&pLockedMem->u, 0, sizeof(pLockedMem->u));
619 for (size_t i = 0; i < cPages; i++)
620 {
621 AssertReleaseReturn(paPages[i].Phys != 0 && paPages[i].Phys != NIL_RTHCPHYS && !(paPages[i].Phys & PAGE_OFFSET_MASK), VERR_INTERNAL_ERROR);
622 pLockedMem->aPhysPages[i].Phys = paPages[i].Phys;
623 pLockedMem->aPhysPages[i].uReserved = (RTHCUINTPTR)pLockedMem;
624 }
625
626 /* map the stuff into guest address space. */
627 if (pVM->mm.s.fPGMInitialized)
628 rc = mmR3MapLocked(pVM, pLockedMem, GCPtr, 0, ~(size_t)0, 0);
629 if (VBOX_SUCCESS(rc))
630 {
631 pLookup->enmType = MMLOOKUPHYPERTYPE_LOCKED;
632 pLookup->u.Locked.pvHC = pvR3;
633 pLookup->u.Locked.pvR0 = pvR0;
634 pLookup->u.Locked.pLockedMem = pLockedMem;
635
636 /* done. */
637 *pGCPtr = GCPtr;
638 return rc;
639 }
640 /* Don't care about failure clean, we're screwed if this fails anyway. */
641 }
642 }
643
644 return rc;
645}
646
647
648/**
649 * Reserves a hypervisor memory area.
650 * Most frequent usage is fence pages and dynamically mappings like the guest PD and PDPT.
651 *
652 * @return VBox status code.
653 *
654 * @param pVM VM handle.
655 * @param cb Size of the memory. Will be rounded up to nearest page.
656 * @param pszDesc Mapping description.
657 * @param pGCPtr Where to store the assigned GC address. Optional.
658 */
659MMR3DECL(int) MMR3HyperReserve(PVM pVM, unsigned cb, const char *pszDesc, PRTGCPTR pGCPtr)
660{
661 LogFlow(("MMR3HyperMapHCRam: cb=%d pszDesc=%p:{%s} pGCPtr=%p\n", (int)cb, pszDesc, pszDesc, pGCPtr));
662
663 /*
664 * Validate input.
665 */
666 if ( cb <= 0
667 || !pszDesc
668 || !*pszDesc)
669 {
670 AssertMsgFailed(("Invalid parameter\n"));
671 return VERR_INVALID_PARAMETER;
672 }
673
674 /*
675 * Add the memory to the hypervisor area.
676 */
677 RTGCPTR GCPtr;
678 PMMLOOKUPHYPER pLookup;
679 int rc = mmR3HyperMap(pVM, cb, pszDesc, &GCPtr, &pLookup);
680 if (VBOX_SUCCESS(rc))
681 {
682 pLookup->enmType = MMLOOKUPHYPERTYPE_DYNAMIC;
683 if (pGCPtr)
684 *pGCPtr = GCPtr;
685 return VINF_SUCCESS;
686 }
687 return rc;
688}
689
690
691/**
692 * Adds memory to the hypervisor memory arena.
693 *
694 * @return VBox status code.
695 * @param pVM The VM handle.
696 * @param cb Size of the memory. Will be rounded up to neares page.
697 * @param pszDesc The description of the memory.
698 * @param pGCPtr Where to store the GC address.
699 * @param ppLookup Where to store the pointer to the lookup record.
700 * @remark We assume the threading structure of VBox imposes natural
701 * serialization of most functions, this one included.
702 */
703static int mmR3HyperMap(PVM pVM, const size_t cb, const char *pszDesc, PRTGCPTR pGCPtr, PMMLOOKUPHYPER *ppLookup)
704{
705 /*
706 * Validate input.
707 */
708 const uint32_t cbAligned = RT_ALIGN(cb, PAGE_SIZE);
709 AssertReturn(cbAligned >= cb, VERR_INVALID_PARAMETER);
710 if (pVM->mm.s.offHyperNextStatic + cbAligned >= pVM->mm.s.cbHyperArea) /* don't use the last page, it's a fence. */
711 {
712 AssertMsgFailed(("Out of static mapping space in the HMA! offHyperAreaGC=%x cbAligned=%x\n",
713 pVM->mm.s.offHyperNextStatic, cbAligned));
714 return VERR_NO_MEMORY;
715 }
716
717 /*
718 * Allocate lookup record.
719 */
720 PMMLOOKUPHYPER pLookup;
721 int rc = MMHyperAlloc(pVM, sizeof(*pLookup), 1, MM_TAG_MM, (void **)&pLookup);
722 if (VBOX_SUCCESS(rc))
723 {
724 /*
725 * Initialize it and insert it.
726 */
727 pLookup->offNext = pVM->mm.s.offLookupHyper;
728 pLookup->cb = cbAligned;
729 pLookup->off = pVM->mm.s.offHyperNextStatic;
730 pVM->mm.s.offLookupHyper = (char *)pLookup - (char *)pVM->mm.s.pHyperHeapHC;
731 if (pLookup->offNext != (int32_t)NIL_OFFSET)
732 pLookup->offNext -= pVM->mm.s.offLookupHyper;
733 pLookup->enmType = MMLOOKUPHYPERTYPE_INVALID;
734 memset(&pLookup->u, 0xff, sizeof(pLookup->u));
735 pLookup->pszDesc = pszDesc;
736
737 /* Mapping. */
738 *pGCPtr = pVM->mm.s.pvHyperAreaGC + pVM->mm.s.offHyperNextStatic;
739 pVM->mm.s.offHyperNextStatic += cbAligned;
740
741 /* Return pointer. */
742 *ppLookup = pLookup;
743 }
744
745 AssertRC(rc);
746 LogFlow(("mmR3HyperMap: returns %Vrc *pGCPtr=%VGv\n", rc, *pGCPtr));
747 return rc;
748}
749
750
751/**
752 * Allocates a new heap.
753 *
754 * @returns VBox status code.
755 * @param pVM The VM handle.
756 * @param cb The size of the new heap.
757 * @param ppHeap Where to store the heap pointer on successful return.
758 */
759static int mmR3HyperHeapCreate(PVM pVM, const size_t cb, PMMHYPERHEAP *ppHeap)
760{
761 /*
762 * Allocate the hypervisor heap.
763 */
764 const uint32_t cbAligned = RT_ALIGN_Z(cb, PAGE_SIZE);
765 AssertReturn(cbAligned >= cb, VERR_INVALID_PARAMETER);
766 void *pv;
767 int rc = SUPPageAlloc(cbAligned >> PAGE_SHIFT, &pv);
768 if (VBOX_SUCCESS(rc))
769 {
770 /*
771 * Initialize the heap and first free chunk.
772 */
773 PMMHYPERHEAP pHeap = (PMMHYPERHEAP)pv;
774 pHeap->u32Magic = MMHYPERHEAP_MAGIC;
775 pHeap->pVMHC = pVM;
776 pHeap->pVMGC = pVM->pVMGC;
777 pHeap->pbHeapHC = (uint8_t *)pHeap + MMYPERHEAP_HDR_SIZE;
778 //pHeap->pbHeapGC = 0; // set by mmR3HyperHeapMap()
779 pHeap->cbHeap = cbAligned - MMYPERHEAP_HDR_SIZE;
780 pHeap->cbFree = pHeap->cbHeap - sizeof(MMHYPERCHUNK);
781 //pHeap->offFreeHead = 0;
782 //pHeap->offFreeTail = 0;
783 pHeap->offPageAligned = pHeap->cbHeap;
784 //pHeap->HyperHeapStatTree = 0;
785
786 PMMHYPERCHUNKFREE pFree = (PMMHYPERCHUNKFREE)pHeap->pbHeapHC;
787 pFree->cb = pHeap->cbFree;
788 //pFree->core.offNext = 0;
789 MMHYPERCHUNK_SET_TYPE(&pFree->core, MMHYPERCHUNK_FLAGS_FREE);
790 pFree->core.offHeap = -(int32_t)MMYPERHEAP_HDR_SIZE;
791 //pFree->offNext = 0;
792 //pFree->offPrev = 0;
793
794 STAMR3Register(pVM, &pHeap->cbHeap, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, "/MM/HyperHeap/cbHeap", STAMUNIT_BYTES, "The heap size.");
795 STAMR3Register(pVM, &pHeap->cbFree, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, "/MM/HyperHeap/cbFree", STAMUNIT_BYTES, "The free space.");
796
797 *ppHeap = pHeap;
798 return VINF_SUCCESS;
799 }
800 AssertMsgFailed(("SUPPageAlloc(%d,) -> %Vrc\n", cbAligned >> PAGE_SHIFT, rc));
801
802 *ppHeap = NULL;
803 return rc;
804}
805
806
807/**
808 * Allocates a new heap.
809 */
810static int mmR3HyperHeapMap(PVM pVM, PMMHYPERHEAP pHeap, PRTGCPTR ppHeapGC)
811{
812 int rc = MMR3HyperMapHCRam(pVM, pHeap, pHeap->cbHeap + MMYPERHEAP_HDR_SIZE, true, "Heap", ppHeapGC);
813 if (VBOX_SUCCESS(rc))
814 {
815 pHeap->pVMGC = pVM->pVMGC;
816 pHeap->pbHeapGC = *ppHeapGC + MMYPERHEAP_HDR_SIZE;
817 /* Reserve a page for fencing. */
818 MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
819 }
820 return rc;
821}
822
823
824#if 0
825/**
826 * Destroys a heap.
827 */
828static int mmR3HyperHeapDestroy(PVM pVM, PMMHYPERHEAP pHeap)
829{
830 /* all this is dealt with when unlocking and freeing locked memory. */
831}
832#endif
833
834
835/**
836 * Allocates memory in the Hypervisor (GC VMM) area which never will
837 * be freed and doesn't have any offset based relation to other heap blocks.
838 *
839 * The latter means that two blocks allocated by this API will not have the
840 * same relative position to each other in GC and HC. In short, never use
841 * this API for allocating nodes for an offset based AVL tree!
842 *
843 * The returned memory is of course zeroed.
844 *
845 * @returns VBox status code.
846 * @param pVM The VM to operate on.
847 * @param cb Number of bytes to allocate.
848 * @param uAlignment Required memory alignment in bytes.
849 * Values are 0,8,16,32 and PAGE_SIZE.
850 * 0 -> default alignment, i.e. 8 bytes.
851 * @param enmTag The statistics tag.
852 * @param ppv Where to store the address to the allocated
853 * memory.
854 * @remark This is assumed not to be used at times when serialization is required.
855 */
856MMDECL(int) MMR3HyperAllocOnceNoRel(PVM pVM, size_t cb, unsigned uAlignment, MMTAG enmTag, void **ppv)
857{
858 AssertMsg(cb >= 8, ("Hey! Do you really mean to allocate less than 8 bytes?! cb=%d\n", cb));
859
860 /*
861 * Choose between allocating a new chunk of HMA memory
862 * and the heap. We will only do BIG allocations from HMA.
863 */
864 if ( cb < _64K
865 && ( uAlignment != PAGE_SIZE
866 || cb < 48*_1K))
867 {
868 int rc = MMHyperAlloc(pVM, cb, uAlignment, enmTag, ppv);
869 if ( rc != VERR_MM_HYPER_NO_MEMORY
870 || cb <= 8*_1K)
871 {
872 Log2(("MMR3HyperAllocOnceNoRel: cb=%#zx uAlignment=%#x returns %Rrc and *ppv=%p\n",
873 cb, uAlignment, rc, *ppv));
874 return rc;
875 }
876 }
877
878 /*
879 * Validate alignment.
880 */
881 switch (uAlignment)
882 {
883 case 0:
884 case 8:
885 case 16:
886 case 32:
887 case PAGE_SIZE:
888 break;
889 default:
890 AssertMsgFailed(("Invalid alignment %u\n", uAlignment));
891 return VERR_INVALID_PARAMETER;
892 }
893
894 /*
895 * Allocate the pages and the HMA space.
896 */
897 cb = RT_ALIGN(cb, PAGE_SIZE);
898 void *pvPages;
899 int rc = SUPPageAlloc(cb >> PAGE_SHIFT, &pvPages);
900 if (VBOX_SUCCESS(rc))
901 {
902 RTGCPTR GCPtr;
903 rc = MMR3HyperMapHCRam(pVM, pvPages, cb, true, mmR3GetTagName(enmTag), &GCPtr);
904 if (VBOX_SUCCESS(rc))
905 {
906 *ppv = pvPages;
907 Log2(("MMR3HyperAllocOnceNoRel: cb=%#x uAlignment=%#x returns VINF_SUCCESS and *ppv=%p\n",
908 cb, uAlignment, *ppv));
909 return rc;
910 }
911 AssertMsgFailed(("Failed to allocate %zd bytes! %Rrc\n", cb, rc));
912 SUPPageFree(pvPages, cb >> PAGE_SHIFT);
913
914 /*
915 * HACK ALERT! Try allocate it off the heap so that we don't freak
916 * out during vga/vmmdev mmio2 allocation with certain ram sizes.
917 */
918 /** @todo make a proper fix for this so we will never end up in this kind of situation! */
919 Log(("MMR3HyperAllocOnceNoRel: MMR3HyperMapHCRam failed with rc=%Rrc, try MMHyperAlloc(,%#d,,) instead\n", rc, cb));
920 int rc2 = MMHyperAlloc(pVM, cb, uAlignment, enmTag, ppv);
921 if (RT_SUCCESS(rc2))
922 {
923 Log2(("MMR3HyperAllocOnceNoRel: cb=%#x uAlignment=%#x returns %Rrc and *ppv=%p\n",
924 cb, uAlignment, rc, *ppv));
925 return rc;
926 }
927 }
928 else
929 AssertMsgFailed(("Failed to allocate %zd bytes! %Rrc\n", cb, rc));
930
931 if (rc == VERR_NO_MEMORY)
932 rc = VERR_MM_HYPER_NO_MEMORY;
933 LogRel(("MMR3HyperAllocOnceNoRel: cb=%#zx uAlignment=%#x returns %Rrc\n", cb, uAlignment, rc));
934 return rc;
935}
936
937
938/**
939 * Convert hypervisor HC virtual address to HC physical address.
940 *
941 * @returns HC physical address.
942 * @param pVM VM Handle
943 * @param pvHC Host context physical address.
944 */
945MMR3DECL(RTHCPHYS) MMR3HyperHCVirt2HCPhys(PVM pVM, void *pvHC)
946{
947 PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((char*)pVM->mm.s.pHyperHeapHC + pVM->mm.s.offLookupHyper);
948 for (;;)
949 {
950 switch (pLookup->enmType)
951 {
952 case MMLOOKUPHYPERTYPE_LOCKED:
953 {
954 unsigned off = (char *)pvHC - (char *)pLookup->u.Locked.pvHC;
955 if (off < pLookup->cb)
956 return (pLookup->u.Locked.pLockedMem->aPhysPages[off >> PAGE_SHIFT].Phys & X86_PTE_PAE_PG_MASK) | (off & PAGE_OFFSET_MASK);
957 break;
958 }
959
960 case MMLOOKUPHYPERTYPE_HCPHYS:
961 {
962 unsigned off = (char *)pvHC - (char *)pLookup->u.HCPhys.pvHC;
963 if (off < pLookup->cb)
964 return pLookup->u.HCPhys.HCPhys + off;
965 break;
966 }
967
968 case MMLOOKUPHYPERTYPE_GCPHYS:
969 case MMLOOKUPHYPERTYPE_MMIO2:
970 case MMLOOKUPHYPERTYPE_DYNAMIC:
971 /* can (or don't want to) convert these kind of records. */
972 break;
973
974 default:
975 AssertMsgFailed(("enmType=%d\n", pLookup->enmType));
976 break;
977 }
978
979 /* next */
980 if ((unsigned)pLookup->offNext == NIL_OFFSET)
981 break;
982 pLookup = (PMMLOOKUPHYPER)((char *)pLookup + pLookup->offNext);
983 }
984
985 AssertMsgFailed(("pvHC=%p is not inside the hypervisor memory area!\n", pvHC));
986 return NIL_RTHCPHYS;
987}
988
989
990#if 0 /* unused, not implemented */
991/**
992 * Convert hypervisor HC physical address to HC virtual address.
993 *
994 * @returns HC virtual address.
995 * @param pVM VM Handle
996 * @param HCPhys Host context physical address.
997 */
998MMR3DECL(void *) MMR3HyperHCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys)
999{
1000 void *pv;
1001 int rc = MMR3HyperHCPhys2HCVirtEx(pVM, HCPhys, &pv);
1002 if (VBOX_SUCCESS(rc))
1003 return pv;
1004 AssertMsgFailed(("Invalid address HCPhys=%x rc=%d\n", HCPhys, rc));
1005 return NULL;
1006}
1007
1008
1009/**
1010 * Convert hypervisor HC physical address to HC virtual address.
1011 *
1012 * @returns VBox status.
1013 * @param pVM VM Handle
1014 * @param HCPhys Host context physical address.
1015 * @param ppv Where to store the HC virtual address.
1016 */
1017MMR3DECL(int) MMR3HyperHCPhys2HCVirtEx(PVM pVM, RTHCPHYS HCPhys, void **ppv)
1018{
1019 /*
1020 * Linear search.
1021 */
1022 /** @todo implement when actually used. */
1023 return VERR_INVALID_POINTER;
1024}
1025#endif /* unused, not implemented */
1026
1027
1028/**
1029 * Read hypervisor memory from GC virtual address.
1030 *
1031 * @returns VBox status.
1032 * @param pVM VM handle.
1033 * @param pvDst Destination address (HC of course).
1034 * @param GCPtr GC virtual address.
1035 * @param cb Number of bytes to read.
1036 */
1037MMR3DECL(int) MMR3HyperReadGCVirt(PVM pVM, void *pvDst, RTGCPTR GCPtr, size_t cb)
1038{
1039 if (GCPtr - pVM->mm.s.pvHyperAreaGC >= pVM->mm.s.cbHyperArea)
1040 return VERR_INVALID_PARAMETER;
1041 return PGMR3MapRead(pVM, pvDst, GCPtr, cb);
1042}
1043
1044
1045/**
1046 * Info handler for 'hma', it dumps the list of lookup records for the hypervisor memory area.
1047 *
1048 * @param pVM The VM handle.
1049 * @param pHlp Callback functions for doing output.
1050 * @param pszArgs Argument string. Optional and specific to the handler.
1051 */
1052static DECLCALLBACK(void) mmR3HyperInfoHma(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs)
1053{
1054 pHlp->pfnPrintf(pHlp, "Hypervisor Memory Area (HMA) Layout: Base %VGv, 0x%08x bytes\n",
1055 pVM->mm.s.pvHyperAreaGC, pVM->mm.s.cbHyperArea);
1056
1057 PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((char*)pVM->mm.s.pHyperHeapHC + pVM->mm.s.offLookupHyper);
1058 for (;;)
1059 {
1060 switch (pLookup->enmType)
1061 {
1062 case MMLOOKUPHYPERTYPE_LOCKED:
1063 pHlp->pfnPrintf(pHlp, "%VGv-%VGv %VHv LOCKED %-*s %s\n",
1064 pLookup->off + pVM->mm.s.pvHyperAreaGC,
1065 pLookup->off + pVM->mm.s.pvHyperAreaGC + pLookup->cb,
1066 pLookup->u.Locked.pvHC,
1067 sizeof(RTHCPTR) * 2,
1068 pLookup->u.Locked.pLockedMem->eType == MM_LOCKED_TYPE_HYPER_NOFREE ? "nofree"
1069 : pLookup->u.Locked.pLockedMem->eType == MM_LOCKED_TYPE_HYPER ? "autofree"
1070 : pLookup->u.Locked.pLockedMem->eType == MM_LOCKED_TYPE_HYPER_PAGES ? "pages"
1071 : pLookup->u.Locked.pLockedMem->eType == MM_LOCKED_TYPE_PHYS ? "gstphys"
1072 : "??",
1073 pLookup->pszDesc);
1074 break;
1075
1076 case MMLOOKUPHYPERTYPE_HCPHYS:
1077 pHlp->pfnPrintf(pHlp, "%VGv-%VGv %VHv HCPHYS %VHp %s\n",
1078 pLookup->off + pVM->mm.s.pvHyperAreaGC,
1079 pLookup->off + pVM->mm.s.pvHyperAreaGC + pLookup->cb,
1080 pLookup->u.HCPhys.pvHC, pLookup->u.HCPhys.HCPhys,
1081 pLookup->pszDesc);
1082 break;
1083
1084 case MMLOOKUPHYPERTYPE_GCPHYS:
1085 pHlp->pfnPrintf(pHlp, "%VGv-%VGv %*s GCPHYS %VGp%*s %s\n",
1086 pLookup->off + pVM->mm.s.pvHyperAreaGC,
1087 pLookup->off + pVM->mm.s.pvHyperAreaGC + pLookup->cb,
1088 sizeof(RTHCPTR) * 2, "",
1089 pLookup->u.GCPhys.GCPhys, RT_ABS(sizeof(RTHCPHYS) - sizeof(RTGCPHYS)) * 2, "",
1090 pLookup->pszDesc);
1091 break;
1092
1093 case MMLOOKUPHYPERTYPE_MMIO2:
1094 pHlp->pfnPrintf(pHlp, "%VGv-%VGv %*s MMIO2 %VGp%*s %s\n",
1095 pLookup->off + pVM->mm.s.pvHyperAreaGC,
1096 pLookup->off + pVM->mm.s.pvHyperAreaGC + pLookup->cb,
1097 sizeof(RTHCPTR) * 2, "",
1098 pLookup->u.MMIO2.off, RT_ABS(sizeof(RTHCPHYS) - sizeof(RTGCPHYS)) * 2, "",
1099 pLookup->pszDesc);
1100 break;
1101
1102 case MMLOOKUPHYPERTYPE_DYNAMIC:
1103 pHlp->pfnPrintf(pHlp, "%VGv-%VGv %*s DYNAMIC %*s %s\n",
1104 pLookup->off + pVM->mm.s.pvHyperAreaGC,
1105 pLookup->off + pVM->mm.s.pvHyperAreaGC + pLookup->cb,
1106 sizeof(RTHCPTR) * 2, "",
1107 sizeof(RTHCPTR) * 2, "",
1108 pLookup->pszDesc);
1109 break;
1110
1111 default:
1112 AssertMsgFailed(("enmType=%d\n", pLookup->enmType));
1113 break;
1114 }
1115
1116 /* next */
1117 if ((unsigned)pLookup->offNext == NIL_OFFSET)
1118 break;
1119 pLookup = (PMMLOOKUPHYPER)((char *)pLookup + pLookup->offNext);
1120 }
1121}
1122
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