VirtualBox

Changeset 4693 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 11, 2007 10:14:38 AM (17 years ago)
Author:
vboxsync
Message:

PGMPhysGCPtr2CCPtr and ReadOnly versions.

Location:
trunk/src/VBox/VMM/VMMAll
Files:
2 edited

Legend:

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

    r4692 r4693  
    379379 * scarse resources (R0 and GC) in the mapping cache. When you're done
    380380 * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
     381 *
     382 * This API will assume your intention is to write to the page, and will
     383 * therefore replace shared and zero pages. If you do not intend to modify
     384 * the page, use the PGMPhysGCPhys2CCPtrReadOnly() API.
    381385 *
    382386 * @returns VBox status code.
     
    392396 * @remark  Avoid calling this API from within critical sections (other than
    393397 *          the PGM one) because of the deadlock risk.
     398 * @thread  Any thread.
    394399 */
    395400PGMDECL(int) PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock)
    396401{
    397 # ifdef NEW_PHYS_CODE
    398     int rc = pgmLock(pVM);
    399     AssertRCReturn(rc);
    400 
     402#ifdef NEW_PHYS_CODE
    401403#ifdef IN_GC
    402404    /* Until a physical TLB is implemented for GC, let PGMGCDynMapGCPageEx handle it. */
    403405    return PGMGCDynMapGCPageEx(pVM, GCPhys, ppv);
    404 
    405406#else
     407    int rc = pgmLock(pVM);
     408    AssertRCReturn(rc);
     409
    406410    /*
    407411     * Query the Physical TLB entry for the page (may fail).
     
    455459
    456460/**
     461 * Requests the mapping of a guest page into the current context.
     462 *
     463 * This API should only be used for very short term, as it will consume
     464 * scarse resources (R0 and GC) in the mapping cache. When you're done
     465 * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
     466 *
     467 * @returns VBox status code.
     468 * @retval  VINF_SUCCESS on success.
     469 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
     470 * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
     471 *
     472 * @param   pVM         The VM handle.
     473 * @param   GCPhys      The guest physical address of the page that should be mapped.
     474 * @param   ppv         Where to store the address corresponding to GCPhys.
     475 * @param   pLock       Where to store the lock information that PGMPhysReleasePageMappingLock needs.
     476 *
     477 * @remark  Avoid calling this API from within critical sections (other than
     478 *          the PGM one) because of the deadlock risk.
     479 * @thread  Any thread.
     480 */
     481PGMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void * const *ppv, PPGMPAGEMAPLOCK pLock)
     482{
     483    /** @todo implement this */
     484    return PGMPhysGCPhys2CCPtr(pVM, GCPhys, (void **)ppv, pLock);
     485}
     486
     487
     488/**
     489 * Requests the mapping of a guest page given by virtual address into the current context.
     490 *
     491 * This API should only be used for very short term, as it will consume
     492 * scarse resources (R0 and GC) in the mapping cache. When you're done
     493 * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
     494 *
     495 * This API will assume your intention is to write to the page, and will
     496 * therefore replace shared and zero pages. If you do not intend to modify
     497 * the page, use the PGMPhysGCPtr2CCPtrReadOnly() API.
     498 *
     499 * @returns VBox status code.
     500 * @retval  VINF_SUCCESS on success.
     501 * @retval  VERR_PAGE_TABLE_NOT_PRESENT if the page directory for the virtual address isn't present.
     502 * @retval  VERR_PAGE_NOT_PRESENT if the page at the virtual address isn't present.
     503 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
     504 * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
     505 *
     506 * @param   pVM         The VM handle.
     507 * @param   GCPhys      The guest physical address of the page that should be mapped.
     508 * @param   ppv         Where to store the address corresponding to GCPhys.
     509 * @param   pLock       Where to store the lock information that PGMPhysReleasePageMappingLock needs.
     510 *
     511 * @remark  Avoid calling this API from within critical sections (other than
     512 *          the PGM one) because of the deadlock risk.
     513 * @thread  EMT
     514 */
     515PGMDECL(int) PGMPhysGCPtr2CCPtr(PVM pVM, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock)
     516{
     517    RTGCPHYS GCPhys;
     518    int rc = PGMPhysGCPtr2GCPhys(pVM, GCPtr, &GCPhys);
     519    if (VBOX_SUCCESS(rc))
     520        rc = PGMPhysGCPhys2CCPtr(pVM, GCPhys, ppv, pLock);
     521    return rc;
     522}
     523
     524
     525/**
     526 * Requests the mapping of a guest page given by virtual address into the current context.
     527 *
     528 * This API should only be used for very short term, as it will consume
     529 * scarse resources (R0 and GC) in the mapping cache. When you're done
     530 * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
     531 *
     532 * @returns VBox status code.
     533 * @retval  VINF_SUCCESS on success.
     534 * @retval  VERR_PAGE_TABLE_NOT_PRESENT if the page directory for the virtual address isn't present.
     535 * @retval  VERR_PAGE_NOT_PRESENT if the page at the virtual address isn't present.
     536 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical backing.
     537 * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
     538 *
     539 * @param   pVM         The VM handle.
     540 * @param   GCPhys      The guest physical address of the page that should be mapped.
     541 * @param   ppv         Where to store the address corresponding to GCPhys.
     542 * @param   pLock       Where to store the lock information that PGMPhysReleasePageMappingLock needs.
     543 *
     544 * @remark  Avoid calling this API from within critical sections (other than
     545 *          the PGM one) because of the deadlock risk.
     546 * @thread  EMT
     547 */
     548PGMDECL(int) PGMPhysGCPtr2CCPtrReadOnly(PVM pVM, RTGCPTR GCPtr, void * const *ppv, PPGMPAGEMAPLOCK pLock)
     549{
     550    RTGCPHYS GCPhys;
     551    int rc = PGMPhysGCPtr2GCPhys(pVM, GCPtr, &GCPhys);
     552    if (VBOX_SUCCESS(rc))
     553        rc = PGMPhysGCPhys2CCPtrReadOnly(pVM, GCPhys, ppv, pLock);
     554    return rc;
     555}
     556
     557
     558/**
    457559 * Release the mapping of a guest page.
    458560 *
    459  * This is the counter part of PGMPhysGCPhys2CCPtr.
     561 * This is the counter part of PGMPhysGCPhys2CCPtr, PGMPhysGCPhys2CCPtrReadOnly
     562 * PGMPhysGCPtr2CCPtr and PGMPhysGCPtr2CCPtrReadOnly.
    460563 *
    461564 * @param   pVM         The VM handle.
  • trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp

    r4692 r4693  
    591591                if ((pTrapStackGC >> PAGE_SHIFT) != ((pTrapStackGC - 10*sizeof(uint32_t)) >> PAGE_SHIFT)) /* fail if we cross a page boundary */
    592592                    goto failure;
    593 
    594                 /** @todo add PGMPhysGCPtr2CCPtr */
    595593                PGMPAGEMAPLOCK PageMappingLock;
    596                 RTGCPHYS GCPhysStack;
    597                 rc = PGMPhysGCPtr2GCPhys(pVM, pTrapStackGC, &GCPhysStack);
    598                 if (VBOX_SUCCESS(rc))
    599                     rc = PGMPhysGCPhys2CCPtr(pVM, GCPhysStack, (void **)&pTrapStack, &PageMappingLock);
     594                rc = PGMPhysGCPtr2CCPtr(pVM, pTrapStackGC, (void **)&pTrapStack, &PageMappingLock);
    600595                if (VBOX_FAILURE(rc))
    601596                {
Note: See TracChangeset for help on using the changeset viewer.

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