VirtualBox

Changeset 38324 in vbox


Ignore:
Timestamp:
Aug 5, 2011 2:02:53 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
73340
Message:

FE/Qt,FE/BFE,MachineDebugger,EM: Added execution scheduling options to the Qt GUI and reworked the main/VMM interface.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/em.h

    r37702 r38324  
    5151    /** Hardware accelerated raw-mode execution. */
    5252    EMSTATE_HWACC,
    53     /** PARAV function. */
    54     EMSTATE_PARAV,
    5553    /** Recompiled mode execution. */
    5654    EMSTATE_REM,
     
    212210 * execution modes at once should the need arise.
    213211 */
    214 typedef enum EMRAWMODE
     212typedef enum EMEXECPOLICY
    215213{
    216     /** No raw execution. */
    217     EMRAW_NONE = 0,
    218     /** Enable Only ring-3 raw execution. */
    219     EMRAW_RING3_ENABLE,
    220     /** Only ring-3 raw execution. */
    221     EMRAW_RING3_DISABLE,
    222     /** Enable raw ring-0 execution. */
    223     EMRAW_RING0_ENABLE,
    224     /** Disable raw ring-0 execution. */
    225     EMRAW_RING0_DISABLE,
    226     EMRAW_END
    227 } EMRAWMODE;
    228 
    229 VMMR3DECL(int)      EMR3RawSetMode(PVM pVM, EMRAWMODE enmMode);
     214    /** The customary invalid zero entry. */
     215    EMEXECPOLICY_INVALID = 0,
     216    /** Whether to recompile ring-0 code or execute it in raw/hm. */
     217    EMEXECPOLICY_RECOMPILE_RING0,
     218    /** Whether to recompile ring-3 code or execute it in raw/hm. */
     219    EMEXECPOLICY_RECOMPILE_RING3,
     220    /** End of valid value (not included). */
     221    EMEXECPOLICY_END,
     222    /** The customary 32-bit type blowup. */
     223    EMEXECPOLICY_32BIT_HACK = 0x7fffffff
     224} EMEXECPOLICY;
     225
     226VMMR3DECL(int)      EMR3SetExecutionPolicy(PVM pVM, EMEXECPOLICY enmPolicy, bool fEnforce);
    230227/** @} */
    231228#endif /* IN_RING3 */
  • trunk/src/VBox/Frontends/VBoxBFE/MachineDebuggerImpl.cpp

    r35346 r38324  
    128128    }
    129129    if (!gpVM)
    130     {
    131130        return E_FAIL;
    132     }
    133 
    134     EMRAWMODE rawModeFlag = enable ? EMRAW_RING3_DISABLE : EMRAW_RING3_ENABLE;
    135     int rcVBox = VMR3ReqCallWait(gpVM, VMCPUID_ANY, (PFNRT)EMR3RawSetMode, 2, gpVM, rawModeFlag);
    136     if (RT_SUCCESS(rcVBox))
    137         return S_OK;
    138 
    139     AssertMsgFailed(("Could not set raw mode flags to %d, rcVBox = %Rrc\n",
    140                      rawModeFlag, rcVBox));
    141     return E_FAIL;
     131
     132    int rcVBox = EMR3SetExecutionPolicy(gpVM, EMEXECPOLICY_RECOMPILE_RING3, enable);
     133    AssertRCReturn(rcVBox, E_FAIL);
     134    return S_OK;
    142135}
    143136
     
    180173    }
    181174    if (!gpVM)
    182     {
    183175        return E_FAIL;
    184     }
    185 
    186     EMRAWMODE rawModeFlag = enable ? EMRAW_RING0_DISABLE : EMRAW_RING0_ENABLE;
    187     int rcVBox = VMR3ReqCallWait(gpVM, VMCPUID_ANY, (PFNRT)EMR3RawSetMode, 2, gpVM, rawModeFlag);
    188     if (RT_SUCCESS(rcVBox))
    189         return S_OK;
    190 
    191     AssertMsgFailed(("Could not set raw mode flags to %d, rcVBox = %Rrc\n",
    192                      rawModeFlag, rcVBox));
    193     return E_FAIL;
     176
     177    int rcVBox = EMR3SetExecutionPolicy(gpVM, EMEXECPOLICY_RECOMPILE_RING0, enable);
     178    AssertRCReturn(rcVBox, E_FAIL);
     179    return S_OK;
    194180}
    195181
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r38311 r38324  
    277277    , mMediaEnumThread (NULL)
    278278    , mIsKWinManaged (false)
     279    , mDisablePatm(false)
     280    , mDisableCsam(false)
     281    , mRecompileSupervisor(false)
     282    , mRecompileUser(false)
    279283    , mVerString ("1.0")
    280284{
     
    51245128            mShowStartVMErrors = false;
    51255129        }
     5130        else if (!::strcmp(arg, "--disable-patm"))
     5131            mDisablePatm = true;
     5132        else if (!::strcmp(arg, "--disable-csam"))
     5133            mDisableCsam = true;
     5134        else if (!::strcmp(arg, "--recompile-supervisor"))
     5135            mRecompileSupervisor = true;
     5136        else if (!::strcmp(arg, "--recompile-user"))
     5137            mRecompileUser = true;
     5138        else if (!::strcmp(arg, "--recompile-all"))
     5139            mDisablePatm = mDisableCsam = mRecompileSupervisor = mRecompileUser = true;
    51265140#ifdef VBOX_WITH_DEBUGGER_GUI
    51275141        else if (!::strcmp (arg, "-dbg") || !::strcmp (arg, "--dbg"))
    5128         {
    51295142            setDebuggerVar(&mDbgEnabled, true);
    5130         }
    51315143        else if (!::strcmp( arg, "-debug") || !::strcmp (arg, "--debug"))
    51325144        {
     
    51605172        /* Not quite debug options, but they're only useful with the debugger bits. */
    51615173        else if (!::strcmp (arg, "--start-paused"))
    5162         {
    51635174            mStartPaused = true;
    5164         }
    51655175        else if (!::strcmp (arg, "--start-running"))
    5166         {
    51675176            mStartPaused = false;
    5168         }
    51695177#endif
    51705178        /** @todo add an else { msgbox(syntax error); exit(1); } here, pretty please... */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r38222 r38324  
    178178    const QRect availableGeometry(int iScreen = 0) const;
    179179
     180    bool isPatmDisabled() const { return mDisablePatm; }
     181    bool isCsamDisabled() const { return mDisableCsam; }
     182    bool isSupervisorCodeExecedRecompiled() const { return mRecompileSupervisor; }
     183    bool isUserCodeExecedRecompiled()       const { return mRecompileUser; }
     184
    180185#ifdef VBOX_WITH_DEBUGGER_GUI
    181186    bool isDebuggerEnabled(CMachine &aMachine);
     
    821826    bool mIsKWinManaged;
    822827
     828    /** The --disable-patm option. */
     829    bool mDisablePatm;
     830    /** The --disable-csam option. */
     831    bool mDisableCsam;
     832    /** The --recompile-supervisor option. */
     833    bool mRecompileSupervisor;
     834    /** The --recompile-user option. */
     835    bool mRecompileUser;
     836
    823837#ifdef VBOX_WITH_DEBUGGER_GUI
    824838    /** Whether the debugger should be accessible or not.
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r38311 r38324  
    170170    char szInfo[64];
    171171    int rc = RTSystemQueryOSInfo (RTSYSOSINFO_RELEASE, szInfo, sizeof(szInfo));
    172     if (RT_SUCCESS (rc) &&
    173         szInfo[0] == '1') /* higher than 1x.x.x */
     172    if (   RT_SUCCESS (rc)
     173        && szInfo[0] == '1') /* higher than 1x.x.x */
    174174    {
    175175        /*
     
    272272            "  --start-running            start the VM running (for overriding --debug*)\n"
    273273            "\n"
     274# endif
     275            "Expert options:\n"
     276            "  --disable-patm             disable code patching (ignored by AMD-V/VT-x)\n"
     277            "  --disable-csam             disable code scanning (ignored by AMD-V/VT-x)\n"
     278            "  --recompile-supervisor     recompiled execution of supervisor code (*)\n"
     279            "  --recompile-user           recompiled execution of user code (*)\n"
     280            "  --recompile-all            recompiled execution of all code, with disabled\n"
     281            "                             code patching and scanning\n"
     282            "  (*) For AMD-V/VT-x setups the effect is --recompile-all.\n"
     283            "\n"
     284# ifdef VBOX_WITH_DEBUGGER_GUI
    274285            "The following environment variables are evaluated:\n"
    275286            "  VBOX_GUI_DBG_ENABLED       enable the GUI debug menu if set\n"
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r38311 r38324  
    203203    CConsole console = session().GetConsole();
    204204
     205    /* Apply debug settings from the command line. */
     206    CMachineDebugger debugger = console.GetDebugger();
     207    if (debugger.isOk())
     208    {
     209        if (vboxGlobal().isPatmDisabled())
     210            debugger.SetPATMEnabled(false);
     211        if (vboxGlobal().isCsamDisabled())
     212            debugger.SetCSAMEnabled(false);
     213        if (vboxGlobal().isSupervisorCodeExecedRecompiled())
     214            debugger.SetRecompileSupervisor(true);
     215        if (vboxGlobal().isUserCodeExecedRecompiled())
     216            debugger.SetRecompileUser(true);
     217    }
     218
    205219    /* Power UP machine: */
    206220    CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled(machine) ?
     
    290304            return;
    291305        }
    292         else
    293             setPause(false);
     306
     307        setPause(false);
    294308    }
    295309
  • trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp

    r35638 r38324  
    184184 * @param   aEnable new user mode code recompile flag.
    185185 */
    186 STDMETHODIMP MachineDebugger::COMSETTER(RecompileUser) (BOOL aEnable)
     186STDMETHODIMP MachineDebugger::COMSETTER(RecompileUser)(BOOL aEnable)
    187187{
    188188    LogFlowThisFunc(("enable=%d\n", aEnable));
    189189
    190190    AutoCaller autoCaller(this);
    191     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    192 
    193     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    194 
    195     if (queueSettings())
    196     {
    197         // queue the request
    198         mRecompileUserQueued = aEnable;
    199         return S_OK;
    200     }
    201 
    202     Console::SafeVMPtr pVM (mParent);
    203     if (FAILED(pVM.rc())) return pVM.rc();
    204 
    205     EMRAWMODE rawModeFlag = aEnable ? EMRAW_RING3_DISABLE : EMRAW_RING3_ENABLE;
    206     int rcVBox = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)EMR3RawSetMode, 2, pVM.raw(), rawModeFlag);
    207     if (RT_SUCCESS(rcVBox))
    208         return S_OK;
    209 
    210     AssertMsgFailed (("Could not set raw mode flags to %d, rcVBox = %Rrc\n",
    211                       rawModeFlag, rcVBox));
    212     return E_FAIL;
     191    HRESULT hrc = autoCaller.rc();
     192    if (SUCCEEDED(hrc))
     193    {
     194        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     195        if (queueSettings())
     196            mRecompileUserQueued = aEnable; // queue the request
     197        else
     198        {
     199            Console::SafeVMPtr ptrVM(mParent);
     200            hrc = ptrVM.rc();
     201            if (SUCCEEDED(hrc))
     202            {
     203                int vrc = EMR3SetExecutionPolicy(ptrVM.raw(), EMEXECPOLICY_RECOMPILE_RING3, RT_BOOL(aEnable));
     204                if (RT_FAILURE(vrc))
     205                    hrc = setError(VBOX_E_VM_ERROR, tr("EMR3SetExecutionPolicy failed with %Rrc"), vrc);
     206            }
     207        }
     208    }
     209    return hrc;
    213210}
    214211
     
    244241 * @param   aEnable new recompile supervisor code flag
    245242 */
    246 STDMETHODIMP MachineDebugger::COMSETTER(RecompileSupervisor) (BOOL aEnable)
     243STDMETHODIMP MachineDebugger::COMSETTER(RecompileSupervisor)(BOOL aEnable)
    247244{
    248245    LogFlowThisFunc(("enable=%d\n", aEnable));
    249246
    250247    AutoCaller autoCaller(this);
    251     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    252 
    253     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    254 
    255     if (queueSettings())
    256     {
    257         // queue the request
    258         mRecompileSupervisorQueued = aEnable;
    259         return S_OK;
    260     }
    261 
    262     Console::SafeVMPtr pVM (mParent);
    263     if (FAILED(pVM.rc())) return pVM.rc();
    264 
    265     EMRAWMODE rawModeFlag = aEnable ? EMRAW_RING0_DISABLE : EMRAW_RING0_ENABLE;
    266     int rcVBox = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)EMR3RawSetMode, 2, pVM.raw(), rawModeFlag);
    267     if (RT_SUCCESS(rcVBox))
    268         return S_OK;
    269 
    270     AssertMsgFailed (("Could not set raw mode flags to %d, rcVBox = %Rrc\n",
    271                       rawModeFlag, rcVBox));
    272     return E_FAIL;
     248    HRESULT hrc = autoCaller.rc();
     249    if (SUCCEEDED(hrc))
     250    {
     251        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     252        if (queueSettings())
     253            mRecompileSupervisorQueued = aEnable; // queue the request
     254        else
     255        {
     256            Console::SafeVMPtr ptrVM(mParent);
     257            hrc = ptrVM.rc();
     258            if (SUCCEEDED(hrc))
     259            {
     260                int vrc = EMR3SetExecutionPolicy(ptrVM.raw(), EMEXECPOLICY_RECOMPILE_RING0, RT_BOOL(aEnable));
     261                if (RT_FAILURE(vrc))
     262                    hrc = setError(VBOX_E_VM_ERROR, tr("EMR3SetExecutionPolicy failed with %Rrc"), vrc);
     263            }
     264        }
     265    }
     266    return hrc;
    273267}
    274268
  • trunk/src/VBox/VMM/VMMR3/EM.cpp

    r36825 r38324  
    586586
    587587/**
     588 * Argument packet for emR3SetExecutionPolicy.
     589 */
     590struct EMR3SETEXECPOLICYARGS
     591{
     592    EMEXECPOLICY    enmPolicy;
     593    bool            fEnforce;
     594};
     595
     596
     597/**
     598 * @callback_method_impl{FNVMMEMTRENDEZVOUS, Rendezvous callback for EMR3SetExecutionPolicy.}
     599 */
     600static DECLCALLBACK(VBOXSTRICTRC) emR3SetExecutionPolicy(PVM pVM, PVMCPU pVCpu, void *pvUser)
     601{
     602    /*
     603     * Only the first CPU changes the variables.
     604     */
     605    if (pVCpu->idCpu == 0)
     606    {
     607        struct EMR3SETEXECPOLICYARGS *pArgs = (struct EMR3SETEXECPOLICYARGS *)pvUser;
     608        switch (pArgs->enmPolicy)
     609        {
     610            case EMEXECPOLICY_RECOMPILE_RING0:
     611                pVM->fRawR0Enabled = !pArgs->fEnforce;
     612                break;
     613            case EMEXECPOLICY_RECOMPILE_RING3:
     614                pVM->fRawR3Enabled = !pArgs->fEnforce;
     615                break;
     616            default:
     617                AssertFailedReturn(VERR_INVALID_PARAMETER);
     618        }
     619        Log(("emR3SetExecutionPolicy: fRawR3Enabled=%RTbool fRawR0Enabled=%RTbool\n",
     620              pVM->fRawR3Enabled, pVM->fRawR0Enabled));
     621    }
     622
     623    /*
     624     * Force rescheduling if in RAW, HWACCM or REM.
     625     */
     626    return    pVCpu->em.s.enmState == EMSTATE_RAW
     627           || pVCpu->em.s.enmState == EMSTATE_HWACC
     628           || pVCpu->em.s.enmState == EMSTATE_REM
     629         ? VINF_EM_RESCHEDULE
     630         : VINF_SUCCESS;
     631}
     632
     633
     634/**
     635 * Changes a the execution scheduling policy.
     636 *
     637 * This is used to enable or disable raw-mode / hardware-virtualization
     638 * execution of user and supervisor code.
     639 *
     640 * @returns VINF_SUCCESS on success.
     641 * @returns VINF_RESCHEDULE if a rescheduling might be required.
     642 * @returns VERR_INVALID_PARAMETER on an invalid enmMode value.
     643 *
     644 * @param   pVM             The VM to operate on.
     645 * @param   enmPolicy       The scheduling policy to change.
     646 * @param   fEnforce        Whether to enforce the policy or not.
     647 */
     648VMMR3DECL(int) EMR3SetExecutionPolicy(PVM pVM, EMEXECPOLICY enmPolicy, bool fEnforce)
     649{
     650    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     651    AssertReturn(enmPolicy > EMEXECPOLICY_INVALID && enmPolicy < EMEXECPOLICY_END, VERR_INVALID_PARAMETER);
     652
     653    struct EMR3SETEXECPOLICYARGS Args = { enmPolicy, fEnforce };
     654    return VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_DESCENDING, emR3SetExecutionPolicy, &Args);
     655}
     656
     657
     658/**
    588659 * Raise a fatal error.
    589660 *
     
    616687        case EMSTATE_HWACC:             return "EMSTATE_HWACC";
    617688        case EMSTATE_REM:               return "EMSTATE_REM";
    618         case EMSTATE_PARAV:             return "EMSTATE_PARAV";
    619689        case EMSTATE_HALTED:            return "EMSTATE_HALTED";
    620690        case EMSTATE_WAIT_SIPI:         return "EMSTATE_WAIT_SIPI";
  • trunk/src/VBox/VMM/VMMR3/EMRaw.cpp

    r35346 r38324  
    6868
    6969
    70 /*******************************************************************************
    71 *   Defined Constants And Macros                                               *
    72 *******************************************************************************/
    73 
    7470
    7571/*******************************************************************************
     
    8783#define EMHANDLERC_WITH_PATM
    8884#include "EMHandleRCTmpl.h"
    89 
    90 /**
    91  * Enables or disables a set of raw-mode execution modes.
    92  *
    93  * @returns VINF_SUCCESS on success.
    94  * @returns VINF_RESCHEDULE if a rescheduling might be required.
    95  * @returns VERR_INVALID_PARAMETER on an invalid enmMode value.
    96  *
    97  * @param   pVM         The VM to operate on.
    98  * @param   enmMode     The execution mode change.
    99  * @thread  The emulation thread.
    100  */
    101 VMMR3DECL(int) EMR3RawSetMode(PVM pVM, EMRAWMODE enmMode)
    102 {
    103     switch (enmMode)
    104     {
    105         case EMRAW_NONE:
    106             pVM->fRawR3Enabled = false;
    107             pVM->fRawR0Enabled = false;
    108             break;
    109         case EMRAW_RING3_ENABLE:
    110             pVM->fRawR3Enabled = true;
    111             break;
    112         case EMRAW_RING3_DISABLE:
    113             pVM->fRawR3Enabled = false;
    114             break;
    115         case EMRAW_RING0_ENABLE:
    116             pVM->fRawR0Enabled = true;
    117             break;
    118         case EMRAW_RING0_DISABLE:
    119             pVM->fRawR0Enabled = false;
    120             break;
    121         default:
    122             AssertMsgFailed(("Invalid enmMode=%d\n", enmMode));
    123             return VERR_INVALID_PARAMETER;
    124     }
    125     Log(("EMR3SetRawMode: fRawR3Enabled=%RTbool fRawR0Enabled=%RTbool\n",
    126           pVM->fRawR3Enabled, pVM->fRawR0Enabled));
    127     return pVM->aCpus[0].em.s.enmState == EMSTATE_RAW ? VINF_EM_RESCHEDULE : VINF_SUCCESS;
    128 }
    12985
    13086
  • trunk/src/VBox/VMM/testcase/tstAnimate.cpp

    r36408 r38324  
    866866                    if (RT_SUCCESS(rc))
    867867                    {
    868                         rc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)EMR3RawSetMode, 2, pVM, EMRAW_NONE);
    869                         AssertReleaseRC(rc);
     868                        rc = EMR3SetExecutionPolicy(pVM, EMEXECPOLICY_RECOMPILE_RING0, true); AssertReleaseRC(rc);
     869                        rc = EMR3SetExecutionPolicy(pVM, EMEXECPOLICY_RECOMPILE_RING3, true); AssertReleaseRC(rc);
    870870                        DBGFR3Info(pVM, "cpumguest", "verbose", NULL);
    871871                        if (fPowerOn)
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