PGMR0SharedPage.cpp revision faa31dfcb46e5e2fb9c2bf224d113a0ca136ddec
/* $Id$ */
/** @file
* PGM - Page Manager and Monitor, Ring-0.
*/
/*
* Copyright (C) 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_PGM_SHARED
#include "../PGMInternal.h"
#include "../PGMInline.h"
#ifdef VBOX_WITH_PAGE_SHARING
/**
* Check a registered module for shared page changes
*
* @returns The following VBox status codes.
*
* @param pVM The VM handle.
* @param pGVM Pointer to the GVM instance data.
* @param idCpu VCPU id
* @param pModule Module description
* @param cRegions Number of regions
* @param pRegions Region array
*/
VMMR0DECL(int) PGMR0SharedModuleCheck(PVM pVM, PGVM pGVM, VMCPUID idCpu, PGMMSHAREDMODULE pModule, uint32_t cRegions, PGMMSHAREDREGIONDESC pRegions)
{
int rc = VINF_SUCCESS;
bool fFlushTLBs = false;
Log(("PGMR0SharedModuleCheck: check %s %s base=%RGv size=%x\n", pModule->szName, pModule->szVersion, pModule->Core.Key, pModule->cbModule));
/* Check every region of the shared module. */
{
unsigned idxPage = 0;
while (cbRegion)
{
/** @todo inefficient to fetch each guest page like this... */
if ( rc == VINF_SUCCESS
{
if ( pPage
{
if (rc == VINF_SUCCESS)
{
/* Any change for this page? */
{
Log(("PGMR0SharedModuleCheck: shared page gc virt=%RGv phys %RGp host %RHp->%RHp\n", pRegions[idxRegion].GCRegionAddr + idxPage * PAGE_SIZE, PageDesc.GCPhys, PGM_PAGE_GET_HCPHYS(pPage), PageDesc.HCPhys));
{
bool fFlush = false;
/* Page was replaced by an existing shared version of it; clear all references first. */
Assert(rc == VINF_SUCCESS || (VMCPU_FF_ISSET(pVCpu, VMCPU_FF_PGM_SYNC_CR3) && (pVCpu->pgm.s.fSyncFlags & PGM_SYNC_CLEAR_PGM_POOL)));
if (rc == VINF_SUCCESS)
fFlushTLBs |= fFlush;
/* 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. */
}
}
else
break;
}
}
else
{
|| rc == VERR_PAGE_NOT_PRESENT
|| rc == VERR_PAGE_TABLE_NOT_PRESENT);
}
idxPage++;
}
}
if (fFlushTLBs)
return rc;
}
#endif