Changeset 57056 in vbox for trunk/src/VBox
- Timestamp:
- Jul 22, 2015 2:12:42 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp
r56985 r57056 524 524 * @param cLeaves The number of leaves in the array. 525 525 * @param uLeaf The leaf to locate. 526 * @param uSubLeaf The subleaf to locate. Pass 0 if no sub leaves.526 * @param uSubLeaf The subleaf to locate. Pass 0 if no sub-leaves. 527 527 */ 528 528 static PCPUMCPUIDLEAF cpumR3CpuIdGetLeaf(PCPUMCPUIDLEAF paLeaves, uint32_t cLeaves, uint32_t uLeaf, uint32_t uSubLeaf) … … 545 545 * @param cLeaves The number of leaves in the array. 546 546 * @param uLeaf The leaf to locate. 547 * @param uSubLeaf The subleaf to locate. Pass 0 if no sub leaves.547 * @param uSubLeaf The subleaf to locate. Pass 0 if no sub-leaves. 548 548 * @param pLegacy The legacy output leaf. 549 549 */ … … 715 715 * Inserts a CPU ID leaf, replacing any existing ones. 716 716 * 717 * When inserting a simple leaf where we already got a series of sub leaves with717 * When inserting a simple leaf where we already got a series of sub-leaves with 718 718 * the same leaf number (eax), the simple leaf will replace the whole series. 719 719 * … … 1038 1038 * @param pLeaf Where to store the found leaf. 1039 1039 * @param uLeaf The leaf to locate. 1040 * @param uSubLeaf The subleaf to locate. Pass 0 if no sub leaves.1040 * @param uSubLeaf The subleaf to locate. Pass 0 if no sub-leaves. 1041 1041 */ 1042 1042 VMMR3DECL(int) CPUMR3CpuIdGetLeaf(PVM pVM, PCPUMCPUIDLEAF pLeaf, uint32_t uLeaf, uint32_t uSubLeaf) … … 1174 1174 relevant details in the release log. */ 1175 1175 LogRel(("CPUM: VERR_CPUM_TOO_MANY_CPUID_SUBLEAVES! uLeaf=%#x cSubLeaves=%#x\n", uLeaf, cSubLeaves)); 1176 LogRel(("------------------ dump of problematic sub leaves ------------------\n"));1176 LogRel(("------------------ dump of problematic sub-leaves -----------------\n")); 1177 1177 for (uint32_t uSubLeaf = 0; uSubLeaf < 128; uSubLeaf++) 1178 1178 { … … 2402 2402 2403 2403 /** 2404 * Used by cpumR3CpuIdSanitize to ensure that we don't have any sub-leaves for 2405 * the given leaf. 2406 * 2407 * @returns pLeaf. 2408 * @param pCpum The CPUM instance data. 2409 * @param pLeaf The leaf to ensure is alone with it's EAX input value. 2410 */ 2411 static PCPUMCPUIDLEAF cpumR3CpuIdMakeSingleLeaf(PCPUM pCpum, PCPUMCPUIDLEAF pLeaf) 2412 { 2413 Assert((uintptr_t)(pLeaf - pCpum->GuestInfo.paCpuIdLeavesR3) < pCpum->GuestInfo.cCpuIdLeaves); 2414 if (pLeaf->fSubLeafMask != 0) 2415 { 2416 /* 2417 * Figure out how many sub-leaves in need of removal (we'll keep the first). 2418 * Log everything while we're at it. 2419 */ 2420 LogRel(("CPUM:\n" 2421 "CPUM: Unexpected CPUID sub-leaves for leaf %#x; fSubLeafMask=%#x\n", pLeaf->uLeaf, pLeaf->fSubLeafMask)); 2422 PCPUMCPUIDLEAF pLast = &pCpum->GuestInfo.paCpuIdLeavesR3[pCpum->GuestInfo.cCpuIdLeaves - 1]; 2423 PCPUMCPUIDLEAF pSubLeaf = pLeaf; 2424 for (;;) 2425 { 2426 LogRel(("CPUM: %08x/%08x: %08x %08x %08x %08x; flags=%#x mask=%#x\n", 2427 pSubLeaf->uLeaf, pSubLeaf->uSubLeaf, 2428 pSubLeaf->uEax, pSubLeaf->uEbx, pSubLeaf->uEcx, pSubLeaf->uEdx, 2429 pSubLeaf->fFlags, pSubLeaf->fSubLeafMask)); 2430 if (pSubLeaf == pLast || pSubLeaf[1].uLeaf != pLeaf->uLeaf) 2431 break; 2432 pSubLeaf++; 2433 } 2434 LogRel(("CPUM:\n")); 2435 2436 /* 2437 * Remove the offending sub-leaves. 2438 */ 2439 if (pSubLeaf != pLeaf) 2440 { 2441 if (pSubLeaf != pLast) 2442 memmove(pLeaf + 1, pSubLeaf + 1, (uintptr_t)pLast - (uintptr_t)pSubLeaf); 2443 pCpum->GuestInfo.cCpuIdLeaves -= (uint32_t)(pSubLeaf - pLeaf); 2444 } 2445 2446 /* 2447 * Convert the first sub-leaf into a single leaf. 2448 */ 2449 pLeaf->uSubLeaf = 0; 2450 pLeaf->fSubLeafMask = 0; 2451 } 2452 return pLeaf; 2453 } 2454 2455 2456 /** 2404 2457 * Sanitizes and adjust the CPUID leaves. 2405 2458 * … … 2451 2504 PCPUMCPUIDLEAF pStdFeatureLeaf = cpumR3CpuIdGetExactLeaf(pCpum, 1, 0); /* Note! Must refetch when used later. */ 2452 2505 AssertLogRelReturn(pStdFeatureLeaf, VERR_CPUM_IPE_2); 2453 AssertLogRelReturn(pStdFeatureLeaf->fSubLeafMask == 0, VERR_CPUM_IPE_2);2506 pStdFeatureLeaf = cpumR3CpuIdMakeSingleLeaf(pCpum, pStdFeatureLeaf); 2454 2507 2455 2508 pStdFeatureLeaf->uEdx &= X86_CPUID_FEATURE_EDX_FPU … … 2623 2676 if (pExtFeatureLeaf) 2624 2677 { 2625 AssertLogRelReturn(pExtFeatureLeaf->fSubLeafMask == 0, VERR_CPUM_IPE_2);2678 pExtFeatureLeaf = cpumR3CpuIdMakeSingleLeaf(pCpum, pExtFeatureLeaf); 2626 2679 2627 2680 pExtFeatureLeaf->uEdx &= X86_CPUID_AMD_FEATURE_EDX_FPU … … 2759 2812 * AMD: Reserved 2760 2813 * VIA: Reserved 2761 * Safe to expose. Restrict the number of calls to 1 since we don't 2762 * implement this kind of subleaves (is there hardware that does??). 2814 * Safe to expose. 2763 2815 */ 2764 2816 uint32_t uSubLeaf = 0;
Note:
See TracChangeset
for help on using the changeset viewer.