PGMR0.cpp revision 611910c4ba57eb6db5c0d508ca7b923efd654aec
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * PGM - Page Manager and Monitor, Ring-0.
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * Copyright (C) 2007 Sun Microsystems, Inc.
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * available from http://www.virtualbox.org. This file is free software;
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * you can redistribute it and/or modify it under the terms of the GNU
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * General Public License (GPL) as published by the Free Software
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * additional information or have any questions.
eb3a3435bb6f3ad6a38085912929372669c498favboxsync/*******************************************************************************
eb3a3435bb6f3ad6a38085912929372669c498favboxsync* Header Files *
eb3a3435bb6f3ad6a38085912929372669c498favboxsync*******************************************************************************/
eb3a3435bb6f3ad6a38085912929372669c498favboxsync#define PGM_BTH_NAME(name) PGM_BTH_NAME_32BIT_PROT(name)
eb3a3435bb6f3ad6a38085912929372669c498favboxsync#define PGM_BTH_NAME(name) PGM_BTH_NAME_PAE_PROT(name)
eb3a3435bb6f3ad6a38085912929372669c498favboxsync#define PGM_BTH_NAME(name) PGM_BTH_NAME_AMD64_PROT(name)
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * Worker function for PGMR3PhysAllocateHandyPages and pgmPhysEnsureHandyPage.
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * @returns The following VBox status codes.
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * @retval VINF_SUCCESS on success. FF cleared.
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * @retval VINF_EM_NO_MEMORY if we're out of memory. The FF is set in this case.
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * @param pVM The VM handle.
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * @remarks Must be called from within the PGM critical section.
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * #PF Handler for nested paging.
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * @returns VBox status code (appropriate for trap handling and GC return).
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * @param pVM VM Handle.
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * @param enmShwPagingMode Paging mode for the nested page tables
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * @param uErr The trap error code.
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * @param pRegFrame Trap register frame.
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * @param pvFault The fault address.
4b783d68e6d569ab798901917ace422a4810edf0vboxsyncPGMR0DECL(int) PGMR0Trap0eHandlerNestedPaging(PVM pVM, PGMMODE enmShwPagingMode, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault)
4b783d68e6d569ab798901917ace422a4810edf0vboxsync LogFlow(("PGMTrap0eHandler: uErr=%#x pvFault=%VGp eip=%VGv\n", uErr, pvFault, pRegFrame->eip));
4b783d68e6d569ab798901917ace422a4810edf0vboxsync STAM_STATS({ pVM->pgm.s.CTXSUFF(pStatTrap0eAttribution) = NULL; } );
4b783d68e6d569ab798901917ace422a4810edf0vboxsync /* AMD uses the host's paging mode; Intel's version is on the todo list */
4b783d68e6d569ab798901917ace422a4810edf0vboxsync Assert(enmShwPagingMode == PGMMODE_32_BIT || enmShwPagingMode == PGMMODE_PAE); // || enmShwPagingMode == PGMMODE_AMD64);
4b783d68e6d569ab798901917ace422a4810edf0vboxsync * Error code stats.
4b783d68e6d569ab798901917ace422a4810edf0vboxsync STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSNotPresentWrite);
4b783d68e6d569ab798901917ace422a4810edf0vboxsync STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSNotPresentRead);
4b783d68e6d569ab798901917ace422a4810edf0vboxsync STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eUSReserved);
4b783d68e6d569ab798901917ace422a4810edf0vboxsync { /* Supervisor */
4b783d68e6d569ab798901917ace422a4810edf0vboxsync STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eSVNotPresentWrite);
4b783d68e6d569ab798901917ace422a4810edf0vboxsync STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eSVNotPresentRead);
eb3a3435bb6f3ad6a38085912929372669c498favboxsync STAM_COUNTER_INC(&pVM->pgm.s.StatGCTrap0eSVReserved);
eb3a3435bb6f3ad6a38085912929372669c498favboxsync * Call the worker.
eb3a3435bb6f3ad6a38085912929372669c498favboxsync rc = PGM_BTH_NAME_32BIT_PROT(Trap0eHandler)(pVM, uErr, pRegFrame, pvFault);
eb3a3435bb6f3ad6a38085912929372669c498favboxsync rc = PGM_BTH_NAME_PAE_PROT(Trap0eHandler)(pVM, uErr, pRegFrame, pvFault);
4b783d68e6d569ab798901917ace422a4810edf0vboxsync case PGMMODE_AMD64:
4b783d68e6d569ab798901917ace422a4810edf0vboxsync rc = PGM_BTH_NAME_AMD64_PROT(Trap0eHandler)(pVM, uErr, pRegFrame, pvFault);
4b783d68e6d569ab798901917ace422a4810edf0vboxsync STAM_STATS({ if (!pVM->pgm.s.CTXSUFF(pStatTrap0eAttribution))
4b783d68e6d569ab798901917ace422a4810edf0vboxsync pVM->pgm.s.CTXSUFF(pStatTrap0eAttribution) = &pVM->pgm.s.StatTrap0eMisc; });