PGMR0SharedPage.cpp revision 530c5ad6ea29dc5dc7a512482d3257faafdb2812
/* $Id$ */
/** @file
* PGM - Page Manager and Monitor, Page Sharing, Ring-0.
*/
/*
* Copyright (C) 2010 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 Global module description
* @param cRegions Number of regions (local).
* @param paRegions Region array (local).
*/
{
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));
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. */
{
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", paRegions[idxRegion].GCRegionAddr + idxPage * PAGE_SIZE, PageDesc.GCPhys, PGM_PAGE_GET_HCPHYS(pPage), PageDesc.HCPhys));
{
/* Page was replaced by an existing shared version of it; clear all references first. */
bool fFlush = false;
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 /* VBOX_WITH_PAGE_SHARING */