MMRamRC.cpp revision fa8716d08ff627a8e1c14bcac56e8e3867b3f795
/* $Id$ */
/** @file
* MMRamGC - Guest Context Ram access Routines, pair for MMRamGCA.asm.
*/
/*
* Copyright (C) 2006-2007 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 *
*******************************************************************************/
#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 automatically removed at page fault.
* In other case it must be removed by MMGCRamDeregisterTrapHandler call.
*
* @param pVM Pointer to the VM.
*/
{
}
/**
* Remove MMGCRam Hypervisor page fault handler.
* See description of MMGCRamRegisterTrapHandler call.
*
* @param pVM Pointer to the VM.
*/
{
}
/**
* Read data in guest context with #PF control.
*
* @returns VBox status.
* @param pVM Pointer to the VM.
* @param pDst Where to store the read data.
* @param pSrc Pointer to the data to read.
* @param cb Size of data to read.
*/
{
int rc;
/*
* Save the current trap info, because it will get trashed if our access failed.
*/
/*
* Need to serve the request in a silly loop because the assembly code wasn't
* written for abrbitrary sizes, only 1/2/4/8.
*/
for (;;)
{
switch (cb)
{
default:
}
break;
/* advance */
cb -= cbThisRead;
}
if (RT_FAILURE(rc))
return rc;
}
/**
* Write data in guest context with #PF control.
*
* @returns VBox status.
* @param pVM Pointer to the VM.
* @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.
*
* @deprecated Don't use this as it doesn't check the page state.
*/
{
TRPMSaveTrap(pVCpu); /* save the current trap info, because it will get trashed if our access failed. */
if (RT_FAILURE(rc))
/*
* And mark the relevant guest page as accessed and dirty.
*/
PGMGstModifyPage(VMMGetCpu0(pVM), (RTGCPTR)(RTRCUINTPTR)pDst, cb, X86_PTE_A | X86_PTE_D, ~(uint64_t)(X86_PTE_A | X86_PTE_D));
return rc;
}
/**
* \#PF Handler for servicing traps inside MMGCRamReadNoTrapHandler and MMGCRamWriteNoTrapHandler functions.
*
* @internal
*/
{
/*
* Page fault inside MMGCRamRead()? Resume at *_Error.
*/
{
/* Must be a read violation. */
return VINF_SUCCESS;
}
/*
* Page fault inside MMGCRamWrite()? Resume at _Error.
*/
{
/* Must be a write violation. */
return VINF_SUCCESS;
}
/*
* #PF is not handled - cause guru meditation.
*/
return VERR_INTERNAL_ERROR;
}