VirtualBox

Changeset 46423 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Jun 6, 2013 7:48:27 PM (12 years ago)
Author:
vboxsync
Message:

VMM,Main: Introduced a execute-all-in-IEM debug mode.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/Makefile.kmk

    r46167 r46423  
    128128        VMMR3/DBGFR3Trace.cpp \
    129129        VMMR3/EM.cpp \
     130        VMMR3/EMR3Dbg.cpp \
    130131        $(if $(VBOX_WITH_RAW_MODE),VMMR3/EMRaw.cpp) \
    131132        VMMR3/EMHM.cpp \
  • trunk/src/VBox/VMM/VMMR3/EM.cpp

    r46420 r46423  
    4242#include <VBox/vmm/selm.h>
    4343#include <VBox/vmm/trpm.h>
     44#include <VBox/vmm/iem.h>
    4445#include <VBox/vmm/iom.h>
    4546#include <VBox/vmm/dbgf.h>
     
    4748#ifdef VBOX_WITH_REM
    4849# include <VBox/vmm/rem.h>
    49 #else
    50 # include <VBox/vmm/iem.h>
    5150#endif
    5251#include <VBox/vmm/tm.h>
     
    118117     */
    119118    pVM->em.s.offVM = RT_OFFSETOF(VM, em.s);
     119    PCFGMNODE pCfgRoot = CFGMR3GetRoot(pVM);
     120    PCFGMNODE pCfgEM = CFGMR3GetChild(pCfgRoot, "EM");
     121
    120122    bool fEnabled;
    121     int rc = CFGMR3QueryBool(CFGMR3GetRoot(pVM), "RawR3Enabled", &fEnabled);
    122     pVM->fRecompileUser       = RT_SUCCESS(rc) ? !fEnabled : false;
    123     rc = CFGMR3QueryBool(CFGMR3GetRoot(pVM), "RawR0Enabled", &fEnabled);
    124     pVM->fRecompileSupervisor = RT_SUCCESS(rc) ? !fEnabled : false;
    125     Log(("EMR3Init: fRecompileUser=%RTbool fRecompileSupervisor=%RTbool\n", pVM->fRecompileUser, pVM->fRecompileSupervisor));
     123    int rc = CFGMR3QueryBoolDef(pCfgRoot, "RawR3Enabled", &fEnabled, true);
     124    AssertLogRelRCReturn(rc, rc);
     125    pVM->fRecompileUser       = !fEnabled;
     126
     127    rc = CFGMR3QueryBoolDef(pCfgRoot, "RawR0Enabled", &fEnabled, true);
     128    AssertLogRelRCReturn(rc, rc);
     129    pVM->fRecompileSupervisor = !fEnabled;
    126130
    127131#ifdef VBOX_WITH_RAW_RING1
    128     rc = CFGMR3QueryBool(CFGMR3GetRoot(pVM), "RawR1Enabled", &fEnabled);
    129     pVM->fRawRing1Enabled = RT_SUCCESS(rc) ? fEnabled : false;
    130     Log(("EMR3Init: fRawRing1Enabled=%RTbool\n", pVM->fRawRing1Enabled));
     132    rc = CFGMR3QueryBoolDef(pCfgRoot, "RawR1Enabled", &pVM->fRawRing1Enabled, false);
     133    AssertLogRelRCReturn(rc, rc);
    131134#else
    132     pVM->fRawRing1Enabled = false;      /* disabled by default. */
    133 #endif
     135    pVM->fRawRing1Enabled = false;      /* Disabled by default. */
     136#endif
     137
     138    rc = CFGMR3QueryBoolDef(pCfgEM, "IemExecutesAll", &pVM->em.s.fIemExecutesAll, false);
     139    AssertLogRelRCReturn(rc, rc);
     140
     141    Log(("EMR3Init: fRecompileUser=%RTbool fRecompileSupervisor=%RTbool fRawRing1Enabled=%RTbool fIemExecutesAll=%RTbool\n",
     142         pVM->fRecompileUser, pVM->fRecompileSupervisor, pVM->fRawRing1Enabled, pVM->em.s.fIemExecutesAll));
    134143
    135144#ifdef VBOX_WITH_REM
     
    428437    }
    429438
     439    emR3InitDbg(pVM);
    430440    return VINF_SUCCESS;
    431441}
     
    559569     * Validate version.
    560570     */
    561     if (    uVersion != EM_SAVED_STATE_VERSION
    562         &&  uVersion != EM_SAVED_STATE_VERSION_PRE_MWAIT
    563         &&  uVersion != EM_SAVED_STATE_VERSION_PRE_SMP)
     571    if (    uVersion > EM_SAVED_STATE_VERSION
     572        ||  uVersion < EM_SAVED_STATE_VERSION_PRE_SMP)
    564573    {
    565574        AssertMsgFailed(("emR3Load: Invalid version uVersion=%d (current %d)!\n", uVersion, EM_SAVED_STATE_VERSION));
     
    641650                pVM->fRecompileUser = pArgs->fEnforce;
    642651                break;
     652            case EMEXECPOLICY_IEM_ALL:
     653                pVM->em.s.fIemExecutesAll = pArgs->fEnforce;
     654                break;
    643655            default:
    644656                AssertFailedReturn(VERR_INVALID_PARAMETER);
    645657        }
    646         Log(("emR3SetExecutionPolicy: fRecompileUser=%RTbool fRecompileSupervisor=%RTbool\n",
    647               pVM->fRecompileUser, pVM->fRecompileSupervisor));
     658        Log(("emR3SetExecutionPolicy: fRecompileUser=%RTbool fRecompileSupervisor=%RTbool fIemExecutesAll=%RTbool\n",
     659              pVM->fRecompileUser, pVM->fRecompileSupervisor, pVM->em.s.fIemExecutesAll));
    648660    }
    649661
    650662    /*
    651      * Force rescheduling if in RAW, HM or REM.
     663     * Force rescheduling if in RAW, HM, IEM, or REM.
    652664     */
    653665    return    pVCpu->em.s.enmState == EMSTATE_RAW
    654666           || pVCpu->em.s.enmState == EMSTATE_HM
     667           || pVCpu->em.s.enmState == EMSTATE_IEM
    655668           || pVCpu->em.s.enmState == EMSTATE_REM
    656669         ? VINF_EM_RESCHEDULE
     
    660673
    661674/**
    662  * Changes a the execution scheduling policy.
     675 * Changes an execution scheduling policy parameter.
    663676 *
    664677 * This is used to enable or disable raw-mode / hardware-virtualization
     
    685698
    686699/**
    687  * Checks if raw ring-3 execute mode is enabled.
    688  *
    689  * @returns true if enabled, false if disabled.
     700 * Queries an execution scheduling policy parameter.
     701 *
     702 * @returns VBox status code
    690703 * @param   pUVM            The user mode VM handle.
    691  */
    692 VMMR3DECL(bool) EMR3IsRawRing3Enabled(PUVM pUVM)
     704 * @param   enmPolicy       The scheduling policy to query.
     705 * @param   pfEnforced      Where to return the current value.
     706 */
     707VMMR3DECL(int) EMR3QueryExecutionPolicy(PUVM pUVM, EMEXECPOLICY enmPolicy, bool *pfEnforced)
    693708{
    694     UVM_ASSERT_VALID_EXT_RETURN(pUVM, false);
     709    AssertReturn(enmPolicy > EMEXECPOLICY_INVALID && enmPolicy < EMEXECPOLICY_END, VERR_INVALID_PARAMETER);
     710    AssertPtrReturn(pfEnforced, VERR_INVALID_POINTER);
     711    UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
    695712    PVM pVM = pUVM->pVM;
    696     VM_ASSERT_VALID_EXT_RETURN(pVM, false);
    697     return EMIsRawRing3Enabled(pVM);
    698 }
    699 
    700 
    701 /**
    702  * Checks if raw ring-0 execute mode is enabled.
    703  *
    704  * @returns true if enabled, false if disabled.
    705  * @param   pUVM            The user mode VM handle.
    706  */
    707 VMMR3DECL(bool) EMR3IsRawRing0Enabled(PUVM pUVM)
    708 {
    709     UVM_ASSERT_VALID_EXT_RETURN(pUVM, false);
    710     PVM pVM = pUVM->pVM;
    711     VM_ASSERT_VALID_EXT_RETURN(pVM, false);
    712     return EMIsRawRing0Enabled(pVM);
     713    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     714
     715    /* No need to bother EMTs with a query. */
     716    switch (enmPolicy)
     717    {
     718        case EMEXECPOLICY_RECOMPILE_RING0:
     719            *pfEnforced = pVM->fRecompileSupervisor;
     720            break;
     721        case EMEXECPOLICY_RECOMPILE_RING3:
     722            *pfEnforced = pVM->fRecompileUser;
     723            break;
     724        case EMEXECPOLICY_IEM_ALL:
     725            *pfEnforced = pVM->em.s.fIemExecutesAll;
     726            break;
     727        default:
     728            AssertFailedReturn(VERR_INTERNAL_ERROR_2);
     729    }
     730
     731    return VINF_SUCCESS;
    713732}
    714733
     
    744763        case EMSTATE_NONE:              return "EMSTATE_NONE";
    745764        case EMSTATE_RAW:               return "EMSTATE_RAW";
    746         case EMSTATE_HM:             return "EMSTATE_HM";
     765        case EMSTATE_HM:                return "EMSTATE_HM";
     766        case EMSTATE_IEM:               return "EMSTATE_IEM";
    747767        case EMSTATE_REM:               return "EMSTATE_REM";
    748768        case EMSTATE_HALTED:            return "EMSTATE_HALTED";
     
    944964}
    945965
     966
    946967/**
    947968 * Steps recompiled code.
     
    10901111         * Execute REM.
    10911112         */
    1092         if (RT_LIKELY(EMR3IsExecutionAllowed(pVM, pVCpu)))
     1113        if (RT_LIKELY(emR3IsExecutionAllowed(pVM, pVCpu)))
    10931114        {
    10941115            STAM_PROFILE_START(&pVCpu->em.s.StatREMExec, c);
     
    12401261    if (pVCpu->em.s.enmState == EMSTATE_WAIT_SIPI)
    12411262        return EMSTATE_WAIT_SIPI;
     1263
     1264    /*
     1265     * Execute everything in IEM?
     1266     */
     1267    if (pVM->em.s.fIemExecutesAll)
     1268        return EMSTATE_IEM;
    12421269
    12431270    /* !!! THIS MUST BE IN SYNC WITH remR3CanExecuteRaw !!! */
     
    19421969 * @param   pVM         Pointer to the VM.
    19431970 * @param   pVCpu       Pointer to the VMCPU.
    1944  *
    1945  */
    1946 VMMR3_INT_DECL(bool) EMR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu)
     1971 */
     1972bool emR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu)
    19471973{
    19481974    uint64_t u64UserTime, u64KernelTime;
     
    23422368
    23432369                /*
     2370                 * Execute in the interpreter.
     2371                 */
     2372                case EMSTATE_IEM:
     2373                    rc = VBOXSTRICTRC_TODO(IEMExecLots(pVCpu));
     2374                    fFFDone = false;
     2375                    break;
     2376
     2377                /*
    23442378                 * Application processor execution halted until SIPI.
    23452379                 */
  • trunk/src/VBox/VMM/VMMR3/EMHM.cpp

    r46420 r46423  
    545545        STAM_PROFILE_ADV_STOP(&pVCpu->em.s.StatHmEntry, a);
    546546
    547         if (RT_LIKELY(EMR3IsExecutionAllowed(pVM, pVCpu)))
     547        if (RT_LIKELY(emR3IsExecutionAllowed(pVM, pVCpu)))
    548548        {
    549549            STAM_PROFILE_START(&pVCpu->em.s.StatHmExec, x);
  • trunk/src/VBox/VMM/VMMR3/EMRaw.cpp

    r46420 r46423  
    14481448         */
    14491449        STAM_PROFILE_ADV_STOP(&pVCpu->em.s.StatRAWEntry, b);
    1450         if (RT_LIKELY(EMR3IsExecutionAllowed(pVM, pVCpu)))
     1450        if (RT_LIKELY(emR3IsExecutionAllowed(pVM, pVCpu)))
    14511451        {
    14521452            STAM_PROFILE_START(&pVCpu->em.s.StatRAWExec, c);
  • trunk/src/VBox/VMM/include/EMInternal.h

    r45528 r46423  
    3939
    4040/** The saved state version. */
    41 #define EM_SAVED_STATE_VERSION                          4
     41#define EM_SAVED_STATE_VERSION                          5
     42#define EM_SAVED_STATE_VERSION_PRE_IEM                  4
    4243#define EM_SAVED_STATE_VERSION_PRE_MWAIT                3
    4344#define EM_SAVED_STATE_VERSION_PRE_SMP                  2
     
    308309    RTUINT                  offVM;
    309310
     311    /** Whether IEM executes everything. */
     312    bool                    fIemExecutesAll;
     313    /** Alignment padding. */
     314    bool                    afPadding[7];
     315
    310316    /** Id of the VCPU that last executed code in the recompiler. */
    311317    VMCPUID                 idLastRemCpu;
     
    443449/** @} */
    444450
     451int     emR3InitDbg(PVM pVM);
    445452
    446453int     emR3HmExecute(PVM pVM, PVMCPU pVCpu, bool *pfFFDone);
     
    455462int     emR3RawStep(PVM pVM, PVMCPU pVCpu);
    456463int     emR3SingleStepExecRem(PVM pVM, PVMCPU pVCpu, uint32_t cIterations);
     464bool    emR3IsExecutionAllowed(PVM pVM, PVMCPU pVCpu);
    457465
    458466RT_C_DECLS_END
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