VMMRZ.cpp revision 8a179f8f39b6114b304505d4fb79a987d5e5a623
45e9809aff7304721fddb95654901b32195c9c7avboxsync * VMM - Virtual Machine Monitor, Raw-mode and ring-0 context code.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
45e9809aff7304721fddb95654901b32195c9c7avboxsync * available from http://www.virtualbox.org. This file is free software;
45e9809aff7304721fddb95654901b32195c9c7avboxsync * you can redistribute it and/or modify it under the terms of the GNU
45e9809aff7304721fddb95654901b32195c9c7avboxsync * General Public License (GPL) as published by the Free Software
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
45e9809aff7304721fddb95654901b32195c9c7avboxsync * additional information or have any questions.
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*******************************************************************************
45e9809aff7304721fddb95654901b32195c9c7avboxsync* Header Files *
45e9809aff7304721fddb95654901b32195c9c7avboxsync*******************************************************************************/
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Calls the ring-3 host code.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @returns VBox status code of the ring-3 call.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @retval VERR_VMM_RING3_CALL_DISABLED if called at the wrong time. This must
45e9809aff7304721fddb95654901b32195c9c7avboxsync * be passed up the stack, or if that isn't possible then VMMRZCallRing3
45e9809aff7304721fddb95654901b32195c9c7avboxsync * needs to change it into an assertion.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param pVM The VM handle.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param pVCpu The virtual CPU handle of the calling EMT.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param enmOperation The operation.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @param uArg The argument to the operation.
45e9809aff7304721fddb95654901b32195c9c7avboxsyncVMMRZDECL(int) VMMRZCallRing3(PVM pVM, PVMCPU pVCpu, VMMCALLRING3 enmOperation, uint64_t uArg)
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Check if calling ring-3 has been disabled and only let let fatal calls thru.
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (RT_UNLIKELY( pVCpu->vmm.s.cCallRing3Disabled != 0
45e9809aff7304721fddb95654901b32195c9c7avboxsync * In most cases, it's sufficient to return a status code which
45e9809aff7304721fddb95654901b32195c9c7avboxsync * will then be propagated up the code usually encountering several
45e9809aff7304721fddb95654901b32195c9c7avboxsync * AssertRC invocations along the way. Hitting one of those is more
45e9809aff7304721fddb95654901b32195c9c7avboxsync * helpful than stopping here.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * However, some doesn't check the status code because they are called
45e9809aff7304721fddb95654901b32195c9c7avboxsync * from void functions, and for these we'll turn this into a ring-0
45e9809aff7304721fddb95654901b32195c9c7avboxsync * assertion host call.
45e9809aff7304721fddb95654901b32195c9c7avboxsync if (enmOperation != VMMCALLRING3_REM_REPLAY_HANDLER_NOTIFICATIONS)
45e9809aff7304721fddb95654901b32195c9c7avboxsync RTStrPrintf(g_szRTAssertMsg1, sizeof(pVM->vmm.s.szRing0AssertMsg1),
45e9809aff7304721fddb95654901b32195c9c7avboxsync "VMMRZCallRing3: enmOperation=%d uArg=%#llx idCpu=%#x\n", enmOperation, uArg, pVCpu->idCpu);
45e9809aff7304721fddb95654901b32195c9c7avboxsync RTStrPrintf(pVM->vmm.s.szRing0AssertMsg1, sizeof(pVM->vmm.s.szRing0AssertMsg1),
45e9809aff7304721fddb95654901b32195c9c7avboxsync "VMMRZCallRing3: enmOperation=%d uArg=%#llx idCpu=%#x\n", enmOperation, uArg, pVCpu->idCpu);
45e9809aff7304721fddb95654901b32195c9c7avboxsync * The normal path.
45e9809aff7304721fddb95654901b32195c9c7avboxsync/** @todo profile this! */
45e9809aff7304721fddb95654901b32195c9c7avboxsync int rc = vmmR0CallRing3LongJmp(&pVCpu->vmm.s.CallRing3JmpBufR0, VINF_VMM_CALL_HOST);
#ifdef IN_RC
# ifdef LOG_ENABLED
#ifdef IN_RC
# ifdef LOG_ENABLED