Changeset 81106 in vbox
- Timestamp:
- Oct 3, 2019 9:23:00 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/sup.h
r81096 r81106 504 504 505 505 /** Table indexed by the CPU APIC ID to get the CPU table index. */ 506 uint16_t aiCpuFromApicId[ 1024];506 uint16_t aiCpuFromApicId[4096]; 507 507 /** CPU set index to CPU table index. */ 508 508 uint16_t aiCpuFromCpuSetIdx[1024]; 509 509 /** Table indexed by CPU group to containing offsets to SUPGIPCPUGROUP 510 * structures, invalid entries are set to UINT 16_MAX. The offsets are relative510 * structures, invalid entries are set to UINT32_MAX. The offsets are relative 511 511 * to the start of this structure. 512 * @note Windows only. The other hosts sets all entries to UINT 16_MAX! */513 uint 16_t aoffCpuGroup[SUPGIP_MAX_CPU_GROUPS];512 * @note Windows only. The other hosts sets all entries to UINT32_MAX! */ 513 uint32_t aoffCpuGroup[SUPGIP_MAX_CPU_GROUPS]; 514 514 515 515 /** Array of per-cpu data. … … 542 542 * Upper 16 bits is the major version. Major version is only changed with 543 543 * incompatible changes in the GIP. */ 544 #define SUPGLOBALINFOPAGE_VERSION 0x000 90000544 #define SUPGLOBALINFOPAGE_VERSION 0x000a0000 545 545 546 546 /** -
trunk/include/VBox/sup.mac
r81096 r81106 88 88 .PossibleCpuSet resq 16 89 89 .au32Padding1 resd 48 90 .aiCpuFromApicId resw 102490 .aiCpuFromApicId resw 4096 91 91 .aiCpuFromCpuSetIdx resw 1024 92 .aoffCpuGroup res w25692 .aoffCpuGroup resd 256 93 93 .aCPUs resb SUPGIPCPU_size 94 94 endstruc -
trunk/src/VBox/HostDrivers/Support/SUPDrvGip.cpp
r81096 r81106 189 189 190 190 191 /** 192 * Gets the APIC ID using the best available method, slow version. 193 */ 194 static uint32_t supdrvGipGetApicIdSlow(void) 195 { 196 uint32_t const idApic = ASMGetApicId(); 197 198 /* The Intel CPU topology leaf: */ 199 uint32_t uOther = ASMCpuId_EAX(0); 200 if (uOther >= UINT32_C(0xb) && ASMIsValidStdRange(uOther)) 201 { 202 uOther = ASMGetApicIdExt0B(); 203 if ((uOther & 0xff) == idApic) 204 return uOther; 205 AssertMsgFailed(("ASMGetApicIdExt0B=>%#x idApic=%#x\n", uOther, idApic)); 206 } 207 208 /* The AMD leaf: */ 209 uOther = ASMCpuId_EAX(UINT32_C(0x80000000)); 210 if (uOther >= UINT32_C(0x8000001e) && ASMIsValidExtRange(uOther)) 211 { 212 uOther = ASMGetApicIdExt8000001E(); 213 if ((uOther & 0xff) == idApic) 214 return uOther; 215 AssertMsgFailed(("ASMGetApicIdExt8000001E=>%#x idApic=%#x\n", uOther, idApic)); 216 } 217 return idApic; 218 } 219 220 191 221 /* 192 222 * … … 235 265 if (RT_LIKELY(iCpu < pGip->cCpus && pGip->aCPUs[iCpu].idCpu == idCpu)) 236 266 supdrvGipReInitCpu(&pGip->aCPUs[iCpu], *(uint64_t *)pvUser2); 237 } 267 else 268 LogRelMax(64, ("supdrvGipReInitCpuCallback: iCpu=%#x out of bounds (%#zx, idApic=%#x)\n", 269 iCpu, RT_ELEMENTS(pGip->aiCpuFromApicId), idApic)); 270 } 271 else 272 LogRelMax(64, ("supdrvGipReInitCpuCallback: idApic=%#x out of bounds (%#zx)\n", 273 idApic, RT_ELEMENTS(pGip->aiCpuFromApicId))); 238 274 239 275 NOREF(pvUser2); … … 248 284 /** Bitmap of APIC IDs that has been seen (initialized to zero). 249 285 * Used to detect duplicate APIC IDs (paranoia). */ 250 uint8_t volatile bmApicId[ 1024/ 8];286 uint8_t volatile bmApicId[4096 / 8]; 251 287 /** Mask of supported GIP CPU getter methods (SUPGIPGETCPU_XXX) (all bits set 252 288 * initially). The callback clears the methods not detected. */ … … 611 647 if (RT_SUCCESS(rc)) 612 648 { 613 SUPDRVGIPDETECTGETCPU DetectState; 614 RT_BZERO((void *)&DetectState.bmApicId, sizeof(DetectState.bmApicId)); 615 DetectState.fSupported = UINT32_MAX; 616 DetectState.idCpuProblem = NIL_RTCPUID; 617 rc = RTMpOnAll(supdrvGipDetectGetGipCpuCallback, &DetectState, pGipR0); 618 if (DetectState.idCpuProblem == NIL_RTCPUID) 649 PSUPDRVGIPDETECTGETCPU pDetectState = (PSUPDRVGIPDETECTGETCPU)RTMemTmpAllocZ(sizeof(*pDetectState)); 650 if (pDetectState) 619 651 { 620 if ( DetectState.fSupported != UINT32_MAX 621 && DetectState.fSupported != 0) 652 pDetectState->fSupported = UINT32_MAX; 653 pDetectState->idCpuProblem = NIL_RTCPUID; 654 rc = RTMpOnAll(supdrvGipDetectGetGipCpuCallback, pDetectState, pGipR0); 655 if (pDetectState->idCpuProblem == NIL_RTCPUID) 622 656 { 623 if (pGipR0->fGetGipCpu != DetectState.fSupported) 657 if ( pDetectState->fSupported != UINT32_MAX 658 && pDetectState->fSupported != 0) 624 659 { 625 pGipR0->fGetGipCpu = DetectState.fSupported; 626 LogRel(("SUPR0GipMap: fGetGipCpu=%#x\n", DetectState.fSupported)); 660 if (pGipR0->fGetGipCpu != pDetectState->fSupported) 661 { 662 pGipR0->fGetGipCpu = pDetectState->fSupported; 663 LogRel(("SUPR0GipMap: fGetGipCpu=%#x\n", pDetectState->fSupported)); 664 } 665 } 666 else 667 { 668 LogRel(("SUPR0GipMap: No supported ways of getting the APIC ID or CPU number in ring-3! (%#x)\n", 669 pDetectState->fSupported)); 670 rc = VERR_UNSUPPORTED_CPU; 627 671 } 628 672 } 629 673 else 630 674 { 631 LogRel(("SUPR0GipMap: No supported ways of getting the APIC ID or CPU number in ring-3! (%#x)\n",632 DetectState.fSupported));633 rc = VERR_ UNSUPPORTED_CPU;675 LogRel(("SUPR0GipMap: APIC ID, CPU ID or CPU set index problem detected on CPU #%u (%#x)!\n", 676 pDetectState->idCpuProblem, pDetectState->idCpuProblem)); 677 rc = VERR_INVALID_CPU_ID; 634 678 } 679 RTMemTmpFree(pDetectState); 635 680 } 636 681 else 637 { 638 LogRel(("SUPR0GipMap: APIC ID, CPU ID or CPU set index problem detected on CPU #%u (%#x)!\n", 639 DetectState.idCpuProblem, DetectState.idCpuProblem)); 640 rc = VERR_INVALID_CPU_ID; 641 } 682 rc = VERR_NO_TMP_MEMORY; 642 683 } 643 684 … … 1392 1433 supdrvGipInitCpu(pGip, &pGip->aCPUs[i], u64NanoTS, pGip->u64CpuHz); 1393 1434 1394 idApic = supdrvGipGetApicId (pGip);1435 idApic = supdrvGipGetApicIdSlow(); 1395 1436 ASMAtomicWriteU16(&pGip->aCPUs[i].idApic, idApic); 1396 1437 ASMAtomicWriteS16(&pGip->aCPUs[i].iCpuSet, (int16_t)iCpuSet); … … 1408 1449 if (idApic < RT_ELEMENTS(pGip->aiCpuFromApicId)) 1409 1450 ASMAtomicWriteU16(&pGip->aiCpuFromApicId[idApic], i); 1451 else 1452 LogRelMax(64, ("supdrvGipMpEventOnlineOrInitOnCpu: idApic=%#x is out of bounds (%#zx, i=%u, iCpuSet=%d)\n", 1453 idApic, RT_ELEMENTS(pGip->aiCpuFromApicId), i, iCpuSet)); 1410 1454 if ((unsigned)iCpuSet < RT_ELEMENTS(pGip->aiCpuFromCpuSetIdx)) 1411 1455 ASMAtomicWriteU16(&pGip->aiCpuFromCpuSetIdx[iCpuSet], i); 1456 else 1457 LogRelMax(64, ("supdrvGipMpEventOnlineOrInitOnCpu: iCpuSet=%d is out of bounds (%#zx, i=%u, idApic=%d)\n", 1458 iCpuSet, RT_ELEMENTS(pGip->aiCpuFromApicId), i, idApic)); 1412 1459 1413 1460 /* Add this CPU to this set of CPUs we need to calculate the TSC-delta for. */ … … 1881 1928 pGip->aiCpuFromCpuSetIdx[i] = UINT16_MAX; 1882 1929 for (i = 0; i < RT_ELEMENTS(pGip->aoffCpuGroup); i++) 1883 pGip->aoffCpuGroup[i] = UINT16_MAX;1930 pGip->aoffCpuGroup[i] = UINT32_MAX; 1884 1931 for (i = 0; i < cCpus; i++) 1885 1932 supdrvGipInitCpu(pGip, &pGip->aCPUs[i], u64NanoTS, 0 /*uCpuHz*/); … … 2024 2071 RTCpuSetEmpty(&pDevExt->TscDeltaCpuSet); 2025 2072 RTCpuSetEmpty(&pDevExt->TscDeltaObtainedCpuSet); 2026 2073 #ifdef SUPDRV_USE_TSC_DELTA_THREAD 2027 2074 if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED) 2028 2075 rc = supdrvTscDeltaThreadInit(pDevExt); 2029 2076 #endif 2030 2077 if (RT_SUCCESS(rc)) 2031 2078 { … … 2040 2087 if (RT_SUCCESS(rc)) 2041 2088 { 2042 2089 #ifdef SUPDRV_USE_TSC_DELTA_THREAD 2043 2090 supdrvTscDeltaThreadStartMeasurement(pDevExt, true /* fForceAll */); 2044 2091 #else 2045 2092 uint16_t iCpu; 2046 2093 if (pGip->enmUseTscDelta > SUPGIPUSETSCDELTA_ZERO_CLAIMED) … … 2066 2113 } 2067 2114 if (RT_SUCCESS(rc)) 2068 2115 #endif 2069 2116 { 2070 2117 /* … … 4894 4941 /* This really shouldn't happen. */ 4895 4942 AssertMsgFailed(("idCpu=%#x iCpuSet=%#x (%d)\n", RTMpCpuId(), iCpuSet, iCpuSet)); 4896 pReq->u.Out.idApic = supdrvGipGetApicId (pGip);4943 pReq->u.Out.idApic = supdrvGipGetApicIdSlow(); 4897 4944 pReq->u.Out.u64AdjustedTsc = ASMReadTSC(); 4898 4945 ASMSetFlags(fEFlags); … … 4914 4961 pReq->u.Out.idApic = pGip->aCPUs[iGipCpu].idApic; 4915 4962 else 4916 pReq->u.Out.idApic = supdrvGipGetApicId (pGip);4963 pReq->u.Out.idApic = supdrvGipGetApicIdSlow(); 4917 4964 pReq->u.Out.u64AdjustedTsc = ASMReadTSC(); 4918 4965 ASMSetFlags(fEFlags); -
trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h
r81096 r81106 223 223 * - Move SUP_IOCTL_FAST_DO_NOP and SUP_VMMR0_DO_NEM_RUN after NEM. 224 224 */ 225 #define SUPDRV_IOC_VERSION 0x002 c0000225 #define SUPDRV_IOC_VERSION 0x002d0000 226 226 227 227 /** SUP_IOCTL_COOKIE. */ -
trunk/src/VBox/HostDrivers/Support/testcase/tstGIP-2.cpp
r81096 r81106 155 155 { 156 156 SUPGIPCPU const *pGipCpu = &g_pSUPGlobalInfoPage->aCPUs[iCpu]; 157 RTPrintf("tstGIP-2: aCPU[% u]: enmState=%d iCpuSet=%u idCpu=%#010x iCpuGroup=%u iCpuGroupMember=%u idApic=%#x\n",157 RTPrintf("tstGIP-2: aCPU[%3u]: enmState=%d iCpuSet=%-3u idCpu=%#010x iCpuGroup=%-2u iCpuGroupMember=%-3u idApic=%#06x\n", 158 158 iCpu, pGipCpu->enmState, pGipCpu->iCpuSet, pGipCpu->idCpu, pGipCpu->iCpuGroup, 159 159 pGipCpu->iCpuGroupMember, pGipCpu->idApic); … … 164 164 : "tstGIP-2: it: u64NanoTS delta u64TSC UpIntTSC H TransId CpuHz %sTSC Interval History...\n", 165 165 uCpuHzRef ? " CpuHz deviation Compat " : ""); 166 static SUPGIPCPU s_aaCPUs[2][ 256];166 static SUPGIPCPU s_aaCPUs[2][RTCPUSET_MAX_CPUS]; 167 167 for (uint32_t i = 0; i < cIterations; i++) 168 168 { … … 274 274 RTPrintf("tstGIP-2: TSC deltas:\n"); 275 275 RTPrintf("tstGIP-2: idApic: i64TSCDelta\n"); 276 for (u nsignedi = 0; i < RT_ELEMENTS(g_pSUPGlobalInfoPage->aiCpuFromApicId); i++)276 for (uint32_t i = 0; i < RT_ELEMENTS(g_pSUPGlobalInfoPage->aiCpuFromApicId); i++) 277 277 { 278 278 uint16_t iCpu = g_pSUPGlobalInfoPage->aiCpuFromApicId[i]; 279 279 if (iCpu != UINT16_MAX) 280 {281 RTPrintf("tstGIP-2: %7d: %lld\n", g_pSUPGlobalInfoPage->aCPUs[iCpu].idApic,282 g_pSUPGlobalInfoPage->aCPUs[iCpu].i 64TSCDelta);283 }280 RTPrintf("tstGIP-2: %#7x: %6lld (grp=%#04x mbr=%#05x set=%d cpu=%#05x)\n", 281 g_pSUPGlobalInfoPage->aCPUs[iCpu].idApic, g_pSUPGlobalInfoPage->aCPUs[iCpu].i64TSCDelta, 282 g_pSUPGlobalInfoPage->aCPUs[iCpu].iCpuGroup, g_pSUPGlobalInfoPage->aCPUs[iCpu].iCpuGroupMember, 283 g_pSUPGlobalInfoPage->aCPUs[iCpu].iCpuSet, iCpu); 284 284 } 285 285 286 for (u nsignediCpu = 0; iCpu < g_pSUPGlobalInfoPage->cCpus; iCpu++)286 for (uint32_t iCpu = 0; iCpu < g_pSUPGlobalInfoPage->cCpus; iCpu++) 287 287 if (g_pSUPGlobalInfoPage->aCPUs[iCpu].idApic == UINT16_MAX) 288 RTPrintf("tstGIP-2: offline: %lld\n", g_pSUPGlobalInfoPage->aCPUs[iCpu].i64TSCDelta); 288 RTPrintf("tstGIP-2: offline: %6lld (grp=%#04x mbr=%#05x set=%d cpu=%#05x)\n", 289 g_pSUPGlobalInfoPage->aCPUs[iCpu].i64TSCDelta, g_pSUPGlobalInfoPage->aCPUs[iCpu].iCpuGroup, 290 g_pSUPGlobalInfoPage->aCPUs[iCpu].iCpuGroupMember, g_pSUPGlobalInfoPage->aCPUs[iCpu].iCpuSet, iCpu); 289 291 290 292 RTPrintf("tstGIP-2: enmUseTscDelta=%d fGetGipCpu=%#x\n", -
trunk/src/VBox/HostDrivers/Support/win/SUPDrv-win.cpp
r77816 r81106 1762 1762 for (uint32_t idxGroup = 0; idxGroup < cGroups; idxGroup++) 1763 1763 { 1764 uint32_t cActive = 0; 1765 uint32_t cMax = RTMpGetCpuGroupCounts(idxGroup, &cActive); 1766 uint32_t cbNeeded = RT_UOFFSETOF_DYN(SUPGIPCPUGROUP, aiCpuSetIdxs[cMax]); 1764 uint32_t cActive = 0; 1765 uint32_t const cMax = RTMpGetCpuGroupCounts(idxGroup, &cActive); 1766 uint32_t const cbNeeded = RT_UOFFSETOF_DYN(SUPGIPCPUGROUP, aiCpuSetIdxs[cMax]); 1767 uintptr_t const offGroup = (uintptr_t)pGroup - (uintptr_t)pGip; 1767 1768 AssertReturn(cbNeeded <= cbGipCpuGroups, VERR_INTERNAL_ERROR_3); 1768 1769 AssertReturn(cActive <= cMax, VERR_INTERNAL_ERROR_4); 1769 1770 pGip->aoffCpuGroup[idxGroup] = (uint16_t)((uintptr_t)pGroup - (uintptr_t)pGip); 1770 AssertReturn(offGroup == (uint32_t)offGroup, VERR_INTERNAL_ERROR_5); 1771 1772 pGip->aoffCpuGroup[idxGroup] = offGroup; 1771 1773 pGroup->cMembers = cActive; 1772 1774 pGroup->cMaxMembers = cMax; … … 1813 1815 */ 1814 1816 for (uint32_t idxGroup = 0; idxGroup < pGip->cPossibleCpuGroups; idxGroup++) 1815 if (pGip->aoffCpuGroup[idxGroup] != UINT16_MAX) 1816 { 1817 PSUPGIPCPUGROUP pGroup = (PSUPGIPCPUGROUP)((uintptr_t)pGip + pGip->aoffCpuGroup[idxGroup]); 1818 1819 uint32_t cActive = 0; 1820 uint32_t cMax = RTMpGetCpuGroupCounts(idxGroup, &cActive); 1817 { 1818 uint32_t offGroup = pGip->aoffCpuGroup[idxGroup]; 1819 if (offGroup != UINT32_MAX) 1820 { 1821 PSUPGIPCPUGROUP pGroup = (PSUPGIPCPUGROUP)((uintptr_t)pGip + offGroup); 1822 uint32_t cActive = 0; 1823 uint32_t cMax = RTMpGetCpuGroupCounts(idxGroup, &cActive); 1824 1821 1825 AssertStmt(cMax == pGroup->cMaxMembers, cMax = pGroup->cMaxMembers); 1822 1826 AssertStmt(cActive <= cMax, cActive = cMax); 1823 1827 if (pGroup->cMembers != cActive) 1824 pGroup->cMembers = cActive;1828 ASMAtomicWriteU16(&pGroup->cMembers, cActive); 1825 1829 1826 1830 for (uint32_t idxMember = 0; idxMember < cMax; idxMember++) … … 1831 1835 1832 1836 if (pGroup->aiCpuSetIdxs[idxMember] != idxCpuSet) 1833 pGroup->aiCpuSetIdxs[idxMember] = idxCpuSet; 1834 } 1835 } 1837 ASMAtomicWriteS16(&pGroup->aiCpuSetIdxs[idxMember], idxCpuSet); 1838 } 1839 } 1840 } 1836 1841 } 1837 1842 -
trunk/src/VBox/Runtime/r3/win/mp-win.cpp
r81096 r81106 422 422 { 423 423 uint32_t idxMember; 424 u nsignedoffCpuGroup = pGip->aoffCpuGroup[idxGroup];424 uint32_t offCpuGroup = pGip->aoffCpuGroup[idxGroup]; 425 425 if (offCpuGroup < cbGip) 426 426 { … … 480 480 for (uint32_t idxGroup = 0; idxGroup < g_cRtMpWinMaxCpus; idxGroup++) 481 481 { 482 u nsignedoffCpuGroup = pGip->aoffCpuGroup[idxGroup];482 uint32_t offCpuGroup = pGip->aoffCpuGroup[idxGroup]; 483 483 if (offCpuGroup < cbGip) 484 484 {
Note:
See TracChangeset
for help on using the changeset viewer.