VirtualBox

Changeset 23453 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Sep 30, 2009 9:55:25 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53050
Message:

PGMPhysPageMap cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r23398 r23453  
    432432 * Deal with pages that are not writable, i.e. not in the ALLOCATED state.
    433433 *
    434  * @returns VBox status code.
     434 * @returns VBox strict status code.
    435435 * @retval  VINF_SUCCESS on success.
    436436 * @retval  VINF_PGM_SYNC_CR3 on success and a page pool flush is pending.
     
    476476 * Wrapper for pgmPhysPageMakeWritable which enters the critsect.
    477477 *
    478  * @returns VBox status code.
     478 * @returns VBox strict status code.
    479479 * @retval  VINF_SUCCESS on success.
    480480 * @retval  VINF_PGM_SYNC_CR3 on success and a page pool flush is pending.
     
    509509 * @param   ppv         Where to store the mapping address.
    510510 *
    511  * @remarks Called from within the PGM critical section.
     511 * @remarks Called from within the PGM critical section.  The mapping is only
     512 *          valid while your inside this section.
    512513 */
    513514int pgmPhysPageMapByPageID(PVM pVM, uint32_t idPage, RTHCPHYS HCPhys, void **ppv)
     
    596597 * @remarks Called from within the PGM critical section.
    597598 */
    598 int pgmPhysPageMap(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys, PPPGMPAGEMAP ppMap, void **ppv)
     599static int pgmPhysPageMapCommon(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys, PPPGMPAGEMAP ppMap, void **ppv)
    599600{
    600601    Assert(PGMIsLocked(pVM));
     
    699700
    700701
     702/**
     703 * Combination of pgmPhysPageMakeWritable and pgmPhysPageMapWritable.
     704 *
     705 * This is typically used is paths where we cannot use the TLB methods (like ROM
     706 * pages) or where there is no point in using them since we won't get many hits.
     707 *
     708 * @returns VBox strict status code.
     709 * @retval  VINF_SUCCESS on success.
     710 * @retval  VINF_PGM_SYNC_CR3 on success and a page pool flush is pending.
     711 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
     712 *
     713 * @param   pVM         The VM address.
     714 * @param   pPage       The physical page tracking structure.
     715 * @param   GCPhys      The address of the page.
     716 * @param   ppv         Where to store the mapping address of the page. The page
     717 *                      offset is masked off!
     718 *
     719 * @remarks Called from within the PGM critical section.  The mapping is only
     720 *          valid while your inside this section.
     721 */
     722int pgmPhysPageMakeWritableAndMap(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys, void **ppv)
     723{
     724    int rc = pgmPhysPageMakeWritable(pVM, pPage, GCPhys);
     725    if (RT_SUCCESS(rc))
     726    {
     727        AssertMsg(rc == VINF_SUCCESS || rc == VINF_PGM_SYNC_CR3 /* returned */, ("%Rrc\n", rc));
     728        PPGMPAGEMAP pMapIgnore;
     729        int rc2 = pgmPhysPageMapCommon(pVM, pPage, GCPhys, &pMapIgnore, ppv);
     730        if (RT_FAILURE(rc2)) /* preserve rc */
     731            rc = rc2;
     732    }
     733    return rc;
     734}
     735
     736
     737/**
     738 * Maps a page into the current virtual address space so it can be accessed for
     739 * both writing and reading.
     740 *
     741 * This is typically used is paths where we cannot use the TLB methods (like ROM
     742 * pages) or where there is no point in using them since we won't get many hits.
     743 *
     744 * @returns VBox status code.
     745 * @retval  VINF_SUCCESS on success.
     746 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
     747 *
     748 * @param   pVM         The VM address.
     749 * @param   pPage       The physical page tracking structure. Must be in the
     750 *                      allocated state.
     751 * @param   GCPhys      The address of the page.
     752 * @param   ppv         Where to store the mapping address of the page. The page
     753 *                      offset is masked off!
     754 *
     755 * @remarks Called from within the PGM critical section.  The mapping is only
     756 *          valid while your inside this section.
     757 */
     758int pgmPhysPageMap(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys, void **ppv)
     759{
     760    Assert(PGM_PAGE_GET_STATE(pPage) == PGM_PAGE_STATE_ALLOCATED);
     761    PPGMPAGEMAP pMapIgnore;
     762    return pgmPhysPageMapCommon(pVM, pPage, GCPhys, &pMapIgnore, ppv);
     763}
     764
     765
     766/**
     767 * Maps a page into the current virtual address space so it can be accessed for
     768 * reading.
     769 *
     770 * This is typically used is paths where we cannot use the TLB methods (like ROM
     771 * pages) or where there is no point in using them since we won't get many hits.
     772 *
     773 * @returns VBox status code.
     774 * @retval  VINF_SUCCESS on success.
     775 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
     776 *
     777 * @param   pVM         The VM address.
     778 * @param   pPage       The physical page tracking structure.
     779 * @param   GCPhys      The address of the page.
     780 * @param   ppv         Where to store the mapping address of the page. The page
     781 *                      offset is masked off!
     782 *
     783 * @remarks Called from within the PGM critical section.  The mapping is only
     784 *          valid while your inside this section.
     785 */
     786int pgmPhysPageMapReadOnly(PVM pVM, PPGMPAGE pPage, RTGCPHYS GCPhys, void const **ppv)
     787{
     788    PPGMPAGEMAP pMapIgnore;
     789    return pgmPhysPageMapCommon(pVM, pPage, GCPhys, &pMapIgnore, (void **)ppv);
     790}
     791
     792
    701793#if !defined(IN_RC) && !defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
    702794/**
     
    740832        void *pv;
    741833        PPGMPAGEMAP pMap;
    742         int rc = pgmPhysPageMap(PGM2VM(pPGM), pPage, GCPhys, &pMap, &pv);
     834        int rc = pgmPhysPageMapCommon(PGM2VM(pPGM), pPage, GCPhys, &pMap, &pv);
    743835        if (RT_FAILURE(rc))
    744836            return rc;
     
    782874        void *pv;
    783875        PPGMPAGEMAP pMap;
    784         int rc = pgmPhysPageMap(PGM2VM(pPGM), pPage, GCPhys, &pMap, &pv);
     876        int rc = pgmPhysPageMapCommon(PGM2VM(pPGM), pPage, GCPhys, &pMap, &pv);
    785877        if (RT_FAILURE(rc))
    786878            return rc;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette