PGMBth.h revision e85d76a7e5a047db3cdc8576ff5f412c7b73bbab
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync/* $Id$ */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/** @file
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * VBox - Page Manager / Monitor, Shadow+Guest Paging Template.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/*
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * available from http://www.virtualbox.org. This file is free software;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * you can redistribute it and/or modify it under the terms of the GNU
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * General Public License (GPL) as published by the Free Software
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * additional information or have any questions.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/*******************************************************************************
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync* Internal Functions *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync*******************************************************************************/
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync__BEGIN_DECLS
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, InitData)(PVM pVM, PPGMMODEDATA pModeData, bool fResolveGCAndR0);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, Enter)(PVM pVM, RTGCPHYS GCPhysCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, Relocate)(PVM pVM, RTGCPTR offDelta);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, Trap0eHandler)(PVM pVM, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, SyncCR3)(PVM pVM, uint64_t cr0, uint64_t cr3, uint64_t cr4, bool fGlobal);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, SyncPage)(PVM pVM, X86PDE PdeSrc, RTGCPTR GCPtrPage, unsigned cPages, unsigned uError);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, VerifyAccessSyncPage)(PVM pVM, RTGCPTR Addr, unsigned fPage, unsigned uError);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, InvalidatePage)(PVM pVM, RTGCPTR GCPtrPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, PrefetchPage)(PVM pVM, RTGCPTR GCPtrPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(unsigned, AssertCR3)(PVM pVM, uint64_t cr3, uint64_t cr4, RTGCPTR GCPtr = 0, RTGCPTR cb = ~(RTGCPTR)0);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, MapCR3)(PVM pVM, RTGCPHYS GCPhysCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, UnmapCR3)(PVM pVM);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync__END_DECLS
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/**
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Initializes the both bit of the paging mode data.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @returns VBox status code.
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync * @param pVM The VM handle.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param fResolveGCAndR0 Indicate whether or not GC and Ring-0 symbols can be resolved now.
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync * This is used early in the init process to avoid trouble with PDM
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync * not being initialized yet.
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsyncPGM_BTH_DECL(int, InitData)(PVM pVM, PPGMMODEDATA pModeData, bool fResolveGCAndR0)
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync{
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync Assert(pModeData->uShwType == PGM_SHW_TYPE); Assert(pModeData->uGstType == PGM_GST_TYPE);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /* Ring 3 */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pModeData->pfnR3BthRelocate = PGM_BTH_NAME(Relocate);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pModeData->pfnR3BthSyncCR3 = PGM_BTH_NAME(SyncCR3);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pModeData->pfnR3BthInvalidatePage = PGM_BTH_NAME(InvalidatePage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pModeData->pfnR3BthSyncPage = PGM_BTH_NAME(SyncPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pModeData->pfnR3BthPrefetchPage = PGM_BTH_NAME(PrefetchPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pModeData->pfnR3BthVerifyAccessSyncPage = PGM_BTH_NAME(VerifyAccessSyncPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#ifdef VBOX_STRICT
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pModeData->pfnR3BthAssertCR3 = PGM_BTH_NAME(AssertCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#endif
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pModeData->pfnR3BthMapCR3 = PGM_BTH_NAME(MapCR3);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pModeData->pfnR3BthUnmapCR3 = PGM_BTH_NAME(UnmapCR3);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync if (fResolveGCAndR0)
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync {
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync int rc;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#if PGM_SHW_TYPE != PGM_TYPE_AMD64 && PGM_SHW_TYPE != PGM_TYPE_NESTED && PGM_SHW_TYPE != PGM_TYPE_EPT /* No AMD64 for traditional virtualization, only VT-x and AMD-V. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /* GC */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_BTH_NAME_RC_STR(Trap0eHandler), &pModeData->pfnRCBthTrap0eHandler);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_RC_STR(Trap0eHandler), rc), rc);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_BTH_NAME_RC_STR(InvalidatePage), &pModeData->pfnRCBthInvalidatePage);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_RC_STR(InvalidatePage), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_BTH_NAME_RC_STR(SyncCR3), &pModeData->pfnRCBthSyncCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_RC_STR(SyncPage), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_BTH_NAME_RC_STR(SyncPage), &pModeData->pfnRCBthSyncPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_RC_STR(SyncPage), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_BTH_NAME_RC_STR(PrefetchPage), &pModeData->pfnRCBthPrefetchPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_RC_STR(PrefetchPage), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_BTH_NAME_RC_STR(VerifyAccessSyncPage),&pModeData->pfnRCBthVerifyAccessSyncPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_RC_STR(VerifyAccessSyncPage), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# ifdef VBOX_STRICT
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_BTH_NAME_RC_STR(AssertCR3), &pModeData->pfnRCBthAssertCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_RC_STR(AssertCR3), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# endif
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_BTH_NAME_RC_STR(MapCR3), &pModeData->pfnRCBthMapCR3);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_RC_STR(MapCR3), rc), rc);
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_BTH_NAME_RC_STR(UnmapCR3), &pModeData->pfnRCBthUnmapCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_RC_STR(UnmapCR3), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#endif /* Not AMD64 shadow paging. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /* Ring 0 */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_BTH_NAME_R0_STR(Trap0eHandler), &pModeData->pfnR0BthTrap0eHandler);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_R0_STR(Trap0eHandler), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_BTH_NAME_R0_STR(InvalidatePage), &pModeData->pfnR0BthInvalidatePage);
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_R0_STR(InvalidatePage), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_BTH_NAME_R0_STR(SyncCR3), &pModeData->pfnR0BthSyncCR3);
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_R0_STR(SyncCR3), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_BTH_NAME_R0_STR(SyncPage), &pModeData->pfnR0BthSyncPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_R0_STR(SyncPage), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_BTH_NAME_R0_STR(PrefetchPage), &pModeData->pfnR0BthPrefetchPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_R0_STR(PrefetchPage), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_BTH_NAME_R0_STR(VerifyAccessSyncPage),&pModeData->pfnR0BthVerifyAccessSyncPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_R0_STR(VerifyAccessSyncPage), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#ifdef VBOX_STRICT
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_BTH_NAME_R0_STR(AssertCR3), &pModeData->pfnR0BthAssertCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_R0_STR(AssertCR3), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#endif
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_BTH_NAME_R0_STR(MapCR3), &pModeData->pfnR0BthMapCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_R0_STR(MapCR3), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_BTH_NAME_R0_STR(UnmapCR3), &pModeData->pfnR0BthUnmapCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_BTH_NAME_R0_STR(UnmapCR3), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/**
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync * Enters the shadow+guest mode.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync *
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync * @returns VBox status code.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pVM VM handle.
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync * @param GCPhysCR3 The physical address from the CR3 register.
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, Enter)(PVM pVM, RTGCPHYS GCPhysCR3)
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#ifdef VBOX_WITH_PGMPOOL_PAGING_ONLY
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /* Here we deal with allocation of the root shadow page table for real and protected mode during mode switches;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Other modes rely on MapCR3/UnmapCR3 to setup the shadow root page tables.
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync# if ( ( PGM_SHW_TYPE == PGM_TYPE_32BITS \
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync || PGM_SHW_TYPE == PGM_TYPE_PAE \
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync || PGM_SHW_TYPE == PGM_TYPE_AMD64) \
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync && ( PGM_GST_TYPE == PGM_TYPE_REAL \
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync || PGM_GST_TYPE == PGM_TYPE_PROT))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync Assert(!HWACCMIsNestedPagingActive(pVM));
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /* We only need shadow paging in real and protected mode for VT-x and AMD-V (excluding nested paging/EPT modes) */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync if (HWACCMIsEnabled(pVM))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /* Free the previous root mapping if still active. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync PPGMPOOL pPool = pVM->pgm.s.CTX_SUFF(pPool);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (pVM->pgm.s.CTX_SUFF(pShwPageCR3))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /* It might have been freed already by a pool flush (see e.g. PGMR3MappingsUnfix). */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /** @todo Coordinate this better with the pool. */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync if (pVM->pgm.s.CTX_SUFF(pShwPageCR3)->enmKind != PGMPOOLKIND_FREE)
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pgmPoolFreeByPage(pPool, pVM->pgm.s.CTX_SUFF(pShwPageCR3), pVM->pgm.s.iShwUser, pVM->pgm.s.iShwUserTable);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pVM->pgm.s.pShwPageCR3R3 = 0;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pVM->pgm.s.pShwPageCR3R0 = 0;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pVM->pgm.s.pShwRootR3 = 0;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync# ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pVM->pgm.s.pShwRootR0 = 0;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# endif
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pVM->pgm.s.HCPhysShwCR3 = 0;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pVM->pgm.s.iShwUser = 0;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pVM->pgm.s.iShwUserTable = 0;
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync }
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync /* contruct a fake address */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync RTGCPHYS GCPhysCR3 = RT_BIT_64(63);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pVM->pgm.s.iShwUser = SHW_POOL_ROOT_IDX;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pVM->pgm.s.iShwUserTable = GCPhysCR3 >> PAGE_SHIFT;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync int rc = pgmPoolAlloc(pVM, GCPhysCR3, BTH_PGMPOOLKIND_ROOT, pVM->pgm.s.iShwUser, pVM->pgm.s.iShwUserTable, &pVM->pgm.s.CTX_SUFF(pShwPageCR3));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if (rc == VERR_PGM_POOL_FLUSHED)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync {
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Log(("Bth-Enter: PGM pool flushed -> signal sync cr3\n"));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Assert(VM_FF_ISSET(pVM, VM_FF_PGM_SYNC_CR3));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_PGM_SYNC_CR3;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertRCReturn(rc, rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# ifdef IN_RING0
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pVM->pgm.s.pShwPageCR3R3 = MMHyperCCToR3(pVM, pVM->pgm.s.CTX_SUFF(pShwPageCR3));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pVM->pgm.s.pShwPageCR3R0 = MMHyperCCToR0(pVM, pVM->pgm.s.CTX_SUFF(pShwPageCR3));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# endif
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pVM->pgm.s.pShwRootR3 = (R3PTRTYPE(void *))pVM->pgm.s.CTX_SUFF(pShwPageCR3)->pvPageR3;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Assert(pVM->pgm.s.pShwRootR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# ifndef VBOX_WITH_2X_4GB_ADDR_SPACE
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pVM->pgm.s.pShwRootR0 = (R0PTRTYPE(void *))PGMPOOL_PAGE_2_PTR(pPool->CTX_SUFF(pVM), pVM->pgm.s.CTX_SUFF(pShwPageCR3));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# endif
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pVM->pgm.s.HCPhysShwCR3 = pVM->pgm.s.CTX_SUFF(pShwPageCR3)->Core.Key;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync }
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# endif
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#else
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /* nothing special to do here - InitData does the job. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#endif
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/**
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Relocate any GC pointers related to shadow mode paging.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @returns VBox status code.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pVM The VM handle.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param offDelta The reloation offset.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_BTH_DECL(int, Relocate)(PVM pVM, RTGCPTR offDelta)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync{
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /* nothing special to do here - InitData does the job. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync return VINF_SUCCESS;
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync}
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync