MMRamGC.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/** @file
*
* MMRamGC - Guest Context Ram access Routines, pair for MMRamGCA.asm.
*/
/*
* Copyright (C) 2006 InnoTek Systemberatung GmbH
*
* 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 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.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_MM
#include "MMInternal.h"
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
DECLASM(void) MMGCRamReadNoTrapHandler_EndProc(void);
DECLASM(void) MMGCRamWriteNoTrapHandler_EndProc(void);
DECLASM(void) MMGCRamRead_Error(void);
DECLASM(void) MMGCRamWrite_Error(void);
/**
* Install MMGCRam Hypervisor page fault handler for normal working
* of MMGCRamRead and MMGCRamWrite calls.
* This handler will be authomatically removed at page fault.
* In other case it must be removed by MMGCRamDeregisterTrapHandler call.
*
* @param pVM VM handle.
*/
{
}
/**
* Remove MMGCRam Hypervisor page fault handler.
* See description of MMGCRamRegisterTrapHandler call.
*
* @param pVM VM handle.
*/
{
}
/**
* Read data in guest context with #PF control.
*
* @returns VBox status.
* @param pVM The VM handle.
* @param pDst Where to store the readed data.
* @param pSrc Pointer to the data to read.
* @param cb Size of data to read, only 1/2/4/8 is valid.
*/
{
int rc;
TRPMSaveTrap(pVM); /* save the current trap info, because it will get trashed if our access failed. */
if (VBOX_FAILURE(rc))
return rc;
}
/**
* Write data in guest context with #PF control.
*
* @returns VBox status.
* @param pVM The VM handle.
* @param pDst Where to write the data.
* @param pSrc Pointer to the data to write.
* @param cb Size of data to write, only 1/2/4 is valid.
*/
{
int rc;
TRPMSaveTrap(pVM); /* save the current trap info, because it will get trashed if our access failed. */
if (VBOX_FAILURE(rc))
/*
* And mark the relevant guest page as accessed and dirty.
*/
return rc;
}
/**
* \#PF Handler for servicing traps inside MMGCRamReadNoTrapHandler and MMGCRamWriteNoTrapHandler functions.
*
* @internal
*/
{
/*
* Check where the trap was occurred.
*/
{
/*
* Page fault inside MMGCRamRead() func.
*/
/* Must be read violation. */
if (uErrorCode & X86_TRAP_PF_RW)
return VERR_INTERNAL_ERROR;
/* Return execution to func at error label. */
return VINF_SUCCESS;
}
{
/*
* Page fault inside MMGCRamWrite() func.
*/
/* Must be write violation. */
if (!(uErrorCode & X86_TRAP_PF_RW))
return VERR_INTERNAL_ERROR;
/* Return execution to func at error label. */
return VINF_SUCCESS;
}
/* #PF is not handled - kill the Hypervisor. */
return VERR_INTERNAL_ERROR;
}