VirtualBox

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


Ignore:
Timestamp:
May 21, 2015 5:04:14 PM (10 years ago)
Author:
vboxsync
Message:

PGM: Made the virtual handler callbacks return VBOXSTRICTRC and prepared for RC execution.

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

Legend:

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

    r55937 r56013  
    7272 * @param   pvUser          User argument.
    7373 */
    74 PGM_ALL_CB2_DECL(int) csamCodePageWriteHandler(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf,
    75                                                PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)
     74PGM_ALL_CB2_DECL(VBOXSTRICTRC)
     75csamCodePageWriteHandler(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf,
     76                         PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)
    7677{
    7778    RTGCPTR const GCPtrMonitored = (uintptr_t)pvUser | (GCPtr & PAGE_OFFSET_MASK);
  • trunk/src/VBox/VMM/VMMAll/PATMAll.cpp

    r55937 r56013  
    5858 * @param   pvUser          The address of the guest page we're monitoring.
    5959 */
    60 PGM_ALL_CB2_DECL(int) patmVirtPageHandler(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf,
    61                                           PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)
     60PGM_ALL_CB2_DECL(VBOXSTRICTRC) patmVirtPageHandler(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf,
     61                                                   PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)
    6262{
    6363    Assert(enmAccessType == PGMACCESSTYPE_WRITE); NOREF(enmAccessType);
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r55988 r56013  
    719719                    &&  uErr & X86_TRAP_PF_RW)
    720720                {
     721                    VBOXSTRICTRC rcStrict;
    721722#   ifdef IN_RC
    722723                    STAM_PROFILE_START(&pCur->Stat, h);
     
    724725                    void *pvUser = pCur->CTX_SUFF(pvUser);
    725726                    pgmUnlock(pVM);
    726                     rc = pCurType->CTX_SUFF(pfnPfHandler)(pVM, pVCpu, uErr, pRegFrame, pvFault, pCur->Core.Key,
    727                                                           pvFault - pCur->Core.Key, pvUser);
     727                    rcStrict = pCurType->CTX_SUFF(pfnPfHandler)(pVM, pVCpu, uErr, pRegFrame, pvFault, pCur->Core.Key,
     728                                                                pvFault - pCur->Core.Key, pvUser);
    728729                    pgmLock(pVM);
    729730                    STAM_PROFILE_STOP(&pCur->Stat, h);
    730731#   else
    731732                    AssertFailed();
    732                     rc = VINF_EM_RAW_EMULATE_INSTR; /* can't happen with VMX */
     733                    rcStrict = VINF_EM_RAW_EMULATE_INSTR; /* can't happen with VMX */
    733734#   endif
    734735                    STAM_COUNTER_INC(&pVCpu->pgm.s.CTX_SUFF(pStats)->StatRZTrap0eHandlersMapping);
    735736                    STAM_STATS({ pVCpu->pgm.s.CTX_SUFF(pStatTrap0eAttribution) = &pVCpu->pgm.s.CTX_SUFF(pStats)->StatRZTrap0eTime2Mapping; });
    736                     return rc;
     737                    return VBOXSTRICTRC_TODO(rcStrict);
    737738                }
    738739
     
    816817                     ||  pCurType->enmKind != PGMVIRTHANDLERKIND_WRITE ) )
    817818            {
     819                VBOXSTRICTRC rcStrict;
    818820#   ifdef IN_RC
    819821                STAM_PROFILE_START(&pCur->Stat, h);
    820822                void *pvUser = pCur->CTX_SUFF(pvUser);
    821823                pgmUnlock(pVM);
    822                 rc = pCurType->CTX_SUFF(pfnPfHandler)(pVM, pVCpu, uErr, pRegFrame, pvFault, pCur->Core.Key,
    823                                                       pvFault - pCur->Core.Key, pvUser);
     824                rcStrict = pCurType->CTX_SUFF(pfnPfHandler)(pVM, pVCpu, uErr, pRegFrame, pvFault, pCur->Core.Key,
     825                                                            pvFault - pCur->Core.Key, pvUser);
    824826                pgmLock(pVM);
    825827                STAM_PROFILE_STOP(&pCur->Stat, h);
    826828#   else
    827                 rc = VINF_EM_RAW_EMULATE_INSTR; /** @todo for VMX */
     829                rcStrict = VINF_EM_RAW_EMULATE_INSTR; /** @todo for VMX */
    828830#   endif
    829831                STAM_STATS({ pVCpu->pgm.s.CTX_SUFF(pStatTrap0eAttribution) = &pVCpu->pgm.s.CTX_SUFF(pStats)->StatRZTrap0eTime2HndVirt; });
    830                 return rc;
     832                return VBOXSTRICTRC_TODO(rcStrict);
    831833            }
    832834        }
  • trunk/src/VBox/VMM/VMMAll/SELMAll.cpp

    r55899 r56013  
    4747#endif
    4848
     49
     50#ifndef IN_RING0
     51
     52# ifdef SELM_TRACK_GUEST_GDT_CHANGES
     53/**
     54 * @callback_method_impl{FNPGMVIRTHANDLER}
     55 */
     56PGM_ALL_CB2_DECL(VBOXSTRICTRC)
     57selmGuestGDTWriteHandler(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf,
     58                         PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)
     59{
     60    Assert(enmAccessType == PGMACCESSTYPE_WRITE); NOREF(enmAccessType);
     61    Log(("selmGuestGDTWriteHandler: write to %RGv size %d\n", GCPtr, cbBuf)); NOREF(GCPtr); NOREF(cbBuf);
     62    NOREF(pvPtr); NOREF(pvBuf); NOREF(enmOrigin); NOREF(pvUser);
     63
     64#  ifdef IN_RING3
     65    VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_GDT);
     66    return VINF_PGM_HANDLER_DO_DEFAULT;
     67
     68#  else  /* IN_RC: */
     69    /*
     70     * Execute the write, doing necessary pre and post shadow GDT checks.
     71     */
     72    PCPUMCTX pCtx        = CPUMQueryGuestCtxPtr(pVCpu);
     73    uint32_t offGuestGdt = pCtx->gdtr.pGdt - GCPtr;
     74    selmRCGuestGdtPreWriteCheck(pVM, pVCpu, offGuestGdt, cbBuf, pCtx);
     75    memcpy(pvBuf, pvPtr, cbBuf);
     76    VBOXSTRICTRC rcStrict = selmRCGuestGdtPostWriteCheck(pVM, pVCpu, offGuestGdt, cbBuf, pCtx);
     77    if (!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_SELM_SYNC_GDT))
     78        STAM_COUNTER_INC(&pVM->selm.s.StatRCWriteGuestGDTHandled);
     79    else
     80        STAM_COUNTER_INC(&pVM->selm.s.StatRCWriteGuestGDTUnhandled);
     81    return rcStrict;
     82#  endif
     83}
     84# endif
     85
     86
     87# ifdef SELM_TRACK_GUEST_LDT_CHANGES
     88/**
     89 * @callback_method_impl{FNPGMVIRTHANDLER}
     90 */
     91PGM_ALL_CB2_DECL(VBOXSTRICTRC)
     92selmGuestLDTWriteHandler(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf,
     93                         PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)
     94{
     95    Assert(enmAccessType == PGMACCESSTYPE_WRITE); NOREF(enmAccessType);
     96    Log(("selmGuestLDTWriteHandler: write to %RGv size %d\n", GCPtr, cbBuf)); NOREF(GCPtr); NOREF(cbBuf);
     97    NOREF(pvPtr); NOREF(pvBuf); NOREF(enmOrigin); NOREF(pvUser);
     98
     99    VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_LDT);
     100#  ifdef IN_RING3
     101    return VINF_PGM_HANDLER_DO_DEFAULT;
     102#  else
     103    STAM_COUNTER_INC(&pVM->selm.s.StatRCWriteGuestLDT);
     104    return VINF_EM_RAW_EMULATE_INSTR_LDT_FAULT;
     105#  endif
     106}
     107# endif
     108
     109
     110# ifdef SELM_TRACK_GUEST_TSS_CHANGES
     111/**
     112 * @callback_method_impl{FNPGMVIRTHANDLER}
     113 */
     114PGM_ALL_CB2_DECL(VBOXSTRICTRC)
     115selmGuestTSSWriteHandler(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf,
     116                         PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)
     117{
     118    Assert(enmAccessType == PGMACCESSTYPE_WRITE); NOREF(enmAccessType);
     119    Log(("selmGuestTSSWriteHandler: write %.*Rhxs to %RGv size %d\n", RT_MIN(8, cbBuf), pvBuf, GCPtr, cbBuf));
     120    NOREF(pvBuf); NOREF(GCPtr); NOREF(cbBuf); NOREF(enmOrigin); NOREF(pvUser); NOREF(pvPtr);
     121
     122#  ifdef IN_RING3
     123    /** @todo This can be optimized by checking for the ESP0 offset and tracking TR
     124     *        reloads in REM (setting VM_FF_SELM_SYNC_TSS if TR is reloaded). We
     125     *        should probably also deregister the virtual handler if TR.base/size
     126     *        changes while we're in REM.  May also share
     127     *        selmRCGuestTssPostWriteCheck code. */
     128    VMCPU_FF_SET(pVCpu, VMCPU_FF_SELM_SYNC_TSS);
     129    return VINF_PGM_HANDLER_DO_DEFAULT;
     130
     131#  else  /* IN_RC */
     132    /*
     133     * Do the write and check if anything relevant changed.
     134     */
     135    Assert(pVM->selm.s.GCPtrGuestTss != (uintptr_t)RTRCPTR_MAX);
     136    memcpy(pvPtr, pvBuf, cbBuf);
     137    return selmRCGuestTssPostWriteCheck(pVM, pVCpu, GCPtr - pVM->selm.s.GCPtrGuestTss, cbBuf);
     138#  endif
     139}
     140# endif
     141
     142#endif /* IN_RING0 */
    49143
    50144
  • trunk/src/VBox/VMM/VMMAll/TRPMAll.cpp

    r55001 r56013  
    4141#include "internal/pgm.h"
    4242
     43
     44
     45#if defined(TRPM_TRACK_GUEST_IDT_CHANGES) && !defined(IN_RING0)
     46/**
     47 * \#PF Handler callback for virtual access handler ranges.
     48 *
     49 * Important to realize that a physical page in a range can have aliases, and
     50 * for ALL and WRITE handlers these will also trigger.
     51 *
     52 * @returns VINF_SUCCESS if the handler have carried out the operation.
     53 * @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
     54 * @param   pVM             Pointer to the VM.
     55 * @param   pVCpu           Pointer to the cross context CPU context for the
     56 *                          calling EMT.
     57 * @param   GCPtr           The virtual address the guest is writing to. (not correct if it's an alias!)
     58 * @param   pvPtr           The HC mapping of that address.
     59 * @param   pvBuf           What the guest is reading/writing.
     60 * @param   cbBuf           How much it's reading/writing.
     61 * @param   enmAccessType   The access type.
     62 * @param   enmOrigin       The origin of this call.
     63 * @param   pvUser          User argument.
     64 */
     65PGM_ALL_CB2_DECL(VBOXSTRICTRC)
     66trpmGuestIDTWriteHandler(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf,
     67                         PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser)
     68{
     69    Assert(enmAccessType == PGMACCESSTYPE_WRITE); NOREF(enmAccessType);
     70    Log(("trpmGuestIDTWriteHandler: write to %RGv size %d\n", GCPtr, cbBuf)); NOREF(GCPtr); NOREF(cbBuf);
     71    NOREF(pvPtr); NOREF(pvUser); NOREF(pvBuf); NOREF(enmOrigin); NOREF(pvUser);
     72    Assert(!HMIsEnabled(pVM));
     73
     74    /** @todo Check which IDT entry and keep the update cost low in TRPMR3SyncIDT() and CSAMCheckGates(). */
     75    VMCPU_FF_SET(pVCpu, VMCPU_FF_TRPM_SYNC_IDT);
     76# ifdef IN_RC
     77    STAM_COUNTER_INC(&pVM->trpm.s.StatRCWriteGuestIDTFault);
     78# endif
     79    return VINF_PGM_HANDLER_DO_DEFAULT;
     80}
     81#endif /* TRPM_TRACK_GUEST_IDT_CHANGES && !IN_RING0 */
    4382
    4483
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