PGMR0SharedPage.cpp revision 05aea370c2b0e20fb84a962ed30a8c22c16d51cc
/* $Id$ */
/** @file
* PGM - Page Manager and Monitor, Page Sharing, Ring-0.
*/
/*
* Copyright (C) 2010-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 *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_PGM_SHARED
#include "PGMInternal.h"
#include "PGMInline.h"
#ifdef VBOX_WITH_PAGE_SHARING
/**
* Check a registered module for shared page changes.
*
* The PGM lock shall be taken prior to calling this method.
*
* @returns The following VBox status codes.
*
* @param pVM Pointer to the VM.
* @param pGVM Pointer to the GVM instance data.
* @param idCpu The ID of the calling virtual CPU.
* @param pModule Global module description.
* @param paRegionsGCPtrs Array parallel to pModules->aRegions with the
* addresses of the regions in the calling
* process.
*/
VMMR0DECL(int) PGMR0SharedModuleCheck(PVM pVM, PGVM pGVM, VMCPUID idCpu, PGMMSHAREDMODULE pModule, PCRTGCPTR64 paRegionsGCPtrs)
{
int rc = VINF_SUCCESS;
bool fFlushTLBs = false;
bool fFlushRemTLBs = false;
Log(("PGMR0SharedModuleCheck: check %s %s base=%RGv size=%x\n", pModule->szName, pModule->szVersion, pModule->Core.Key, pModule->cbModule));
PGM_LOCK_ASSERT_OWNER(pVM); /* This cannot fail as we grab the lock in pgmR3SharedModuleRegRendezvous before calling into ring-0. */
/*
* Check every region of the shared module.
*/
{
while (cbLeft)
{
/** @todo inefficient to fetch each guest page like this... */
if ( rc == VINF_SUCCESS
{
if ( pPage
&& PGM_PAGE_GET_READ_LOCKS(pPage) == 0
&& PGM_PAGE_GET_WRITE_LOCKS(pPage) == 0 )
{
if (RT_FAILURE(rc))
break;
/*
* Any change for this page?
*/
{
Log(("PGMR0SharedModuleCheck: shared page gst virt=%RGv phys=%RGp host %RHp->%RHp\n",
/* Page was either replaced by an existing shared
version of it or converted into a read-only shared
page, so, clear all references. */
bool fFlush = false;
if (rc == VINF_SUCCESS)
fFlushTLBs |= fFlush;
fFlushRemTLBs = true;
{
/* Update the physical address and page id now. */
/* Invalidate page map TLB entry for this page too. */
}
/* else: nothing changed (== this page is now a shared
page), so no need to flush anything. */
# ifdef VBOX_STRICT /* check sum hack */
# endif
}
}
}
else
{
|| rc == VERR_PAGE_NOT_PRESENT
|| rc == VERR_PAGE_TABLE_NOT_PRESENT);
}
idxPage++;
}
}
/*
* Do TLB flushing if necessary.
*/
if (fFlushTLBs)
if (fFlushRemTLBs)
return rc;
}
#endif /* VBOX_WITH_PAGE_SHARING */