Changeset 64281 in vbox for trunk/src/VBox/HostDrivers/Support/win
- Timestamp:
- Oct 15, 2016 4:46:29 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
r64255 r64281 1711 1711 1712 1712 1713 void VBOXCALL supdrvOSInitGipGroupTable(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip)1713 size_t VBOXCALL supdrvOSGipGetGroupTableSize(PSUPDRVDEVEXT pDevExt) 1714 1714 { 1715 1715 NOREF(pDevExt); 1716 uint32_t cMaxCpus = RTMpGetCount(); 1717 uint32_t cGroups = RTMpGetMaxCpuGroupCount(); 1718 1719 return cGroups * RT_OFFSETOF(SUPGIPCPUGROUP, aiCpuSetIdxs) 1720 + RT_SIZEOFMEMB(SUPGIPCPUGROUP, aiCpuSetIdxs[0]) * cMaxCpus; 1721 } 1722 1723 1724 int VBOXCALL supdrvOSInitGipGroupTable(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, size_t cbGipCpuGroups) 1725 { 1726 Assert(cbGipCpuGroups > 0); NOREF(cbGipCpuGroups); NOREF(pDevExt); 1727 1728 unsigned const cGroups = RTMpGetMaxCpuGroupCount(); 1729 AssertReturn(cGroups > 0 && cGroups < RT_ELEMENTS(pGip->aoffCpuGroup), VERR_INTERNAL_ERROR_2); 1730 pGip->cPossibleCpuGroups = cGroups; 1731 1732 PSUPGIPCPUGROUP pGroup = (PSUPGIPCPUGROUP)&pGip->aCPUs[pGip->cCpus]; 1733 for (uint32_t idxGroup = 0; idxGroup < cGroups; idxGroup++) 1734 { 1735 uint32_t cActive = 0; 1736 uint32_t cMax = RTMpGetCpuGroupCounts(idxGroup, &cActive); 1737 uint32_t cbNeeded = RT_OFFSETOF(SUPGIPCPUGROUP, aiCpuSetIdxs[cMax]); 1738 AssertReturn(cbNeeded <= cbGipCpuGroups, VERR_INTERNAL_ERROR_3); 1739 AssertReturn(cActive <= cMax, VERR_INTERNAL_ERROR_4); 1740 1741 pGip->aoffCpuGroup[idxGroup] = (uint16_t)((uintptr_t)pGroup - (uintptr_t)pGip); 1742 pGroup->cMembers = cActive; 1743 pGroup->cMaxMembers = cMax; 1744 for (uint32_t idxMember = 0; idxMember < cMax; idxMember++) 1745 { 1746 pGroup->aiCpuSetIdxs[idxMember] = RTMpSetIndexFromCpuGroupMember(idxGroup, idxMember); 1747 Assert((unsigned)pGroup->aiCpuSetIdxs[idxMember] < pGip->cPossibleCpus); 1748 } 1749 1750 /* advance. */ 1751 cbGipCpuGroups -= cbNeeded; 1752 pGroup = (PSUPGIPCPUGROUP)&pGroup->aiCpuSetIdxs[cMax]; 1753 } 1754 1755 return VINF_SUCCESS; 1756 } 1757 1758 1759 void VBOXCALL supdrvOSGipInitGroupBitsForCpu(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, PSUPGIPCPU pGipCpu) 1760 { 1761 NOREF(pDevExt); 1716 1762 1717 1763 /* 1718 * T he indexes are assigned in group order (see initterm-r0drv-nt.cpp).1764 * Translate the CPU index into a group and member. 1719 1765 */ 1720 if ( g_pfnKeQueryMaximumGroupCount 1721 && g_pfnKeGetProcessorIndexFromNumber) 1722 { 1723 unsigned cGroups = g_pfnKeQueryMaximumGroupCount(); 1724 AssertStmt(cGroups > 0, cGroups = 1); 1725 AssertStmt(cGroups < RT_ELEMENTS(pGip->aiFirstCpuSetIdxFromCpuGroup), 1726 cGroups = RT_ELEMENTS(pGip->aiFirstCpuSetIdxFromCpuGroup)); 1727 pGip->cPossibleCpuGroups = cGroups; 1728 1729 KEPROCESSORINDEX idxCpuMin = 0; 1730 for (unsigned iGroup = 0; iGroup < cGroups; iGroup++) 1731 { 1732 PROCESSOR_NUMBER ProcNum; 1733 ProcNum.Group = (USHORT)iGroup; 1734 ProcNum.Number = 0; 1735 ProcNum.Reserved = 0; 1736 KEPROCESSORINDEX idxCpu = g_pfnKeGetProcessorIndexFromNumber(&ProcNum); 1737 Assert(idxCpu != INVALID_PROCESSOR_INDEX); 1738 Assert(idxCpu >= idxCpuMin); 1739 idxCpuMin = idxCpu; 1740 pGip->aiFirstCpuSetIdxFromCpuGroup[iGroup] = (uint16_t)idxCpu; 1741 } 1742 } 1743 else 1744 { 1745 Assert(!g_pfnKeQueryMaximumGroupCount); 1746 Assert(!g_pfnKeGetProcessorIndexFromNumber); 1747 1748 pGip->cPossibleCpuGroups = 1; 1749 pGip->aiFirstCpuSetIdxFromCpuGroup[0] = 0; 1750 } 1751 } 1752 1753 1754 uint16_t VBOXCALL supdrvOSGipGetGroupFromCpu(PSUPDRVDEVEXT pDevExt, RTCPUID idCpu, uint16_t *piCpuGroupMember) 1755 { 1756 NOREF(pDevExt); 1766 PROCESSOR_NUMBER ProcNum = { 0, pGipCpu->iCpuSet, 0 }; 1767 if (g_pfnKeGetProcessorNumberFromIndex) 1768 { 1769 NTSTATUS rcNt = g_pfnKeGetProcessorNumberFromIndex(pGipCpu->iCpuSet, &ProcNum); 1770 if (NT_SUCCESS(rcNt)) 1771 Assert(ProcNum.Group < g_pfnKeQueryMaximumGroupCount()); 1772 else 1773 { 1774 AssertFailed(); 1775 ProcNum.Group = 0; 1776 ProcNum.Number = pGipCpu->iCpuSet; 1777 } 1778 } 1779 pGipCpu->iCpuGroup = ProcNum.Group; 1780 pGipCpu->iCpuGroupMember = ProcNum.Number; 1757 1781 1758 1782 /* 1759 * This is just a wrapper around KeGetProcessorNumberFromIndex.1783 * Update the group info. Just do this wholesale for now (doesn't scale well). 1760 1784 */ 1761 if (g_pfnKeGetProcessorNumberFromIndex) 1762 { 1763 PROCESSOR_NUMBER ProcNum = { UINT16_MAX, UINT8_MAX, 0 }; 1764 NTSTATUS rcNt = g_pfnKeGetProcessorNumberFromIndex(idCpu, &ProcNum); 1765 if (NT_SUCCESS(rcNt)) 1766 { 1767 Assert(ProcNum.Group < g_pfnKeQueryMaximumGroupCount()); 1768 *piCpuGroupMember = ProcNum.Number; 1769 return ProcNum.Group; 1770 } 1771 1772 AssertMsgFailed(("rcNt=%#x for idCpu=%u\n", rcNt, idCpu)); 1773 } 1774 1775 *piCpuGroupMember = 0; 1776 return idCpu; 1785 for (uint32_t idxGroup = 0; idxGroup < pGip->cPossibleCpuGroups; idxGroup++) 1786 if (pGip->aoffCpuGroup[idxGroup] != UINT16_MAX) 1787 { 1788 PSUPGIPCPUGROUP pGroup = (PSUPGIPCPUGROUP)((uintptr_t)pGip + pGip->aoffCpuGroup[idxGroup]); 1789 1790 uint32_t cActive = 0; 1791 uint32_t cMax = RTMpGetCpuGroupCounts(idxGroup, &cActive); 1792 AssertStmt(cMax == pGroup->cMaxMembers, cMax = pGroup->cMaxMembers); 1793 AssertStmt(cActive <= cMax, cActive = cMax); 1794 if (pGroup->cMembers != cActive) 1795 pGroup->cMembers = cActive; 1796 1797 for (uint32_t idxMember = 0; idxMember < cMax; idxMember++) 1798 { 1799 int idxCpuSet = RTMpSetIndexFromCpuGroupMember(idxGroup, idxMember); 1800 AssertMsg((unsigned)idxCpuSet < pGip->cPossibleCpus, 1801 ("%d vs %d for %u.%u\n", idxCpuSet, pGip->cPossibleCpus, idxGroup, idxMember)); 1802 1803 if (pGroup->aiCpuSetIdxs[idxMember] != idxCpuSet) 1804 pGroup->aiCpuSetIdxs[idxMember] = idxCpuSet; 1805 } 1806 } 1777 1807 } 1778 1808
Note:
See TracChangeset
for help on using the changeset viewer.