Changeset 6635 in vbox
- Timestamp:
- Jan 30, 2008 9:45:30 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27696
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp
r6542 r6635 390 390 391 391 /** 392 * Try acquire the 'used' lock. 393 * 394 * @returns IPRT status code, see RTSemFastMutexRequest. 395 * @param pGVMM The GVMM instance data. 396 */ 397 DECLINLINE(int) gvmmR0UsedLock(PGVMM pGVMM) 398 { 399 LogFlow(("++gvmmR0UsedLock(%p)\n", pGVMM)); 400 int rc = RTSemFastMutexRequest(pGVMM->UsedLock); 401 LogFlow(("gvmmR0UsedLock(%p)->%Rrc\n", pGVMM, rc)); 402 return rc; 403 } 404 405 406 /** 407 * Release the 'used' lock. 408 * 409 * @returns IPRT status code, see RTSemFastMutexRelease. 410 * @param pGVMM The GVMM instance data. 411 */ 412 DECLINLINE(int) gvmmR0UsedUnlock(PGVMM pGVMM) 413 { 414 LogFlow(("--gvmmR0UsedUnlock(%p)\n", pGVMM)); 415 int rc = RTSemFastMutexRelease(pGVMM->UsedLock); 416 AssertRC(rc); 417 return rc; 418 } 419 420 421 /** 422 * Try acquire the 'create & destroy' lock. 423 * 424 * @returns IPRT status code, see RTSemFastMutexRequest. 425 * @param pGVMM The GVMM instance data. 426 */ 427 DECLINLINE(int) gvmmR0CreateDestroyLock(PGVMM pGVMM) 428 { 429 LogFlow(("++gvmmR0CreateDestroyLock(%p)\n", pGVMM)); 430 int rc = RTSemFastMutexRequest(pGVMM->CreateDestroyLock); 431 LogFlow(("gvmmR0CreateDestroyLock(%p)->%Rrc\n", pGVMM, rc)); 432 return rc; 433 } 434 435 436 /** 437 * Release the 'create & destroy' lock. 438 * 439 * @returns IPRT status code, see RTSemFastMutexRequest. 440 * @param pGVMM The GVMM instance data. 441 */ 442 DECLINLINE(int) gvmmR0CreateDestroyUnlock(PGVMM pGVMM) 443 { 444 LogFlow(("--gvmmR0CreateDestroyUnlock(%p)\n", pGVMM)); 445 int rc = RTSemFastMutexRelease(pGVMM->CreateDestroyLock); 446 AssertRC(rc); 447 return rc; 448 } 449 450 451 /** 392 452 * Request wrapper for the GVMMR0CreateVM API. 393 453 * … … 446 506 * The whole allocation process is protected by the lock. 447 507 */ 448 int rc = RTSemFastMutexRequest(pGVMM->CreateDestroyLock);508 int rc = gvmmR0CreateDestroyLock(pGVMM); 449 509 AssertRCReturn(rc, rc); 450 510 … … 469 529 * Move the handle from the free to used list and perform permission checks. 470 530 */ 471 rc = RTSemFastMutexRequest(pGVMM->UsedLock);531 rc = gvmmR0UsedLock(pGVMM); 472 532 AssertRC(rc); 473 533 … … 482 542 pHandle->hEMT = NIL_RTNATIVETHREAD; 483 543 484 RTSemFastMutexRelease(pGVMM->UsedLock);544 gvmmR0UsedUnlock(pGVMM); 485 545 486 546 rc = SUPR0ObjVerifyAccess(pHandle->pvObj, pSession, NULL); … … 544 604 545 605 /* complete the handle - take the UsedLock sem just to be careful. */ 546 rc = RTSemFastMutexRequest(pGVMM->UsedLock);606 rc = gvmmR0UsedLock(pGVMM); 547 607 AssertRC(rc); 548 608 … … 552 612 553 613 554 RTSemFastMutexRelease(pGVMM->UsedLock);555 RTSemFastMutexRelease(pGVMM->CreateDestroyLock);614 gvmmR0UsedUnlock(pGVMM); 615 gvmmR0CreateDestroyUnlock(pGVMM); 556 616 557 617 *ppVM = pVM; … … 579 639 void *pvObj = pHandle->pvObj; 580 640 pHandle->pvObj = NULL; 581 RTSemFastMutexRelease(pGVMM->CreateDestroyLock);641 gvmmR0CreateDestroyUnlock(pGVMM); 582 642 583 643 SUPR0ObjRelease(pvObj, pSession); … … 595 655 rc = VERR_GVM_TOO_MANY_VMS; 596 656 597 RTSemFastMutexRelease(pGVMM->CreateDestroyLock);657 gvmmR0CreateDestroyUnlock(pGVMM); 598 658 return rc; 599 659 } … … 654 714 * Take the lock, validate the handle and update the structure members. 655 715 */ 656 int rc = RTSemFastMutexRequest(pGVMM->CreateDestroyLock);716 int rc = gvmmR0CreateDestroyLock(pGVMM); 657 717 AssertRCReturn(rc, rc); 658 rc = RTSemFastMutexRequest(pGVMM->UsedLock);718 rc = gvmmR0UsedLock(pGVMM); 659 719 AssertRC(rc); 660 720 … … 671 731 rc = VERR_INTERNAL_ERROR; 672 732 673 RTSemFastMutexRelease(pGVMM->UsedLock);674 RTSemFastMutexRelease(pGVMM->CreateDestroyLock);733 gvmmR0UsedUnlock(pGVMM); 734 gvmmR0CreateDestroyUnlock(pGVMM); 675 735 LogFlow(("GVMMR0AssociateEMTWithVM: returns %Vrc (hEMT=%RTnthrd)\n", rc, hEMT)); 676 736 return rc; … … 750 810 * Take the lock, validate the handle and update the structure members. 751 811 */ 752 int rc = RTSemFastMutexRequest(pGVMM->CreateDestroyLock);812 int rc = gvmmR0CreateDestroyLock(pGVMM); 753 813 AssertRCReturn(rc, rc); 754 rc = RTSemFastMutexRequest(pGVMM->UsedLock);814 rc = gvmmR0UsedLock(pGVMM); 755 815 AssertRC(rc); 756 816 … … 772 832 rc = VERR_INVALID_HANDLE; 773 833 774 RTSemFastMutexRelease(pGVMM->UsedLock);775 RTSemFastMutexRelease(pGVMM->CreateDestroyLock);834 gvmmR0UsedUnlock(pGVMM); 835 gvmmR0CreateDestroyUnlock(pGVMM); 776 836 LogFlow(("GVMMR0DisassociateEMTFromVM: returns %Vrc (hEMT=%RTnthrd)\n", rc, hEMT)); 777 837 return rc; … … 821 881 * object, we take some precautions against racing callers just in case... 822 882 */ 823 int rc = RTSemFastMutexRequest(pGVMM->CreateDestroyLock);883 int rc = gvmmR0CreateDestroyLock(pGVMM); 824 884 AssertRC(rc); 825 885 … … 835 895 void *pvObj = pHandle->pvObj; 836 896 pHandle->pvObj = NULL; 837 RTSemFastMutexRelease(pGVMM->CreateDestroyLock);897 gvmmR0CreateDestroyUnlock(pGVMM); 838 898 839 899 SUPR0ObjRelease(pvObj, pHandle->pSession); … … 843 903 SUPR0Printf("GVMMR0DestroyVM: pHandle=%p:{.pVM=%p, hEMT=%p, .pvObj=%p} pVM=%p hSelf=%p\n", 844 904 pHandle, pHandle->pVM, pHandle->hEMT, pHandle->pvObj, pVM, hSelf); 845 RTSemFastMutexRelease(pGVMM->CreateDestroyLock);905 gvmmR0CreateDestroyUnlock(pGVMM); 846 906 rc = VERR_INTERNAL_ERROR; 847 907 } … … 877 937 } 878 938 879 int rc = RTSemFastMutexRequest(pGVMM->CreateDestroyLock);939 int rc = gvmmR0CreateDestroyLock(pGVMM); 880 940 AssertRC(rc); 881 rc = RTSemFastMutexRequest(pGVMM->UsedLock);941 rc = gvmmR0UsedLock(pGVMM); 882 942 AssertRC(rc); 883 943 … … 888 948 { 889 949 SUPR0Printf("GVM: used list index %d is out of range!\n", pHandle->iNext); 890 RTSemFastMutexRelease(pGVMM->UsedLock);891 RTSemFastMutexRelease(pGVMM->CreateDestroyLock);950 gvmmR0UsedUnlock(pGVMM); 951 gvmmR0CreateDestroyUnlock(pGVMM); 892 952 return; 893 953 } … … 904 964 { 905 965 SUPR0Printf("GVM: used list index %d is out of range!\n"); 906 RTSemFastMutexRelease(pGVMM->UsedLock);907 RTSemFastMutexRelease(pGVMM->CreateDestroyLock);966 gvmmR0UsedUnlock(pGVMM); 967 gvmmR0CreateDestroyUnlock(pGVMM); 908 968 return; 909 969 } … … 921 981 { 922 982 SUPR0Printf("GVM: can't find the handle previous previous of %d!\n", pHandle->iSelf); 923 RTSemFastMutexRelease(pGVMM->UsedLock);924 RTSemFastMutexRelease(pGVMM->CreateDestroyLock);983 gvmmR0UsedUnlock(pGVMM); 984 gvmmR0CreateDestroyUnlock(pGVMM); 925 985 return; 926 986 } … … 931 991 pGVMM->cVMs--; 932 992 933 RTSemFastMutexRelease(pGVMM->UsedLock);993 gvmmR0UsedUnlock(pGVMM); 934 994 935 995 /* … … 980 1040 * Reacquire the UsedLock here to since we're updating handle fields. 981 1041 */ 982 rc = RTSemFastMutexRequest(pGVMM->UsedLock);1042 rc = gvmmR0UsedLock(pGVMM); 983 1043 AssertRC(rc); 984 1044 … … 991 1051 ASMAtomicXchgSize(&pHandle->hEMT, NIL_RTNATIVETHREAD); 992 1052 993 RTSemFastMutexRelease(pGVMM->UsedLock);994 RTSemFastMutexRelease(pGVMM->CreateDestroyLock);1053 gvmmR0UsedUnlock(pGVMM); 1054 gvmmR0CreateDestroyUnlock(pGVMM); 995 1055 LogFlow(("gvmmR0HandleObjDestructor: returns\n")); 996 1056 } … … 1068 1128 if (fTakeUsedLock) 1069 1129 { 1070 int rc = RTSemFastMutexRequest(pGVMM->UsedLock);1130 int rc = gvmmR0UsedLock(pGVMM); 1071 1131 AssertRCReturn(rc, rc); 1072 1132 … … 1077 1137 || pGVM->pVM != pVM)) 1078 1138 { 1079 RTSemFastMutexRelease(pGVMM->UsedLock);1139 gvmmR0UsedUnlock(pGVMM); 1080 1140 return VERR_INVALID_HANDLE; 1081 1141 } … … 1089 1149 1090 1150 pGVM = pHandle->pGVM; 1091 if ( !RT_UNLIKELY(!VALID_PTR(pGVM)))1151 if (RT_UNLIKELY(!VALID_PTR(pGVM))) 1092 1152 return VERR_INVALID_HANDLE; 1093 if ( !RT_UNLIKELY(pGVM->pVM != pVM))1153 if (RT_UNLIKELY(pGVM->pVM != pVM)) 1094 1154 return VERR_INVALID_HANDLE; 1095 1155 } … … 1365 1425 * Interrupts must NOT be disabled at this point because we ask for GIP time! 1366 1426 */ 1367 rc = RTSemFastMutexRequest(pGVMM->UsedLock);1427 rc = gvmmR0UsedLock(pGVMM); 1368 1428 AssertRC(rc); 1369 1429 … … 1384 1444 pGVM->gvmm.s.StatsSched.cHaltBlocking++; 1385 1445 ASMAtomicXchgU64(&pGVM->gvmm.s.u64HaltExpire, u64ExpireGipTime); 1386 RTSemFastMutexRelease(pGVMM->UsedLock);1446 gvmmR0UsedUnlock(pGVMM); 1387 1447 1388 1448 uint32_t cMillies = (u64ExpireGipTime - u64Now) / 1000000; … … 1398 1458 { 1399 1459 pGVM->gvmm.s.StatsSched.cHaltNotBlocking++; 1400 RTSemFastMutexRelease(pGVMM->UsedLock);1460 gvmmR0UsedUnlock(pGVMM); 1401 1461 } 1402 1462 … … 1458 1518 1459 1519 1460 rc2 = RTSemFastMutexRelease(pGVMM->UsedLock);1520 rc2 = gvmmR0UsedUnlock(pGVMM); 1461 1521 AssertRC(rc2); 1462 1522 } … … 1491 1551 if (RT_SUCCESS(rc)) 1492 1552 { 1493 rc = RTSemFastMutexRequest(pGVMM->UsedLock);1553 rc = gvmmR0UsedLock(pGVMM); 1494 1554 AssertRC(rc); 1495 1555 pGVM->gvmm.s.StatsSched.cPollCalls++; … … 1506 1566 } 1507 1567 1508 RTSemFastMutexRelease(pGVMM->UsedLock);1568 gvmmR0UsedUnlock(pGVMM); 1509 1569 } 1510 1570 … … 1552 1612 memset(&pStats->SchedVM, 0, sizeof(pStats->SchedVM)); 1553 1613 1554 int rc = RTSemFastMutexRequest(pGVMM->UsedLock);1614 int rc = gvmmR0UsedLock(pGVMM); 1555 1615 AssertRCReturn(rc, rc); 1556 1616 } … … 1591 1651 } 1592 1652 1593 RTSemFastMutexRelease(pGVMM->UsedLock);1653 gvmmR0UsedUnlock(pGVMM); 1594 1654 1595 1655 return VINF_SUCCESS; … … 1664 1724 GVMM_GET_VALID_INSTANCE(pGVMM, VERR_INTERNAL_ERROR); 1665 1725 1666 int rc = RTSemFastMutexRequest(pGVMM->UsedLock);1726 int rc = gvmmR0UsedLock(pGVMM); 1667 1727 AssertRCReturn(rc, rc); 1668 1728 } … … 1702 1762 } 1703 1763 1704 RTSemFastMutexRelease(pGVMM->UsedLock);1764 gvmmR0UsedUnlock(pGVMM); 1705 1765 1706 1766 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.