VirtualBox

Changeset 47788 in vbox


Ignore:
Timestamp:
Aug 16, 2013 9:00:23 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
88049
Message:

EM/HM: Try execute single instructions in IEM before asking REM.

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

Legend:

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

    r47712 r47788  
    416416
    417417        /* these should be considered for release statistics. */
    418         EM_REG_COUNTER(&pVCpu->em.s.StatIOEmu,                 "/PROF/CPU%d/EM/Emulation/IO",      "Profiling of emR3RawExecuteIOInstruction.");
    419         EM_REG_COUNTER(&pVCpu->em.s.StatPrivEmu,               "/PROF/CPU%d/EM/Emulation/Priv",    "Profiling of emR3RawPrivileged.");
    420         EM_REG_PROFILE(&pVCpu->em.s.StatHmEntry,           "/PROF/CPU%d/EM/HmEnter",        "Profiling Hardware Accelerated Mode entry overhead.");
    421         EM_REG_PROFILE(&pVCpu->em.s.StatHmExec,            "/PROF/CPU%d/EM/HmExec",         "Profiling Hardware Accelerated Mode execution.");
    422         EM_REG_PROFILE(&pVCpu->em.s.StatREMEmu,               "/PROF/CPU%d/EM/REMEmuSingle",      "Profiling single instruction REM execution.");
    423         EM_REG_PROFILE(&pVCpu->em.s.StatREMExec,              "/PROF/CPU%d/EM/REMExec",           "Profiling REM execution.");
    424         EM_REG_PROFILE(&pVCpu->em.s.StatREMSync,              "/PROF/CPU%d/EM/REMSync",           "Profiling REM context syncing.");
    425         EM_REG_PROFILE(&pVCpu->em.s.StatRAWEntry,             "/PROF/CPU%d/EM/RAWEnter",          "Profiling Raw Mode entry overhead.");
    426         EM_REG_PROFILE(&pVCpu->em.s.StatRAWExec,              "/PROF/CPU%d/EM/RAWExec",           "Profiling Raw Mode execution.");
    427         EM_REG_PROFILE(&pVCpu->em.s.StatRAWTail,              "/PROF/CPU%d/EM/RAWTail",           "Profiling Raw Mode tail overhead.");
     418        EM_REG_COUNTER(&pVCpu->em.s.StatIOEmu,      "/PROF/CPU%d/EM/Emulation/IO",      "Profiling of emR3RawExecuteIOInstruction.");
     419        EM_REG_COUNTER(&pVCpu->em.s.StatPrivEmu,    "/PROF/CPU%d/EM/Emulation/Priv",    "Profiling of emR3RawPrivileged.");
     420        EM_REG_PROFILE(&pVCpu->em.s.StatHmEntry,    "/PROF/CPU%d/EM/HmEnter",        "Profiling Hardware Accelerated Mode entry overhead.");
     421        EM_REG_PROFILE(&pVCpu->em.s.StatHmExec,     "/PROF/CPU%d/EM/HmExec",         "Profiling Hardware Accelerated Mode execution.");
     422        EM_REG_PROFILE(&pVCpu->em.s.StatIEMEmu,     "/PROF/CPU%d/EM/IEMEmuSingle",      "Profiling single instruction IEM execution.");
     423        EM_REG_PROFILE(&pVCpu->em.s.StatREMEmu,     "/PROF/CPU%d/EM/REMEmuSingle",      "Profiling single instruction REM execution.");
     424        EM_REG_PROFILE(&pVCpu->em.s.StatREMExec,    "/PROF/CPU%d/EM/REMExec",           "Profiling REM execution.");
     425        EM_REG_PROFILE(&pVCpu->em.s.StatREMSync,    "/PROF/CPU%d/EM/REMSync",           "Profiling REM context syncing.");
     426        EM_REG_PROFILE(&pVCpu->em.s.StatRAWEntry,   "/PROF/CPU%d/EM/RAWEnter",          "Profiling Raw Mode entry overhead.");
     427        EM_REG_PROFILE(&pVCpu->em.s.StatRAWExec,    "/PROF/CPU%d/EM/RAWExec",           "Profiling Raw Mode execution.");
     428        EM_REG_PROFILE(&pVCpu->em.s.StatRAWTail,    "/PROF/CPU%d/EM/RAWTail",           "Profiling Raw Mode tail overhead.");
    428429
    429430#endif /* VBOX_WITH_STATISTICS */
  • trunk/src/VBox/VMM/VMMR3/EMHM.cpp

    r47671 r47788  
    6161*   Internal Functions                                                         *
    6262*******************************************************************************/
    63 DECLINLINE(int) emR3ExecuteInstruction(PVM pVM, PVMCPU pVCpu, const char *pszPrefix, int rcGC = VINF_SUCCESS);
    64 static int emR3ExecuteIOInstruction(PVM pVM, PVMCPU pVCpu);
    65 static int emR3HmForcedActions(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
     63DECLINLINE(int) emR3HmExecuteInstruction(PVM pVM, PVMCPU pVCpu, const char *pszPrefix, int rcGC = VINF_SUCCESS);
     64static int      emR3HmExecuteIOInstruction(PVM pVM, PVMCPU pVCpu);
     65static int      emR3HmForcedActions(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
    6666
    6767#define EMHANDLERC_WITH_HM
     68#define emR3ExecuteInstruction   emR3HmExecuteInstruction
     69#define emR3ExecuteIOInstruction emR3HmExecuteIOInstruction
    6870#include "EMHandleRCTmpl.h"
    69 
    70 
    71 #if defined(DEBUG) && defined(SOME_UNUSED_FUNCTIONS)
    72 
    73 /**
    74  * Steps hardware accelerated mode.
    75  *
    76  * @returns VBox status code.
    77  * @param   pVM     Pointer to the VM.
    78  * @param   pVCpu   Pointer to the VMCPU.
    79  */
    80 static int emR3HmStep(PVM pVM, PVMCPU pVCpu)
    81 {
    82     Assert(pVCpu->em.s.enmState == EMSTATE_DEBUG_GUEST_HM);
    83 
    84     int         rc;
    85     PCPUMCTX    pCtx   = pVCpu->em.s.pCtx;
    86 # ifdef VBOX_WITH_RAW_MODE
    87     Assert(!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_SELM_SYNC_GDT | VMCPU_FF_SELM_SYNC_LDT | VMCPU_FF_TRPM_SYNC_IDT | VMCPU_FF_SELM_SYNC_TSS));
    88 # endif
    89 
    90     /*
    91      * Check vital forced actions, but ignore pending interrupts and timers.
    92      */
    93     if (    VM_FF_IS_PENDING(pVM, VM_FF_HIGH_PRIORITY_PRE_RAW_MASK)
    94         ||  VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_HIGH_PRIORITY_PRE_RAW_MASK))
    95     {
    96         rc = emR3HmForcedActions(pVM, pVCpu, pCtx);
    97         if (rc != VINF_SUCCESS)
    98             return rc;
    99     }
    100     /*
    101      * Set flags for single stepping.
    102      */
    103     CPUMSetGuestEFlags(pVCpu, CPUMGetGuestEFlags(pVCpu) | X86_EFL_TF | X86_EFL_RF);
    104 
    105     /*
    106      * Single step.
    107      * We do not start time or anything, if anything we should just do a few nanoseconds.
    108      */
    109     do
    110     {
    111         rc = VMMR3HmRunGC(pVM, pVCpu);
    112     } while (   rc == VINF_SUCCESS
    113              || rc == VINF_EM_RAW_INTERRUPT);
    114     VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_RESUME_GUEST_MASK);
    115 
    116     /*
    117      * Make sure the trap flag is cleared.
    118      * (Too bad if the guest is trying to single step too.)
    119      */
    120     CPUMSetGuestEFlags(pVCpu, CPUMGetGuestEFlags(pVCpu) & ~X86_EFL_TF);
    121 
    122     /*
    123      * Deal with the return codes.
    124      */
    125     rc = emR3HighPriorityPostForcedActions(pVM, pVCpu, rc);
    126     rc = emR3HmHandleRC(pVM, pVCpu, pCtx, rc);
    127     return rc;
    128 }
    129 
    130 
    131 static int emR3SingleStepExecHm(PVM pVM, PVMCPU pVCpu, uint32_t cIterations)
    132 {
    133     int     rc          = VINF_SUCCESS;
    134     EMSTATE enmOldState = pVCpu->em.s.enmState;
    135     pVCpu->em.s.enmState  = EMSTATE_DEBUG_GUEST_HM;
    136 
    137     Log(("Single step BEGIN:\n"));
    138     for (uint32_t i = 0; i < cIterations; i++)
    139     {
    140         DBGFR3PrgStep(pVCpu);
    141         DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, "RSS");
    142         rc = emR3HmStep(pVM, pVCpu);
    143         if (    rc != VINF_SUCCESS
    144             ||  !HMR3CanExecuteGuest(pVM, pVCpu->em.s.pCtx))
    145             break;
    146     }
    147     Log(("Single step END: rc=%Rrc\n", rc));
    148     CPUMSetGuestEFlags(pVCpu, CPUMGetGuestEFlags(pVCpu) & ~X86_EFL_TF);
    149     pVCpu->em.s.enmState = enmOldState;
    150     return rc == VINF_SUCCESS ? VINF_EM_RESCHEDULE_REM : rc;
    151 }
    152 
    153 #endif /* DEBUG */
    15471
    15572
     
    249166 */
    250167#ifdef LOG_ENABLED
    251 static int emR3ExecuteInstructionWorker(PVM pVM, PVMCPU pVCpu, int rcRC, const char *pszPrefix)
     168static int emR3HmExecuteInstructionWorker(PVM pVM, PVMCPU pVCpu, int rcRC, const char *pszPrefix)
    252169#else
    253 static int emR3ExecuteInstructionWorker(PVM pVM, PVMCPU pVCpu, int rcRC)
     170static int emR3HmExecuteInstructionWorker(PVM pVM, PVMCPU pVCpu, int rcRC)
    254171#endif
    255172{
     
    260177    NOREF(rcRC);
    261178
    262     /*
    263      *
    264      * The simple solution is to use the recompiler.
    265      * The better solution is to disassemble the current instruction and
    266      * try handle as many as possible without using REM.
    267      *
    268      */
    269 
    270179#ifdef LOG_ENABLED
    271180    /*
    272      * Disassemble the instruction if requested.
    273      */
     181     * Log it.
     182     */
     183    Log(("EMINS: %04x:%RGv RSP=%RGv\n", pCtx->cs.Sel, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));
    274184    if (pszPrefix)
    275185    {
     
    277187        DBGFR3_DISAS_INSTR_CUR_LOG(pVCpu, pszPrefix);
    278188    }
    279 #endif /* LOG_ENABLED */
    280 
    281 #if 0
    282     /* Try our own instruction emulator before falling back to the recompiler. */
    283     DISCPUSTATE Cpu;
    284     rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pCtx->rip, &Cpu, "GEN EMU");
    285     if (RT_SUCCESS(rc))
    286     {
    287         switch (Cpu.pCurInstr->uOpcode)
    288         {
    289         /* @todo we can do more now */
    290         case OP_MOV:
    291         case OP_AND:
    292         case OP_OR:
    293         case OP_XOR:
    294         case OP_POP:
    295         case OP_INC:
    296         case OP_DEC:
    297         case OP_XCHG:
    298             STAM_PROFILE_START(&pVCpu->em.s.StatMiscEmu, a);
    299             rc = EMInterpretInstructionCpuUpdtPC(pVM, pVCpu, &Cpu, CPUMCTX2CORE(pCtx), 0);
    300             if (RT_SUCCESS(rc))
    301             {
    302 #ifdef EM_NOTIFY_HM
    303                 if (pVCpu->em.s.enmState == EMSTATE_DEBUG_GUEST_HM)
    304                     HMR3NotifyEmulated(pVCpu);
    305 #endif
    306                 STAM_PROFILE_STOP(&pVCpu->em.s.StatMiscEmu, a);
    307                 return rc;
    308             }
    309             if (rc != VERR_EM_INTERPRETER)
    310                 AssertMsgFailedReturn(("rc=%Rrc\n", rc), rc);
    311             STAM_PROFILE_STOP(&pVCpu->em.s.StatMiscEmu, a);
    312             break;
    313         }
    314     }
    315 #endif /* 0 */
    316     STAM_PROFILE_START(&pVCpu->em.s.StatREMEmu, a);
    317     Log(("EMINS: %04x:%RGv RSP=%RGv\n", pCtx->cs.Sel, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));
     189#endif
     190
     191    /*
     192     * Use IEM and fallback on REM if the functionality is missing.
     193     * Once IEM gets mature enough, nothing should ever fall back.
     194     */
     195#if defined(VBOX_WITH_FIRST_IEM_STEP) || !defined(VBOX_WITH_REM)
     196    STAM_PROFILE_START(&pVCpu->em.s.StatIEMEmu, a);
     197    rc = VBOXSTRICTRC_TODO(IEMExecOne(pVCpu));
     198    STAM_PROFILE_STOP(&pVCpu->em.s.StatIEMEmu, a);
     199
     200    if (   rc == VERR_IEM_ASPECT_NOT_IMPLEMENTED
     201        || rc == VERR_IEM_INSTR_NOT_IMPLEMENTED)
     202#endif
     203    {
    318204#ifdef VBOX_WITH_REM
    319     EMRemLock(pVM);
    320     /* Flush the recompiler TLB if the VCPU has changed. */
    321     if (pVM->em.s.idLastRemCpu != pVCpu->idCpu)
    322         CPUMSetChangedFlags(pVCpu, CPUM_CHANGED_ALL);
    323     pVM->em.s.idLastRemCpu = pVCpu->idCpu;
    324 
    325     rc = REMR3EmulateInstruction(pVM, pVCpu);
    326     EMRemUnlock(pVM);
    327 #else
    328     rc = VBOXSTRICTRC_TODO(IEMExecOne(pVCpu)); NOREF(pVM);
    329 #endif
    330     STAM_PROFILE_STOP(&pVCpu->em.s.StatREMEmu, a);
     205        STAM_PROFILE_START(&pVCpu->em.s.StatREMEmu, a);
     206# ifndef VBOX_WITH_FIRST_IEM_STEP
     207        Log(("EMINS[rem]: %04x:%RGv RSP=%RGv\n", pCtx->cs.Sel, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));
     208# elif defined(DEBUG_bird)
     209        AssertFailed();
     210# endif
     211        EMRemLock(pVM);
     212        /* Flush the recompiler TLB if the VCPU has changed. */
     213        if (pVM->em.s.idLastRemCpu != pVCpu->idCpu)
     214            CPUMSetChangedFlags(pVCpu, CPUM_CHANGED_ALL);
     215        pVM->em.s.idLastRemCpu = pVCpu->idCpu;
     216
     217        rc = REMR3EmulateInstruction(pVM, pVCpu);
     218        EMRemUnlock(pVM);
     219        STAM_PROFILE_STOP(&pVCpu->em.s.StatREMEmu, a);
     220#else  /* !VBOX_WITH_REM */
     221        NOREF(pVM);
     222#endif /* !VBOX_WITH_REM */
     223    }
    331224
    332225#ifdef EM_NOTIFY_HM
     
    349242 * @param   rcGC        GC return code
    350243 */
    351 DECLINLINE(int) emR3ExecuteInstruction(PVM pVM, PVMCPU pVCpu, const char *pszPrefix, int rcGC)
     244DECLINLINE(int) emR3HmExecuteInstruction(PVM pVM, PVMCPU pVCpu, const char *pszPrefix, int rcGC)
    352245{
    353246#ifdef LOG_ENABLED
    354     return emR3ExecuteInstructionWorker(pVM, pVCpu, rcGC, pszPrefix);
     247    return emR3HmExecuteInstructionWorker(pVM, pVCpu, rcGC, pszPrefix);
    355248#else
    356     return emR3ExecuteInstructionWorker(pVM, pVCpu, rcGC);
     249    return emR3HmExecuteInstructionWorker(pVM, pVCpu, rcGC);
    357250#endif
    358251}
     
    365258 * @param   pVCpu       Pointer to the VMCPU.
    366259 */
    367 static int emR3ExecuteIOInstruction(PVM pVM, PVMCPU pVCpu)
     260static int emR3HmExecuteIOInstruction(PVM pVM, PVMCPU pVCpu)
    368261{
    369262    PCPUMCTX pCtx = pVCpu->em.s.pCtx;
     
    371264    STAM_PROFILE_START(&pVCpu->em.s.StatIOEmu, a);
    372265
    373     /* Try to restart the io instruction that was refused in ring-0. */
     266    /*
     267     * Try to restart the io instruction that was refused in ring-0.
     268     */
    374269    VBOXSTRICTRC rcStrict = HMR3RestartPendingIOInstr(pVM, pVCpu, pCtx);
    375270    if (IOM_SUCCESS(rcStrict))
     
    383278
    384279#ifdef VBOX_WITH_FIRST_IEM_STEP
    385     /* Hand it over to the interpreter. */
     280    /*
     281     * Hand it over to the interpreter.
     282     */
    386283    rcStrict = IEMExecOne(pVCpu);
    387     LogFlow(("emR3ExecuteIOInstruction: %Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
     284    LogFlow(("emR3HmExecuteIOInstruction: %Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
    388285    STAM_COUNTER_INC(&pVCpu->em.s.CTX_SUFF(pStats)->StatIoIem);
    389286    STAM_PROFILE_STOP(&pVCpu->em.s.StatIOEmu, a);
     
    449346            pCtx->rip += Cpu.cbInstr;
    450347            STAM_PROFILE_STOP(&pVCpu->em.s.StatIOEmu, a);
    451             LogFlow(("emR3ExecuteIOInstruction: %Rrc 1\n", VBOXSTRICTRC_VAL(rcStrict)));
     348            LogFlow(("emR3HmExecuteIOInstruction: %Rrc 1\n", VBOXSTRICTRC_VAL(rcStrict)));
    452349            return VBOXSTRICTRC_TODO(rcStrict);
    453350        }
     
    458355            Assert(TRPMHasTrap(pVCpu));
    459356            STAM_PROFILE_STOP(&pVCpu->em.s.StatIOEmu, a);
    460             LogFlow(("emR3ExecuteIOInstruction: VINF_SUCCESS 2\n"));
     357            LogFlow(("emR3HmExecuteIOInstruction: VINF_SUCCESS 2\n"));
    461358            return VINF_SUCCESS;
    462359        }
     
    466363        {
    467364            STAM_PROFILE_STOP(&pVCpu->em.s.StatIOEmu, a);
    468             LogFlow(("emR3ExecuteIOInstruction: %Rrc 3\n", VBOXSTRICTRC_VAL(rcStrict)));
     365            LogFlow(("emR3HmExecuteIOInstruction: %Rrc 3\n", VBOXSTRICTRC_VAL(rcStrict)));
    469366            return VBOXSTRICTRC_TODO(rcStrict);
    470367        }
     
    473370
    474371    STAM_PROFILE_STOP(&pVCpu->em.s.StatIOEmu, a);
    475     int rc3 = emR3ExecuteInstruction(pVM, pVCpu, "IO: ");
    476     LogFlow(("emR3ExecuteIOInstruction: %Rrc 4 (rc2=%Rrc, rc3=%Rrc)\n", VBOXSTRICTRC_VAL(rcStrict), rc2, rc3));
     372    int rc3 = emR3HmExecuteInstruction(pVM, pVCpu, "IO: ");
     373    LogFlow(("emR3HmExecuteIOInstruction: %Rrc 4 (rc2=%Rrc, rc3=%Rrc)\n", VBOXSTRICTRC_VAL(rcStrict), rc2, rc3));
    477374    return rc3;
    478375#endif
  • trunk/src/VBox/VMM/VMMR3/EMRaw.cpp

    r47421 r47788  
    5959*   Internal Functions                                                         *
    6060*******************************************************************************/
    61 static int emR3RawForcedActions(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
    62 DECLINLINE(int) emR3ExecuteInstruction(PVM pVM, PVMCPU pVCpu, const char *pszPrefix, int rcGC = VINF_SUCCESS);
    63 static int emR3RawGuestTrap(PVM pVM, PVMCPU pVCpu);
    64 static int emR3PatchTrap(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, int gcret);
    65 static int emR3RawPrivileged(PVM pVM, PVMCPU pVCpu);
    66 static int emR3ExecuteIOInstruction(PVM pVM, PVMCPU pVCpu);
    67 static int emR3RawRingSwitch(PVM pVM, PVMCPU pVCpu);
     61static int      emR3RawForcedActions(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
     62DECLINLINE(int) emR3RawExecuteInstruction(PVM pVM, PVMCPU pVCpu, const char *pszPrefix, int rcGC = VINF_SUCCESS);
     63static int      emR3RawGuestTrap(PVM pVM, PVMCPU pVCpu);
     64static int      emR3RawPatchTrap(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, int gcret);
     65static int      emR3RawPrivileged(PVM pVM, PVMCPU pVCpu);
     66static int      emR3RawExecuteIOInstruction(PVM pVM, PVMCPU pVCpu);
     67static int      emR3RawRingSwitch(PVM pVM, PVMCPU pVCpu);
    6868
    6969#define EMHANDLERC_WITH_PATM
     70#define emR3ExecuteInstruction   emR3RawExecuteInstruction
     71#define emR3ExecuteIOInstruction emR3RawExecuteIOInstruction
    7072#include "EMHandleRCTmpl.h"
    7173
     
    264266 */
    265267#ifdef LOG_ENABLED
    266 static int emR3ExecuteInstructionWorker(PVM pVM, PVMCPU pVCpu, int rcGC, const char *pszPrefix)
     268static int emR3RawExecuteInstructionWorker(PVM pVM, PVMCPU pVCpu, int rcGC, const char *pszPrefix)
    267269#else
    268 static int emR3ExecuteInstructionWorker(PVM pVM, PVMCPU pVCpu, int rcGC)
     270static int emR3RawExecuteInstructionWorker(PVM pVM, PVMCPU pVCpu, int rcGC)
    269271#endif
    270272{
     
    299301    if (PATMIsPatchGCAddr(pVM, pCtx->eip))
    300302    {
    301         Log(("emR3ExecuteInstruction: In patch block. eip=%RRv\n", (RTRCPTR)pCtx->eip));
     303        Log(("emR3RawExecuteInstruction: In patch block. eip=%RRv\n", (RTRCPTR)pCtx->eip));
    302304
    303305        RTGCPTR pNewEip;
     
    310312             */
    311313            case VINF_SUCCESS:
    312                 Log(("emR3ExecuteInstruction: Executing instruction starting at new address %RGv IF=%d VMIF=%x\n",
     314                Log(("emR3RawExecuteInstruction: Executing instruction starting at new address %RGv IF=%d VMIF=%x\n",
    313315                     pNewEip, pCtx->eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags));
    314316                pCtx->eip = pNewEip;
     
    321323                     */
    322324                    Log(("PATCH: IF=1 -> emulate last instruction as it can't be interrupted!!\n"));
    323                     return emR3ExecuteInstruction(pVM, pVCpu, "PATCHIR");
     325                    return emR3RawExecuteInstruction(pVM, pVCpu, "PATCHIR");
    324326                }
    325327                else if (rcGC == VINF_PATM_PENDING_IRQ_AFTER_IRET)
    326328                {
    327329                    /* special case: iret, that sets IF,  detected a pending irq/event */
    328                     return emR3ExecuteInstruction(pVM, pVCpu, "PATCHIRET");
     330                    return emR3RawExecuteInstruction(pVM, pVCpu, "PATCHIRET");
    329331                }
    330332                return VINF_EM_RESCHEDULE_REM;
     
    334336             */
    335337            case VINF_PATCH_EMULATE_INSTR:
    336                 Log(("emR3ExecuteInstruction: Emulate patched instruction at %RGv IF=%d VMIF=%x\n",
     338                Log(("emR3RawExecuteInstruction: Emulate patched instruction at %RGv IF=%d VMIF=%x\n",
    337339                     pNewEip, pCtx->eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags));
    338340                pCtx->eip = pNewEip;
    339                 return emR3ExecuteInstruction(pVM, pVCpu, "PATCHIR");
     341                return emR3RawExecuteInstruction(pVM, pVCpu, "PATCHIR");
    340342
    341343            /*
     
    343345             */
    344346            case VERR_PATCH_DISABLED:
    345                 Log(("emR3ExecuteInstruction: Disabled patch -> new eip %RGv IF=%d VMIF=%x\n",
     347                Log(("emR3RawExecuteInstruction: Disabled patch -> new eip %RGv IF=%d VMIF=%x\n",
    346348                     pNewEip, pCtx->eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags));
    347349                pCtx->eip = pNewEip;
     
    352354                     */
    353355                    Log(("PATCH: IF=1 -> emulate last instruction as it can't be interrupted!!\n"));
    354                     return emR3ExecuteInstruction(pVM, pVCpu, "PATCHIR");
     356                    return emR3RawExecuteInstruction(pVM, pVCpu, "PATCHIR");
    355357                }
    356358                return VINF_EM_RESCHEDULE_REM;
     
    397399 * @param   rcGC        GC return code
    398400 */
    399 DECLINLINE(int) emR3ExecuteInstruction(PVM pVM, PVMCPU pVCpu, const char *pszPrefix, int rcGC)
     401DECLINLINE(int) emR3RawExecuteInstruction(PVM pVM, PVMCPU pVCpu, const char *pszPrefix, int rcGC)
    400402{
    401403#ifdef LOG_ENABLED
    402     return emR3ExecuteInstructionWorker(pVM, pVCpu, rcGC, pszPrefix);
     404    return emR3RawExecuteInstructionWorker(pVM, pVCpu, rcGC, pszPrefix);
    403405#else
    404     return emR3ExecuteInstructionWorker(pVM, pVCpu, rcGC);
     406    return emR3RawExecuteInstructionWorker(pVM, pVCpu, rcGC);
    405407#endif
    406408}
     
    413415 * @param   pVCpu       Pointer to the VMCPU.
    414416 */
    415 static int emR3ExecuteIOInstruction(PVM pVM, PVMCPU pVCpu)
     417static int emR3RawExecuteIOInstruction(PVM pVM, PVMCPU pVCpu)
    416418{
    417419#ifdef VBOX_WITH_FIRST_IEM_STEP
     
    420422    /* Hand it over to the interpreter. */
    421423    VBOXSTRICTRC rcStrict = IEMExecOne(pVCpu);
    422     LogFlow(("emR3ExecuteIOInstruction: %Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
     424    LogFlow(("emR3RawExecuteIOInstruction: %Rrc\n", VBOXSTRICTRC_VAL(rcStrict)));
    423425    STAM_COUNTER_INC(&pVCpu->em.s.CTX_SUFF(pStats)->StatIoIem);
    424426    STAM_PROFILE_STOP(&pVCpu->em.s.StatIOEmu, a);
     
    507509    }
    508510    STAM_PROFILE_STOP(&pVCpu->em.s.StatIOEmu, a);
    509     return emR3ExecuteInstruction(pVM, pVCpu, "IO: ");
     511    return emR3RawExecuteInstruction(pVM, pVCpu, "IO: ");
    510512#endif
    511513}
     
    551553    {
    552554        LogFlow(("emR3RawGuestTrap: trap %#x in patch code; eip=%08x\n", u8TrapNo, pCtx->eip));
    553         return emR3PatchTrap(pVM, pVCpu, pCtx, rc);
     555        return emR3RawPatchTrap(pVM, pVCpu, pCtx, rc);
    554556    }
    555557#endif
     
    620622                if (RT_SUCCESS(rc))
    621623                    return rc;
    622                 return emR3ExecuteInstruction(pVM, pVCpu, "Monitor: ");
     624                return emR3RawExecuteInstruction(pVM, pVCpu, "Monitor: ");
    623625            }
    624626        }
     
    642644            rc = TRPMResetTrap(pVCpu);
    643645            AssertRC(rc);
    644             return emR3ExecuteInstruction(pVM, pVCpu, "IO Guest Trap: ");
     646            return emR3RawExecuteInstruction(pVM, pVCpu, "IO Guest Trap: ");
    645647        }
    646648    }
     
    728730
    729731    /* go to the REM to emulate a single instruction */
    730     return emR3ExecuteInstruction(pVM, pVCpu, "RSWITCH: ");
     732    return emR3RawExecuteInstruction(pVM, pVCpu, "RSWITCH: ");
    731733}
    732734
     
    741743 * @param   gcret   GC return code.
    742744 */
    743 static int emR3PatchTrap(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, int gcret)
     745static int emR3RawPatchTrap(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, int gcret)
    744746{
    745747    uint8_t         u8TrapNo;
     
    769771        if (RT_FAILURE(rc))
    770772        {
    771             AssertReleaseMsgFailed(("emR3PatchTrap: no trap! (rc=%Rrc) gcret=%Rrc\n", rc, gcret));
     773            AssertReleaseMsgFailed(("emR3RawPatchTrap: no trap! (rc=%Rrc) gcret=%Rrc\n", rc, gcret));
    772774            return rc;
    773775        }
     
    828830        }
    829831#endif /* LOG_ENABLED */
    830         Log(("emR3PatchTrap: in patch: eip=%08x: trap=%02x err=%08x cr2=%08x cr0=%08x\n",
     832        Log(("emR3RawPatchTrap: in patch: eip=%08x: trap=%02x err=%08x cr2=%08x cr0=%08x\n",
    831833             pCtx->eip, u8TrapNo, uErrorCode, uCR2, (uint32_t)pCtx->cr0));
    832834
     
    841843            {
    842844                /** @todo execute a whole block */
    843                 Log(("emR3PatchTrap: Executing faulting instruction at new address %RGv\n", pNewEip));
     845                Log(("emR3RawPatchTrap: Executing faulting instruction at new address %RGv\n", pNewEip));
    844846                if (!(pVCpu->em.s.pPatmGCState->uVMFlags & X86_EFL_IF))
    845                     Log(("emR3PatchTrap: Virtual IF flag disabled!!\n"));
     847                    Log(("emR3RawPatchTrap: Virtual IF flag disabled!!\n"));
    846848
    847849                pCtx->eip = pNewEip;
     
    864866                    /* Note: possibly because a reschedule is required (e.g. iret to V86 code) */
    865867
    866                     return emR3ExecuteInstruction(pVM, pVCpu, "PATCHIR");
     868                    return emR3RawExecuteInstruction(pVM, pVCpu, "PATCHIR");
    867869                    /* Interrupts are enabled; just go back to the original instruction.
    868870                    return VINF_SUCCESS; */
     
    875877             */
    876878            case VINF_PATCH_EMULATE_INSTR:
    877                 Log(("emR3PatchTrap: Emulate patched instruction at %RGv IF=%d VMIF=%x\n",
     879                Log(("emR3RawPatchTrap: Emulate patched instruction at %RGv IF=%d VMIF=%x\n",
    878880                     pNewEip, pCtx->eflags.Bits.u1IF, pVCpu->em.s.pPatmGCState->uVMFlags));
    879881                pCtx->eip = pNewEip;
    880882                AssertRelease(pCtx->eip);
    881                 return emR3ExecuteInstruction(pVM, pVCpu, "PATCHEMUL: ");
     883                return emR3RawExecuteInstruction(pVM, pVCpu, "PATCHEMUL: ");
    882884
    883885            /*
     
    886888            case VERR_PATCH_DISABLED:
    887889                if (!(pVCpu->em.s.pPatmGCState->uVMFlags & X86_EFL_IF))
    888                     Log(("emR3PatchTrap: Virtual IF flag disabled!!\n"));
     890                    Log(("emR3RawPatchTrap: Virtual IF flag disabled!!\n"));
    889891                pCtx->eip = pNewEip;
    890892                AssertRelease(pCtx->eip);
     
    896898                     */
    897899                    Log(("PATCH: IF=1 -> emulate last instruction as it can't be interrupted!!\n"));
    898                     return emR3ExecuteInstruction(pVM, pVCpu, "PATCHIR");
     900                    return emR3RawExecuteInstruction(pVM, pVCpu, "PATCHIR");
    899901                }
    900902                return VINF_EM_RESCHEDULE_REM;
     
    11531155
    11541156    if (PATMIsPatchGCAddr(pVM, pCtx->eip))
    1155         return emR3PatchTrap(pVM, pVCpu, pCtx, VINF_PATM_PATCH_TRAP_GP);
    1156 
    1157     return emR3ExecuteInstruction(pVM, pVCpu, "PRIV");
     1157        return emR3RawPatchTrap(pVM, pVCpu, pCtx, VINF_PATM_PATCH_TRAP_GP);
     1158
     1159    return emR3RawExecuteInstruction(pVM, pVCpu, "PRIV");
    11581160}
    11591161
  • trunk/src/VBox/VMM/include/EMHandleRCTmpl.h

    r47089 r47788  
    1818#ifndef ___EMHandleRCTmpl_h
    1919#define ___EMHandleRCTmpl_h
     20
     21#if defined(EMHANDLERC_WITH_PATM) && defined(EMHANDLERC_WITH_HM)
     22# error "Only one define"
     23#endif
     24
    2025
    2126/**
     
    8287        case VINF_PATM_PATCH_TRAP_PF:
    8388        case VINF_PATM_PATCH_INT3:
    84             rc = emR3PatchTrap(pVM, pVCpu, pCtx, rc);
     89            rc = emR3RawPatchTrap(pVM, pVCpu, pCtx, rc);
    8590            break;
    8691
  • trunk/src/VBox/VMM/include/EMInternal.h

    r47421 r47788  
    412412    STAMPROFILEADV          StatHmEntry;
    413413    STAMPROFILE             StatHmExec;
     414    STAMPROFILE             StatIEMEmu;
    414415    STAMPROFILE             StatREMEmu;
    415416    STAMPROFILE             StatREMExec;
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