Changeset 38324 in vbox
- Timestamp:
- Aug 5, 2011 2:02:53 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 73340
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/em.h
r37702 r38324 51 51 /** Hardware accelerated raw-mode execution. */ 52 52 EMSTATE_HWACC, 53 /** PARAV function. */54 EMSTATE_PARAV,55 53 /** Recompiled mode execution. */ 56 54 EMSTATE_REM, … … 212 210 * execution modes at once should the need arise. 213 211 */ 214 typedef enum EM RAWMODE212 typedef enum EMEXECPOLICY 215 213 { 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 226 VMMR3DECL(int) EMR3SetExecutionPolicy(PVM pVM, EMEXECPOLICY enmPolicy, bool fEnforce); 230 227 /** @} */ 231 228 #endif /* IN_RING3 */ -
trunk/src/VBox/Frontends/VBoxBFE/MachineDebuggerImpl.cpp
r35346 r38324 128 128 } 129 129 if (!gpVM) 130 {131 130 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; 142 135 } 143 136 … … 180 173 } 181 174 if (!gpVM) 182 {183 175 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; 194 180 } 195 181 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r38311 r38324 277 277 , mMediaEnumThread (NULL) 278 278 , mIsKWinManaged (false) 279 , mDisablePatm(false) 280 , mDisableCsam(false) 281 , mRecompileSupervisor(false) 282 , mRecompileUser(false) 279 283 , mVerString ("1.0") 280 284 { … … 5124 5128 mShowStartVMErrors = false; 5125 5129 } 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; 5126 5140 #ifdef VBOX_WITH_DEBUGGER_GUI 5127 5141 else if (!::strcmp (arg, "-dbg") || !::strcmp (arg, "--dbg")) 5128 {5129 5142 setDebuggerVar(&mDbgEnabled, true); 5130 }5131 5143 else if (!::strcmp( arg, "-debug") || !::strcmp (arg, "--debug")) 5132 5144 { … … 5160 5172 /* Not quite debug options, but they're only useful with the debugger bits. */ 5161 5173 else if (!::strcmp (arg, "--start-paused")) 5162 {5163 5174 mStartPaused = true; 5164 }5165 5175 else if (!::strcmp (arg, "--start-running")) 5166 {5167 5176 mStartPaused = false; 5168 }5169 5177 #endif 5170 5178 /** @todo add an else { msgbox(syntax error); exit(1); } here, pretty please... */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r38222 r38324 178 178 const QRect availableGeometry(int iScreen = 0) const; 179 179 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 180 185 #ifdef VBOX_WITH_DEBUGGER_GUI 181 186 bool isDebuggerEnabled(CMachine &aMachine); … … 821 826 bool mIsKWinManaged; 822 827 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 823 837 #ifdef VBOX_WITH_DEBUGGER_GUI 824 838 /** Whether the debugger should be accessible or not. -
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r38311 r38324 170 170 char szInfo[64]; 171 171 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 */ 174 174 { 175 175 /* … … 272 272 " --start-running start the VM running (for overriding --debug*)\n" 273 273 "\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 274 285 "The following environment variables are evaluated:\n" 275 286 " VBOX_GUI_DBG_ENABLED enable the GUI debug menu if set\n" -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r38311 r38324 203 203 CConsole console = session().GetConsole(); 204 204 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 205 219 /* Power UP machine: */ 206 220 CProgress progress = vboxGlobal().isStartPausedEnabled() || vboxGlobal().isDebuggerAutoShowEnabled(machine) ? … … 290 304 return; 291 305 } 292 else 293 306 307 setPause(false); 294 308 } 295 309 -
trunk/src/VBox/Main/src-client/MachineDebuggerImpl.cpp
r35638 r38324 184 184 * @param aEnable new user mode code recompile flag. 185 185 */ 186 STDMETHODIMP MachineDebugger::COMSETTER(RecompileUser) 186 STDMETHODIMP MachineDebugger::COMSETTER(RecompileUser)(BOOL aEnable) 187 187 { 188 188 LogFlowThisFunc(("enable=%d\n", aEnable)); 189 189 190 190 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; 213 210 } 214 211 … … 244 241 * @param aEnable new recompile supervisor code flag 245 242 */ 246 STDMETHODIMP MachineDebugger::COMSETTER(RecompileSupervisor) 243 STDMETHODIMP MachineDebugger::COMSETTER(RecompileSupervisor)(BOOL aEnable) 247 244 { 248 245 LogFlowThisFunc(("enable=%d\n", aEnable)); 249 246 250 247 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; 273 267 } 274 268 -
trunk/src/VBox/VMM/VMMR3/EM.cpp
r36825 r38324 586 586 587 587 /** 588 * Argument packet for emR3SetExecutionPolicy. 589 */ 590 struct EMR3SETEXECPOLICYARGS 591 { 592 EMEXECPOLICY enmPolicy; 593 bool fEnforce; 594 }; 595 596 597 /** 598 * @callback_method_impl{FNVMMEMTRENDEZVOUS, Rendezvous callback for EMR3SetExecutionPolicy.} 599 */ 600 static 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 */ 648 VMMR3DECL(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 /** 588 659 * Raise a fatal error. 589 660 * … … 616 687 case EMSTATE_HWACC: return "EMSTATE_HWACC"; 617 688 case EMSTATE_REM: return "EMSTATE_REM"; 618 case EMSTATE_PARAV: return "EMSTATE_PARAV";619 689 case EMSTATE_HALTED: return "EMSTATE_HALTED"; 620 690 case EMSTATE_WAIT_SIPI: return "EMSTATE_WAIT_SIPI"; -
trunk/src/VBox/VMM/VMMR3/EMRaw.cpp
r35346 r38324 68 68 69 69 70 /*******************************************************************************71 * Defined Constants And Macros *72 *******************************************************************************/73 74 70 75 71 /******************************************************************************* … … 87 83 #define EMHANDLERC_WITH_PATM 88 84 #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 }129 85 130 86 -
trunk/src/VBox/VMM/testcase/tstAnimate.cpp
r36408 r38324 866 866 if (RT_SUCCESS(rc)) 867 867 { 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); 870 870 DBGFR3Info(pVM, "cpumguest", "verbose", NULL); 871 871 if (fPowerOn)
Note:
See TracChangeset
for help on using the changeset viewer.