Changeset 20700 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Jun 19, 2009 8:31:03 AM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/IOM.cpp
r20687 r20700 228 228 static void iomR3FlushCache(PVM pVM) 229 229 { 230 iomLock(pVM); 230 231 /* 231 232 * Caching of port and statistics (saves some time in rep outs/ins instruction emulation) … … 251 252 pVM->iom.s.pMMIORangeLastRC = NIL_RTRCPTR; 252 253 pVM->iom.s.pMMIOStatsLastRC = NIL_RTRCPTR; 254 255 iomUnlock(pVM); 253 256 } 254 257 … … 395 398 PIOMIOPORTSTATS iomR3IOPortStatsCreate(PVM pVM, RTIOPORT Port, const char *pszDesc) 396 399 { 400 Assert(IOMIsLockOwner(pVM)); 397 401 /* check if it already exists. */ 398 402 PIOMIOPORTSTATS pPort = (PIOMIOPORTSTATS)RTAvloIOPortGet(&pVM->iom.s.pTreesR3->IOPortStatTree, Port); … … 447 451 PIOMMMIOSTATS iomR3MMIOStatsCreate(PVM pVM, RTGCPHYS GCPhys, const char *pszDesc) 448 452 { 453 Assert(IOMIsLockOwner(pVM)); 449 454 #ifdef DEBUG_sandervl 450 455 AssertGCPhys32(GCPhys); … … 564 569 * Try Insert it. 565 570 */ 571 iomLock(pVM); 566 572 if (RTAvlroIOPortInsert(&pVM->iom.s.pTreesR3->IOPortTreeR3, &pRange->Core)) 567 573 { … … 570 576 iomR3IOPortStatsCreate(pVM, PortStart + iPort, pszDesc); 571 577 #endif 578 iomUnlock(pVM); 572 579 return VINF_SUCCESS; 573 580 } 581 iomUnlock(pVM); 574 582 575 583 /* conflict. */ … … 627 635 } 628 636 637 iomLock(pVM); 638 629 639 /* 630 640 * Validate that there are ring-3 ranges for the ports. … … 637 647 { 638 648 AssertMsgFailed(("No R3! Port=#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc)); 649 iomUnlock(pVM); 639 650 return VERR_IOM_NO_HC_IOPORT_RANGE; 640 651 } … … 647 658 { 648 659 AssertMsgFailed(("Not owner! Port=%#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc)); 660 iomUnlock(pVM); 649 661 return VERR_IOM_NOT_IOPORT_RANGE_OWNER; 650 662 } … … 679 691 */ 680 692 if (RTAvlroIOPortInsert(&pVM->iom.s.CTX_SUFF(pTrees)->IOPortTreeRC, &pRange->Core)) 693 { 694 iomUnlock(pVM); 681 695 return VINF_SUCCESS; 696 } 682 697 683 698 /* conflict. */ … … 686 701 rc = VERR_IOM_IOPORT_RANGE_CONFLICT; 687 702 } 688 703 iomUnlock(pVM); 689 704 return rc; 690 705 } … … 735 750 } 736 751 752 iomLock(pVM); 737 753 /* 738 754 * Validate that there are ring-3 ranges for the ports. … … 745 761 { 746 762 AssertMsgFailed(("No R3! Port=#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc)); 763 iomUnlock(pVM); 747 764 return VERR_IOM_NO_HC_IOPORT_RANGE; 748 765 } … … 755 772 { 756 773 AssertMsgFailed(("Not owner! Port=%#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc)); 774 iomUnlock(pVM); 757 775 return VERR_IOM_NOT_IOPORT_RANGE_OWNER; 758 776 } … … 787 805 */ 788 806 if (RTAvlroIOPortInsert(&pVM->iom.s.CTX_SUFF(pTrees)->IOPortTreeR0, &pRange->Core)) 807 { 808 iomUnlock(pVM); 789 809 return VINF_SUCCESS; 810 } 790 811 791 812 /* conflict. */ … … 794 815 rc = VERR_IOM_IOPORT_RANGE_CONFLICT; 795 816 } 796 817 iomUnlock(pVM); 797 818 return rc; 798 819 } … … 831 852 return VERR_IOM_INVALID_IOPORT_RANGE; 832 853 } 854 855 iomLock(pVM); 833 856 834 857 /* Flush the IO port lookup cache */ … … 851 874 AssertMsgFailed(("Removal of ports in range %#x-%#x rejected because not owner of %#x-%#x (%s)\n", 852 875 PortStart, PortLast, pRange->Core.Key, pRange->Core.KeyLast, pRange->pszDesc)); 876 iomUnlock(pVM); 853 877 return VERR_IOM_NOT_IOPORT_RANGE_OWNER; 854 878 } … … 909 933 */ 910 934 Assert(pRange->Core.KeyLast > PortLast && pRange->Core.Key < Port); 911 /* create tail. */ 912 PIOMIOPORTRANGERC pRangeNew; 913 int rc = MMHyperAlloc(pVM, sizeof(*pRangeNew), 0, MM_TAG_IOM, (void **)&pRangeNew); 914 if (RT_FAILURE(rc)) 915 return rc; 916 917 *pRangeNew = *pRange; 918 pRangeNew->Core.Key = PortLast; 919 pRangeNew->Port = PortLast; 920 pRangeNew->cPorts = pRangeNew->Core.KeyLast - PortLast + 1; 921 922 /* adjust head */ 923 pRange->Core.KeyLast = Port - 1; 924 pRange->cPorts = Port - pRange->Port; 925 926 /* insert */ 927 if (!RTAvlroIOPortInsert(&pVM->iom.s.pTreesR3->IOPortTreeRC, &pRangeNew->Core)) 928 { 929 AssertMsgFailed(("This cannot happen!\n")); 930 MMHyperFree(pVM, pRangeNew); 931 rc = VERR_INTERNAL_ERROR; 932 } 933 break; 935 /* create tail. */ 936 PIOMIOPORTRANGERC pRangeNew; 937 int rc = MMHyperAlloc(pVM, sizeof(*pRangeNew), 0, MM_TAG_IOM, (void **)&pRangeNew); 938 if (RT_FAILURE(rc)) 939 { 940 iomUnlock(pVM); 941 return rc; 942 } 943 *pRangeNew = *pRange; 944 pRangeNew->Core.Key = PortLast; 945 pRangeNew->Port = PortLast; 946 pRangeNew->cPorts = pRangeNew->Core.KeyLast - PortLast + 1; 947 948 /* adjust head */ 949 pRange->Core.KeyLast = Port - 1; 950 pRange->cPorts = Port - pRange->Port; 951 952 /* insert */ 953 if (!RTAvlroIOPortInsert(&pVM->iom.s.pTreesR3->IOPortTreeRC, &pRangeNew->Core)) 954 { 955 AssertMsgFailed(("This cannot happen!\n")); 956 MMHyperFree(pVM, pRangeNew); 957 rc = VERR_INTERNAL_ERROR; 958 } 959 break; 934 960 } 935 961 } … … 989 1015 */ 990 1016 Assert(pRange->Core.KeyLast > PortLast && pRange->Core.Key < Port); 991 /* create tail. */ 992 PIOMIOPORTRANGER0 pRangeNew; 993 int rc = MMHyperAlloc(pVM, sizeof(*pRangeNew), 0, MM_TAG_IOM, (void **)&pRangeNew); 994 if (RT_FAILURE(rc)) 995 return rc; 996 997 *pRangeNew = *pRange; 998 pRangeNew->Core.Key = PortLast; 999 pRangeNew->Port = PortLast; 1000 pRangeNew->cPorts = pRangeNew->Core.KeyLast - PortLast + 1; 1001 1002 /* adjust head */ 1003 pRange->Core.KeyLast = Port - 1; 1004 pRange->cPorts = Port - pRange->Port; 1005 1006 /* insert */ 1007 if (!RTAvlroIOPortInsert(&pVM->iom.s.pTreesR3->IOPortTreeR0, &pRangeNew->Core)) 1008 { 1009 AssertMsgFailed(("This cannot happen!\n")); 1010 MMHyperFree(pVM, pRangeNew); 1011 rc = VERR_INTERNAL_ERROR; 1012 } 1013 break; 1017 /* create tail. */ 1018 PIOMIOPORTRANGER0 pRangeNew; 1019 int rc = MMHyperAlloc(pVM, sizeof(*pRangeNew), 0, MM_TAG_IOM, (void **)&pRangeNew); 1020 if (RT_FAILURE(rc)) 1021 { 1022 iomUnlock(pVM); 1023 return rc; 1024 } 1025 *pRangeNew = *pRange; 1026 pRangeNew->Core.Key = PortLast; 1027 pRangeNew->Port = PortLast; 1028 pRangeNew->cPorts = pRangeNew->Core.KeyLast - PortLast + 1; 1029 1030 /* adjust head */ 1031 pRange->Core.KeyLast = Port - 1; 1032 pRange->cPorts = Port - pRange->Port; 1033 1034 /* insert */ 1035 if (!RTAvlroIOPortInsert(&pVM->iom.s.pTreesR3->IOPortTreeR0, &pRangeNew->Core)) 1036 { 1037 AssertMsgFailed(("This cannot happen!\n")); 1038 MMHyperFree(pVM, pRangeNew); 1039 rc = VERR_INTERNAL_ERROR; 1040 } 1041 break; 1014 1042 } 1015 1043 } … … 1071 1099 int rc = MMHyperAlloc(pVM, sizeof(*pRangeNew), 0, MM_TAG_IOM, (void **)&pRangeNew); 1072 1100 if (RT_FAILURE(rc)) 1101 { 1102 iomUnlock(pVM); 1073 1103 return rc; 1074 1104 } 1075 1105 *pRangeNew = *pRange; 1076 1106 pRangeNew->Core.Key = PortLast; … … 1097 1127 1098 1128 /* done */ 1129 iomUnlock(pVM); 1099 1130 return rc; 1100 1131 } … … 1446 1477 if (RT_SUCCESS(rc)) 1447 1478 { 1479 iomLock(pVM); 1448 1480 if (RTAvlroGCPhysInsert(&pVM->iom.s.pTreesR3->MMIOTree, &pRange->Core)) 1481 { 1482 iomUnlock(pVM); 1449 1483 return VINF_SUCCESS; 1484 } 1485 iomUnlock(pVM); 1450 1486 1451 1487 /* bail out */ … … 1598 1634 } 1599 1635 1636 iomLock(pVM); 1637 1600 1638 /* 1601 1639 * Check ownership and such for the entire area. … … 1606 1644 PIOMMMIORANGE pRange = iomMMIOGetRange(&pVM->iom.s, GCPhys); 1607 1645 if (!pRange) 1646 { 1647 iomUnlock(pVM); 1608 1648 return VERR_IOM_MMIO_RANGE_NOT_FOUND; 1649 } 1609 1650 AssertMsgReturn(pRange->pDevInsR3 == pDevIns, 1610 1651 ("Not owner! GCPhys=%RGp %RGp LB%#x %s\n", GCPhys, GCPhysStart, cbRange, pRange->pszDesc), … … 1618 1659 GCPhys = pRange->Core.KeyLast + 1; 1619 1660 } 1661 iomUnlock(pVM); 1620 1662 1621 1663 /* … … 1625 1667 while (GCPhys <= GCPhysLast && GCPhys >= GCPhysStart) 1626 1668 { 1669 iomLock(pVM); 1627 1670 PIOMMMIORANGE pRange = (PIOMMMIORANGE)RTAvlroGCPhysRemove(&pVM->iom.s.pTreesR3->MMIOTree, GCPhys); 1628 1671 Assert(pRange); 1629 1672 Assert(pRange->Core.Key == GCPhys && pRange->Core.KeyLast <= GCPhysLast); 1673 iomUnlock(pVM); 1630 1674 1631 1675 /* remove it from PGM */ -
trunk/src/VBox/VMM/IOMInternal.h
r20530 r20700 529 529 DECLINLINE(PIOMMMIOSTATS) iomMMIOGetStats(PIOM pIOM, RTGCPHYS GCPhys, PIOMMMIORANGE pRange) 530 530 { 531 Assert(IOMIsLockOwner(IOM2VM(pIOM))); 531 532 /* For large ranges, we'll put everything on the first byte. */ 532 533 if (pRange->cb > PAGE_SIZE)
Note:
See TracChangeset
for help on using the changeset viewer.