VirtualBox

儲存庫 vbox 的更動 13235


忽略:
時間撮記:
2008-10-13 下午08:48:53 (16 年 以前)
作者:
vboxsync
訊息:

PGM: Merged PGMGCInvalidatePage into PGMInvalidatePage nad fixed the callers of it to handle the return codes correctly. other cleanup.

位置:
trunk
檔案:
修改 7 筆資料

圖例:

未更動
新增
刪除
  • trunk/include/VBox/pgm.h

    r13232 r13235  
    338338VMMDECL(X86PDPE)    PGMGstGetPaePDPtr(PVM pVM, unsigned iPdPt);
    339339
     340VMMDECL(int)        PGMInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
    340341VMMDECL(int)        PGMFlushTLB(PVM pVM, uint64_t cr3, bool fGlobal);
     342VMMDECL(int)        PGMSyncCR3(PVM pVM, uint64_t cr0, uint64_t cr3, uint64_t cr4, bool fGlobal);
    341343VMMDECL(int)        PGMUpdateCR3(PVM pVM, uint64_t cr3);
    342 VMMDECL(int)        PGMSyncCR3(PVM pVM, uint64_t cr0, uint64_t cr3, uint64_t cr4, bool fGlobal);
    343344VMMDECL(int)        PGMChangeMode(PVM pVM, uint64_t cr0, uint64_t cr4, uint64_t efer);
    344345VMMDECL(PGMMODE)    PGMGetGuestMode(PVM pVM);
     
    432433VMMDECL(int)        PGMPhysWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
    433434VMMDECL(int)        PGMPhysSimpleDirtyWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
    434 VMMDECL(int)        PGMInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
    435435#endif /* !IN_GC */
    436436VMMDECL(int)        PGMPhysInterpretedRead(PVM pVM, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb);
     
    454454 * @{
    455455 */
    456 VMMRCDECL(int)      PGMGCInvalidatePage(PVM pVM, RTGCPTR GCPtrPage);
    457456/** @} */
    458457#endif /* IN_GC */
  • trunk/src/VBox/VMM/PGM.cpp

    r13188 r13235  
    15481548
    15491549    /* GC only: */
    1550     STAM_REG(pVM, &pPGM->StatRCInvalidatePage,              STAMTYPE_PROFILE, "/PGM/RC/InvalidatePage",             STAMUNIT_TICKS_PER_CALL, "PGMGCInvalidatePage() profiling.");
    15511550    STAM_REG(pVM, &pPGM->StatRCDynMapCacheHits,             STAMTYPE_COUNTER, "/PGM/RC/DynMapCache/Hits" ,          STAMUNIT_OCCURENCES,     "Number of dynamic page mapping cache hits.");
    15521551    STAM_REG(pVM, &pPGM->StatRCDynMapCacheMisses,           STAMTYPE_COUNTER, "/PGM/RC/DynMapCache/Misses" ,        STAMUNIT_OCCURENCES,     "Number of dynamic page mapping cache misses.");
     1552    STAM_REG(pVM, &pPGM->StatRCInvlPgConflict,              STAMTYPE_COUNTER, "/PGM/RC/InvlPgConflict",             STAMUNIT_OCCURENCES,     "Number of times PGMInvalidatePage() detected a mapping conflict.");
     1553    STAM_REG(pVM, &pPGM->StatRCInvlPgSyncMonCR3,            STAMTYPE_COUNTER, "/PGM/RC/InvlPgSyncMonitorCR3",       STAMUNIT_OCCURENCES,     "Number of times PGMInvalidatePage() ran into PGM_SYNC_MONITOR_CR3.");
    15531554
    15541555    /* RZ only: */
  • trunk/src/VBox/VMM/PGMInternal.h

    r13100 r13235  
    24272427
    24282428    /* RC only: */
    2429     STAMPROFILE StatRCInvalidatePage;               /**< RC: PGMGCInvalidatePage() profiling. */
    24302429    STAMCOUNTER StatRCDynMapCacheMisses;            /**< RC: The number of dynamic page mapping cache hits */
    24312430    STAMCOUNTER StatRCDynMapCacheHits;              /**< RC: The number of dynamic page mapping cache misses */
     2431    STAMCOUNTER StatRCInvlPgConflict;               /**< RC: Number of times PGMInvalidatePage() detected a mapping conflict. */
     2432    STAMCOUNTER StatRCInvlPgSyncMonCR3;             /**< RC: Number of times PGMInvalidatePage() ran into PGM_SYNC_MONITOR_CR3. */
    24322433
    24332434    /* RZ only: */
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r13193 r13235  
    17861786     */
    17871787#ifdef IN_GC
    1788     // Note: we could also use PGMFlushPage here, but it currently doesn't always use invlpg!!!!!!!!!!
    1789     LogFlow(("GC: EMULATE: invlpg %08X\n", pAddrGC));
    1790     rc = PGMGCInvalidatePage(pVM, pAddrGC);
    1791 #else
     1788    LogFlow(("RC: EMULATE: invlpg %RGv\n", pAddrGC));
     1789#endif
    17921790    rc = PGMInvalidatePage(pVM, pAddrGC);
    1793 #endif
    1794     if (VBOX_SUCCESS(rc))
     1791    if (    rc == VINF_SUCCESS
     1792        ||  rc == VINF_PGM_SYNC_CR3 /* we can rely on the FF */)
    17951793        return VINF_SUCCESS;
    1796     Log(("PGMInvalidatePage %VGv returned %VGv (%d)\n", pAddrGC, rc, rc));
    1797     Assert(rc == VERR_REM_FLUSHED_PAGES_OVERFLOW);
    1798     /** @todo r=bird: we shouldn't ignore returns codes like this... I'm 99% sure the error is fatal. */
    1799     return VERR_EM_INTERPRETER;
     1794    AssertMsgReturn(   rc == VERR_REM_FLUSHED_PAGES_OVERFLOW
     1795                    || rc == VINF_EM_RAW_EMULATE_INSTR,
     1796                    ("%Rrc addr=%RGv\n", rc, pAddrGC),
     1797                    VERR_EM_INTERPRETER);
     1798    return rc;
    18001799}
    18011800
     
    18301829     */
    18311830#ifdef IN_GC
    1832     // Note: we could also use PGMFlushPage here, but it currently doesn't always use invlpg!!!!!!!!!!
    1833     LogFlow(("GC: EMULATE: invlpg %08X\n", addr));
    1834     rc = PGMGCInvalidatePage(pVM, addr);
    1835 #else
     1831    LogFlow(("RC: EMULATE: invlpg %RGv\n", addr));
     1832#endif
    18361833    rc = PGMInvalidatePage(pVM, addr);
    1837 #endif
    1838     if (VBOX_SUCCESS(rc))
     1834    if (    rc == VINF_SUCCESS
     1835        ||  rc == VINF_PGM_SYNC_CR3 /* we can rely on the FF */)
    18391836        return VINF_SUCCESS;
    1840     /** @todo r=bird: we shouldn't ignore returns codes like this... I'm 99% sure the error is fatal. */
    1841     return VERR_EM_INTERPRETER;
     1837    AssertMsgReturn(   rc == VERR_REM_FLUSHED_PAGES_OVERFLOW
     1838                    || rc == VINF_EM_RAW_EMULATE_INSTR,
     1839                    ("%Rrc addr=%RGv\n", rc, addr),
     1840                    VERR_EM_INTERPRETER);
     1841    return rc;
    18421842}
    18431843
  • trunk/src/VBox/VMM/VMMAll/PGMAll.cpp

    r13232 r13235  
    624624
    625625
    626 #ifndef IN_GC
    627626/**
    628627 * Emulation of the invlpg instruction (HC only actually).
    629628 *
    630  * @returns VBox status code.
     629 * @returns VBox status code, special care required.
     630 * @retval  VINF_PGM_SYNC_CR3 - handled.
     631 * @retval  VINF_EM_RAW_EMULATE_INSTR - not handled (RC only).
     632 * @retval  VERR_REM_FLUSHED_PAGES_OVERFLOW - not handled.
     633 *
    631634 * @param   pVM         VM handle.
    632635 * @param   GCPtrPage   Page to invalidate.
    633  * @remark  ASSUMES the page table entry or page directory is
    634  *          valid. Fairly safe, but there could be edge cases!
     636 *
     637 * @remark  ASSUMES the page table entry or page directory is valid. Fairly
     638 *          safe, but there could be edge cases!
     639 *
    635640 * @todo    Flush page or page directory only if necessary!
    636641 */
     
    638643{
    639644    int rc;
    640 
    641645    Log3(("PGMInvalidatePage: GCPtrPage=%VGv\n", GCPtrPage));
    642646
    643     /** @todo merge PGMGCInvalidatePage with this one */
    644 
    645 # ifndef IN_RING3
     647#ifndef IN_RING3
    646648    /*
    647649     * Notify the recompiler so it can record this instruction.
     
    649651     */
    650652    rc = REMNotifyInvalidatePage(pVM, GCPtrPage);
    651     if (VBOX_FAILURE(rc))
     653    if (rc != VINF_SUCCESS)
    652654        return rc;
    653 # endif
    654 
     655#endif /* !IN_RING3 */
     656
     657
     658#ifdef IN_GC
     659    /*
     660     * Check for conflicts and pending CR3 monitoring updates.
     661     */
     662    if (!pVM->pgm.s.fMappingsFixed)
     663    {
     664        if (    pgmGetMapping(pVM, GCPtrPage)
     665            &&  PGMGstGetPage(pVM, GCPtrPage, NULL, NULL) != VERR_PAGE_TABLE_NOT_PRESENT)
     666        {
     667            LogFlow(("PGMGCInvalidatePage: Conflict!\n"));
     668            VM_FF_SET(pVM, VM_FF_PGM_SYNC_CR3);
     669            STAM_COUNTER_INC(&pVM->pgm.s.StatRCInvlPgConflict);
     670            return VINF_PGM_SYNC_CR3;
     671        }
     672
     673        if (pVM->pgm.s.fSyncFlags & PGM_SYNC_MONITOR_CR3)
     674        {
     675            LogFlow(("PGMGCInvalidatePage: PGM_SYNC_MONITOR_CR3 -> reinterpret instruction in R3\n"));
     676            STAM_COUNTER_INC(&pVM->pgm.s.StatRCInvlPgSyncMonCR3);
     677            return VINF_EM_RAW_EMULATE_INSTR;
     678        }
     679    }
     680#endif /* IN_GC */
     681
     682    /*
     683     * Call paging mode specific worker.
     684     */
    655685    STAM_PROFILE_START(&pVM->pgm.s.CTX_MID_Z(Stat,InvalidatePage), a);
    656686    rc = PGM_BTH_PFN(InvalidatePage, pVM)(pVM, GCPtrPage);
    657687    STAM_PROFILE_STOP(&pVM->pgm.s.CTX_MID_Z(Stat,InvalidatePage), a);
    658688
    659 # ifndef IN_RING0
     689#ifdef IN_RING3
    660690    /*
    661691     * Check if we have a pending update of the CR3 monitoring.
     
    669699        rc = PGM_GST_PFN(MonitorCR3, pVM)(pVM, pVM->pgm.s.GCPhysCR3);
    670700    }
    671 # endif
    672 
    673 # ifdef IN_RING3
     701
    674702    /*
    675703     * Inform CSAM about the flush
    676      */
    677     /* note: This is to check if monitored pages have been changed; when we implement callbacks for virtual handlers, this is no longer required. */
     704     *
     705     * Note: This is to check if monitored pages have been changed; when we implement
     706     *       callbacks for virtual handlers, this is no longer required.
     707     */
    678708    CSAMR3FlushPage(pVM, GCPtrPage);
    679 # endif
     709#endif /* IN_RING3 */
    680710    return rc;
    681711}
    682 #endif /* !IN_GC */
    683712
    684713
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r13232 r13235  
    11101110                    && !(pPDEDst[iPD].u & PGM_PDFLAGS_MAPPING))
    11111111                {
    1112                 pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPDEDst[iPD].u & SHW_PDE_PG_MASK), SHW_POOL_ROOT_IDX, iPdpte * X86_PG_PAE_ENTRIES + iPD);
    1113                 pPDEDst[iPD].u = 0;
     1112                    pgmPoolFreeByPage(pPool, pgmPoolGetPage(pPool, pPDEDst[iPD].u & SHW_PDE_PG_MASK), SHW_POOL_ROOT_IDX, iPdpte * X86_PG_PAE_ENTRIES + iPD);
     1113                    pPDEDst[iPD].u = 0;
    11141114                }
    11151115            }
  • trunk/src/VBox/VMM/VMMGC/PGMGC.cpp

    r13106 r13235  
    166166#undef PGM_SHW_NAME
    167167
    168 
    169 
    170 /**
    171  * Emulation of the invlpg instruction.
    172  *
    173  * @returns VBox status code suitable for scheduling.
    174  * @param   pVM         VM handle.
    175  * @param   GCPtrPage   Page to invalidate.
    176  */
    177 VMMRCDECL(int) PGMGCInvalidatePage(PVM pVM, RTGCPTR GCPtrPage)
    178 {
    179     LogFlow(("PGMGCInvalidatePage: GCPtrPage=%VGv\n", GCPtrPage));
    180 
    181     STAM_PROFILE_START(&pVM->pgm.s.StatRCInvalidatePage, a);
    182 
    183     /*
    184      * Check for conflicts and pending CR3 monitoring updates.
    185      */
    186     if (!pVM->pgm.s.fMappingsFixed)
    187     {
    188         if (    pgmGetMapping(pVM, GCPtrPage)
    189             /** @todo &&  (PGMGstGetPDE(pVM, GCPtrPage) & X86_PDE_P) - FIX THIS NOW!!! */ )
    190         {
    191             LogFlow(("PGMGCInvalidatePage: Conflict!\n"));
    192             VM_FF_SET(pVM, VM_FF_PGM_SYNC_CR3);
    193             STAM_PROFILE_STOP(&pVM->pgm.s.StatRCInvalidatePage, a);
    194             return VINF_PGM_SYNC_CR3;
    195         }
    196 
    197         if (pVM->pgm.s.fSyncFlags & PGM_SYNC_MONITOR_CR3)
    198         {
    199             LogFlow(("PGMGCInvalidatePage: PGM_SYNC_MONITOR_CR3 -> reinterpret instruction in HC\n"));
    200             STAM_PROFILE_STOP(&pVM->pgm.s.StatRCInvalidatePage, a);
    201             /** @todo counter for these... */
    202             return VINF_EM_RAW_EMULATE_INSTR;
    203         }
    204     }
    205 
    206     /*
    207      * Notify the recompiler so it can record this instruction.
    208      * Failure happens when it's out of space. We'll return to HC in that case.
    209      */
    210     int rc = REMNotifyInvalidatePage(pVM, GCPtrPage);
    211     if (rc == VINF_SUCCESS)
    212         rc = PGM_BTH_PFN(InvalidatePage, pVM)(pVM, GCPtrPage);
    213 
    214     STAM_PROFILE_STOP(&pVM->pgm.s.StatRCInvalidatePage, a);
    215     return rc;
    216 }
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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