Changeset 37467 in vbox
- Timestamp:
- Jun 15, 2011 1:08:45 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 72281
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IOMAll.cpp
r37466 r37467 40 40 41 41 42 43 /**44 * Try take the EMT/IOM lock, wait in ring-3 return VERR_SEM_BUSY in R0/RC.45 *46 * @retval VINF_SUCCESS on success (always in ring-3).47 * @retval VERR_SEM_BUSY in RC and R0 if the semaphore is busy.48 *49 * @param pVM VM handle.50 */51 int iomLock(PVM pVM)52 {53 Assert(pVM->cCpus == 1 || !PGMIsLockOwner(pVM));54 int rc = PDMCritSectEnter(&pVM->iom.s.EmtLock, VERR_SEM_BUSY);55 return rc;56 }57 58 59 /**60 * Try take the EMT/IOM lock, no waiting.61 *62 * @retval VINF_SUCCESS on success.63 * @retval VERR_SEM_BUSY if busy.64 *65 * @param pVM VM handle.66 */67 int iomTryLock(PVM pVM)68 {69 int rc = PDMCritSectTryEnter(&pVM->iom.s.EmtLock);70 return rc;71 }72 73 74 /**75 * Release EMT/IOM lock.76 *77 * @param pVM VM handle.78 */79 void iomUnlock(PVM pVM)80 {81 PDMCritSectLeave(&pVM->iom.s.EmtLock);82 }83 84 85 42 /** 86 43 * Check if this VCPU currently owns the IOM lock. … … 91 48 VMMDECL(bool) IOMIsLockOwner(PVM pVM) 92 49 { 93 return PDMCritSectIsOwner(&pVM->iom.s. EmtLock);50 return PDMCritSectIsOwner(&pVM->iom.s.CritSect); 94 51 } 95 52 … … 266 223 * handle is buggy and doesn't handle all cases. */ 267 224 /* Take the IOM lock before performing any device I/O. */ 268 int rc2 = iomLock(pVM);225 int rc2 = IOM_LOCK(pVM); 269 226 #ifndef IN_RING3 270 227 if (rc2 == VERR_SEM_BUSY) … … 311 268 { 312 269 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->InRZToR3); }); 313 iomUnlock(pVM);270 IOM_UNLOCK(pVM); 314 271 return VINF_IOM_HC_IOPORT_READ; 315 272 } … … 317 274 void *pvUser = pRange->pvUser; 318 275 PPDMDEVINS pDevIns = pRange->pDevIns; 319 PPDMCRITSECT pCritSect = pDevIns->CTX_SUFF(pCritSectRo); 320 321 /* 322 * Call the device - 4 variations. 323 */ 324 VBOXSTRICTRC rcStrict; 325 if (pCritSect) 326 { 327 iomUnlock(pVM); 328 rcStrict = PDMCritSectEnter(pCritSect, VINF_IOM_HC_IOPORT_READ); 329 if (rcStrict != VINF_SUCCESS) 330 { 331 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->InRZToR3); }); 332 return rcStrict; 333 } 334 #ifdef VBOX_WITH_STATISTICS 335 if (pStats) 336 { 337 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfIn), a); 338 rcStrict = pfnInCallback(pDevIns, pvUser, Port, pu32Value, (unsigned)cbValue); 339 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfIn), a); 340 } 341 else 342 #endif 343 rcStrict = pfnInCallback(pDevIns, pvUser, Port, pu32Value, (unsigned)cbValue); 344 PDMCritSectLeave(pCritSect); 276 IOM_UNLOCK(pVM); 277 278 /* 279 * Call the device. 280 */ 281 VBOXSTRICTRC rcStrict = PDMCritSectEnter(pDevIns->CTX_SUFF(pCritSectRo), VINF_IOM_HC_IOPORT_READ); 282 if (rcStrict != VINF_SUCCESS) 283 { 284 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->InRZToR3); }); 285 return rcStrict; 286 } 287 #ifdef VBOX_WITH_STATISTICS 288 if (pStats) 289 { 290 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfIn), a); 291 rcStrict = pfnInCallback(pDevIns, pvUser, Port, pu32Value, (unsigned)cbValue); 292 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfIn), a); 345 293 } 346 294 else 347 { 348 #ifdef VBOX_WITH_STATISTICS 349 if (pStats) 350 { 351 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfIn), a); 352 rcStrict = pfnInCallback(pDevIns, pvUser, Port, pu32Value, (unsigned)cbValue); 353 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfIn), a); 354 } 355 else 356 #endif 357 rcStrict = pfnInCallback(pDevIns, pvUser, Port, pu32Value, (unsigned)cbValue); 358 } 295 #endif 296 rcStrict = pfnInCallback(pDevIns, pvUser, Port, pu32Value, (unsigned)cbValue); 297 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 298 359 299 #ifdef VBOX_WITH_STATISTICS 360 300 if (rcStrict == VINF_SUCCESS && pStats) … … 376 316 default: 377 317 AssertMsgFailed(("Invalid I/O port size %d. Port=%d\n", cbValue, Port)); 378 if (!pCritSect)379 iomUnlock(pVM);380 318 return VERR_IOM_INVALID_IOPORT_SIZE; 381 319 } 382 320 } 383 321 Log3(("IOMIOPortRead: Port=%RTiop *pu32=%08RX32 cb=%d rc=%Rrc\n", Port, *pu32Value, cbValue, VBOXSTRICTRC_VAL(rcStrict))); 384 if (!pCritSect)385 iomUnlock(pVM);386 322 return rcStrict; 387 323 } … … 398 334 STAM_COUNTER_INC(&pStats->InRZToR3); 399 335 # endif 400 iomUnlock(pVM);336 IOM_UNLOCK(pVM); 401 337 return VINF_IOM_HC_IOPORT_READ; 402 338 } … … 413 349 # ifndef IN_RING3 414 350 /* Ring-3 will have to create the statistics record. */ 415 iomUnlock(pVM);351 IOM_UNLOCK(pVM); 416 352 return VINF_IOM_HC_IOPORT_READ; 417 353 # else … … 431 367 default: 432 368 AssertMsgFailed(("Invalid I/O port size %d. Port=%d\n", cbValue, Port)); 433 iomUnlock(pVM);369 IOM_UNLOCK(pVM); 434 370 return VERR_IOM_INVALID_IOPORT_SIZE; 435 371 } 436 372 Log3(("IOMIOPortRead: Port=%RTiop *pu32=%08RX32 cb=%d rc=VINF_SUCCESS\n", Port, *pu32Value, cbValue)); 437 iomUnlock(pVM);373 IOM_UNLOCK(pVM); 438 374 return VINF_SUCCESS; 439 375 } … … 459 395 { 460 396 /* Take the IOM lock before performing any device I/O. */ 461 int rc2 = iomLock(pVM);397 int rc2 = IOM_LOCK(pVM); 462 398 #ifndef IN_RING3 463 399 if (rc2 == VERR_SEM_BUSY) … … 507 443 { 508 444 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->InRZToR3); }); 509 iomUnlock(pVM);445 IOM_UNLOCK(pVM); 510 446 return VINF_IOM_HC_IOPORT_READ; 511 447 } … … 513 449 void *pvUser = pRange->pvUser; 514 450 PPDMDEVINS pDevIns = pRange->pDevIns; 515 PPDMCRITSECT pCritSect = pDevIns->CTX_SUFF(pCritSectRo); 516 517 /* 518 * Call the device - 4 variations. 519 */ 520 VBOXSTRICTRC rcStrict; 521 if (pCritSect) 522 { 523 iomUnlock(pVM); 524 rcStrict = PDMCritSectEnter(pCritSect, VINF_IOM_HC_IOPORT_READ); 525 if (rcStrict != VINF_SUCCESS) 526 { 527 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->InRZToR3); }); 528 return rcStrict; 529 } 530 #ifdef VBOX_WITH_STATISTICS 531 if (pStats) 532 { 533 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfIn), a); 534 rcStrict = pfnInStrCallback(pDevIns, pvUser, Port, pGCPtrDst, pcTransfers, cb); 535 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfIn), a); 536 } 537 else 538 #endif 539 rcStrict = pfnInStrCallback(pDevIns, pvUser, Port, pGCPtrDst, pcTransfers, cb); 540 PDMCritSectLeave(pCritSect); 451 IOM_UNLOCK(pVM); 452 453 /* 454 * Call the device. 455 */ 456 VBOXSTRICTRC rcStrict = PDMCritSectEnter(pDevIns->CTX_SUFF(pCritSectRo), VINF_IOM_HC_IOPORT_READ); 457 if (rcStrict != VINF_SUCCESS) 458 { 459 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->InRZToR3); }); 460 return rcStrict; 461 } 462 #ifdef VBOX_WITH_STATISTICS 463 if (pStats) 464 { 465 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfIn), a); 466 rcStrict = pfnInStrCallback(pDevIns, pvUser, Port, pGCPtrDst, pcTransfers, cb); 467 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfIn), a); 541 468 } 542 469 else 543 { 544 #ifdef VBOX_WITH_STATISTICS 545 if (pStats) 546 { 547 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfIn), a); 548 rcStrict = pfnInStrCallback(pDevIns, pvUser, Port, pGCPtrDst, pcTransfers, cb); 549 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfIn), a); 550 } 551 else 552 #endif 553 rcStrict = pfnInStrCallback(pDevIns, pvUser, Port, pGCPtrDst, pcTransfers, cb); 554 } 470 #endif 471 rcStrict = pfnInStrCallback(pDevIns, pvUser, Port, pGCPtrDst, pcTransfers, cb); 472 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 555 473 556 474 #ifdef VBOX_WITH_STATISTICS … … 564 482 Log3(("IOMIOPortReadStr: Port=%RTiop pGCPtrDst=%p pcTransfer=%p:{%#x->%#x} cb=%d rc=%Rrc\n", 565 483 Port, pGCPtrDst, pcTransfers, cTransfers, *pcTransfers, cb, VBOXSTRICTRC_VAL(rcStrict))); 566 if (!pCritSect)567 iomUnlock(pVM);568 484 return rcStrict; 569 485 } … … 580 496 STAM_COUNTER_INC(&pStats->InRZToR3); 581 497 # endif 582 iomUnlock(pVM);498 IOM_UNLOCK(pVM); 583 499 return VINF_IOM_HC_IOPORT_READ; 584 500 } … … 595 511 # ifndef IN_RING3 596 512 /* Ring-3 will have to create the statistics record. */ 597 iomUnlock(pVM);513 IOM_UNLOCK(pVM); 598 514 return VINF_IOM_HC_IOPORT_READ; 599 515 # else … … 607 523 Log3(("IOMIOPortReadStr: Port=%RTiop pGCPtrDst=%p pcTransfer=%p:{%#x->%#x} cb=%d rc=VINF_SUCCESS\n", 608 524 Port, pGCPtrDst, pcTransfers, cTransfers, *pcTransfers, cb)); 609 iomUnlock(pVM);525 IOM_UNLOCK(pVM); 610 526 return VINF_SUCCESS; 611 527 } … … 630 546 { 631 547 /* Take the IOM lock before performing any device I/O. */ 632 int rc2 = iomLock(pVM);548 int rc2 = IOM_LOCK(pVM); 633 549 #ifndef IN_RING3 634 550 if (rc2 == VERR_SEM_BUSY) … … 677 593 { 678 594 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->OutRZToR3); }); 679 iomUnlock(pVM);595 IOM_UNLOCK(pVM); 680 596 return VINF_IOM_HC_IOPORT_WRITE; 681 597 } … … 683 599 void *pvUser = pRange->pvUser; 684 600 PPDMDEVINS pDevIns = pRange->pDevIns; 685 PPDMCRITSECT pCritSect = pDevIns->CTX_SUFF(pCritSectRo); 686 687 /* 688 * Call the device - 4 variations. 689 */ 690 VBOXSTRICTRC rcStrict; 691 if (pCritSect) 692 { 693 iomUnlock(pVM); 694 rcStrict = PDMCritSectEnter(pCritSect, VINF_IOM_HC_IOPORT_WRITE); 695 if (rcStrict != VINF_SUCCESS) 696 { 697 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->OutRZToR3); }); 698 return rcStrict; 699 } 700 #ifdef VBOX_WITH_STATISTICS 701 if (pStats) 702 { 703 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfOut), a); 704 rcStrict = pfnOutCallback(pDevIns, pvUser, Port, u32Value, (unsigned)cbValue); 705 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfOut), a); 706 } 707 else 708 #endif 709 rcStrict = pfnOutCallback(pDevIns, pvUser, Port, u32Value, (unsigned)cbValue); 710 PDMCritSectLeave(pCritSect); 601 IOM_UNLOCK(pVM); 602 603 /* 604 * Call the device. 605 */ 606 VBOXSTRICTRC rcStrict = PDMCritSectEnter(pDevIns->CTX_SUFF(pCritSectRo), VINF_IOM_HC_IOPORT_WRITE); 607 if (rcStrict != VINF_SUCCESS) 608 { 609 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->OutRZToR3); }); 610 return rcStrict; 611 } 612 #ifdef VBOX_WITH_STATISTICS 613 if (pStats) 614 { 615 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfOut), a); 616 rcStrict = pfnOutCallback(pDevIns, pvUser, Port, u32Value, (unsigned)cbValue); 617 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfOut), a); 711 618 } 712 619 else 713 { 714 #ifdef VBOX_WITH_STATISTICS 715 if (pStats) 716 { 717 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfOut), a); 718 rcStrict = pfnOutCallback(pDevIns, pvUser, Port, u32Value, (unsigned)cbValue); 719 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfOut), a); 720 } 721 else 722 #endif 723 rcStrict = pfnOutCallback(pDevIns, pvUser, Port, u32Value, (unsigned)cbValue); 724 } 620 #endif 621 rcStrict = pfnOutCallback(pDevIns, pvUser, Port, u32Value, (unsigned)cbValue); 622 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 725 623 726 624 #ifdef VBOX_WITH_STATISTICS … … 733 631 #endif 734 632 Log3(("IOMIOPortWrite: Port=%RTiop u32=%08RX32 cb=%d rc=%Rrc\n", Port, u32Value, cbValue, VBOXSTRICTRC_VAL(rcStrict))); 735 if (!pCritSect)736 iomUnlock(pVM);737 633 return rcStrict; 738 634 } … … 749 645 STAM_COUNTER_INC(&pStats->OutRZToR3); 750 646 # endif 751 iomUnlock(pVM);647 IOM_UNLOCK(pVM); 752 648 return VINF_IOM_HC_IOPORT_WRITE; 753 649 } … … 765 661 # ifndef IN_RING3 766 662 /* R3 will have to create the statistics record. */ 767 iomUnlock(pVM);663 IOM_UNLOCK(pVM); 768 664 return VINF_IOM_HC_IOPORT_WRITE; 769 665 # else … … 775 671 #endif 776 672 Log3(("IOMIOPortWrite: Port=%RTiop u32=%08RX32 cb=%d nop\n", Port, u32Value, cbValue)); 777 iomUnlock(pVM);673 IOM_UNLOCK(pVM); 778 674 return VINF_SUCCESS; 779 675 } … … 799 695 { 800 696 /* Take the IOM lock before performing any device I/O. */ 801 int rc2 = iomLock(pVM);697 int rc2 = IOM_LOCK(pVM); 802 698 #ifndef IN_RING3 803 699 if (rc2 == VERR_SEM_BUSY) … … 847 743 { 848 744 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->OutRZToR3); }); 849 iomUnlock(pVM);745 IOM_UNLOCK(pVM); 850 746 return VINF_IOM_HC_IOPORT_WRITE; 851 747 } … … 853 749 void *pvUser = pRange->pvUser; 854 750 PPDMDEVINS pDevIns = pRange->pDevIns; 855 PPDMCRITSECT pCritSect = pDevIns->CTX_SUFF(pCritSectRo); 856 857 /* 858 * Call the device - 4 variations. 859 */ 860 VBOXSTRICTRC rcStrict; 861 if (pCritSect) 862 { 863 iomUnlock(pVM); 864 rcStrict = PDMCritSectEnter(pCritSect, VINF_IOM_HC_IOPORT_WRITE); 865 if (rcStrict != VINF_SUCCESS) 866 { 867 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->OutRZToR3); }); 868 return rcStrict; 869 } 870 #ifdef VBOX_WITH_STATISTICS 871 if (pStats) 872 { 873 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfOut), a); 874 rcStrict = pfnOutStrCallback(pDevIns, pvUser, Port, pGCPtrSrc, pcTransfers, cb); 875 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfOut), a); 876 } 877 else 878 #endif 879 rcStrict = pfnOutStrCallback(pDevIns, pvUser, Port, pGCPtrSrc, pcTransfers, cb); 880 PDMCritSectLeave(pCritSect); 751 IOM_UNLOCK(pVM); 752 753 /* 754 * Call the device. 755 */ 756 VBOXSTRICTRC rcStrict = PDMCritSectEnter(pDevIns->CTX_SUFF(pCritSectRo), VINF_IOM_HC_IOPORT_WRITE); 757 if (rcStrict != VINF_SUCCESS) 758 { 759 STAM_STATS({ if (pStats) STAM_COUNTER_INC(&pStats->OutRZToR3); }); 760 return rcStrict; 761 } 762 #ifdef VBOX_WITH_STATISTICS 763 if (pStats) 764 { 765 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfOut), a); 766 rcStrict = pfnOutStrCallback(pDevIns, pvUser, Port, pGCPtrSrc, pcTransfers, cb); 767 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfOut), a); 881 768 } 882 769 else 883 { 884 #ifdef VBOX_WITH_STATISTICS 885 if (pStats) 886 { 887 STAM_PROFILE_START(&pStats->CTX_SUFF_Z(ProfOut), a); 888 rcStrict = pfnOutStrCallback(pDevIns, pvUser, Port, pGCPtrSrc, pcTransfers, cb); 889 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfOut), a); 890 } 891 else 892 #endif 893 rcStrict = pfnOutStrCallback(pDevIns, pvUser, Port, pGCPtrSrc, pcTransfers, cb); 894 } 770 #endif 771 rcStrict = pfnOutStrCallback(pDevIns, pvUser, Port, pGCPtrSrc, pcTransfers, cb); 772 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 895 773 896 774 #ifdef VBOX_WITH_STATISTICS … … 904 782 Log3(("IOMIOPortWriteStr: Port=%RTiop pGCPtrSrc=%p pcTransfer=%p:{%#x->%#x} cb=%d rcStrict=%Rrc\n", 905 783 Port, pGCPtrSrc, pcTransfers, cTransfers, *pcTransfers, cb, VBOXSTRICTRC_VAL(rcStrict))); 906 if (!pCritSect)907 iomUnlock(pVM);908 784 return rcStrict; 909 785 } … … 920 796 STAM_COUNTER_INC(&pStats->OutRZToR3); 921 797 # endif 922 iomUnlock(pVM);798 IOM_UNLOCK(pVM); 923 799 return VINF_IOM_HC_IOPORT_WRITE; 924 800 } … … 935 811 # ifndef IN_RING3 936 812 /* Ring-3 will have to create the statistics record. */ 937 iomUnlock(pVM);813 IOM_UNLOCK(pVM); 938 814 return VINF_IOM_HC_IOPORT_WRITE; 939 815 # else … … 947 823 Log3(("IOMIOPortWriteStr: Port=%RTiop pGCPtrSrc=%p pcTransfer=%p:{%#x->%#x} cb=%d rc=VINF_SUCCESS\n", 948 824 Port, pGCPtrSrc, pcTransfers, cTransfers, *pcTransfers, cb)); 949 iomUnlock(pVM);825 IOM_UNLOCK(pVM); 950 826 return VINF_SUCCESS; 951 827 } -
trunk/src/VBox/VMM/VMMAll/IOMAllMMIO.cpp
r37466 r37467 1070 1070 { 1071 1071 /* Take the IOM lock before performing any MMIO. */ 1072 int rc = iomLock(pVM);1072 int rc = IOM_LOCK(pVM); 1073 1073 #ifndef IN_RING3 1074 1074 if (rc == VERR_SEM_BUSY) … … 1093 1093 { 1094 1094 # ifdef IN_RING3 1095 iomUnlock(pVM);1095 IOM_UNLOCK(pVM); 1096 1096 return VERR_NO_MEMORY; 1097 1097 # else 1098 1098 STAM_PROFILE_STOP(&pVM->iom.s.StatRZMMIOHandler, a); 1099 1099 STAM_COUNTER_INC(&pVM->iom.s.StatRZMMIOFailures); 1100 iomUnlock(pVM);1100 IOM_UNLOCK(pVM); 1101 1101 return VINF_IOM_HC_MMIO_READ_WRITE; 1102 1102 # endif … … 1127 1127 STAM_PROFILE_STOP(&pVM->iom.s.StatRZMMIOHandler, a); 1128 1128 STAM_COUNTER_INC(&pVM->iom.s.StatRZMMIOFailures); 1129 iomUnlock(pVM);1129 IOM_UNLOCK(pVM); 1130 1130 return VINF_IOM_HC_MMIO_READ_WRITE; 1131 1131 } … … 1137 1137 iomMmioRetainRange(pRange); 1138 1138 PPDMDEVINS pDevIns = pRange->CTX_SUFF(pDevIns); 1139 PPDMCRITSECT pLock = pDevIns->CTX_SUFF(pCritSectRo); 1140 if (!pLock) 1141 pLock = &pVM->iom.s.EmtLock; 1142 else 1143 { 1144 iomUnlock(pVM); 1145 rc = PDMCritSectEnter(pLock, VINF_IOM_HC_MMIO_READ_WRITE); 1146 if (rc != VINF_SUCCESS) 1147 { 1148 iomMmioReleaseRange(pVM, pRange); 1149 return rc; 1150 } 1139 IOM_UNLOCK(pVM); 1140 rc = PDMCritSectEnter(pDevIns->CTX_SUFF(pCritSectRo), VINF_IOM_HC_MMIO_READ_WRITE); 1141 if (rc != VINF_SUCCESS) 1142 { 1143 iomMmioReleaseRange(pVM, pRange); 1144 return rc; 1151 1145 } 1152 1146 … … 1162 1156 { 1163 1157 iomMmioReleaseRange(pVM, pRange); 1164 PDMCritSectLeave(p Lock);1158 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 1165 1159 return rc; 1166 1160 } … … 1296 1290 STAM_PROFILE_STOP(&pVM->iom.s.StatRZMMIOHandler, a); 1297 1291 iomMmioReleaseRange(pVM, pRange); 1298 PDMCritSectLeave(p Lock);1292 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 1299 1293 return rc; 1300 1294 } … … 1330 1324 VMMDECL(VBOXSTRICTRC) IOMMMIOPhysHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore, RTGCPHYS GCPhysFault) 1331 1325 { 1332 int rc2 = iomLock(pVM);1326 int rc2 = IOM_LOCK(pVM); 1333 1327 #ifndef IN_RING3 1334 1328 if (rc2 == VERR_SEM_BUSY) … … 1336 1330 #endif 1337 1331 VBOXSTRICTRC rcStrict = iomMMIOHandler(pVM, (uint32_t)uErrorCode, pCtxCore, GCPhysFault, iomMmioGetRange(pVM, GCPhysFault)); 1338 iomUnlock(pVM);1332 IOM_UNLOCK(pVM); 1339 1333 return VBOXSTRICTRC_VAL(rcStrict); 1340 1334 } … … 1367 1361 * Validate the range. 1368 1362 */ 1369 int rc = iomLock(pVM);1363 int rc = IOM_LOCK(pVM); 1370 1364 AssertRC(rc); 1371 1365 Assert(pRange == iomMmioGetRange(pVM, GCPhysFault)); … … 1376 1370 iomMmioRetainRange(pRange); 1377 1371 PPDMDEVINS pDevIns = pRange->CTX_SUFF(pDevIns); 1378 PPDMCRITSECT pLock = pDevIns->CTX_SUFF(pCritSectRo); 1379 if (!pLock) 1380 pLock = &pVM->iom.s.EmtLock; 1381 else 1382 { 1383 iomUnlock(pVM); 1384 rc = PDMCritSectEnter(pLock, VINF_IOM_HC_MMIO_READ_WRITE); 1385 if (rc != VINF_SUCCESS) 1386 { 1387 iomMmioReleaseRange(pVM, pRange); 1388 return rc; 1389 } 1372 IOM_UNLOCK(pVM); 1373 rc = PDMCritSectEnter(pDevIns->CTX_SUFF(pCritSectRo), VINF_IOM_HC_MMIO_READ_WRITE); 1374 if (rc != VINF_SUCCESS) 1375 { 1376 iomMmioReleaseRange(pVM, pRange); 1377 return rc; 1390 1378 } 1391 1379 … … 1400 1388 AssertRC(rc); 1401 1389 iomMmioReleaseRange(pVM, pRange); 1402 PDMCritSectLeave(p Lock);1390 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 1403 1391 return rc; 1404 1392 } … … 1419 1407 { 1420 1408 /* Take the IOM lock before performing any MMIO. */ 1421 int rc = iomLock(pVM);1409 int rc = IOM_LOCK(pVM); 1422 1410 #ifndef IN_RING3 1423 1411 if (rc == VERR_SEM_BUSY) … … 1436 1424 if (!pRange) 1437 1425 { 1438 iomUnlock(pVM);1426 IOM_UNLOCK(pVM); 1439 1427 return VERR_INTERNAL_ERROR; 1440 1428 } … … 1443 1431 if (!pStats) 1444 1432 { 1445 iomUnlock(pVM);1433 IOM_UNLOCK(pVM); 1446 1434 # ifdef IN_RING3 1447 1435 return VERR_NO_MEMORY; … … 1460 1448 iomMmioRetainRange(pRange); 1461 1449 PPDMDEVINS pDevIns = pRange->CTX_SUFF(pDevIns); 1462 PPDMCRITSECT pLock = pDevIns->CTX_SUFF(pCritSectRo); 1463 if (!pLock) 1464 pLock = &pVM->iom.s.EmtLock; 1465 else 1450 IOM_UNLOCK(pVM); 1451 rc = PDMCritSectEnter(pDevIns->CTX_SUFF(pCritSectRo), VINF_IOM_HC_MMIO_WRITE); 1452 if (rc != VINF_SUCCESS) 1466 1453 { 1467 iomUnlock(pVM); 1468 rc = PDMCritSectEnter(pLock, VINF_IOM_HC_MMIO_WRITE); 1469 if (rc != VINF_SUCCESS) 1470 { 1471 iomMmioReleaseRange(pVM, pRange); 1472 return rc; 1473 } 1454 iomMmioReleaseRange(pVM, pRange); 1455 return rc; 1474 1456 } 1475 1457 … … 1485 1467 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=VINF_SUCCESS\n", GCPhys, *pu32Value, cbValue)); 1486 1468 iomMmioReleaseRange(pVM, pRange); 1487 PDMCritSectLeave(p Lock);1469 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 1488 1470 return rc; 1489 1471 #ifndef IN_RING3 … … 1495 1477 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, rc)); 1496 1478 iomMmioReleaseRange(pVM, pRange); 1497 PDMCritSectLeave(p Lock);1479 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 1498 1480 return rc; 1499 1481 … … 1501 1483 switch (cbValue) 1502 1484 { 1503 case 1: *(uint8_t *)pu32Value= UINT8_C(0x00); break;1485 case 1: *(uint8_t *)pu32Value = UINT8_C(0x00); break; 1504 1486 case 2: *(uint16_t *)pu32Value = UINT16_C(0x0000); break; 1505 1487 case 4: *(uint32_t *)pu32Value = UINT32_C(0x00000000); break; … … 1509 1491 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, rc)); 1510 1492 iomMmioReleaseRange(pVM, pRange); 1511 PDMCritSectLeave(p Lock);1493 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 1512 1494 return VINF_SUCCESS; 1513 1495 … … 1515 1497 switch (cbValue) 1516 1498 { 1517 case 1: *(uint8_t *)pu32Value= UINT8_C(0xff); break;1499 case 1: *(uint8_t *)pu32Value = UINT8_C(0xff); break; 1518 1500 case 2: *(uint16_t *)pu32Value = UINT16_C(0xffff); break; 1519 1501 case 4: *(uint32_t *)pu32Value = UINT32_C(0xffffffff); break; … … 1523 1505 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, *pu32Value, cbValue, rc)); 1524 1506 iomMmioReleaseRange(pVM, pRange); 1525 PDMCritSectLeave(p Lock);1507 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 1526 1508 return VINF_SUCCESS; 1527 1509 } … … 1532 1514 { 1533 1515 STAM_COUNTER_INC(&pStats->CTX_MID_Z(Read,ToR3)); 1534 iomUnlock(pVM);1516 IOM_UNLOCK(pVM); 1535 1517 return VINF_IOM_HC_MMIO_READ; 1536 1518 } … … 1551 1533 } 1552 1534 Log4(("IOMMMIORead: GCPhys=%RGp *pu32=%08RX32 cb=%d rc=VINF_SUCCESS\n", GCPhys, *pu32Value, cbValue)); 1553 iomUnlock(pVM);1535 IOM_UNLOCK(pVM); 1554 1536 return VINF_SUCCESS; 1555 1537 } … … 1569 1551 { 1570 1552 /* Take the IOM lock before performing any MMIO. */ 1571 int rc = iomLock(pVM);1553 int rc = IOM_LOCK(pVM); 1572 1554 #ifndef IN_RING3 1573 1555 if (rc == VERR_SEM_BUSY) … … 1586 1568 if (!pRange) 1587 1569 { 1588 iomUnlock(pVM);1570 IOM_UNLOCK(pVM); 1589 1571 return VERR_INTERNAL_ERROR; 1590 1572 } … … 1593 1575 if (!pStats) 1594 1576 { 1595 iomUnlock(pVM);1577 IOM_UNLOCK(pVM); 1596 1578 # ifdef IN_RING3 1597 1579 return VERR_NO_MEMORY; … … 1610 1592 iomMmioRetainRange(pRange); 1611 1593 PPDMDEVINS pDevIns = pRange->CTX_SUFF(pDevIns); 1612 PPDMCRITSECT pLock = pDevIns->CTX_SUFF(pCritSectRo); 1613 if (!pLock) 1614 pLock = &pVM->iom.s.EmtLock; 1615 else 1594 IOM_UNLOCK(pVM); 1595 rc = PDMCritSectEnter(pDevIns->CTX_SUFF(pCritSectRo), VINF_IOM_HC_MMIO_READ); 1596 if (rc != VINF_SUCCESS) 1616 1597 { 1617 iomUnlock(pVM); 1618 rc = PDMCritSectEnter(pLock, VINF_IOM_HC_MMIO_READ); 1619 if (rc != VINF_SUCCESS) 1620 { 1621 iomMmioReleaseRange(pVM, pRange); 1622 return rc; 1623 } 1598 iomMmioReleaseRange(pVM, pRange); 1599 return rc; 1624 1600 } 1625 1601 … … 1638 1614 Log4(("IOMMMIOWrite: GCPhys=%RGp u32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, u32Value, cbValue, rc)); 1639 1615 iomMmioReleaseRange(pVM, pRange); 1640 PDMCritSectLeave(p Lock);1616 PDMCritSectLeave(pDevIns->CTX_SUFF(pCritSectRo)); 1641 1617 return rc; 1642 1618 } … … 1645 1621 { 1646 1622 STAM_COUNTER_INC(&pStats->CTX_MID_Z(Write,ToR3)); 1647 iomUnlock(pVM);1623 IOM_UNLOCK(pVM); 1648 1624 return VINF_IOM_HC_MMIO_WRITE; 1649 1625 } … … 1656 1632 STAM_PROFILE_STOP(&pStats->CTX_SUFF_Z(ProfWrite), a); 1657 1633 Log4(("IOMMMIOWrite: GCPhys=%RGp u32=%08RX32 cb=%d rc=%Rrc\n", GCPhys, u32Value, cbValue, VINF_SUCCESS)); 1658 iomUnlock(pVM);1634 IOM_UNLOCK(pVM); 1659 1635 return VINF_SUCCESS; 1660 1636 } 1637 1661 1638 1662 1639 /** … … 2015 1992 return VINF_SUCCESS; /* ignore */ 2016 1993 2017 PDMCritSectEnter(&pVM->iom.s.EmtLock, VINF_SUCCESS);1994 IOM_LOCK(pVM); 2018 1995 2019 1996 /* … … 2035 2012 int rc = PGMHandlerPhysicalPageAlias(pVM, pRange->GCPhys, GCPhys, GCPhysRemapped); 2036 2013 2037 PDMCritSectLeave(&pVM->iom.s.EmtLock);2014 IOM_UNLOCK(pVM); 2038 2015 AssertRCReturn(rc, rc); 2039 2016 -
trunk/src/VBox/VMM/VMMR3/IOM.cpp
r37466 r37467 149 149 AssertCompileMemberAlignment(VM, iom.s, 32); 150 150 AssertCompile(sizeof(pVM->iom.s) <= sizeof(pVM->iom.padding)); 151 AssertCompileMemberAlignment(IOM, EmtLock, sizeof(uintptr_t));151 AssertCompileMemberAlignment(IOM, CritSect, sizeof(uintptr_t)); 152 152 153 153 /* … … 159 159 * Initialize the REM critical section. 160 160 */ 161 int rc = PDMR3CritSectInit(pVM, &pVM->iom.s. EmtLock, RT_SRC_POS, "IOM Lock");161 int rc = PDMR3CritSectInit(pVM, &pVM->iom.s.CritSect, RT_SRC_POS, "IOM Lock"); 162 162 AssertRCReturn(rc, rc); 163 163 … … 227 227 static void iomR3FlushCache(PVM pVM) 228 228 { 229 iomLock(pVM); 229 IOM_LOCK(pVM); 230 230 231 /* 231 232 * Caching of port and statistics (saves some time in rep outs/ins instruction emulation) … … 252 253 pVM->iom.s.pMMIOStatsLastRC = NIL_RTRCPTR; 253 254 254 iomUnlock(pVM);255 IOM_UNLOCK(pVM); 255 256 } 256 257 … … 562 563 * Try Insert it. 563 564 */ 564 iomLock(pVM);565 IOM_LOCK(pVM); 565 566 if (RTAvlroIOPortInsert(&pVM->iom.s.pTreesR3->IOPortTreeR3, &pRange->Core)) 566 567 { 567 568 #ifdef VBOX_WITH_STATISTICS 568 569 for (unsigned iPort = 0; iPort < cPorts; iPort++) 569 570 iomR3IOPortStatsCreate(pVM, PortStart + iPort, pszDesc); 570 571 iomUnlock(pVM);571 #endif 572 IOM_UNLOCK(pVM); 572 573 return VINF_SUCCESS; 573 574 } 574 iomUnlock(pVM);575 IOM_UNLOCK(pVM); 575 576 576 577 /* conflict. */ … … 628 629 } 629 630 630 iomLock(pVM);631 IOM_LOCK(pVM); 631 632 632 633 /* … … 640 641 { 641 642 AssertMsgFailed(("No R3! Port=#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc)); 642 iomUnlock(pVM);643 IOM_UNLOCK(pVM); 643 644 return VERR_IOM_NO_HC_IOPORT_RANGE; 644 645 } … … 651 652 { 652 653 AssertMsgFailed(("Not owner! Port=%#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc)); 653 iomUnlock(pVM);654 IOM_UNLOCK(pVM); 654 655 return VERR_IOM_NOT_IOPORT_RANGE_OWNER; 655 656 } … … 685 686 if (RTAvlroIOPortInsert(&pVM->iom.s.CTX_SUFF(pTrees)->IOPortTreeRC, &pRange->Core)) 686 687 { 687 iomUnlock(pVM);688 IOM_UNLOCK(pVM); 688 689 return VINF_SUCCESS; 689 690 } … … 694 695 rc = VERR_IOM_IOPORT_RANGE_CONFLICT; 695 696 } 696 iomUnlock(pVM);697 IOM_UNLOCK(pVM); 697 698 return rc; 698 699 } … … 743 744 } 744 745 745 iomLock(pVM);746 IOM_LOCK(pVM); 746 747 /* 747 748 * Validate that there are ring-3 ranges for the ports. … … 754 755 { 755 756 AssertMsgFailed(("No R3! Port=#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc)); 756 iomUnlock(pVM);757 IOM_UNLOCK(pVM); 757 758 return VERR_IOM_NO_HC_IOPORT_RANGE; 758 759 } … … 765 766 { 766 767 AssertMsgFailed(("Not owner! Port=%#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc)); 767 iomUnlock(pVM);768 IOM_UNLOCK(pVM); 768 769 return VERR_IOM_NOT_IOPORT_RANGE_OWNER; 769 770 } … … 799 800 if (RTAvlroIOPortInsert(&pVM->iom.s.CTX_SUFF(pTrees)->IOPortTreeR0, &pRange->Core)) 800 801 { 801 iomUnlock(pVM);802 IOM_UNLOCK(pVM); 802 803 return VINF_SUCCESS; 803 804 } … … 808 809 rc = VERR_IOM_IOPORT_RANGE_CONFLICT; 809 810 } 810 iomUnlock(pVM);811 IOM_UNLOCK(pVM); 811 812 return rc; 812 813 } … … 846 847 } 847 848 848 iomLock(pVM);849 IOM_LOCK(pVM); 849 850 850 851 /* Flush the IO port lookup cache */ … … 867 868 AssertMsgFailed(("Removal of ports in range %#x-%#x rejected because not owner of %#x-%#x (%s)\n", 868 869 PortStart, PortLast, pRange->Core.Key, pRange->Core.KeyLast, pRange->pszDesc)); 869 iomUnlock(pVM);870 IOM_UNLOCK(pVM); 870 871 return VERR_IOM_NOT_IOPORT_RANGE_OWNER; 871 872 } … … 931 932 if (RT_FAILURE(rc2)) 932 933 { 933 iomUnlock(pVM);934 IOM_UNLOCK(pVM); 934 935 return rc2; 935 936 } … … 1014 1015 if (RT_FAILURE(rc2)) 1015 1016 { 1016 iomUnlock(pVM);1017 IOM_UNLOCK(pVM); 1017 1018 return rc2; 1018 1019 } … … 1096 1097 if (RT_FAILURE(rc2)) 1097 1098 { 1098 iomUnlock(pVM);1099 IOM_UNLOCK(pVM); 1099 1100 return rc2; 1100 1101 } … … 1125 1126 1126 1127 /* done */ 1127 iomUnlock(pVM);1128 IOM_UNLOCK(pVM); 1128 1129 return rc; 1129 1130 } … … 1471 1472 * Try register it with PGM and then insert it into the tree. 1472 1473 */ 1473 iomLock(pVM);1474 IOM_LOCK(pVM); 1474 1475 iomR3FlushCache(pVM); 1475 1476 rc = PGMR3PhysMMIORegister(pVM, GCPhysStart, cbRange, … … 1481 1482 if (RTAvlroGCPhysInsert(&pVM->iom.s.pTreesR3->MMIOTree, &pRange->Core)) 1482 1483 { 1483 iomUnlock(pVM);1484 IOM_UNLOCK(pVM); 1484 1485 return VINF_SUCCESS; 1485 1486 } 1486 1487 1487 1488 /* bail out */ 1488 iomUnlock(pVM);1489 IOM_UNLOCK(pVM); 1489 1490 DBGFR3Info(pVM, "mmio", NULL, NULL); 1490 1491 AssertMsgFailed(("This cannot happen!\n")); … … 1492 1493 } 1493 1494 else 1494 iomUnlock(pVM);1495 IOM_UNLOCK(pVM); 1495 1496 1496 1497 MMHyperFree(pVM, pRange); … … 1540 1541 * Find the MMIO range and check that the input matches. 1541 1542 */ 1542 iomLock(pVM);1543 IOM_LOCK(pVM); 1543 1544 PIOMMMIORANGE pRange = iomMmioGetRange(pVM, GCPhysStart); 1544 AssertReturnStmt(pRange, iomUnlock(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND);1545 AssertReturnStmt(pRange->pDevInsR3 == pDevIns, iomUnlock(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER);1546 AssertReturnStmt(pRange->GCPhys == GCPhysStart, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE);1547 AssertReturnStmt(pRange->cb == cbRange, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE);1545 AssertReturnStmt(pRange, IOM_UNLOCK(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND); 1546 AssertReturnStmt(pRange->pDevInsR3 == pDevIns, IOM_UNLOCK(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER); 1547 AssertReturnStmt(pRange->GCPhys == GCPhysStart, IOM_UNLOCK(pVM), VERR_IOM_INVALID_MMIO_RANGE); 1548 AssertReturnStmt(pRange->cb == cbRange, IOM_UNLOCK(pVM), VERR_IOM_INVALID_MMIO_RANGE); 1548 1549 1549 1550 pRange->pvUserRC = pvUser; … … 1552 1553 pRange->pfnFillCallbackRC = pfnFillCallback; 1553 1554 pRange->pDevInsRC = MMHyperCCToRC(pVM, pDevIns); 1554 iomUnlock(pVM);1555 IOM_UNLOCK(pVM); 1555 1556 1556 1557 return VINF_SUCCESS; … … 1597 1598 * Find the MMIO range and check that the input matches. 1598 1599 */ 1599 iomLock(pVM);1600 IOM_LOCK(pVM); 1600 1601 PIOMMMIORANGE pRange = iomMmioGetRange(pVM, GCPhysStart); 1601 AssertReturnStmt(pRange, iomUnlock(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND);1602 AssertReturnStmt(pRange->pDevInsR3 == pDevIns, iomUnlock(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER);1603 AssertReturnStmt(pRange->GCPhys == GCPhysStart, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE);1604 AssertReturnStmt(pRange->cb == cbRange, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE);1602 AssertReturnStmt(pRange, IOM_UNLOCK(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND); 1603 AssertReturnStmt(pRange->pDevInsR3 == pDevIns, IOM_UNLOCK(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER); 1604 AssertReturnStmt(pRange->GCPhys == GCPhysStart, IOM_UNLOCK(pVM), VERR_IOM_INVALID_MMIO_RANGE); 1605 AssertReturnStmt(pRange->cb == cbRange, IOM_UNLOCK(pVM), VERR_IOM_INVALID_MMIO_RANGE); 1605 1606 1606 1607 pRange->pvUserR0 = pvUser; … … 1609 1610 pRange->pfnFillCallbackR0 = pfnFillCallback; 1610 1611 pRange->pDevInsR0 = MMHyperCCToR0(pVM, pDevIns); 1611 iomUnlock(pVM);1612 IOM_UNLOCK(pVM); 1612 1613 1613 1614 return VINF_SUCCESS; … … 1644 1645 } 1645 1646 1646 iomLock(pVM);1647 IOM_LOCK(pVM); 1647 1648 1648 1649 /* … … 1655 1656 if (!pRange) 1656 1657 { 1657 iomUnlock(pVM);1658 IOM_UNLOCK(pVM); 1658 1659 return VERR_IOM_MMIO_RANGE_NOT_FOUND; 1659 1660 } 1660 1661 AssertMsgReturnStmt(pRange->pDevInsR3 == pDevIns, 1661 1662 ("Not owner! GCPhys=%RGp %RGp LB%#x %s\n", GCPhys, GCPhysStart, cbRange, pRange->pszDesc), 1662 iomUnlock(pVM),1663 IOM_UNLOCK(pVM), 1663 1664 VERR_IOM_NOT_MMIO_RANGE_OWNER); 1664 1665 AssertMsgReturnStmt(pRange->Core.KeyLast <= GCPhysLast, 1665 1666 ("Incomplete R3 range! GCPhys=%RGp %RGp LB%#x %s\n", GCPhys, GCPhysStart, cbRange, pRange->pszDesc), 1666 iomUnlock(pVM),1667 IOM_UNLOCK(pVM), 1667 1668 VERR_IOM_INCOMPLETE_MMIO_RANGE); 1668 1669 … … 1683 1684 Assert(pRange); 1684 1685 Assert(pRange->Core.Key == GCPhys && pRange->Core.KeyLast <= GCPhysLast); 1685 iomUnlock(pVM); /** @todo r=bird: Why are we leving the lock here? We don't leave it when registering the range above... */1686 IOM_UNLOCK(pVM); /** @todo r=bird: Why are we leaving the lock here? We don't leave it when registering the range above... */ 1686 1687 1687 1688 /* remove it from PGM */ … … 1689 1690 AssertRC(rc); 1690 1691 1691 iomLock(pVM);1692 IOM_LOCK(pVM); 1692 1693 1693 1694 /* advance and free. */ … … 1701 1702 } 1702 1703 1703 iomUnlock(pVM);1704 IOM_UNLOCK(pVM); 1704 1705 return VINF_SUCCESS; 1705 1706 } -
trunk/src/VBox/VMM/include/IOMInline.h
r37452 r37467 35 35 DECLINLINE(CTX_SUFF(PIOMIOPORTRANGE)) iomIOPortGetRange(PVM pVM, RTIOPORT Port) 36 36 { 37 Assert(PDMCritSectIsOwner(&pVM->iom.s. EmtLock) || !PDMCritSectIsInitialized(&pVM->iom.s.EmtLock));37 Assert(PDMCritSectIsOwner(&pVM->iom.s.CritSect)); 38 38 return (CTX_SUFF(PIOMIOPORTRANGE))RTAvlroIOPortRangeGet(&pVM->iom.s.CTX_SUFF(pTrees)->CTX_SUFF(IOPortTree), Port); 39 39 } … … 51 51 DECLINLINE(PIOMIOPORTRANGER3) iomIOPortGetRangeR3(PVM pVM, RTIOPORT Port) 52 52 { 53 Assert(PDMCritSectIsOwner(&pVM->iom.s. EmtLock) || !PDMCritSectIsInitialized(&pVM->iom.s.EmtLock));53 Assert(PDMCritSectIsOwner(&pVM->iom.s.CritSect)); 54 54 return (PIOMIOPORTRANGER3)RTAvlroIOPortRangeGet(&pVM->iom.s.CTX_SUFF(pTrees)->IOPortTreeR3, Port); 55 55 } … … 67 67 DECLINLINE(PIOMMMIORANGE) iomMmioGetRange(PVM pVM, RTGCPHYS GCPhys) 68 68 { 69 Assert(PDMCritSectIsOwner(&pVM->iom.s. EmtLock));69 Assert(PDMCritSectIsOwner(&pVM->iom.s.CritSect)); 70 70 PIOMMMIORANGE pRange = pVM->iom.s.CTX_SUFF(pMMIORangeLast); 71 71 if ( !pRange … … 101 101 DECLINLINE(PIOMMMIORANGE) iomMmioGetRangeWithRef(PVM pVM, RTGCPHYS GCPhys) 102 102 { 103 int rc = PDMCritSectEnter(&pVM->iom.s. EmtLock, VINF_SUCCESS);103 int rc = PDMCritSectEnter(&pVM->iom.s.CritSect, VINF_SUCCESS); 104 104 AssertRCReturn(rc, NULL); 105 105 … … 112 112 iomMmioRetainRange(pRange); 113 113 114 PDMCritSectLeave(&pVM->iom.s. EmtLock);114 PDMCritSectLeave(&pVM->iom.s.CritSect); 115 115 return pRange; 116 116 } … … 169 169 DECLINLINE(PIOMMMIOSTATS) iomMmioGetStats(PVM pVM, RTGCPHYS GCPhys, PIOMMMIORANGE pRange) 170 170 { 171 PDMCritSectEnter(&pVM->iom.s. EmtLock, VINF_SUCCESS);171 PDMCritSectEnter(&pVM->iom.s.CritSect, VINF_SUCCESS); 172 172 173 173 /* For large ranges, we'll put everything on the first byte. */ … … 186 186 } 187 187 188 PDMCritSectLeave(&pVM->iom.s. EmtLock);188 PDMCritSectLeave(&pVM->iom.s.CritSect); 189 189 return pStats; 190 190 } -
trunk/src/VBox/VMM/include/IOMInternal.h
r37452 r37467 323 323 324 324 /** Lock serializing EMT access to IOM. */ 325 PDMCRITSECT EmtLock;325 PDMCRITSECT CritSect; 326 326 327 327 /** @name Caching of I/O Port and MMIO ranges and statistics. … … 433 433 434 434 /* IOM locking helpers. */ 435 int iomLock(PVM pVM); 436 int iomTryLock(PVM pVM); 437 void iomUnlock(PVM pVM); 435 #define IOM_LOCK(a_pVM) PDMCritSectEnter(&(a_pVM)->iom.s.CritSect, VERR_SEM_BUSY) 436 #define IOM_UNLOCK(a_pVM) do { PDMCritSectLeave(&(a_pVM)->iom.s.CritSect); } while (0) 437 438 438 439 439 /* Disassembly helpers used in IOMAll.cpp & IOMAllMMIO.cpp */ -
trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp
r37354 r37467 378 378 #endif 379 379 380 CHECK_MEMBER_ALIGNMENT(IOM, EmtLock, sizeof(uintptr_t));380 CHECK_MEMBER_ALIGNMENT(IOM, CritSect, sizeof(uintptr_t)); 381 381 CHECK_MEMBER_ALIGNMENT(EM, CritSectREM, sizeof(uintptr_t)); 382 382 CHECK_MEMBER_ALIGNMENT(PGM, CritSect, sizeof(uintptr_t));
Note:
See TracChangeset
for help on using the changeset viewer.