MMAll.cpp revision 1c94c0a63ba68be1a7b2c640e70d7a06464e4fca
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync * MM - Memory Monitor(/Manager) - Any Context.
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync * available from http://www.virtualbox.org. This file is free software;
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync * you can redistribute it and/or modify it under the terms of the GNU
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync * General Public License (GPL) as published by the Free Software
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * additional information or have any questions.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync/*******************************************************************************
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync* Header Files *
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync*******************************************************************************/
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Lookup a host context ring-3 address.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @returns Pointer to the corresponding lookup record.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @returns NULL on failure.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param pVM The VM handle.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param R3Ptr The host context ring-3 address to lookup.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param poff Where to store the offset into the HMA memory chunk.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsyncDECLINLINE(PMMLOOKUPHYPER) mmHyperLookupR3(PVM pVM, RTR3PTR R3Ptr, uint32_t *poff)
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync /** @todo cache last lookup this stuff ain't cheap! */
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper);
0a249d1fff442e1f0f29959e2a0da91d024554fcvboxsync const uint32_t off = (RTR3UINTPTR)R3Ptr - (RTR3UINTPTR)pLookup->u.Locked.pvHC;
0a249d1fff442e1f0f29959e2a0da91d024554fcvboxsync const uint32_t off = (RTR3UINTPTR)R3Ptr - (RTR3UINTPTR)pLookup->u.HCPhys.pvHC;
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync case MMLOOKUPHYPERTYPE_GCPHYS: /* (for now we'll not allow these kind of conversions) */
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync AssertMsgFailed(("enmType=%d\n", pLookup->enmType));
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync pLookup = (PMMLOOKUPHYPER)((char *)pLookup + pLookup->offNext);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync AssertMsgFailed(("R3Ptr=%p is not inside the hypervisor memory area!\n", R3Ptr));
be75da5235e6ed26c171a06f0a7d0e718bd7f60bvboxsync * Lookup a host context ring-0 address.
1ab75e3bb644b29eb1cadd4f6075147012c22757vboxsync * @returns Pointer to the corresponding lookup record.
ebd3c63c626c8039fdb7b95570390699333a7072vboxsync * @returns NULL on failure.
be75da5235e6ed26c171a06f0a7d0e718bd7f60bvboxsync * @param pVM The VM handle.
be75da5235e6ed26c171a06f0a7d0e718bd7f60bvboxsync * @param R0Ptr The host context ring-0 address to lookup.
be75da5235e6ed26c171a06f0a7d0e718bd7f60bvboxsync * @param poff Where to store the offset into the HMA memory chunk.
be75da5235e6ed26c171a06f0a7d0e718bd7f60bvboxsyncDECLINLINE(PMMLOOKUPHYPER) mmHyperLookupR0(PVM pVM, RTR0PTR R0Ptr, uint32_t *poff)
38e7976384c17215607055e2574ae71d386ba7bbvboxsync * Translate Ring-0 VM addresses into Ring-3 VM addresses before feeding it to mmHyperLookupR3.
be75da5235e6ed26c171a06f0a7d0e718bd7f60bvboxsync /** @todo fix this properly; the ring 0 pVM address differs from the R3 one. (#1865) */
be75da5235e6ed26c171a06f0a7d0e718bd7f60bvboxsync RTR0UINTPTR offVM = (RTR0UINTPTR)R0Ptr - (RTR0UINTPTR)pVM->pVMR0;
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Lookup a guest context address.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @returns Pointer to the corresponding lookup record.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @returns NULL on failure.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param pVM The VM handle.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param GCPtr The guest context address to lookup.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param poff Where to store the offset into the HMA memory chunk.
f55e40eab578fb43357fe057f8088cc16bb1a9e9vboxsyncDECLINLINE(PMMLOOKUPHYPER) mmHyperLookupGC(PVM pVM, RTGCPTR GCPtr, uint32_t *poff)
f55e40eab578fb43357fe057f8088cc16bb1a9e9vboxsync /** @todo cache last lookup this stuff ain't cheap! */
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync unsigned offGC = (RTGCUINTPTR)GCPtr - (RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC;
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync AssertMsgFailed(("enmType=%d\n", pLookup->enmType));
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync pLookup = (PMMLOOKUPHYPER)((char *)pLookup + pLookup->offNext);
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync AssertMsgFailed(("GCPtr=%p is not inside the hypervisor memory area!\n", GCPtr));
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * Lookup a current context address.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @returns Pointer to the corresponding lookup record.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @returns NULL on failure.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param pVM The VM handle.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param pv The current context address to lookup.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsync * @param poff Where to store the offset into the HMA memory chunk.
320484435d67c1fb90dca3e8836d81bf939c8ba2vboxsyncDECLINLINE(PMMLOOKUPHYPER) mmHyperLookupCC(PVM pVM, void *pv, uint32_t *poff)
case MMLOOKUPHYPERTYPE_LOCKED:
case MMLOOKUPHYPERTYPE_HCPHYS:
return NIL_RTR3PTR;
case MMLOOKUPHYPERTYPE_LOCKED:
case MMLOOKUPHYPERTYPE_HCPHYS:
return NIL_RTR0PTR;
#ifdef IN_GC
* Converts a ring-0 host context address in the Hypervisor memory region to a ring-3 host context address.
if (pLookup)
return NIL_RTR3PTR;
* Converts a ring-0 host context address in the Hypervisor memory region to a guest context address.
if (pLookup)
return NIL_RTGCPTR;
#ifndef IN_RING0
* Converts a ring-0 host context address in the Hypervisor memory region to a current context address.
if (pLookup)
return NULL;
* Converts a ring-3 host context address in the Hypervisor memory region to a ring-0 host context address.
if (pLookup)
return NIL_RTR0PTR;
* Converts a ring-3 host context address in the Hypervisor memory region to a guest context address.
if (pLookup)
return NIL_RTGCPTR;
* Converts a ring-3 host context address in the Hypervisor memory region to a current context address.
#ifndef IN_RING3
if (pLookup)
return NULL;
if (pLookup)
return NIL_RTR3PTR;
* Converts a guest context address in the Hypervisor memory region to a ring-0 host context address.
if (pLookup)
return NIL_RTR0PTR;
#ifndef IN_GC
if (pLookup)
return NULL;
* Converts a current context address in the Hypervisor memory region to a ring-3 host context address.
#ifndef IN_RING3
if (pLookup)
return NIL_RTR3PTR;
* Converts a current context address in the Hypervisor memory region to a ring-0 host context address.
#ifndef IN_RING0
if (pLookup)
return NIL_RTR0PTR;
#ifndef IN_GC
if (pLookup)
return NIL_RTGCPTR;
PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper);
case MMLOOKUPHYPERTYPE_LOCKED:
case MMLOOKUPHYPERTYPE_HCPHYS:
case MMLOOKUPHYPERTYPE_MMIO2:
return (RTGCPTR)0;
PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((char*)CTXSUFF(pVM->mm.s.pHyperHeap) + pVM->mm.s.offLookupHyper);
case MMLOOKUPHYPERTYPE_LOCKED:
case MMLOOKUPHYPERTYPE_HCPHYS:
return (RTHCPTR)0;
return (RTHCPTR)0;
#ifdef IN_GC