Changeset 38835 in vbox for trunk/src/VBox/VMM/VMMR3
- Timestamp:
- Sep 23, 2011 11:17:04 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/VMM.cpp
r37955 r38835 187 187 188 188 /* 189 * Initialize the VMM sync critical section and semaphores. 190 */ 191 rc = RTCritSectInit(&pVM->vmm.s.CritSectSync); 192 AssertRCReturn(rc, rc); 189 * Initialize the VMM rendezvous semaphores. 190 */ 193 191 pVM->vmm.s.pahEvtRendezvousEnterOrdered = (PRTSEMEVENT)MMR3HeapAlloc(pVM, MM_TAG_VMM, sizeof(RTSEMEVENT) * pVM->cCpus); 194 192 if (!pVM->vmm.s.pahEvtRendezvousEnterOrdered) … … 740 738 } 741 739 742 RTCritSectDelete(&pVM->vmm.s.CritSectSync);743 740 for (VMCPUID i = 0; i < pVM->cCpus; i++) 744 741 { … … 1365 1362 AssertReturnVoid(idCpu < pVM->cCpus); 1366 1363 1367 int rc = VMR3ReqCallNoWait U(pVM->pUVM, idCpu, (PFNRT)vmmR3SendSipi, 3, pVM, idCpu, uVector);1364 int rc = VMR3ReqCallNoWait(pVM, idCpu, (PFNRT)vmmR3SendSipi, 3, pVM, idCpu, uVector); 1368 1365 AssertRC(rc); 1369 1366 } … … 1379 1376 AssertReturnVoid(idCpu < pVM->cCpus); 1380 1377 1381 int rc = VMR3ReqCallNoWait U(pVM->pUVM, idCpu, (PFNRT)vmmR3SendInitIpi, 2, pVM, idCpu);1378 int rc = VMR3ReqCallNoWait(pVM, idCpu, (PFNRT)vmmR3SendInitIpi, 2, pVM, idCpu); 1382 1379 AssertRC(rc); 1383 1380 } … … 1393 1390 VMMR3DECL(int) VMMR3RegisterPatchMemory(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem) 1394 1391 { 1392 VM_ASSERT_EMT(pVM); 1395 1393 if (HWACCMIsEnabled(pVM)) 1396 1394 return HWACMMR3EnablePatching(pVM, pPatchMem, cbPatchMem); … … 1413 1411 1414 1412 return VINF_SUCCESS; 1415 }1416 1417 1418 /**1419 * VCPU worker for VMMR3SynchronizeAllVCpus.1420 *1421 * @param pVM The VM to operate on.1422 * @param idCpu Virtual CPU to perform SIPI on1423 * @param uVector SIPI vector1424 */1425 DECLCALLBACK(int) vmmR3SyncVCpu(PVM pVM)1426 {1427 /* Block until the job in the caller has finished. */1428 RTCritSectEnter(&pVM->vmm.s.CritSectSync);1429 RTCritSectLeave(&pVM->vmm.s.CritSectSync);1430 return VINF_SUCCESS;1431 }1432 1433 1434 /**1435 * Atomically execute a callback handler1436 * Note: This is very expensive; avoid using it frequently!1437 *1438 * @param pVM The VM to operate on.1439 * @param pfnHandler Callback handler1440 * @param pvUser User specified parameter1441 *1442 * @thread EMT1443 * @todo Remove this if not used again soon.1444 */1445 VMMR3DECL(int) VMMR3AtomicExecuteHandler(PVM pVM, PFNATOMICHANDLER pfnHandler, void *pvUser)1446 {1447 int rc;1448 PVMCPU pVCpu = VMMGetCpu(pVM);1449 AssertReturn(pVCpu, VERR_VM_THREAD_NOT_EMT);1450 1451 /* Shortcut for the uniprocessor case. */1452 if (pVM->cCpus == 1)1453 return pfnHandler(pVM, pvUser);1454 1455 RTCritSectEnter(&pVM->vmm.s.CritSectSync);1456 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)1457 {1458 if (idCpu != pVCpu->idCpu)1459 {1460 rc = VMR3ReqCallNoWaitU(pVM->pUVM, idCpu, (PFNRT)vmmR3SyncVCpu, 1, pVM);1461 AssertRC(rc);1462 }1463 }1464 /* Wait until all other VCPUs are waiting for us. */1465 while (RTCritSectGetWaiters(&pVM->vmm.s.CritSectSync) != (int32_t)(pVM->cCpus - 1))1466 RTThreadSleep(1);1467 1468 rc = pfnHandler(pVM, pvUser);1469 RTCritSectLeave(&pVM->vmm.s.CritSectSync);1470 return rc;1471 1413 } 1472 1414 … … 1517 1459 { 1518 1460 int rc; 1461 pVCpu->vmm.s.fInRendezvous = true; 1519 1462 1520 1463 /* … … 1665 1608 } 1666 1609 1610 pVCpu->vmm.s.fInRendezvous = false; 1667 1611 if (!fIsCaller) 1668 1612 return vmmR3EmtRendezvousNonCallerReturn(pVM); … … 1728 1672 (PFNRT)VMMR3EmtRendezvous, 4, pVM, fFlags, pfnRendezvous, pvUser); 1729 1673 else if (pVM->cCpus == 1) 1674 { 1730 1675 /* 1731 1676 * Shortcut for the single EMT case. 1732 1677 */ 1678 AssertLogRelReturn(!pVCpu->vmm.s.fInRendezvous, VERR_DEADLOCK); 1679 pVCpu->vmm.s.fInRendezvous = true; 1733 1680 rcStrict = pfnRendezvous(pVM, pVCpu, pvUser); 1681 pVCpu->vmm.s.fInRendezvous = false; 1682 } 1734 1683 else 1735 1684 { … … 1742 1691 if (RT_UNLIKELY(!ASMAtomicCmpXchgU32(&pVM->vmm.s.u32RendezvousLock, 0x77778888, 0))) 1743 1692 { 1693 AssertLogRelReturn(!pVCpu->vmm.s.fInRendezvous, VERR_DEADLOCK); 1694 1744 1695 while (!ASMAtomicCmpXchgU32(&pVM->vmm.s.u32RendezvousLock, 0x77778888, 0)) 1745 1696 { … … 1820 1771 VERR_IPE_UNEXPECTED_INFO_STATUS); 1821 1772 return VBOXSTRICTRC_VAL(rcStrict); 1773 } 1774 1775 1776 /** 1777 * Disables/enables EMT rendezvous. 1778 * 1779 * This is used to make sure EMT rendezvous does not take place while 1780 * processing a priority request. 1781 * 1782 * @returns Old rendezvous-disabled state. 1783 * @param pVCpu The handle of the calling EMT. 1784 * @param fDisabled True if disabled, false if enabled. 1785 */ 1786 VMMR3_INT_DECL(bool) VMMR3EmtRendezvousSetDisabled(PVMCPU pVCpu, bool fDisabled) 1787 { 1788 VMCPU_ASSERT_EMT(pVCpu); 1789 bool fOld = pVCpu->vmm.s.fInRendezvous; 1790 pVCpu->vmm.s.fInRendezvous = fDisabled; 1791 return fOld; 1822 1792 } 1823 1793
Note:
See TracChangeset
for help on using the changeset viewer.