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