Changeset 55062 in vbox
- Timestamp:
- Apr 1, 2015 12:45:12 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
-
include/VBox/vmm/cpum.h (modified) (1 diff)
-
src/VBox/VMM/VMMAll/CPUMAllRegs.cpp (modified) (2 diffs)
-
src/VBox/VMM/VMMR0/CPUMR0.cpp (modified) (4 diffs)
-
src/VBox/VMM/VMMR3/CPUM.cpp (modified) (2 diffs)
-
src/VBox/VMM/VMMR3/CPUMDbg.cpp (modified) (3 diffs)
-
src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp (modified) (3 diffs)
-
src/VBox/VMM/VMMR3/VMMSwitcher.cpp (modified) (1 diff)
-
src/VBox/VMM/include/CPUMInternal.h (modified) (4 diffs)
-
src/VBox/VMM/include/CPUMInternal.mac (modified) (1 diff)
-
src/VBox/VMM/testcase/tstVMStruct.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/cpum.h
r55000 r55062 1219 1219 VMMR3DECL(uint32_t) CPUMR3RemEnter(PVMCPU pVCpu, uint32_t *puCpl); 1220 1220 VMMR3DECL(void) CPUMR3RemLeave(PVMCPU pVCpu, bool fNoOutOfSyncSels); 1221 VMMDECL(bool) CPUMSupports FXSR(PVM pVM);1221 VMMDECL(bool) CPUMSupportsXSave(PVM pVM); 1222 1222 VMMDECL(bool) CPUMIsHostUsingSysEnter(PVM pVM); 1223 1223 VMMDECL(bool) CPUMIsHostUsingSysCall(PVM pVM); -
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r55000 r55062 746 746 pVCpu->cpum.s.fChanged |= CPUM_CHANGED_GLOBAL_TLB_FLUSH; 747 747 pVCpu->cpum.s.fChanged |= CPUM_CHANGED_CR4; 748 if (!CPUMSupportsFXSR(pVCpu->CTX_SUFF(pVM)))749 cr4 &= ~X86_CR4_OSFXSR;750 748 pVCpu->cpum.s.Guest.cr4 = cr4; 751 749 return VINF_SUCCESS; … … 2480 2478 2481 2479 /** 2482 * Checks if the CPU supports the FXSAVE and FXRSTOR instruction. 2480 * Checks if the CPU supports the XSAVE and XRSTOR instruction. 2481 * 2483 2482 * @returns true if supported. 2484 2483 * @returns false if not supported. 2485 2484 * @param pVM Pointer to the VM. 2486 2485 */ 2487 VMMDECL(bool) CPUMSupports FXSR(PVM pVM)2488 { 2489 return pVM->cpum.s. CPUFeatures.edx.u1FXSR!= 0;2486 VMMDECL(bool) CPUMSupportsXSave(PVM pVM) 2487 { 2488 return pVM->cpum.s.HostFeatures.fXSaveRstor != 0; 2490 2489 } 2491 2490 -
trunk/src/VBox/VMM/VMMR0/CPUMR0.cpp
r55048 r55062 339 339 VMMR0_INT_DECL(int) CPUMR0Trap07Handler(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 340 340 { 341 Assert(pVM->cpum.s. CPUFeatures.edx.u1FXSR);341 Assert(pVM->cpum.s.HostFeatures.fFxSaveRstor); 342 342 Assert(ASMGetCR4() & X86_CR4_OSFXSR); 343 343 … … 399 399 VMMR0_INT_DECL(int) CPUMR0LoadGuestFPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 400 400 { 401 402 401 Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD)); 403 402 #if HC_ARCH_BITS == 32 && defined(VBOX_WITH_64_BITS_GUESTS) && !defined(VBOX_WITH_HYBRID_32BIT_KERNEL) … … 423 422 uint64_t uHostEfer = 0; 424 423 bool fRestoreEfer = false; 425 if (pVM->cpum.s. CPUFeaturesExt.edx & X86_CPUID_AMD_FEATURE_EDX_FFXSR)424 if (pVM->cpum.s.HostFeatures.fLeakyFxSR) 426 425 { 427 426 /** @todo r=ramshankar: Can't we used a cached value here … … 460 459 VMMR0_INT_DECL(int) CPUMR0SaveGuestFPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx) 461 460 { 462 Assert(pVM->cpum.s. CPUFeatures.edx.u1FXSR);461 Assert(pVM->cpum.s.HostFeatures.fFxSaveRstor); 463 462 Assert(ASMGetCR4() & X86_CR4_OSFXSR); 464 463 AssertReturn((pVCpu->cpum.s.fUseFlags & CPUM_USED_FPU), VINF_SUCCESS); -
trunk/src/VBox/VMM/VMMR3/CPUM.cpp
r55054 r55062 640 640 return VMSetError(pVM, VERR_UNSUPPORTED_CPU, RT_SRC_POS, "Host CPU does not support RDTSC."); 641 641 642 /* Bogus on AMD? */ 643 if (!pVM->cpum.s.CPUFeatures.edx.u1SEP) 644 Log(("The CPU doesn't support SYSENTER/SYSEXIT!\n")); 645 646 /* 647 * Setup the CR4 AND and OR masks used in the switcher 642 /* 643 * Setup the CR4 AND and OR masks used in the raw-mode switcher. 648 644 */ 649 645 pVM->cpum.s.CR4.AndMask = X86_CR4_OSXMMEEXCPT | X86_CR4_PVI | X86_CR4_VME; … … 653 649 * Allocate memory for the extended CPU state. 654 650 */ 655 uint32_t cbMaxXState = sizeof(X86FXSTATE);651 uint32_t cbMaxXState = pVM->cpum.s.HostFeatures.cbMaxExtendedState; 656 652 cbMaxXState = RT_ALIGN(cbMaxXState, 128); 653 AssertLogRelReturn(cbMaxXState >= sizeof(X86FXSTATE) && cbMaxXState <= _8K, VERR_CPUM_IPE_2); 654 657 655 uint8_t *pbXStates; 658 656 rc = MMR3HyperAllocOnceNoRelEx(pVM, cbMaxXState * 3 * pVM->cCpus, PAGE_SIZE, MM_TAG_CPUM_CTX, -
trunk/src/VBox/VMM/VMMR3/CPUMDbg.cpp
r55048 r55062 239 239 240 240 /** 241 * Is the FPU state in FXSAVE format or not.242 *243 * @returns true if it is, false if it's in FNSAVE.244 * @param pVCpu Pointer to the VMCPU.245 */246 DECLINLINE(bool) cpumR3RegIsFxSaveFormat(PVMCPU pVCpu)247 {248 #ifdef RT_ARCH_AMD64249 NOREF(pVCpu);250 return true;251 #else252 return pVCpu->pVMR3->cpum.s.CPUFeatures.edx.u1FXSR;253 #endif254 }255 256 257 /**258 241 * Determins the tag register value for a CPU register when the FPU state 259 242 * format is FXSAVE. … … 300 283 Assert(pDesc->enmType == DBGFREGVALTYPE_U16); 301 284 302 if (cpumR3RegIsFxSaveFormat(pVCpu)) 303 pValue->u16 = cpumR3RegCalcFpuTagFromFxSave(pFpu, 0) 304 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 1) << 2) 305 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 2) << 4) 306 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 3) << 6) 307 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 4) << 8) 308 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 5) << 10) 309 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 6) << 12) 310 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 7) << 14); 311 else 312 { 313 PCX86FPUSTATE pOldFpu = (PCX86FPUSTATE)pFpu; 314 pValue->u16 = pOldFpu->FTW; 315 } 285 pValue->u16 = cpumR3RegCalcFpuTagFromFxSave(pFpu, 0) 286 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 1) << 2) 287 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 2) << 4) 288 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 3) << 6) 289 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 4) << 8) 290 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 5) << 10) 291 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 6) << 12) 292 | (cpumR3RegCalcFpuTagFromFxSave(pFpu, 7) << 14); 316 293 return VINF_SUCCESS; 317 294 } … … 620 597 621 598 PX86FXSTATE pFpuCtx = &pVCpu->cpum.s.Guest.CTX_SUFF(pXState)->x87; 622 if (cpumR3RegIsFxSaveFormat(pVCpu)) 623 { 624 unsigned iReg = (pFpuCtx->FSW >> 11) & 7; 625 iReg += pDesc->offRegister; 626 iReg &= 7; 627 pValue->r80Ex = pFpuCtx->aRegs[iReg].r80Ex; 628 } 629 else 630 { 631 PCX86FPUSTATE pOldFpuCtx = (PCX86FPUSTATE)pFpuCtx; 632 633 unsigned iReg = (pOldFpuCtx->FSW >> 11) & 7; 634 iReg += pDesc->offRegister; 635 iReg &= 7; 636 pValue->r80Ex = pOldFpuCtx->regs[iReg].r80Ex; 637 } 599 unsigned iReg = (pFpuCtx->FSW >> 11) & 7; 600 iReg += pDesc->offRegister; 601 iReg &= 7; 602 pValue->r80Ex = pFpuCtx->aRegs[iReg].r80Ex; 638 603 639 604 return VINF_SUCCESS; -
trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp
r55060 r55062 1501 1501 1502 1502 1503 static PCCPUMCPUIDLEAF cpumR3CpuIdFindLeafEx(PCCPUMCPUIDLEAF paLeaves, uint32_t cLeaves, uint32_t uLeaf, uint32_t uSubLeaf) 1504 { 1505 PCCPUMCPUIDLEAF pLeaf = cpumR3CpuIdFindLeaf(paLeaves, cLeaves, uLeaf); 1506 if ( !pLeaf 1507 || pLeaf->uSubLeaf != (uSubLeaf & pLeaf->fSubLeafMask)) 1508 return pLeaf; 1509 1510 /* Linear sub-leaf search. Lazy as usual. */ 1511 cLeaves = pLeaf - paLeaves; 1512 while ( cLeaves-- > 0 1513 && pLeaf->uLeaf == uLeaf) 1514 { 1515 if (pLeaf->uSubLeaf == (uSubLeaf & pLeaf->fSubLeafMask)) 1516 return pLeaf; 1517 pLeaf++; 1518 } 1519 1520 return NULL; 1521 } 1522 1523 1503 1524 int cpumR3CpuIdExplodeFeatures(PCCPUMCPUIDLEAF paLeaves, uint32_t cLeaves, PCPUMFEATURES pFeatures) 1504 1525 { … … 1538 1559 pFeatures->fPat = RT_BOOL(paLeaves[1].uEdx & X86_CPUID_FEATURE_EDX_PAT); 1539 1560 pFeatures->fFxSaveRstor = RT_BOOL(paLeaves[1].uEdx & X86_CPUID_FEATURE_EDX_FXSR); 1561 pFeatures->fXSaveRstor = RT_BOOL(paLeaves[1].uEcx & X86_CPUID_FEATURE_ECX_XSAVE); 1540 1562 pFeatures->fMmx = RT_BOOL(paLeaves[1].uEdx & X86_CPUID_FEATURE_EDX_MMX); 1563 pFeatures->fSse = RT_BOOL(paLeaves[1].uEdx & X86_CPUID_FEATURE_EDX_SSE); 1564 pFeatures->fSse2 = RT_BOOL(paLeaves[1].uEdx & X86_CPUID_FEATURE_EDX_SSE2); 1565 pFeatures->fSse3 = RT_BOOL(paLeaves[1].uEcx & X86_CPUID_FEATURE_ECX_SSE3); 1566 pFeatures->fSsse3 = RT_BOOL(paLeaves[1].uEcx & X86_CPUID_FEATURE_ECX_SSSE3); 1567 pFeatures->fSse41 = RT_BOOL(paLeaves[1].uEcx & X86_CPUID_FEATURE_ECX_SSE4_1); 1568 pFeatures->fSse42 = RT_BOOL(paLeaves[1].uEcx & X86_CPUID_FEATURE_ECX_SSE4_2); 1569 pFeatures->fAvx = RT_BOOL(paLeaves[1].uEcx & X86_CPUID_FEATURE_ECX_AVX); 1541 1570 pFeatures->fTsc = RT_BOOL(paLeaves[1].uEdx & X86_CPUID_FEATURE_EDX_TSC); 1542 1571 pFeatures->fSysEnter = RT_BOOL(paLeaves[1].uEdx & X86_CPUID_FEATURE_EDX_SEP); 1543 1572 pFeatures->fHypervisorPresent = RT_BOOL(paLeaves[1].uEcx & X86_CPUID_FEATURE_ECX_HVP); 1544 1573 pFeatures->fMonitorMWait = RT_BOOL(paLeaves[1].uEcx & X86_CPUID_FEATURE_ECX_MONITOR); 1574 1575 /* Structured extended features. */ 1576 PCCPUMCPUIDLEAF const pSxfLeaf0 = cpumR3CpuIdFindLeafEx(paLeaves, cLeaves, 7, 0); 1577 if (pSxfLeaf0) 1578 { 1579 pFeatures->fAvx2 = RT_BOOL(pSxfLeaf0->uEcx & X86_CPUID_STEXT_FEATURE_EBX_AVX2); 1580 pFeatures->fAvx512Foundation = RT_BOOL(pSxfLeaf0->uEcx & X86_CPUID_STEXT_FEATURE_EBX_AVX512F); 1581 } 1545 1582 1546 1583 /* MWAIT/MONITOR leaf. */ … … 1585 1622 && pFeatures->enmCpuVendor == CPUMCPUVENDOR_AMD 1586 1623 && pFeatures->uFamily >= 6 /* K7 and up */; 1624 1625 /* 1626 * Max extended (/FPU) state. 1627 */ 1628 pFeatures->cbMaxExtendedState = pFeatures->fFxSaveRstor ? sizeof(X86FXSTATE) : sizeof(X86FPUSTATE); 1629 if (pFeatures->fXSaveRstor) 1630 { 1631 PCCPUMCPUIDLEAF const pXStateLeaf0 = cpumR3CpuIdFindLeafEx(paLeaves, cLeaves, 13, 0); 1632 if (pXStateLeaf0) 1633 { 1634 if ( pXStateLeaf0->uEcx >= sizeof(X86FXSTATE) 1635 && pXStateLeaf0->uEcx <= _8K 1636 && RT_ALIGN_32(pXStateLeaf0->uEcx, 8) == pXStateLeaf0->uEcx 1637 && pXStateLeaf0->uEbx >= sizeof(X86FXSTATE) 1638 && pXStateLeaf0->uEbx <= pXStateLeaf0->uEcx 1639 && RT_ALIGN_32(pXStateLeaf0->uEbx, 8) == pXStateLeaf0->uEbx) 1640 { 1641 pFeatures->cbMaxExtendedState = pXStateLeaf0->uEcx; 1642 } 1643 else 1644 AssertLogRelMsgFailedStmt(("Unexpected max/cur XSAVE area sizes: %#x/%#x\n", pXStateLeaf0->uEcx, pXStateLeaf0->uEbx), 1645 pFeatures->fXSaveRstor = 0); 1646 } 1647 else 1648 AssertLogRelMsgFailedStmt(("Expected leaf eax=0xd/ecx=0 with the XSAVE/XRSTOR feature!\n"), 1649 pFeatures->fXSaveRstor = 0); 1650 } 1587 1651 } 1588 1652 else -
trunk/src/VBox/VMM/VMMR3/VMMSwitcher.cpp
r55054 r55062 698 698 uint32_t offTrg = *u.pu32++; 699 699 Assert(offTrg < pSwitcher->cbCode); 700 if (!CPUMSupports FXSR(pVM))700 if (!CPUMSupportsXSave(pVM)) 701 701 { 702 702 *uSrc.pu8++ = 0xe9; /* jmp rel32 */ -
trunk/src/VBox/VMM/include/CPUMInternal.h
r55054 r55062 172 172 uint8_t cMaxPhysAddrWidth; 173 173 /** Alignment padding. */ 174 uint8_t abPadding[3]; 174 uint8_t abPadding[1]; 175 /** Max size of the extended state (or FPU state if no XSAVE). */ 176 uint16_t cbMaxExtendedState; 175 177 176 178 /** Supports MSRs. */ … … 187 189 /** Supports the FXSAVE and FXRSTOR instructions. */ 188 190 uint32_t fFxSaveRstor : 1; 191 /** Supports the XSAVE and XRSTOR instructions. */ 192 uint32_t fXSaveRstor : 1; 189 193 /** Supports MMX. */ 190 194 uint32_t fMmx : 1; 195 /** Supports SSE. */ 196 uint32_t fSse : 1; 197 /** Supports SSE2. */ 198 uint32_t fSse2 : 1; 199 /** Supports SSE3. */ 200 uint32_t fSse3 : 1; 201 /** Supports SSSE3. */ 202 uint32_t fSsse3 : 1; 203 /** Supports SSE4.1. */ 204 uint32_t fSse41 : 1; 205 /** Supports SSE4.2. */ 206 uint32_t fSse42 : 1; 207 /** Supports AVX. */ 208 uint32_t fAvx : 1; 209 /** Supports AVX2. */ 210 uint32_t fAvx2 : 1; 211 /** Supports AVX512 foundation. */ 212 uint32_t fAvx512Foundation : 1; 191 213 /** Supports RDTSC. */ 192 214 uint32_t fTsc : 1; … … 220 242 uint32_t fLeakyFxSR : 1; 221 243 222 /** Alignment padding. */ 223 uint32_t fPadding : 12; 224 244 /** Alignment padding / reserved for future use. */ 245 uint32_t fPadding : 2; 225 246 uint64_t auPadding[2]; 226 247 } CPUMFEATURES; … … 469 490 uint32_t fHostUseFlags; 470 491 471 /** Host CPU Features - ECX */472 struct473 {474 /** edx part */475 X86CPUIDFEATEDX edx;476 /** ecx part */477 X86CPUIDFEATECX ecx;478 } CPUFeatures;479 /** Host extended CPU features. */480 struct481 {482 /** edx part */483 uint32_t edx;484 /** ecx part */485 uint32_t ecx;486 } CPUFeaturesExt;487 488 492 /** CR4 mask */ 489 493 struct -
trunk/src/VBox/VMM/include/CPUMInternal.mac
r55049 r55062 78 78 .offCPUMCPU0 resd 1 79 79 .fHostUseFlags resd 1 80 81 ; CPUID eax=182 .CPUFeatures.edx resd 183 .CPUFeatures.ecx resd 184 85 ; CPUID eax=0x8000000186 .CPUFeaturesExt.edx resd 187 .CPUFeaturesExt.ecx resd 188 80 89 81 ; CR4 masks -
trunk/src/VBox/VMM/testcase/tstVMStruct.h
r55048 r55062 29 29 GEN_CHECK_OFF(CPUM, offCPUMCPU0); 30 30 GEN_CHECK_OFF(CPUM, fHostUseFlags); 31 GEN_CHECK_OFF(CPUM, CPUFeatures);32 GEN_CHECK_OFF(CPUM, CPUFeaturesExt);33 GEN_CHECK_OFF(CPUM, CPUFeaturesExt);34 31 GEN_CHECK_OFF(CPUM, CR4); 35 32 #ifndef VBOX_FOR_DTRACE_LIB
Note:
See TracChangeset
for help on using the changeset viewer.

