VMMRZ.cpp revision e14391f78ef5b4888eab64068347691a4c290cd8
/* $Id$ */
/** @file
* VMM - Virtual Machine Monitor, Raw-mode and ring-0 context code.
*/
/*
* Copyright (C) 2009-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "VMMInternal.h"
#include <iprt/asm-amd64-x86.h>
/**
* Calls the ring-3 host code.
*
* @returns VBox status code of the ring-3 call.
* @retval VERR_VMM_RING3_CALL_DISABLED if called at the wrong time. This must
* be passed up the stack, or if that isn't possible then VMMRZCallRing3
* needs to change it into an assertion.
*
*
* @param pVM Pointer to the VM.
* @param pVCpu Pointer to the VMCPU of the calling EMT.
* @param enmOperation The operation.
* @param uArg The argument to the operation.
*/
{
/*
* Check if calling ring-3 has been disabled and only let let fatal calls thru.
*/
{
#ifndef IN_RING0
/*
* In most cases, it's sufficient to return a status code which
* will then be propagated up the code usually encountering several
* AssertRC invocations along the way. Hitting one of those is more
* helpful than stopping here.
*
* However, some doesn't check the status code because they are called
* from void functions, and for these we'll turn this into a ring-0
* assertion host call.
*/
return VERR_VMM_RING3_CALL_DISABLED;
#endif
#ifdef IN_RC
#endif
}
/*
* The normal path.
*/
/** @todo profile this! */
#ifdef IN_RC
#else
int rc;
{
rc = pVCpu->vmm.s.pfnCallRing3CallbackR0(pVCpu, enmOperation, pVCpu->vmm.s.pvCallRing3CallbackUserR0);
if (RT_FAILURE(rc))
return rc;
}
if (RT_FAILURE(rc))
return rc;
#endif
}
/**
* Simple wrapper that adds the pVCpu argument.
*
* @returns VBox status code of the ring-3 call.
* @retval VERR_VMM_RING3_CALL_DISABLED if called at the wrong time. This must
* be passed up the stack, or if that isn't possible then VMMRZCallRing3
* needs to change it into an assertion.
*
* @param pVM Pointer to the VM.
* @param enmOperation The operation.
* @param uArg The argument to the operation.
*/
{
}
/**
* Disables all host calls, except certain fatal ones.
*
* @param pVCpu The CPU struct for the calling EMT.
* @thread EMT.
*/
{
#if defined(LOG_ENABLED) && defined(IN_RING0)
#endif
if (ASMAtomicIncU32(&pVCpu->vmm.s.cCallRing3Disabled) == 1) /** @todo replace with unordered variant (ASMAtomicUoIncU32). */
{
/** @todo it might make more sense to just disable logging here, then we
* won't flush away important bits... but that goes both ways really. */
#ifdef IN_RC
#else
# ifdef LOG_ENABLED
# endif
#endif
}
#if defined(LOG_ENABLED) && defined(IN_RING0)
#endif
}
/**
* Counters VMMRZCallRing3Disable and re-enables host calls.
*
* @param pVCpu The CPU struct for the calling EMT.
* @thread EMT.
*/
{
#if defined(LOG_ENABLED) && defined(IN_RING0)
#endif
if (ASMAtomicDecU32(&pVCpu->vmm.s.cCallRing3Disabled) == 0) /** @todo replace with unordered variant (ASMAtomicUoDecU32). */
{
#ifdef IN_RC
#else
# ifdef LOG_ENABLED
# endif
#endif
}
#if defined(LOG_ENABLED) && defined(IN_RING0)
#endif
}
/**
* Checks whether its possible to call host context or not.
*
* @returns true if it's safe, false if it isn't.
* @param pVCpu The CPU struct for the calling EMT.
*/
{
}
/**
* Sets the ring-0 callback before doing the ring-3 call.
*
* @param pVCpu Pointer to the VMCPU.
* @param pfnCallback Pointer to the callback.
* @param pvUser The user argument.
*
* @return VBox status code.
*/
VMMRZDECL(int) VMMRZCallRing3SetNotification(PVMCPU pVCpu, R0PTRTYPE(PFNVMMR0CALLRING3NOTIFICATION) pfnCallback, RTR0PTR pvUser)
{
return VERR_ALREADY_EXISTS;
return VINF_SUCCESS;
}
/**
* Removes the ring-0 callback.
*
* @param pVCpu Pointer to the VMCPU.
*/
{
}
/**
* Checks whether there is a ring-0 callback notification active.
*
* @param pVCpu Pointer to the VMCPU.
* @returns true if there the notification is active, false otherwise.
*/
{
}