VirtualBox

Changeset 72598 in vbox


Ignore:
Timestamp:
Jun 18, 2018 1:32:05 PM (7 years ago)
Author:
vboxsync
Message:

EMHM.cpp: Prepping for EMHistoryExec-to-ring-3 and CPUMCTX_EXTRN_xxx.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/EMHM.cpp

    r72488 r72598  
    150150                rcStrict = VINF_EM_DBG_STEPPED;
    151151            Log(("EMR3HmSingleInstruction: returns %Rrc (rip %llx -> %llx)\n", VBOXSTRICTRC_VAL(rcStrict), uOldRip, pCtx->rip));
     152            CPUM_IMPORT_EXTRN_RET(pVCpu, ~CPUMCTX_EXTRN_KEEPER_MASK);
    152153            return rcStrict;
    153154        }
     
    176177    PCPUMCTX pCtx = pVCpu->em.s.pCtx;
    177178#endif
    178     int      rc;
    179179    NOREF(rcRC);
    180180
     
    196196     */
    197197    STAM_PROFILE_START(&pVCpu->em.s.StatIEMEmu, a);
    198     rc = VBOXSTRICTRC_TODO(IEMExecOne(pVCpu));
     198    VBOXSTRICTRC rcStrict;
     199    uint32_t     idxContinueExitRec = pVCpu->em.s.idxContinueExitRec;
     200    RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
     201    if (idxContinueExitRec >= RT_ELEMENTS(pVCpu->em.s.aExitRecords))
     202    {
     203        CPUM_IMPORT_EXTRN_RET(pVCpu, IEM_CPUMCTX_EXTRN_MUST_MASK);
     204        rcStrict = VBOXSTRICTRC_TODO(IEMExecOne(pVCpu));
     205    }
     206    else
     207    {
     208        RT_UNTRUSTED_VALIDATED_FENCE();
     209        rcStrict = EMHistoryExec(pVCpu, &pVCpu->em.s.aExitRecords[idxContinueExitRec], 0);
     210        LogFlow(("emR3HmExecuteInstruction: %Rrc (EMHistoryExec)\n", VBOXSTRICTRC_VAL(rcStrict)));
     211    }
    199212    STAM_PROFILE_STOP(&pVCpu->em.s.StatIEMEmu, a);
    200213
    201     if (   rc == VERR_IEM_ASPECT_NOT_IMPLEMENTED
    202         || rc == VERR_IEM_INSTR_NOT_IMPLEMENTED)
     214    if (   rcStrict == VERR_IEM_ASPECT_NOT_IMPLEMENTED
     215        || rcStrict == VERR_IEM_INSTR_NOT_IMPLEMENTED)
    203216    {
    204217#ifdef VBOX_WITH_REM
     
    210223        pVM->em.s.idLastRemCpu = pVCpu->idCpu;
    211224
    212         rc = REMR3EmulateInstruction(pVM, pVCpu);
     225        rcStrict = REMR3EmulateInstruction(pVM, pVCpu);
    213226        EMRemUnlock(pVM);
    214227        STAM_PROFILE_STOP(&pVCpu->em.s.StatREMEmu, b);
     
    222235        HMR3NotifyEmulated(pVCpu);
    223236#endif
    224     return rc;
     237    return VBOXSTRICTRC_TODO(rcStrict);
    225238}
    226239
     
    260273    STAM_PROFILE_START(&pVCpu->em.s.StatIOEmu, a);
    261274
    262     /*
    263      * Try to restart the io instruction that was refused in ring-0.
    264      */
    265     VBOXSTRICTRC rcStrict = HMR3RestartPendingIOInstr(pVM, pVCpu, pCtx);
    266     if (IOM_SUCCESS(rcStrict))
    267     {
     275    VBOXSTRICTRC rcStrict;
     276    uint32_t     idxContinueExitRec = pVCpu->em.s.idxContinueExitRec;
     277    RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
     278    if (idxContinueExitRec >= RT_ELEMENTS(pVCpu->em.s.aExitRecords))
     279    {
     280        /*
     281         * Try to restart the io instruction that was refused in ring-0.
     282         */
     283        rcStrict = HMR3RestartPendingIOInstr(pVM, pVCpu, pCtx);
     284        if (IOM_SUCCESS(rcStrict))
     285        {
     286            STAM_COUNTER_INC(&pVCpu->em.s.CTX_SUFF(pStats)->StatIoRestarted);
     287            STAM_PROFILE_STOP(&pVCpu->em.s.StatIOEmu, a);
     288            return VBOXSTRICTRC_TODO(rcStrict);     /* rip already updated. */
     289        }
     290        AssertMsgReturn(rcStrict == VERR_NOT_FOUND, ("%Rrc\n", VBOXSTRICTRC_VAL(rcStrict)),
     291                        RT_SUCCESS_NP(rcStrict) ? VERR_IPE_UNEXPECTED_INFO_STATUS : VBOXSTRICTRC_TODO(rcStrict));
     292
     293        /*
     294         * Hand it over to the interpreter.
     295         */
     296        CPUM_IMPORT_EXTRN_RET(pVCpu, IEM_CPUMCTX_EXTRN_MUST_MASK);
     297        rcStrict = IEMExecOne(pVCpu);
     298        LogFlow(("emR3HmExecuteIOInstruction: %Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
     299    }
     300    else
     301    {
     302        RT_UNTRUSTED_VALIDATED_FENCE();
     303        CPUM_IMPORT_EXTRN_RET(pVCpu, IEM_CPUMCTX_EXTRN_MUST_MASK);
     304        Assert(!HMR3HasPendingIOInstr(pVCpu));
     305        rcStrict = EMHistoryExec(pVCpu, &pVCpu->em.s.aExitRecords[idxContinueExitRec], 0);
     306        LogFlow(("emR3HmExecuteIOInstruction: %Rrc (EMHistoryExec)\n", VBOXSTRICTRC_VAL(rcStrict)));
    268307        STAM_COUNTER_INC(&pVCpu->em.s.CTX_SUFF(pStats)->StatIoRestarted);
    269         STAM_PROFILE_STOP(&pVCpu->em.s.StatIOEmu, a);
    270         return VBOXSTRICTRC_TODO(rcStrict);     /* rip already updated. */
    271     }
    272     AssertMsgReturn(rcStrict == VERR_NOT_FOUND, ("%Rrc\n", VBOXSTRICTRC_VAL(rcStrict)),
    273                     RT_SUCCESS_NP(rcStrict) ? VERR_IPE_UNEXPECTED_INFO_STATUS : VBOXSTRICTRC_TODO(rcStrict));
    274 
    275     /*
    276      * Hand it over to the interpreter.
    277      */
    278     rcStrict = IEMExecOne(pVCpu);
    279     LogFlow(("emR3HmExecuteIOInstruction: %Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
     308    }
     309
    280310    STAM_COUNTER_INC(&pVCpu->em.s.CTX_SUFF(pStats)->StatIoIem);
    281311    STAM_PROFILE_STOP(&pVCpu->em.s.StatIOEmu, a);
     
    303333    if (VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL))
    304334    {
     335        CPUM_IMPORT_EXTRN_RET(pVCpu, CPUMCTX_EXTRN_CR0 | CPUMCTX_EXTRN_CR3 | CPUMCTX_EXTRN_CR4);
    305336        Assert(pVCpu->em.s.enmState != EMSTATE_WAIT_SIPI);
    306337        int rc = PGMSyncCR3(pVCpu, pCtx->cr0, pCtx->cr3, pCtx->cr4, VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_PGM_SYNC_CR3));
     
    314345        /* Prefetch pages for EIP and ESP. */
    315346        /** @todo This is rather expensive. Should investigate if it really helps at all. */
     347        /** @todo this should be skipped! */
     348        CPUM_IMPORT_EXTRN_RET(pVCpu, CPUMCTX_EXTRN_CS | CPUMCTX_EXTRN_SS);
    316349        rc = PGMPrefetchPage(pVCpu, SELMToFlat(pVM, DISSELREG_CS, CPUMCTX2CORE(pCtx), pCtx->rip));
    317350        if (rc == VINF_SUCCESS)
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r72560 r72598  
    3838*********************************************************************************************************************************/
    3939#define LOG_GROUP LOG_GROUP_HM
     40#define VMCPU_INCL_CPUM_GST_CTX
    4041#include <VBox/vmm/cpum.h>
    4142#include <VBox/vmm/stam.h>
     
    32983299
    32993300/**
     3301 * Checks if there is an I/O instruction pending.
     3302 *
     3303 * @returns true if pending, false if not.
     3304 * @param   pVCpu       The cross context virtual CPU structure.
     3305 */
     3306VMMR3_INT_DECL(bool) HMR3HasPendingIOInstr(PVMCPU pVCpu)
     3307{
     3308    return pVCpu->hm.s.PendingIO.enmType != HMPENDINGIO_INVALID
     3309        && pVCpu->hm.s.PendingIO.GCPtrRip == pVCpu->cpum.GstCtx.rip;
     3310}
     3311
     3312
     3313/**
    33003314 * Restart an I/O instruction that was refused in ring-0
    33013315 *
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