Changeset 92392 in vbox for trunk/src/VBox/VMM/VMMRZ
- Timestamp:
- Nov 12, 2021 10:39:56 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 148246
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMRZ/VMMRZ.cpp
r90953 r92392 29 29 #include <iprt/asm-amd64-x86.h> 30 30 #include <iprt/string.h> 31 32 33 /**34 * Calls the ring-3 host code.35 *36 * @returns VBox status code of the ring-3 call.37 * @retval VERR_VMM_RING3_CALL_DISABLED if called at the wrong time. This must38 * be passed up the stack, or if that isn't possible then VMMRZCallRing339 * needs to change it into an assertion.40 *41 *42 * @param pVM The cross context VM structure.43 * @param pVCpu The cross context virtual CPU structure of the calling EMT.44 * @param enmOperation The operation.45 * @param uArg The argument to the operation.46 */47 VMMRZDECL(int) VMMRZCallRing3(PVMCC pVM, PVMCPUCC pVCpu, VMMCALLRING3 enmOperation, uint64_t uArg)48 {49 VMCPU_ASSERT_EMT(pVCpu);50 51 /*52 * Check if calling ring-3 has been disabled and only let let fatal calls thru.53 */54 if (RT_UNLIKELY( pVCpu->vmm.s.cCallRing3Disabled != 055 && enmOperation != VMMCALLRING3_VM_R0_ASSERTION))56 {57 #ifndef IN_RING058 /*59 * In most cases, it's sufficient to return a status code which60 * will then be propagated up the code usually encountering several61 * AssertRC invocations along the way. Hitting one of those is more62 * helpful than stopping here.63 *64 * However, some doesn't check the status code because they are called65 * from void functions, and for these we'll turn this into a ring-066 * assertion host call.67 */68 if (enmOperation != VMMCALLRING3_REM_REPLAY_HANDLER_NOTIFICATIONS)69 return VERR_VMM_RING3_CALL_DISABLED;70 #endif71 #ifdef IN_RC72 RTStrPrintf(g_szRTAssertMsg1, sizeof(pVM->vmm.s.szRing0AssertMsg1),73 "VMMRZCallRing3: enmOperation=%d uArg=%#llx idCpu=%#x cCallRing3Disabled=%#x\n",74 enmOperation, uArg, pVCpu->idCpu, pVCpu->vmm.s.cCallRing3Disabled);75 #endif76 RTStrPrintf(pVM->vmm.s.szRing0AssertMsg1, sizeof(pVM->vmm.s.szRing0AssertMsg1),77 "VMMRZCallRing3: enmOperation=%d uArg=%#llx idCpu=%#x cCallRing3Disabled=%#x\n",78 enmOperation, uArg, pVCpu->idCpu, pVCpu->vmm.s.cCallRing3Disabled);79 enmOperation = VMMCALLRING3_VM_R0_ASSERTION;80 }81 82 /*83 * The normal path.84 */85 /** @todo profile this! */86 pVCpu->vmm.s.enmCallRing3Operation = enmOperation;87 pVCpu->vmm.s.u64CallRing3Arg = uArg;88 pVCpu->vmm.s.rcCallRing3 = VERR_VMM_RING3_CALL_NO_RC;89 #ifdef IN_RC90 pVM->vmm.s.pfnRCToHost(VINF_VMM_CALL_HOST);91 #else92 int rc;93 if (pVCpu->vmm.s.pfnCallRing3CallbackR0)94 {95 rc = pVCpu->vmm.s.pfnCallRing3CallbackR0(pVCpu, enmOperation, pVCpu->vmm.s.pvCallRing3CallbackUserR0);96 if (RT_FAILURE(rc))97 return rc;98 }99 rc = vmmR0CallRing3LongJmp(&pVCpu->vmm.s.CallRing3JmpBufR0, VINF_VMM_CALL_HOST);100 if (RT_FAILURE(rc))101 return rc;102 #endif103 return pVCpu->vmm.s.rcCallRing3;104 }105 106 107 /**108 * Simple wrapper that adds the pVCpu argument.109 *110 * @returns VBox status code of the ring-3 call.111 * @retval VERR_VMM_RING3_CALL_DISABLED if called at the wrong time. This must112 * be passed up the stack, or if that isn't possible then VMMRZCallRing3113 * needs to change it into an assertion.114 *115 * @param pVM The cross context VM structure.116 * @param enmOperation The operation.117 * @param uArg The argument to the operation.118 */119 VMMRZDECL(int) VMMRZCallRing3NoCpu(PVMCC pVM, VMMCALLRING3 enmOperation, uint64_t uArg)120 {121 return VMMRZCallRing3(pVM, VMMGetCpu(pVM), enmOperation, uArg);122 }123 31 124 32 … … 194 102 } 195 103 196 197 /**198 * Sets the ring-0 callback before doing the ring-3 call.199 *200 * @param pVCpu The cross context virtual CPU structure.201 * @param pfnCallback Pointer to the callback.202 * @param pvUser The user argument.203 *204 * @return VBox status code.205 */206 VMMRZDECL(int) VMMRZCallRing3SetNotification(PVMCPUCC pVCpu, R0PTRTYPE(PFNVMMR0CALLRING3NOTIFICATION) pfnCallback, RTR0PTR pvUser)207 {208 AssertPtrReturn(pVCpu, VERR_INVALID_POINTER);209 AssertPtrReturn(pfnCallback, VERR_INVALID_POINTER);210 211 if (pVCpu->vmm.s.pfnCallRing3CallbackR0)212 return VERR_ALREADY_EXISTS;213 214 pVCpu->vmm.s.pfnCallRing3CallbackR0 = pfnCallback;215 pVCpu->vmm.s.pvCallRing3CallbackUserR0 = pvUser;216 return VINF_SUCCESS;217 }218 219 220 /**221 * Removes the ring-0 callback.222 *223 * @param pVCpu The cross context virtual CPU structure.224 */225 VMMRZDECL(void) VMMRZCallRing3RemoveNotification(PVMCPUCC pVCpu)226 {227 pVCpu->vmm.s.pfnCallRing3CallbackR0 = NULL;228 }229 230 231 /**232 * Checks whether there is a ring-0 callback notification active.233 *234 * @param pVCpu The cross context virtual CPU structure.235 * @returns true if there the notification is active, false otherwise.236 */237 VMMRZDECL(bool) VMMRZCallRing3IsNotificationSet(PVMCPUCC pVCpu)238 {239 return pVCpu->vmm.s.pfnCallRing3CallbackR0 != NULL;240 }241
Note:
See TracChangeset
for help on using the changeset viewer.