PGMGst.h revision 9f1e0743f565b1975bb4efd7311b30cfa0d3e384
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * VBox - Page Manager / Monitor, Guest Paging Template.
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * 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* Defined Constants And Macros *
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync*******************************************************************************/
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync# define GST_BIG_PAGE_OFFSET_MASK X86_PAGE_4M_OFFSET_MASK
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# define GST_GET_PDE_BIG_PG_GCPHYS(PdeGst) pgmGstGet4MBPhysPage(&pVM->pgm.s, PdeGst)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# define GST_BIG_PAGE_OFFSET_MASK X86_PAGE_2M_OFFSET_MASK
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# define GST_GET_PDE_BIG_PG_GCPHYS(PdeGst) (PdeGst.u & GST_PDE_BIG_PG_MASK)
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync# define GST_TOTAL_PD_ENTRIES (X86_PG_PAE_ENTRIES * X86_PG_PAE_PDPE_ENTRIES)
bf8889d6b20936475381d2ed2b80b06eaf2a03d1vboxsync# define GST_TOTAL_PD_ENTRIES (X86_PG_AMD64_ENTRIES * X86_PG_AMD64_PDPE_ENTRIES)
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync/*******************************************************************************
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync* Internal Functions *
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsync*******************************************************************************/
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsyncPGM_GST_DECL(int, InitData)(PVM pVM, PPGMMODEDATA pModeData, bool fResolveGCAndR0);
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsyncPGM_GST_DECL(int, Enter)(PVM pVM, RTGCPHYS GCPhysCR3);
6b07d9a23ed1c650aa0a3b8de9d19f51b6b67e9fvboxsyncPGM_GST_DECL(int, Relocate)(PVM pVM, RTGCPTR offDelta);
07557d07616212d7ba6e7ab3059e85cb14633775vboxsyncstatic DECLCALLBACK(int) pgmR3Gst32BitWriteHandlerCR3(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
07557d07616212d7ba6e7ab3059e85cb14633775vboxsyncstatic DECLCALLBACK(int) pgmR3GstPAEWriteHandlerCR3(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsyncPGM_GST_DECL(int, GetPage)(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTGCPHYS pGCPhys);
e94ff1af89bf631c68367d4e291ddbb491b5e5c0vboxsyncPGM_GST_DECL(int, ModifyPage)(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
529e6bec97f5ef2e005c99c205c9624583ecb7f0vboxsyncPGM_GST_DECL(int, GetPDE)(PVM pVM, RTGCPTR GCPtr, PX86PDEPAE pPDE);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsyncPGM_GST_DECL(int, MapCR3)(PVM pVM, RTGCPHYS GCPhysCR3);
529e6bec97f5ef2e005c99c205c9624583ecb7f0vboxsyncPGM_GST_DECL(int, MonitorCR3)(PVM pVM, RTGCPHYS GCPhysCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Initializes the guest bit of the paging mode data.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @returns VBox status code.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pVM The VM handle.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param fResolveGCAndR0 Indicate whether or not GC and Ring-0 symbols can be resolved now.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * This is used early in the init process to avoid trouble with PDM
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * not being initialized yet.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncPGM_GST_DECL(int, InitData)(PVM pVM, PPGMMODEDATA pModeData, bool fResolveGCAndR0)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /* Ring-3 */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pModeData->pfnR3GstRelocate = PGM_GST_NAME(Relocate);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pModeData->pfnR3GstGetPage = PGM_GST_NAME(GetPage);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync pModeData->pfnR3GstModifyPage = PGM_GST_NAME(ModifyPage);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync pModeData->pfnR3GstUnmapCR3 = PGM_GST_NAME(UnmapCR3);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync pModeData->pfnR3GstMonitorCR3 = PGM_GST_NAME(MonitorCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pModeData->pfnR3GstUnmonitorCR3 = PGM_GST_NAME(UnmonitorCR3);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync# if PGM_GST_TYPE == PGM_TYPE_32BIT || PGM_GST_TYPE == PGM_TYPE_PAE
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync pModeData->pfnR3GstWriteHandlerCR3 = PGM_GST_NAME(WriteHandlerCR3);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pModeData->pszR3GstWriteHandlerCR3 = "Guest CR3 Write access handler";
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync pModeData->pfnR3GstPAEWriteHandlerCR3 = PGM_GST_NAME(WriteHandlerCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync pModeData->pszR3GstPAEWriteHandlerCR3 = "Guest CR3 Write access handler (PAE)";
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync#if PGM_SHW_TYPE != PGM_TYPE_AMD64 /* No AMD64 for traditional virtualization, only VT-x and AMD-V. */
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_GST_NAME_RC_STR(GetPage), &pModeData->pfnRCGstGetPage);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_RC_STR(GetPage), rc), rc);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_GST_NAME_RC_STR(ModifyPage), &pModeData->pfnRCGstModifyPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_RC_STR(ModifyPage), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_GST_NAME_RC_STR(GetPDE), &pModeData->pfnRCGstGetPDE);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_RC_STR(GetPDE), rc), rc);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_GST_NAME_RC_STR(MonitorCR3), &pModeData->pfnRCGstMonitorCR3);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_RC_STR(MonitorCR3), rc), rc);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_GST_NAME_RC_STR(UnmonitorCR3), &pModeData->pfnRCGstUnmonitorCR3);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_RC_STR(UnmonitorCR3), rc), rc);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_GST_NAME_RC_STR(MapCR3), &pModeData->pfnRCGstMapCR3);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_RC_STR(MapCR3), rc), rc);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_GST_NAME_RC_STR(UnmapCR3), &pModeData->pfnRCGstUnmapCR3);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_RC_STR(UnmapCR3), rc), rc);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync# if PGM_GST_TYPE == PGM_TYPE_32BIT || PGM_GST_TYPE == PGM_TYPE_PAE
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_GST_NAME_RC_STR(WriteHandlerCR3), &pModeData->pfnRCGstWriteHandlerCR3);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_RC_STR(WriteHandlerCR3), rc), rc);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync rc = PDMR3LdrGetSymbolRC(pVM, NULL, PGM_GST_NAME_RC_STR(WriteHandlerCR3), &pModeData->pfnRCGstPAEWriteHandlerCR3);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_RC_STR(WriteHandlerCR3), rc), rc);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync#endif /* Not AMD64 shadow paging. */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync /* Ring-0 */
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_GST_NAME_R0_STR(GetPage), &pModeData->pfnR0GstGetPage);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_R0_STR(GetPage), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_GST_NAME_R0_STR(ModifyPage), &pModeData->pfnR0GstModifyPage);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_R0_STR(ModifyPage), rc), rc);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_GST_NAME_R0_STR(GetPDE), &pModeData->pfnR0GstGetPDE);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_R0_STR(GetPDE), rc), rc);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_GST_NAME_R0_STR(MonitorCR3), &pModeData->pfnR0GstMonitorCR3);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_R0_STR(MonitorCR3), rc), rc);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_GST_NAME_R0_STR(UnmonitorCR3), &pModeData->pfnR0GstUnmonitorCR3);
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_R0_STR(UnmonitorCR3), rc), rc);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_GST_NAME_R0_STR(MapCR3), &pModeData->pfnR0GstMapCR3);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_R0_STR(MapCR3), rc), rc);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_GST_NAME_R0_STR(UnmapCR3), &pModeData->pfnR0GstUnmapCR3);
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_R0_STR(UnmapCR3), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync# if PGM_GST_TYPE == PGM_TYPE_32BIT || PGM_GST_TYPE == PGM_TYPE_PAE
1f1f533d5b88c35cf740dca55c6f1937d1035a36vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_GST_NAME_R0_STR(WriteHandlerCR3), &pModeData->pfnR0GstWriteHandlerCR3);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_R0_STR(WriteHandlerCR3), rc), rc);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync rc = PDMR3LdrGetSymbolR0(pVM, NULL, PGM_GST_NAME_R0_STR(WriteHandlerCR3), &pModeData->pfnR0GstPAEWriteHandlerCR3);
b9473064e26edc9a65150b4206ea1e52f3ca600avboxsync AssertMsgRCReturn(rc, ("%s -> rc=%Rrc\n", PGM_GST_NAME_R0_STR(WriteHandlerCR3), rc), rc);
07557d07616212d7ba6e7ab3059e85cb14633775vboxsync * Enters the guest mode.
529e6bec97f5ef2e005c99c205c9624583ecb7f0vboxsync * @returns VBox status code.
b9473064e26edc9a65150b4206ea1e52f3ca600avboxsync * @param pVM VM handle.
07557d07616212d7ba6e7ab3059e85cb14633775vboxsync * @param GCPhysCR3 The physical address from the CR3 register.
07557d07616212d7ba6e7ab3059e85cb14633775vboxsyncPGM_GST_DECL(int, Enter)(PVM pVM, RTGCPHYS GCPhysCR3)
07557d07616212d7ba6e7ab3059e85cb14633775vboxsync * Map and monitor CR3
07557d07616212d7ba6e7ab3059e85cb14633775vboxsync * Relocate any GC pointers related to guest mode paging.
07557d07616212d7ba6e7ab3059e85cb14633775vboxsync * @returns VBox status code.
07557d07616212d7ba6e7ab3059e85cb14633775vboxsync * @param pVM The VM handle.
07557d07616212d7ba6e7ab3059e85cb14633775vboxsync * @param offDelta The reloation offset.
07557d07616212d7ba6e7ab3059e85cb14633775vboxsyncPGM_GST_DECL(int, Relocate)(PVM pVM, RTGCPTR offDelta)
07557d07616212d7ba6e7ab3059e85cb14633775vboxsync /* nothing special to do here - InitData does the job. */
9a379ef11a4bb232c8e41c12b82ec94c8e10d9a0vboxsync * Exits the guest mode.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @returns VBox status code.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pVM VM handle.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Physical write access for the Guest CR3 in 32-bit mode.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @returns VINF_SUCCESS if the handler have carried out the operation.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pVM VM Handle.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param GCPhys The physical address the guest is writing to.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pvPhys The HC mapping of that address.
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync * @param pvBuf What the guest is reading/writing.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param cbBuf How much it's reading/writing.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param enmAccessType The access type.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pvUser User argument.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic DECLCALLBACK(int) pgmR3Gst32BitWriteHandlerCR3(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsg(!pVM->pgm.s.fMappingsFixed, ("Shouldn't be registered when mappings are fixed!\n"));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Log2(("pgmR3Gst32BitWriteHandlerCR3: ff=%#x GCPhys=%RGp pvPhys=%p cbBuf=%d pvBuf={%.*Rhxs}\n", pVM->fForcedActions, GCPhys, pvPhys, cbBuf, cbBuf, pvBuf));
2b114c590cf5a19f8047cd7bde9c7e5ae00aa22bvboxsync * Do the write operation.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync && !VM_FF_ISPENDING(pVM, VM_FF_PGM_SYNC_CR3 | VM_FF_PGM_SYNC_CR3_NON_GLOBAL))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Check for conflicts.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync const unsigned iPD2 = (unsigned)(offPD + cbBuf - 1) / sizeof(X86PDE);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync if ( ( pVM->pgm.s.pGst32BitPdR3->a[iPD1].n.u1Present
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Log(("pgmR3Gst32BitWriteHandlerCR3: detected conflict. iPD1=%#x iPD2=%#x GCPhys=%RGp\n", iPD1, iPD2, GCPhys));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync STAM_COUNTER_INC(&pVM->pgm.s.StatR3GuestPDWriteConflict);
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#endif /* 32BIT */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Physical write access handler for the Guest CR3 in PAE mode.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @returns VINF_SUCCESS if the handler have carried out the operation.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pVM VM Handle.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param GCPhys The physical address the guest is writing to.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pvPhys The HC mapping of that address.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pvBuf What the guest is reading/writing.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param cbBuf How much it's reading/writing.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param enmAccessType The access type.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * @param pvUser User argument.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsyncstatic DECLCALLBACK(int) pgmR3GstPAEWriteHandlerCR3(PVM pVM, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, void *pvUser)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync AssertMsg(!pVM->pgm.s.fMappingsFixed, ("Shouldn't be registered when mappings are fixed!\n"));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Log2(("pgmR3GstPAEWriteHandlerCR3: ff=%#x GCPhys=%RGp pvPhys=%p cbBuf=%d pvBuf={%.*Rhxs}\n", pVM->fForcedActions, GCPhys, pvPhys, cbBuf, cbBuf, pvBuf));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Do the write operation.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync && !VM_FF_ISPENDING(pVM, VM_FF_PGM_SYNC_CR3 | VM_FF_PGM_SYNC_CR3_NON_GLOBAL))
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Check if any of the PDs have changed.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * We'll simply check all of them instead of figuring out which one/two to check.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync for (unsigned i = 0; i < 4; i++)
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync && (pVM->pgm.s.pGstPaePdptR3->a[i].u & X86_PDPE_PG_MASK) != pVM->pgm.s.aGCPhysGstPaePDsMonitored[i])
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync Log(("pgmR3GstPAEWriteHandlerCR3: detected updated PDPE; [%d] = %#llx, Old GCPhys=%RGp\n",
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync i, pVM->pgm.s.pGstPaePdptR3->a[i].u, pVM->pgm.s.aGCPhysGstPaePDsMonitored[i]));
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * The PD has changed.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * We will schedule a monitoring update for the next TLB Flush,
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * InvalidatePage or SyncCR3.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * This isn't perfect, because a lazy page sync might be dealing with an half
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * updated PDPE. However, we assume that the guest OS is disabling interrupts
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * and being extremely careful (cmpxchg8b) when updating a PDPE where it's
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * executing.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Flag a updating of the monitor at the next crossroad so we don't monitor the
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * wrong pages for soo long that they can be reused as code pages and freak out
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * the recompiler or something.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#endif /* PAE */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync#endif /* !VBOX_WITH_PGMPOOL_PAGING_ONLY */