Changeset 61776 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Jun 20, 2016 11:25:06 PM (9 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/APICAll.cpp
r61736 r61776 2068 2068 2069 2069 /* Don't allow enabling xAPIC/x2APIC if the VM is configured with the APIC disabled. */ 2070 if (pApic->enm OriginalMode == APICMODE_DISABLED)2070 if (pApic->enmMaxMode == PDMAPICMODE_NONE) 2071 2071 { 2072 2072 LogRel(("APIC%u: Disallowing APIC base MSR write as the VM is configured with APIC disabled!\n", 2073 pVCpu->idCpu));2073 pVCpu->idCpu)); 2074 2074 return apicMsrAccessError(pVCpu, MSR_IA32_APICBASE, APICMSRACCESS_WRITE_DISALLOWED_CONFIG); 2075 2075 } … … 2078 2078 * Act on state transition. 2079 2079 */ 2080 /** @todo We need to update the CPUID according to the state, which we2081 * currently don't do as CPUMSetGuestCpuIdFeature() is setting2082 * per-VM CPUID bits while we need per-VCPU specific bits. */2083 2080 if (enmNewMode != enmOldMode) 2084 2081 { … … 2099 2096 APICR3Reset(pVCpu, false /* fResetApicBaseMsr */); 2100 2097 uBaseMsr &= ~(MSR_IA32_APICBASE_EN | MSR_IA32_APICBASE_EXTD); 2101 CPUM ClearGuestCpuIdFeature(pVCpu->CTX_SUFF(pVM), CPUMCPUIDFEATURE_APIC);2098 CPUMSetGuestCpuIdPerCpuApicFeature(pVCpu, false /*fVisible*/); 2102 2099 LogRel(("APIC%u: Switched mode to disabled\n", pVCpu->idCpu)); 2103 2100 break; … … 2113 2110 2114 2111 uBaseMsr |= MSR_IA32_APICBASE_EN; 2115 CPUMSetGuestCpuId Feature(pVCpu->CTX_SUFF(pVM), CPUMCPUIDFEATURE_APIC);2112 CPUMSetGuestCpuIdPerCpuApicFeature(pVCpu, true /*fVisible*/); 2116 2113 LogRel(("APIC%u: Switched mode to xAPIC\n", pVCpu->idCpu)); 2117 2114 break; … … 2120 2117 case APICMODE_X2APIC: 2121 2118 { 2122 if (pApic->enm OriginalMode !=APICMODE_X2APIC)2119 if (pApic->enmMaxMode != PDMAPICMODE_X2APIC) 2123 2120 { 2124 2121 LogRel(("APIC%u: Disallowing transition to x2APIC mode as the VM is configured with the x2APIC disabled!\n", -
trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp
r61071 r61776 734 734 VMMDECL(int) CPUMSetGuestCR4(PVMCPU pVCpu, uint64_t cr4) 735 735 { 736 /* 737 * The CR4.OSXSAVE bit is reflected in CPUID(1).ECX[27]. 738 */ 739 if ( (cr4 & X86_CR4_OSXSAVE) 740 != (pVCpu->cpum.s.Guest.cr4 & X86_CR4_OSXSAVE) ) 741 { 742 PVM pVM = pVCpu->CTX_SUFF(pVM); 743 if (cr4 & X86_CR4_OSXSAVE) 744 CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_OSXSAVE); 745 else 746 CPUMClearGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_OSXSAVE); 747 } 736 /* Note! We don't bother with OSXSAVE and legacy CPUID patches. */ 748 737 749 738 if ( (cr4 & (X86_CR4_PGE | X86_CR4_PAE | X86_CR4_PSE)) … … 1288 1277 1289 1278 /* 1290 * Deal with CPU specific information (currently only APIC ID).1279 * Deal with CPU specific information. 1291 1280 */ 1292 if (pLeaf->fFlags & (CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_OSXSAVE)) 1281 if (pLeaf->fFlags & ( CPUMCPUIDLEAF_F_CONTAINS_APIC_ID 1282 | CPUMCPUIDLEAF_F_CONTAINS_OSXSAVE 1283 | CPUMCPUIDLEAF_F_CONTAINS_APIC )) 1293 1284 { 1294 1285 if (uLeaf == 1) … … 1298 1289 AssertMsg((pLeaf->uEbx >> 24) == 0, ("%#x\n", pLeaf->uEbx)); /* raw-mode assumption */ 1299 1290 *pEbx = (pLeaf->uEbx & UINT32_C(0x00ffffff)) | (pVCpu->idCpu << 24); 1291 1292 /* EDX: Bit 9: AND with APICBASE.EN. */ 1293 if (!pVCpu->cpum.s.fCpuIdApicFeatureVisible && (pLeaf->fFlags & CPUMCPUIDLEAF_F_CONTAINS_APIC)) 1294 *pEdx &= ~X86_CPUID_FEATURE_EDX_APIC; 1300 1295 1301 1296 /* ECX: Bit 27: CR4.OSXSAVE mirror. */ … … 1308 1303 AssertMsg(pLeaf->uEdx == 0, ("%#x\n", pLeaf->uEdx)); /* raw-mode assumption */ 1309 1304 *pEdx = pVCpu->idCpu; 1305 Assert(!(pLeaf->fFlags & ~(CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_INTEL_TOPOLOGY_SUBLEAVES))); 1310 1306 } 1311 1307 else if (uLeaf == UINT32_C(0x8000001e)) … … 1314 1310 AssertMsg(pLeaf->uEax == 0, ("%#x\n", pLeaf->uEax)); /* raw-mode assumption */ 1315 1311 *pEax = pVCpu->idCpu; 1312 Assert(!(pLeaf->fFlags & ~CPUMCPUIDLEAF_F_CONTAINS_APIC_ID)); 1313 } 1314 else if (uLeaf == UINT32_C(0x80000001)) 1315 { 1316 /* EDX: Bit 9: AND with APICBASE.EN. */ 1317 if (!pVCpu->cpum.s.fCpuIdApicFeatureVisible) 1318 *pEdx &= ~X86_CPUID_AMD_FEATURE_EDX_APIC; 1319 Assert(!(pLeaf->fFlags & ~CPUMCPUIDLEAF_F_CONTAINS_APIC)); 1316 1320 } 1317 1321 else … … 1363 1367 1364 1368 /** 1365 * Sets a CPUID feature bit. 1366 * 1367 * @param pVM The cross context VM structure. 1368 * @param enmFeature The feature to set. 1369 */ 1370 VMMDECL(void) CPUMSetGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature) 1371 { 1372 PCPUMCPUIDLEAF pLeaf; 1373 1374 switch (enmFeature) 1369 * Sets the visibility of the X86_CPUID_FEATURE_EDX_APIC and 1370 * X86_CPUID_AMD_FEATURE_EDX_APIC CPUID bits. 1371 * 1372 * @returns Previous value. 1373 * @param pVCpu The cross context virtual CPU structure to make the 1374 * change on. Usually the calling EMT. 1375 * @param fVisible Whether to make it visible (true) or hide it (false). 1376 */ 1377 VMM_INT_DECL(bool) CPUMSetGuestCpuIdPerCpuApicFeature(PVMCPU pVCpu, bool fVisible) 1378 { 1379 bool fOld = pVCpu->cpum.s.fCpuIdApicFeatureVisible; 1380 pVCpu->cpum.s.fCpuIdApicFeatureVisible = fVisible; 1381 1382 #ifdef VBOX_WITH_RAW_MODE_NOT_R0 1383 /* 1384 * Patch manager saved state legacy pain. 1385 */ 1386 PVM pVM = pVCpu->CTX_SUFF(pVM); 1387 PCPUMCPUIDLEAF pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1388 if (pLeaf) 1375 1389 { 1376 /* 1377 * Set the APIC bit in both feature masks. 1378 */ 1379 case CPUMCPUIDFEATURE_APIC: 1380 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1381 if (pLeaf) 1382 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx |= X86_CPUID_FEATURE_EDX_APIC; 1383 1384 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1385 if ( pLeaf 1386 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD) 1387 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_AMD_FEATURE_EDX_APIC; 1388 1389 pVM->cpum.s.GuestFeatures.fApic = 1; 1390 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled xAPIC\n")); 1391 break; 1392 1393 /* 1394 * Set the x2APIC bit in the standard feature mask. 1395 */ 1396 case CPUMCPUIDFEATURE_X2APIC: 1397 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1398 if (pLeaf) 1399 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEcx = pLeaf->uEcx |= X86_CPUID_FEATURE_ECX_X2APIC; 1400 pVM->cpum.s.GuestFeatures.fX2Apic = 1; 1401 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled x2APIC\n")); 1402 break; 1403 1404 /* 1405 * Set the sysenter/sysexit bit in the standard feature mask. 1406 * Assumes the caller knows what it's doing! (host must support these) 1407 */ 1408 case CPUMCPUIDFEATURE_SEP: 1409 if (!pVM->cpum.s.HostFeatures.fSysEnter) 1410 { 1411 AssertMsgFailed(("ERROR: Can't turn on SEP when the host doesn't support it!!\n")); 1412 return; 1413 } 1414 1415 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1416 if (pLeaf) 1417 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx |= X86_CPUID_FEATURE_EDX_SEP; 1418 pVM->cpum.s.GuestFeatures.fSysEnter = 1; 1419 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled SYSENTER/EXIT\n")); 1420 break; 1421 1422 /* 1423 * Set the syscall/sysret bit in the extended feature mask. 1424 * Assumes the caller knows what it's doing! (host must support these) 1425 */ 1426 case CPUMCPUIDFEATURE_SYSCALL: 1427 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1428 if ( !pLeaf 1429 || !pVM->cpum.s.HostFeatures.fSysCall) 1430 { 1431 #if HC_ARCH_BITS == 32 1432 /* X86_CPUID_EXT_FEATURE_EDX_SYSCALL not set it seems in 32-bit 1433 mode by Intel, even when the cpu is capable of doing so in 1434 64-bit mode. Long mode requires syscall support. */ 1435 if (!pVM->cpum.s.HostFeatures.fLongMode) 1390 if (fVisible || (pLeaf->fFlags & CPUMCPUIDLEAF_F_CONTAINS_APIC)) 1391 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx; 1392 else 1393 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx & ~X86_CPUID_FEATURE_EDX_APIC; 1394 } 1395 1396 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1397 if (pLeaf) 1398 { 1399 if (fVisible || (pLeaf->fFlags & CPUMCPUIDLEAF_F_CONTAINS_APIC)) 1400 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx; 1401 else 1402 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx & ~X86_CPUID_AMD_FEATURE_EDX_APIC; 1403 } 1436 1404 #endif 1437 { 1438 LogRel(("CPUM: WARNING! Can't turn on SYSCALL/SYSRET when the host doesn't support it!\n")); 1439 return; 1440 } 1441 } 1442 1443 /* Valid for both Intel and AMD CPUs, although only in 64 bits mode for Intel. */ 1444 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_EXT_FEATURE_EDX_SYSCALL; 1445 pVM->cpum.s.GuestFeatures.fSysCall = 1; 1446 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled SYSCALL/RET\n")); 1447 break; 1448 1449 /* 1450 * Set the PAE bit in both feature masks. 1451 * Assumes the caller knows what it's doing! (host must support these) 1452 */ 1453 case CPUMCPUIDFEATURE_PAE: 1454 if (!pVM->cpum.s.HostFeatures.fPae) 1455 { 1456 LogRel(("CPUM: WARNING! Can't turn on PAE when the host doesn't support it!\n")); 1457 return; 1458 } 1459 1460 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1461 if (pLeaf) 1462 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx |= X86_CPUID_FEATURE_EDX_PAE; 1463 1464 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1465 if ( pLeaf 1466 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD) 1467 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_AMD_FEATURE_EDX_PAE; 1468 1469 pVM->cpum.s.GuestFeatures.fPae = 1; 1470 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled PAE\n")); 1471 break; 1472 1473 /* 1474 * Set the LONG MODE bit in the extended feature mask. 1475 * Assumes the caller knows what it's doing! (host must support these) 1476 */ 1477 case CPUMCPUIDFEATURE_LONG_MODE: 1478 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1479 if ( !pLeaf 1480 || !pVM->cpum.s.HostFeatures.fLongMode) 1481 { 1482 LogRel(("CPUM: WARNING! Can't turn on LONG MODE when the host doesn't support it!\n")); 1483 return; 1484 } 1485 1486 /* Valid for both Intel and AMD. */ 1487 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_EXT_FEATURE_EDX_LONG_MODE; 1488 pVM->cpum.s.GuestFeatures.fLongMode = 1; 1489 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled LONG MODE\n")); 1490 break; 1491 1492 /* 1493 * Set the NX/XD bit in the extended feature mask. 1494 * Assumes the caller knows what it's doing! (host must support these) 1495 */ 1496 case CPUMCPUIDFEATURE_NX: 1497 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1498 if ( !pLeaf 1499 || !pVM->cpum.s.HostFeatures.fNoExecute) 1500 { 1501 LogRel(("CPUM: WARNING! Can't turn on NX/XD when the host doesn't support it!\n")); 1502 return; 1503 } 1504 1505 /* Valid for both Intel and AMD. */ 1506 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_EXT_FEATURE_EDX_NX; 1507 pVM->cpum.s.GuestFeatures.fNoExecute = 1; 1508 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled NX\n")); 1509 break; 1510 1511 1512 /* 1513 * Set the LAHF/SAHF support in 64-bit mode. 1514 * Assumes the caller knows what it's doing! (host must support this) 1515 */ 1516 case CPUMCPUIDFEATURE_LAHF: 1517 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1518 if ( !pLeaf 1519 || !pVM->cpum.s.HostFeatures.fLahfSahf) 1520 { 1521 LogRel(("CPUM: WARNING! Can't turn on LAHF/SAHF when the host doesn't support it!\n")); 1522 return; 1523 } 1524 1525 /* Valid for both Intel and AMD. */ 1526 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEcx = pLeaf->uEcx |= X86_CPUID_EXT_FEATURE_ECX_LAHF_SAHF; 1527 pVM->cpum.s.GuestFeatures.fLahfSahf = 1; 1528 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled LAHF/SAHF\n")); 1529 break; 1530 1531 /* 1532 * Set the page attribute table bit. This is alternative page level 1533 * cache control that doesn't much matter when everything is 1534 * virtualized, though it may when passing thru device memory. 1535 */ 1536 case CPUMCPUIDFEATURE_PAT: 1537 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1538 if (pLeaf) 1539 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx |= X86_CPUID_FEATURE_EDX_PAT; 1540 1541 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1542 if ( pLeaf 1543 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD) 1544 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_AMD_FEATURE_EDX_PAT; 1545 1546 pVM->cpum.s.GuestFeatures.fPat = 1; 1547 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled PAT\n")); 1548 break; 1549 1550 /* 1551 * Set the RDTSCP support bit. 1552 * Assumes the caller knows what it's doing! (host must support this) 1553 */ 1554 case CPUMCPUIDFEATURE_RDTSCP: 1555 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1556 if ( !pLeaf 1557 || !pVM->cpum.s.HostFeatures.fRdTscP 1558 || pVM->cpum.s.u8PortableCpuIdLevel > 0) 1559 { 1560 if (!pVM->cpum.s.u8PortableCpuIdLevel) 1561 LogRel(("CPUM: WARNING! Can't turn on RDTSCP when the host doesn't support it!\n")); 1562 return; 1563 } 1564 1565 /* Valid for both Intel and AMD. */ 1566 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_EXT_FEATURE_EDX_RDTSCP; 1567 pVM->cpum.s.HostFeatures.fRdTscP = 1; 1568 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled RDTSCP.\n")); 1569 break; 1570 1571 /* 1572 * Set the Hypervisor Present bit in the standard feature mask. 1573 */ 1574 case CPUMCPUIDFEATURE_HVP: 1575 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1576 if (pLeaf) 1577 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEcx = pLeaf->uEcx |= X86_CPUID_FEATURE_ECX_HVP; 1578 pVM->cpum.s.GuestFeatures.fHypervisorPresent = 1; 1579 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled Hypervisor Present bit\n")); 1580 break; 1581 1582 /* 1583 * Set the MWAIT Extensions Present bit in the MWAIT/MONITOR leaf. 1584 * This currently includes the Present bit and MWAITBREAK bit as well. 1585 */ 1586 case CPUMCPUIDFEATURE_MWAIT_EXTS: 1587 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000005)); 1588 if ( !pLeaf 1589 || !pVM->cpum.s.HostFeatures.fMWaitExtensions) 1590 { 1591 LogRel(("CPUM: WARNING! Can't turn on MWAIT Extensions when the host doesn't support it!\n")); 1592 return; 1593 } 1594 1595 /* Valid for both Intel and AMD. */ 1596 pVM->cpum.s.aGuestCpuIdPatmStd[5].uEcx = pLeaf->uEcx |= X86_CPUID_MWAIT_ECX_EXT | X86_CPUID_MWAIT_ECX_BREAKIRQIF0; 1597 pVM->cpum.s.GuestFeatures.fMWaitExtensions = 1; 1598 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled MWAIT Extensions.\n")); 1599 break; 1600 1601 /* 1602 * OSXSAVE - only used from CPUMSetGuestCR4. 1603 */ 1604 case CPUMCPUIDFEATURE_OSXSAVE: 1605 AssertLogRelReturnVoid(pVM->cpum.s.HostFeatures.fXSaveRstor && pVM->cpum.s.HostFeatures.fOpSysXSaveRstor); 1606 1607 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1608 AssertLogRelReturnVoid(pLeaf); 1609 1610 /* UNI: Special case for single CPU to make life simple for CPUMPatchHlpCpuId. */ 1611 if (pVM->cCpus == 1) 1612 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEcx = pLeaf->uEcx |= X86_CPUID_FEATURE_ECX_OSXSAVE; 1613 /* SMP: Set flag indicating OSXSAVE updating (superfluous because of the APIC ID, but that's fine). */ 1614 else 1615 ASMAtomicOrU32(&pLeaf->fFlags, CPUMCPUIDLEAF_F_CONTAINS_OSXSAVE); 1616 break; 1617 1618 default: 1619 AssertMsgFailed(("enmFeature=%d\n", enmFeature)); 1620 break; 1621 } 1622 1623 for (VMCPUID i = 0; i < pVM->cCpus; i++) 1624 { 1625 PVMCPU pVCpu = &pVM->aCpus[i]; 1626 pVCpu->cpum.s.fChanged |= CPUM_CHANGED_CPUID; 1627 } 1628 } 1629 1630 1631 /** 1632 * Queries a CPUID feature bit. 1633 * 1634 * @returns boolean for feature presence 1635 * @param pVM The cross context VM structure. 1636 * @param enmFeature The feature to query. 1637 */ 1638 VMMDECL(bool) CPUMGetGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature) 1639 { 1640 switch (enmFeature) 1641 { 1642 case CPUMCPUIDFEATURE_APIC: return pVM->cpum.s.GuestFeatures.fApic; 1643 case CPUMCPUIDFEATURE_X2APIC: return pVM->cpum.s.GuestFeatures.fX2Apic; 1644 case CPUMCPUIDFEATURE_SYSCALL: return pVM->cpum.s.GuestFeatures.fSysCall; 1645 case CPUMCPUIDFEATURE_SEP: return pVM->cpum.s.GuestFeatures.fSysEnter; 1646 case CPUMCPUIDFEATURE_PAE: return pVM->cpum.s.GuestFeatures.fPae; 1647 case CPUMCPUIDFEATURE_NX: return pVM->cpum.s.GuestFeatures.fNoExecute; 1648 case CPUMCPUIDFEATURE_LAHF: return pVM->cpum.s.GuestFeatures.fLahfSahf; 1649 case CPUMCPUIDFEATURE_LONG_MODE: return pVM->cpum.s.GuestFeatures.fLongMode; 1650 case CPUMCPUIDFEATURE_PAT: return pVM->cpum.s.GuestFeatures.fPat; 1651 case CPUMCPUIDFEATURE_RDTSCP: return pVM->cpum.s.GuestFeatures.fRdTscP; 1652 case CPUMCPUIDFEATURE_HVP: return pVM->cpum.s.GuestFeatures.fHypervisorPresent; 1653 case CPUMCPUIDFEATURE_MWAIT_EXTS: return pVM->cpum.s.GuestFeatures.fMWaitExtensions; 1654 1655 case CPUMCPUIDFEATURE_OSXSAVE: 1656 case CPUMCPUIDFEATURE_INVALID: 1657 case CPUMCPUIDFEATURE_32BIT_HACK: 1658 break; 1659 } 1660 AssertFailed(); 1661 return false; 1662 } 1663 1664 1665 /** 1666 * Clears a CPUID feature bit. 1667 * 1668 * @param pVM The cross context VM structure. 1669 * @param enmFeature The feature to clear. 1670 */ 1671 VMMDECL(void) CPUMClearGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature) 1672 { 1673 PCPUMCPUIDLEAF pLeaf; 1674 switch (enmFeature) 1675 { 1676 case CPUMCPUIDFEATURE_APIC: 1677 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1678 if (pLeaf) 1679 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_FEATURE_EDX_APIC; 1680 1681 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1682 if ( pLeaf 1683 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD) 1684 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_AMD_FEATURE_EDX_APIC; 1685 1686 pVM->cpum.s.GuestFeatures.fApic = 0; 1687 Log(("CPUM: ClearGuestCpuIdFeature: Disabled xAPIC\n")); 1688 break; 1689 1690 case CPUMCPUIDFEATURE_X2APIC: 1691 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1692 if (pLeaf) 1693 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEcx = pLeaf->uEcx &= ~X86_CPUID_FEATURE_ECX_X2APIC; 1694 pVM->cpum.s.GuestFeatures.fX2Apic = 0; 1695 Log(("CPUM: ClearGuestCpuIdFeature: Disabled x2APIC\n")); 1696 break; 1697 1698 case CPUMCPUIDFEATURE_PAE: 1699 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1700 if (pLeaf) 1701 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_FEATURE_EDX_PAE; 1702 1703 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1704 if ( pLeaf 1705 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD) 1706 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_AMD_FEATURE_EDX_PAE; 1707 1708 pVM->cpum.s.GuestFeatures.fPae = 0; 1709 Log(("CPUM: ClearGuestCpuIdFeature: Disabled PAE!\n")); 1710 break; 1711 1712 case CPUMCPUIDFEATURE_PAT: 1713 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1714 if (pLeaf) 1715 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_FEATURE_EDX_PAT; 1716 1717 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1718 if ( pLeaf 1719 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD) 1720 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_AMD_FEATURE_EDX_PAT; 1721 1722 pVM->cpum.s.GuestFeatures.fPat = 0; 1723 Log(("CPUM: ClearGuestCpuIdFeature: Disabled PAT!\n")); 1724 break; 1725 1726 case CPUMCPUIDFEATURE_LONG_MODE: 1727 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1728 if (pLeaf) 1729 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_EXT_FEATURE_EDX_LONG_MODE; 1730 pVM->cpum.s.GuestFeatures.fLongMode = 0; 1731 break; 1732 1733 case CPUMCPUIDFEATURE_LAHF: 1734 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1735 if (pLeaf) 1736 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEcx = pLeaf->uEcx &= ~X86_CPUID_EXT_FEATURE_ECX_LAHF_SAHF; 1737 pVM->cpum.s.GuestFeatures.fLahfSahf = 0; 1738 break; 1739 1740 case CPUMCPUIDFEATURE_RDTSCP: 1741 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 1742 if (pLeaf) 1743 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_EXT_FEATURE_EDX_RDTSCP; 1744 pVM->cpum.s.GuestFeatures.fRdTscP = 0; 1745 Log(("CPUM: ClearGuestCpuIdFeature: Disabled RDTSCP!\n")); 1746 break; 1747 1748 case CPUMCPUIDFEATURE_HVP: 1749 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1750 if (pLeaf) 1751 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEcx = pLeaf->uEcx &= ~X86_CPUID_FEATURE_ECX_HVP; 1752 pVM->cpum.s.GuestFeatures.fHypervisorPresent = 0; 1753 break; 1754 1755 case CPUMCPUIDFEATURE_MWAIT_EXTS: 1756 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000005)); 1757 if (pLeaf) 1758 pVM->cpum.s.aGuestCpuIdPatmStd[5].uEcx = pLeaf->uEcx &= ~(X86_CPUID_MWAIT_ECX_EXT | X86_CPUID_MWAIT_ECX_BREAKIRQIF0); 1759 pVM->cpum.s.GuestFeatures.fMWaitExtensions = 0; 1760 Log(("CPUM: ClearGuestCpuIdFeature: Disabled MWAIT Extensions!\n")); 1761 break; 1762 1763 /* 1764 * OSXSAVE - only used from CPUMSetGuestCR4. 1765 */ 1766 case CPUMCPUIDFEATURE_OSXSAVE: 1767 AssertLogRelReturnVoid(pVM->cpum.s.HostFeatures.fXSaveRstor && pVM->cpum.s.HostFeatures.fOpSysXSaveRstor); 1768 1769 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 1770 AssertLogRelReturnVoid(pLeaf); 1771 1772 /* UNI: Special case for single CPU to make life easy for CPUMPatchHlpCpuId. */ 1773 if (pVM->cCpus == 1) 1774 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEcx = pLeaf->uEcx &= ~X86_CPUID_FEATURE_ECX_OSXSAVE; 1775 /* else: SMP: We never set the OSXSAVE bit and leaving the CONTAINS_OSXSAVE flag is fine. */ 1776 break; 1777 1778 1779 default: 1780 AssertMsgFailed(("enmFeature=%d\n", enmFeature)); 1781 break; 1782 } 1783 1784 for (VMCPUID i = 0; i < pVM->cCpus; i++) 1785 { 1786 PVMCPU pVCpu = &pVM->aCpus[i]; 1787 pVCpu->cpum.s.fChanged |= CPUM_CHANGED_CPUID; 1788 } 1405 1406 return fOld; 1789 1407 } 1790 1408 -
trunk/src/VBox/VMM/VMMAll/EMAll.cpp
r60915 r61776 1274 1274 uint32_t uCR4 = CPUMGetGuestCR4(pVCpu); 1275 1275 1276 if (! CPUMGetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_RDTSCP))1276 if (!pVM->cpum.ro.GuestFeatures.fRdTscP) 1277 1277 { 1278 1278 AssertFailed(); -
trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp
r61735 r61776 647 647 648 648 649 /** @interface_method_impl{PDMAPICHLPR0,pfnChangeFeature} */650 static DECLCALLBACK(void) pdmR0ApicHlp_ChangeFeature(PPDMDEVINS pDevIns, PDMAPICMODE enmMode)651 {652 PDMDEV_ASSERT_DEVINS(pDevIns);653 LogFlow(("pdmR0ApicHlp_ChangeFeature: caller=%p/%d: mode=%d\n", pDevIns, pDevIns->iInstance, (int)enmMode));654 switch (enmMode)655 {656 case PDMAPICMODE_NONE:657 CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_APIC);658 CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_X2APIC);659 break;660 case PDMAPICMODE_APIC:661 CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_APIC);662 CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_X2APIC);663 break;664 case PDMAPICMODE_X2APIC:665 CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_X2APIC);666 CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMR0, CPUMCPUIDFEATURE_APIC);667 break;668 default:669 AssertMsgFailed(("Unknown APIC mode: %d\n", (int)enmMode));670 }671 }672 673 674 649 /** @interface_method_impl{PDMAPICHLPR0,pfnLock} */ 675 650 static DECLCALLBACK(int) pdmR0ApicHlp_Lock(PPDMDEVINS pDevIns, int rc) … … 706 681 pdmR0ApicHlp_BusBroadcastEoi, 707 682 pdmR0ApicHlp_CalcIrqTag, 708 pdmR0ApicHlp_ChangeFeature,709 683 pdmR0ApicHlp_Lock, 710 684 pdmR0ApicHlp_Unlock, -
trunk/src/VBox/VMM/VMMR3/APIC.cpp
r61769 r61776 262 262 PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu); 263 263 PAPIC pApic = VM_TO_APIC(pVCpu->CTX_SUFF(pVM)); 264 uint64_t uApicBaseMsr = MSR_IA32_APICBASE_ADDR; ;264 uint64_t uApicBaseMsr = MSR_IA32_APICBASE_ADDR; 265 265 if (pVCpu->idCpu == 0) 266 266 uApicBaseMsr |= MSR_IA32_APICBASE_BSP; 267 267 268 /* If the VM was configured with disabled mode, don't enable xAPIC mode. */269 if (pApic->enm OriginalMode != APICMODE_DISABLED)268 /* If the VM was configured with no APIC, don't enable xAPIC mode, obviously. */ 269 if (pApic->enmMaxMode != PDMAPICMODE_NONE) 270 270 { 271 271 uApicBaseMsr |= MSR_IA32_APICBASE_EN; … … 276 276 * See Intel spec. 10.12.5.1 "x2APIC States". 277 277 */ 278 /** @todo CPUID bits needs to be done on a per-VCPU basis! */ 279 if (!CPUMGetGuestCpuIdFeature(pVCpu->CTX_SUFF(pVM), CPUMCPUIDFEATURE_APIC)) 280 { 278 if (CPUMSetGuestCpuIdPerCpuApicFeature(pVCpu, true /*fVisible*/) == false) 281 279 LogRel(("APIC%u: Resetting mode to xAPIC\n", pVCpu->idCpu)); 282 CPUMSetGuestCpuIdFeature(pVCpu->CTX_SUFF(pVM), CPUMCPUIDFEATURE_APIC);283 }284 280 } 285 281 … … 773 769 774 770 775 /**776 * Converts legacy PDMAPICMODE to the new APICMODE enum.777 *778 * @returns The new APIC mode.779 * @param enmLegacyMode The legacy mode to convert.780 */781 static APICMODE apicR3ConvertFromLegacyApicMode(PDMAPICMODE enmLegacyMode)782 {783 switch (enmLegacyMode)784 {785 case PDMAPICMODE_NONE: return APICMODE_DISABLED;786 case PDMAPICMODE_APIC: return APICMODE_XAPIC;787 case PDMAPICMODE_X2APIC: return APICMODE_X2APIC;788 case PDMAPICMODE_INVALID: return APICMODE_INVALID;789 default: break;790 }791 return (APICMODE)enmLegacyMode;792 }793 794 795 /**796 * Converts the new APICMODE enum to the legacy PDMAPICMODE enum.797 *798 * @returns The legacy APIC mode.799 * @param enmMode The APIC mode to convert.800 */801 static PDMAPICMODE apicR3ConvertToLegacyApicMode(APICMODE enmMode)802 {803 switch (enmMode)804 {805 case APICMODE_DISABLED: return PDMAPICMODE_NONE;806 case APICMODE_XAPIC: return PDMAPICMODE_APIC;807 case APICMODE_X2APIC: return PDMAPICMODE_X2APIC;808 case APICMODE_INVALID: return PDMAPICMODE_INVALID;809 default: break;810 }811 return (PDMAPICMODE)enmMode;812 }813 814 815 771 #ifdef APIC_FUZZY_SSM_COMPAT_TEST 772 816 773 /** 817 774 * Reads a 32-bit register at a specified offset. … … 923 880 } 924 881 } 882 925 883 #endif /* APIC_FUZZY_SSM_COMPAT_TEST */ 926 927 884 928 885 /** … … 938 895 SSMR3PutU32(pSSM, pVM->cCpus); 939 896 SSMR3PutBool(pSSM, pApic->fIoApicPresent); 940 return SSMR3PutU32(pSSM, apicR3ConvertToLegacyApicMode(pApic->enmOriginalMode));897 return SSMR3PutU32(pSSM, pApic->enmMaxMode); 941 898 } 942 899 … … 968 925 fIoApicPresent, pApic->fIoApicPresent); 969 926 970 /* Load and verify configured APIC mode. */971 uint32_t u LegacyApicMode;972 rc = SSMR3GetU32(pSSM, &u LegacyApicMode);927 /* Load and verify configured max APIC mode. */ 928 uint32_t uSavedMaxApicMode; 929 rc = SSMR3GetU32(pSSM, &uSavedMaxApicMode); 973 930 AssertRCReturn(rc, rc); 974 APICMODE const enmApicMode = apicR3ConvertFromLegacyApicMode((PDMAPICMODE)uLegacyApicMode); 975 if (enmApicMode != pApic->enmOriginalMode) 976 return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - uApicMode: saved=%u (%u) config=%u (%u)"), 977 uLegacyApicMode, enmApicMode, apicR3ConvertToLegacyApicMode(pApic->enmOriginalMode), 978 pApic->enmOriginalMode); 931 if (uSavedMaxApicMode != pApic->enmMaxMode) 932 return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - uApicMode: saved=%u config=%u"), 933 uSavedMaxApicMode, pApic->enmMaxMode); 979 934 return VINF_SUCCESS; 980 935 } … … 1205 1160 PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu); 1206 1161 1162 /** @todo r=bird: This is reckless saved state version handling that will break as soon as APIC_SAVED_STATE_VERSION 1163 * is bumped the next time. You should test: uVersion > APIC_SAVED_STATE_VERSION_VBOX_50 1164 * or alternativly always name the new version and do the test: uVersion >= APIC_SAVED_STATE_VERSION_VBOX_51_BETA2 */ 1207 1165 if ( uVersion == APIC_SAVED_STATE_VERSION 1208 1166 || uVersion == APIC_SAVED_STATE_VERSION_VBOX_51_BETA2) … … 1243 1201 AssertRCReturn(rc, rc); 1244 1202 } 1203 1204 /* 1205 * Check that we're still good wrt restored data, then tell CPUM about the current CPUID[1].EDX[9] visibility. 1206 */ 1207 rc = SSMR3HandleGetStatus(pSSM); 1208 AssertRCReturn(rc, rc); 1209 CPUMSetGuestCpuIdPerCpuApicFeature(pVCpu, RT_BOOL(pApicCpu->uApicBaseMsr & MSR_IA32_APICBASE_EN)); 1245 1210 1246 1211 #if defined(APIC_FUZZY_SSM_COMPAT_TEST) || defined(DEBUG_ramshankar) … … 1629 1594 1630 1595 /* 1596 * Init the data. 1597 */ 1598 pApicDev->pDevInsR3 = pDevIns; 1599 pApicDev->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 1600 pApicDev->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 1601 1602 pApic->pApicDevR0 = PDMINS_2_DATA_R0PTR(pDevIns); 1603 pApic->pApicDevR3 = (PAPICDEV)PDMINS_2_DATA_R3PTR(pDevIns); 1604 pApic->pApicDevRC = PDMINS_2_DATA_RCPTR(pDevIns); 1605 1606 /* 1631 1607 * Validate APIC settings. 1632 1608 */ … … 1646 1622 AssertLogRelRCReturn(rc, rc); 1647 1623 1648 uint8_t uOriginalMode; 1649 rc = CFGMR3QueryU8Def(pCfg, "Mode", &uOriginalMode, APICMODE_XAPIC); 1624 /* Max APIC feature level. */ 1625 uint8_t uMaxMode; 1626 rc = CFGMR3QueryU8Def(pCfg, "Mode", &uMaxMode, PDMAPICMODE_APIC); 1650 1627 AssertLogRelRCReturn(rc, rc); 1651 1652 /* Validate APIC modes. */ 1653 APICMODE const enmOriginalMode = (APICMODE)uOriginalMode; 1654 switch (enmOriginalMode) 1655 { 1656 case APICMODE_DISABLED: 1657 { 1628 switch ((PDMAPICMODE)uMaxMode) 1629 { 1630 case PDMAPICMODE_NONE: 1631 #if 1 1658 1632 /** @todo permanently disabling the APIC won't really work (needs 1659 1633 * fixing in HM, CPUM, PDM and possibly other places). See 1660 1634 * @bugref{8353}. */ 1661 #if 0 1662 pApic->enmOriginalMode = enmOriginalMode; 1663 CPUMClearGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_APIC);1664 CPUMClearGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_X2APIC);1635 return VMR3SetError(pVM->pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS, "APIC mode 'none' is not supported yet."); 1636 #endif 1637 case PDMAPICMODE_APIC: 1638 case PDMAPICMODE_X2APIC: 1665 1639 break; 1666 #else1667 return VMR3SetError(pVM->pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS, "APIC mode 'disabled' is not supported yet.");1668 #endif1669 }1670 1671 case APICMODE_X2APIC:1672 {1673 pApic->enmOriginalMode = enmOriginalMode;1674 CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_X2APIC);1675 1676 /* Insert the MSR range of the x2APIC. */1677 rc = CPUMR3MsrRangesInsert(pVM, &g_MsrRange_x2Apic);1678 AssertLogRelRCReturn(rc, rc);1679 break;1680 }1681 1682 case APICMODE_XAPIC:1683 pApic->enmOriginalMode = enmOriginalMode;1684 /* The CPUID bit will be updated in apicR3ResetBaseMsr(). */1685 break;1686 1687 1640 default: 1688 return VMR3SetError(pVM->pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS, "APIC mode %#x unknown.", uOriginalMode); 1689 } 1690 1691 /* 1692 * Initialize the APIC state. 1693 */ 1694 pApicDev->pDevInsR3 = pDevIns; 1695 pApicDev->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns); 1696 pApicDev->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns); 1697 1698 pApic->pApicDevR0 = PDMINS_2_DATA_R0PTR(pDevIns); 1699 pApic->pApicDevR3 = (PAPICDEV)PDMINS_2_DATA_R3PTR(pDevIns); 1700 pApic->pApicDevRC = PDMINS_2_DATA_RCPTR(pDevIns); 1701 1702 rc = apicR3InitState(pVM); 1703 AssertRCReturn(rc, rc); 1641 return VMR3SetError(pVM->pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS, "APIC mode %d unknown.", uMaxMode); 1642 } 1643 pApic->enmMaxMode = (PDMAPICMODE)uMaxMode; 1704 1644 1705 1645 /* … … 1710 1650 1711 1651 /* 1712 * Register the APIC .1652 * Register the APIC with PDM. 1713 1653 */ 1714 1654 PDMAPICREG ApicReg; … … 1758 1698 AssertLogRelRCReturn(rc, rc); 1759 1699 pApicDev->pCritSectR3 = pApicDev->pApicHlpR3->pfnGetR3CritSect(pDevIns); 1700 1701 /* 1702 * Initialize the APIC state. 1703 */ 1704 /* First insert the MSR range of the x2APIC if enabled. */ 1705 if (pApic->enmMaxMode == PDMAPICMODE_X2APIC) 1706 { 1707 rc = CPUMR3MsrRangesInsert(pVM, &g_MsrRange_x2Apic); 1708 AssertLogRelRCReturn(rc, rc); 1709 } 1710 1711 /* Tell CPUM about the APIC feature level so it can adjust APICBASE MSR GP mask and CPUID bits. */ 1712 pApicDev->pApicHlpR3->pfnSetFeatureLevel(pDevIns, pApic->enmMaxMode); 1713 1714 /* Initialize the state. */ 1715 rc = apicR3InitState(pVM); 1716 AssertRCReturn(rc, rc); 1760 1717 1761 1718 /* -
trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp
r60996 r61776 1188 1188 fFlags |= CPUMCPUIDLEAF_F_CONTAINS_APIC_ID; 1189 1189 1190 /* The APIC bit is per-VCpu and needs flagging. */ 1191 if (uLeaf == 1) 1192 fFlags |= CPUMCPUIDLEAF_F_CONTAINS_APIC; 1193 else if ( uLeaf == UINT32_C(0x80000001) 1194 && ( (uEdx & X86_CPUID_AMD_FEATURE_EDX_APIC) 1195 || ASMIsAmdCpuEx((*ppaLeaves)[0].uEbx, (*ppaLeaves)[0].uEcx, (*ppaLeaves)[0].uEdx)) ) 1196 fFlags |= CPUMCPUIDLEAF_F_CONTAINS_APIC; 1190 1197 1191 1198 /* Check three times here to reduce the chance of CPU migration … … 3144 3151 * Clear them all as we don't currently implement extended CPU state. 3145 3152 */ 3146 /* Figure out the supported XCR0/XSS mask component . */3153 /* Figure out the supported XCR0/XSS mask component and make sure CPUID[1].ECX[27] = CR4.OSXSAVE. */ 3147 3154 uint64_t fGuestXcr0Mask = 0; 3148 3155 pStdFeatureLeaf = cpumR3CpuIdGetExactLeaf(pCpum, 1, 0); … … 3156 3163 fGuestXcr0Mask |= XSAVE_C_ZMM_16HI | XSAVE_C_ZMM_HI256 | XSAVE_C_OPMASK; 3157 3164 fGuestXcr0Mask &= pCpum->fXStateHostMask; 3165 3166 pStdFeatureLeaf->fFlags |= CPUMCPUIDLEAF_F_CONTAINS_OSXSAVE; 3158 3167 } 3159 3168 pStdFeatureLeaf = NULL; … … 3957 3966 3958 3967 /* 3968 * Set the fCpuIdApicFeatureVisible flags so the APIC can assume visibility 3969 * on construction and manage everything from here on. 3970 */ 3971 for (VMCPUID iCpu = 0; iCpu < pVM->cCpus; iCpu++) 3972 pVM->aCpus[iCpu].cpum.s.fCpuIdApicFeatureVisible = true; 3973 3974 /* 3959 3975 * Read the configuration. 3960 3976 */ … … 4072 4088 AssertRCReturn(rc, rc); 4073 4089 if (fEnable) 4074 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);4090 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE); 4075 4091 4076 4092 /* We don't normally enable NX for raw-mode, so give the user a chance to force it on. */ … … 4078 4094 AssertRCReturn(rc, rc); 4079 4095 if (fEnable) 4080 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);4096 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX); 4081 4097 4082 4098 /* We don't enable the Hypervisor Present bit by default, but it may be needed by some guests. */ … … 4084 4100 AssertRCReturn(rc, rc); 4085 4101 if (fEnable) 4086 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);4102 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP); 4087 4103 4088 4104 return VINF_SUCCESS; … … 4097 4113 pCpum->GuestInfo.paMsrRangesR3 = NULL; 4098 4114 return rc; 4115 } 4116 4117 4118 /** 4119 * Sets a CPUID feature bit during VM initialization. 4120 * 4121 * Since the CPUID feature bits are generally related to CPU features, other 4122 * CPUM configuration like MSRs can also be modified by calls to this API. 4123 * 4124 * @param pVM The cross context VM structure. 4125 * @param enmFeature The feature to set. 4126 */ 4127 VMMR3_INT_DECL(void) CPUMR3SetGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature) 4128 { 4129 PCPUMCPUIDLEAF pLeaf; 4130 PCPUMMSRRANGE pMsrRange; 4131 4132 switch (enmFeature) 4133 { 4134 /* 4135 * Set the APIC bit in both feature masks. 4136 */ 4137 case CPUMCPUIDFEATURE_APIC: 4138 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 4139 if (pLeaf && (pLeaf->fFlags & CPUMCPUIDLEAF_F_CONTAINS_APIC)) 4140 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx |= X86_CPUID_FEATURE_EDX_APIC; 4141 4142 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4143 if (pLeaf && (pLeaf->fFlags & CPUMCPUIDLEAF_F_CONTAINS_APIC)) 4144 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_AMD_FEATURE_EDX_APIC; 4145 4146 pVM->cpum.s.GuestFeatures.fApic = 1; 4147 4148 /* Make sure we've got the APICBASE MSR present. */ 4149 pMsrRange = cpumLookupMsrRange(pVM, MSR_IA32_APICBASE); 4150 if (!pMsrRange) 4151 { 4152 static CPUMMSRRANGE const s_ApicBase = 4153 { 4154 /*.uFirst =*/ MSR_IA32_APICBASE, /*.uLast =*/ MSR_IA32_APICBASE, 4155 /*.enmRdFn =*/ kCpumMsrRdFn_Ia32ApicBase, /*.enmWrFn =*/ kCpumMsrWrFn_Ia32ApicBase, 4156 /*.offCpumCpu =*/ UINT16_MAX, /*.fReserved =*/ 0, /*.uValue =*/ 0, /*.fWrIgnMask =*/ 0, /*.fWrGpMask =*/ 0, 4157 /*.szName = */ "IA32_APIC_BASE" 4158 }; 4159 int rc = CPUMR3MsrRangesInsert(pVM, &s_ApicBase); 4160 AssertLogRelRC(rc); 4161 RTLogPrintf("XXXX: CPUMCPUIDFEATURE_APIC !!!\n"); 4162 } 4163 else RTLogPrintf("XXXX: CPUMCPUIDFEATURE_APIC Gp=%RX64 Ign=%RX64\n", pMsrRange->fWrGpMask, pMsrRange->fWrIgnMask); 4164 4165 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled xAPIC\n")); 4166 break; 4167 4168 /* 4169 * Set the x2APIC bit in the standard feature mask. 4170 * Note! ASSUMES CPUMCPUIDFEATURE_APIC is called first. 4171 */ 4172 case CPUMCPUIDFEATURE_X2APIC: 4173 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 4174 if (pLeaf) 4175 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEcx = pLeaf->uEcx |= X86_CPUID_FEATURE_ECX_X2APIC; 4176 pVM->cpum.s.GuestFeatures.fX2Apic = 1; 4177 4178 /* Make sure the MSR doesn't GP or ignore the EXTD bit. */ 4179 pMsrRange = cpumLookupMsrRange(pVM, MSR_IA32_APICBASE); 4180 if (pMsrRange) 4181 { 4182 pMsrRange->fWrGpMask &= ~MSR_IA32_APICBASE_EXTD; 4183 pMsrRange->fWrIgnMask &= ~MSR_IA32_APICBASE_EXTD; 4184 } 4185 4186 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled x2APIC\n")); 4187 break; 4188 4189 /* 4190 * Set the sysenter/sysexit bit in the standard feature mask. 4191 * Assumes the caller knows what it's doing! (host must support these) 4192 */ 4193 case CPUMCPUIDFEATURE_SEP: 4194 if (!pVM->cpum.s.HostFeatures.fSysEnter) 4195 { 4196 AssertMsgFailed(("ERROR: Can't turn on SEP when the host doesn't support it!!\n")); 4197 return; 4198 } 4199 4200 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 4201 if (pLeaf) 4202 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx |= X86_CPUID_FEATURE_EDX_SEP; 4203 pVM->cpum.s.GuestFeatures.fSysEnter = 1; 4204 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled SYSENTER/EXIT\n")); 4205 break; 4206 4207 /* 4208 * Set the syscall/sysret bit in the extended feature mask. 4209 * Assumes the caller knows what it's doing! (host must support these) 4210 */ 4211 case CPUMCPUIDFEATURE_SYSCALL: 4212 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4213 if ( !pLeaf 4214 || !pVM->cpum.s.HostFeatures.fSysCall) 4215 { 4216 #if HC_ARCH_BITS == 32 4217 /* X86_CPUID_EXT_FEATURE_EDX_SYSCALL not set it seems in 32-bit 4218 mode by Intel, even when the cpu is capable of doing so in 4219 64-bit mode. Long mode requires syscall support. */ 4220 if (!pVM->cpum.s.HostFeatures.fLongMode) 4221 #endif 4222 { 4223 LogRel(("CPUM: WARNING! Can't turn on SYSCALL/SYSRET when the host doesn't support it!\n")); 4224 return; 4225 } 4226 } 4227 4228 /* Valid for both Intel and AMD CPUs, although only in 64 bits mode for Intel. */ 4229 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_EXT_FEATURE_EDX_SYSCALL; 4230 pVM->cpum.s.GuestFeatures.fSysCall = 1; 4231 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled SYSCALL/RET\n")); 4232 break; 4233 4234 /* 4235 * Set the PAE bit in both feature masks. 4236 * Assumes the caller knows what it's doing! (host must support these) 4237 */ 4238 case CPUMCPUIDFEATURE_PAE: 4239 if (!pVM->cpum.s.HostFeatures.fPae) 4240 { 4241 LogRel(("CPUM: WARNING! Can't turn on PAE when the host doesn't support it!\n")); 4242 return; 4243 } 4244 4245 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 4246 if (pLeaf) 4247 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx |= X86_CPUID_FEATURE_EDX_PAE; 4248 4249 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4250 if ( pLeaf 4251 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD) 4252 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_AMD_FEATURE_EDX_PAE; 4253 4254 pVM->cpum.s.GuestFeatures.fPae = 1; 4255 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled PAE\n")); 4256 break; 4257 4258 /* 4259 * Set the LONG MODE bit in the extended feature mask. 4260 * Assumes the caller knows what it's doing! (host must support these) 4261 */ 4262 case CPUMCPUIDFEATURE_LONG_MODE: 4263 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4264 if ( !pLeaf 4265 || !pVM->cpum.s.HostFeatures.fLongMode) 4266 { 4267 LogRel(("CPUM: WARNING! Can't turn on LONG MODE when the host doesn't support it!\n")); 4268 return; 4269 } 4270 4271 /* Valid for both Intel and AMD. */ 4272 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_EXT_FEATURE_EDX_LONG_MODE; 4273 pVM->cpum.s.GuestFeatures.fLongMode = 1; 4274 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled LONG MODE\n")); 4275 break; 4276 4277 /* 4278 * Set the NX/XD bit in the extended feature mask. 4279 * Assumes the caller knows what it's doing! (host must support these) 4280 */ 4281 case CPUMCPUIDFEATURE_NX: 4282 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4283 if ( !pLeaf 4284 || !pVM->cpum.s.HostFeatures.fNoExecute) 4285 { 4286 LogRel(("CPUM: WARNING! Can't turn on NX/XD when the host doesn't support it!\n")); 4287 return; 4288 } 4289 4290 /* Valid for both Intel and AMD. */ 4291 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_EXT_FEATURE_EDX_NX; 4292 pVM->cpum.s.GuestFeatures.fNoExecute = 1; 4293 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled NX\n")); 4294 break; 4295 4296 4297 /* 4298 * Set the LAHF/SAHF support in 64-bit mode. 4299 * Assumes the caller knows what it's doing! (host must support this) 4300 */ 4301 case CPUMCPUIDFEATURE_LAHF: 4302 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4303 if ( !pLeaf 4304 || !pVM->cpum.s.HostFeatures.fLahfSahf) 4305 { 4306 LogRel(("CPUM: WARNING! Can't turn on LAHF/SAHF when the host doesn't support it!\n")); 4307 return; 4308 } 4309 4310 /* Valid for both Intel and AMD. */ 4311 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEcx = pLeaf->uEcx |= X86_CPUID_EXT_FEATURE_ECX_LAHF_SAHF; 4312 pVM->cpum.s.GuestFeatures.fLahfSahf = 1; 4313 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled LAHF/SAHF\n")); 4314 break; 4315 4316 /* 4317 * Set the page attribute table bit. This is alternative page level 4318 * cache control that doesn't much matter when everything is 4319 * virtualized, though it may when passing thru device memory. 4320 */ 4321 case CPUMCPUIDFEATURE_PAT: 4322 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 4323 if (pLeaf) 4324 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx |= X86_CPUID_FEATURE_EDX_PAT; 4325 4326 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4327 if ( pLeaf 4328 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD) 4329 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_AMD_FEATURE_EDX_PAT; 4330 4331 pVM->cpum.s.GuestFeatures.fPat = 1; 4332 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled PAT\n")); 4333 break; 4334 4335 /* 4336 * Set the RDTSCP support bit. 4337 * Assumes the caller knows what it's doing! (host must support this) 4338 */ 4339 case CPUMCPUIDFEATURE_RDTSCP: 4340 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4341 if ( !pLeaf 4342 || !pVM->cpum.s.HostFeatures.fRdTscP 4343 || pVM->cpum.s.u8PortableCpuIdLevel > 0) 4344 { 4345 if (!pVM->cpum.s.u8PortableCpuIdLevel) 4346 LogRel(("CPUM: WARNING! Can't turn on RDTSCP when the host doesn't support it!\n")); 4347 return; 4348 } 4349 4350 /* Valid for both Intel and AMD. */ 4351 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx |= X86_CPUID_EXT_FEATURE_EDX_RDTSCP; 4352 pVM->cpum.s.HostFeatures.fRdTscP = 1; 4353 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled RDTSCP.\n")); 4354 break; 4355 4356 /* 4357 * Set the Hypervisor Present bit in the standard feature mask. 4358 */ 4359 case CPUMCPUIDFEATURE_HVP: 4360 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 4361 if (pLeaf) 4362 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEcx = pLeaf->uEcx |= X86_CPUID_FEATURE_ECX_HVP; 4363 pVM->cpum.s.GuestFeatures.fHypervisorPresent = 1; 4364 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled Hypervisor Present bit\n")); 4365 break; 4366 4367 /* 4368 * Set the MWAIT Extensions Present bit in the MWAIT/MONITOR leaf. 4369 * This currently includes the Present bit and MWAITBREAK bit as well. 4370 */ 4371 case CPUMCPUIDFEATURE_MWAIT_EXTS: 4372 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000005)); 4373 if ( !pLeaf 4374 || !pVM->cpum.s.HostFeatures.fMWaitExtensions) 4375 { 4376 LogRel(("CPUM: WARNING! Can't turn on MWAIT Extensions when the host doesn't support it!\n")); 4377 return; 4378 } 4379 4380 /* Valid for both Intel and AMD. */ 4381 pVM->cpum.s.aGuestCpuIdPatmStd[5].uEcx = pLeaf->uEcx |= X86_CPUID_MWAIT_ECX_EXT | X86_CPUID_MWAIT_ECX_BREAKIRQIF0; 4382 pVM->cpum.s.GuestFeatures.fMWaitExtensions = 1; 4383 LogRel(("CPUM: SetGuestCpuIdFeature: Enabled MWAIT Extensions.\n")); 4384 break; 4385 4386 default: 4387 AssertMsgFailed(("enmFeature=%d\n", enmFeature)); 4388 break; 4389 } 4390 4391 /** @todo can probably kill this as this API is now init time only... */ 4392 for (VMCPUID i = 0; i < pVM->cCpus; i++) 4393 { 4394 PVMCPU pVCpu = &pVM->aCpus[i]; 4395 pVCpu->cpum.s.fChanged |= CPUM_CHANGED_CPUID; 4396 } 4397 } 4398 4399 4400 /** 4401 * Queries a CPUID feature bit. 4402 * 4403 * @returns boolean for feature presence 4404 * @param pVM The cross context VM structure. 4405 * @param enmFeature The feature to query. 4406 * @deprecated Use the cpum.ro.GuestFeatures directly instead. 4407 */ 4408 VMMR3_INT_DECL(bool) CPUMR3GetGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature) 4409 { 4410 switch (enmFeature) 4411 { 4412 case CPUMCPUIDFEATURE_APIC: return pVM->cpum.s.GuestFeatures.fApic; 4413 case CPUMCPUIDFEATURE_X2APIC: return pVM->cpum.s.GuestFeatures.fX2Apic; 4414 case CPUMCPUIDFEATURE_SYSCALL: return pVM->cpum.s.GuestFeatures.fSysCall; 4415 case CPUMCPUIDFEATURE_SEP: return pVM->cpum.s.GuestFeatures.fSysEnter; 4416 case CPUMCPUIDFEATURE_PAE: return pVM->cpum.s.GuestFeatures.fPae; 4417 case CPUMCPUIDFEATURE_NX: return pVM->cpum.s.GuestFeatures.fNoExecute; 4418 case CPUMCPUIDFEATURE_LAHF: return pVM->cpum.s.GuestFeatures.fLahfSahf; 4419 case CPUMCPUIDFEATURE_LONG_MODE: return pVM->cpum.s.GuestFeatures.fLongMode; 4420 case CPUMCPUIDFEATURE_PAT: return pVM->cpum.s.GuestFeatures.fPat; 4421 case CPUMCPUIDFEATURE_RDTSCP: return pVM->cpum.s.GuestFeatures.fRdTscP; 4422 case CPUMCPUIDFEATURE_HVP: return pVM->cpum.s.GuestFeatures.fHypervisorPresent; 4423 case CPUMCPUIDFEATURE_MWAIT_EXTS: return pVM->cpum.s.GuestFeatures.fMWaitExtensions; 4424 4425 case CPUMCPUIDFEATURE_INVALID: 4426 case CPUMCPUIDFEATURE_32BIT_HACK: 4427 break; 4428 } 4429 AssertFailed(); 4430 return false; 4431 } 4432 4433 4434 /** 4435 * Clears a CPUID feature bit. 4436 * 4437 * @param pVM The cross context VM structure. 4438 * @param enmFeature The feature to clear. 4439 * 4440 * @deprecated Probably better to default the feature to disabled and only allow 4441 * setting (enabling) it during construction. 4442 */ 4443 VMMR3_INT_DECL(void) CPUMR3ClearGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature) 4444 { 4445 PCPUMCPUIDLEAF pLeaf; 4446 switch (enmFeature) 4447 { 4448 case CPUMCPUIDFEATURE_APIC: 4449 Assert(!pVM->cpum.s.GuestFeatures.fApic); /* We only expect this call during init. No MSR adjusting needed. */ 4450 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 4451 if (pLeaf) 4452 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_FEATURE_EDX_APIC; 4453 4454 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4455 if (pLeaf && (pLeaf->fFlags & CPUMCPUIDLEAF_F_CONTAINS_APIC)) 4456 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_AMD_FEATURE_EDX_APIC; 4457 4458 pVM->cpum.s.GuestFeatures.fApic = 0; 4459 Log(("CPUM: ClearGuestCpuIdFeature: Disabled xAPIC\n")); 4460 break; 4461 4462 case CPUMCPUIDFEATURE_X2APIC: 4463 Assert(!pVM->cpum.s.GuestFeatures.fX2Apic); /* We only expect this call during init. No MSR adjusting needed. */ 4464 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 4465 if (pLeaf) 4466 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEcx = pLeaf->uEcx &= ~X86_CPUID_FEATURE_ECX_X2APIC; 4467 pVM->cpum.s.GuestFeatures.fX2Apic = 0; 4468 Log(("CPUM: ClearGuestCpuIdFeature: Disabled x2APIC\n")); 4469 break; 4470 4471 case CPUMCPUIDFEATURE_PAE: 4472 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 4473 if (pLeaf) 4474 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_FEATURE_EDX_PAE; 4475 4476 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4477 if ( pLeaf 4478 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD) 4479 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_AMD_FEATURE_EDX_PAE; 4480 4481 pVM->cpum.s.GuestFeatures.fPae = 0; 4482 Log(("CPUM: ClearGuestCpuIdFeature: Disabled PAE!\n")); 4483 break; 4484 4485 case CPUMCPUIDFEATURE_PAT: 4486 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 4487 if (pLeaf) 4488 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_FEATURE_EDX_PAT; 4489 4490 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4491 if ( pLeaf 4492 && pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD) 4493 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_AMD_FEATURE_EDX_PAT; 4494 4495 pVM->cpum.s.GuestFeatures.fPat = 0; 4496 Log(("CPUM: ClearGuestCpuIdFeature: Disabled PAT!\n")); 4497 break; 4498 4499 case CPUMCPUIDFEATURE_LONG_MODE: 4500 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4501 if (pLeaf) 4502 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_EXT_FEATURE_EDX_LONG_MODE; 4503 pVM->cpum.s.GuestFeatures.fLongMode = 0; 4504 break; 4505 4506 case CPUMCPUIDFEATURE_LAHF: 4507 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4508 if (pLeaf) 4509 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEcx = pLeaf->uEcx &= ~X86_CPUID_EXT_FEATURE_ECX_LAHF_SAHF; 4510 pVM->cpum.s.GuestFeatures.fLahfSahf = 0; 4511 break; 4512 4513 case CPUMCPUIDFEATURE_RDTSCP: 4514 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x80000001)); 4515 if (pLeaf) 4516 pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx = pLeaf->uEdx &= ~X86_CPUID_EXT_FEATURE_EDX_RDTSCP; 4517 pVM->cpum.s.GuestFeatures.fRdTscP = 0; 4518 Log(("CPUM: ClearGuestCpuIdFeature: Disabled RDTSCP!\n")); 4519 break; 4520 4521 case CPUMCPUIDFEATURE_HVP: 4522 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000001)); 4523 if (pLeaf) 4524 pVM->cpum.s.aGuestCpuIdPatmStd[1].uEcx = pLeaf->uEcx &= ~X86_CPUID_FEATURE_ECX_HVP; 4525 pVM->cpum.s.GuestFeatures.fHypervisorPresent = 0; 4526 break; 4527 4528 case CPUMCPUIDFEATURE_MWAIT_EXTS: 4529 pLeaf = cpumCpuIdGetLeaf(pVM, UINT32_C(0x00000005)); 4530 if (pLeaf) 4531 pVM->cpum.s.aGuestCpuIdPatmStd[5].uEcx = pLeaf->uEcx &= ~(X86_CPUID_MWAIT_ECX_EXT | X86_CPUID_MWAIT_ECX_BREAKIRQIF0); 4532 pVM->cpum.s.GuestFeatures.fMWaitExtensions = 0; 4533 Log(("CPUM: ClearGuestCpuIdFeature: Disabled MWAIT Extensions!\n")); 4534 break; 4535 4536 default: 4537 AssertMsgFailed(("enmFeature=%d\n", enmFeature)); 4538 break; 4539 } 4540 4541 for (VMCPUID i = 0; i < pVM->cCpus; i++) 4542 { 4543 PVMCPU pVCpu = &pVM->aCpus[i]; 4544 pVCpu->cpum.s.fChanged |= CPUM_CHANGED_CPUID; 4545 } 4099 4546 } 4100 4547 -
trunk/src/VBox/VMM/VMMR3/GIMHv.cpp
r61771 r61776 330 330 * Expose HVP (Hypervisor Present) bit to the guest. 331 331 */ 332 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);332 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP); 333 333 334 334 /* -
trunk/src/VBox/VMM/VMMR3/GIMKvm.cpp
r61632 r61776 121 121 * Expose HVP (Hypervisor Present) bit to the guest. 122 122 */ 123 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);123 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP); 124 124 125 125 /* -
trunk/src/VBox/VMM/VMMR3/GIMMinimal.cpp
r61632 r61776 52 52 * Enable the Hypervisor Present. 53 53 */ 54 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);54 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP); 55 55 56 56 return VINF_SUCCESS; -
trunk/src/VBox/VMM/VMMR3/HM.cpp
r61763 r61776 1404 1404 */ 1405 1405 if ( !(pVM->hm.s.vmx.Msrs.VmxProcCtls.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC_USE_SECONDARY_EXEC_CTRL) 1406 && CPUM GetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_RDTSCP))1407 { 1408 CPUM ClearGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_RDTSCP);1406 && CPUMR3GetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_RDTSCP)) 1407 { 1408 CPUMR3ClearGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_RDTSCP); 1409 1409 LogRel(("HM: Disabled RDTSCP\n")); 1410 1410 } … … 1500 1500 * Change the CPU features. 1501 1501 */ 1502 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);1502 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP); 1503 1503 if (pVM->hm.s.fAllow64BitGuests) 1504 1504 { 1505 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);1506 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);1507 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL); /* 64 bits only on Intel CPUs */1508 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);1509 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);1505 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE); 1506 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE); 1507 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL); /* 64 bits only on Intel CPUs */ 1508 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF); 1509 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX); 1510 1510 } 1511 1511 /* Turn on NXE if PAE has been enabled *and* the host has turned on NXE 1512 1512 (we reuse the host EFER in the switcher). */ 1513 1513 /** @todo this needs to be fixed properly!! */ 1514 else if (CPUM GetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE))1514 else if (CPUMR3GetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE)) 1515 1515 { 1516 1516 if (pVM->hm.s.vmx.u64HostEfer & MSR_K6_EFER_NXE) 1517 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);1517 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX); 1518 1518 else 1519 1519 LogRel(("HM: NX not enabled on the host, unavailable to PAE guest\n")); … … 1694 1694 * Change the CPU features. 1695 1695 */ 1696 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);1697 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);1696 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP); 1697 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL); 1698 1698 if (pVM->hm.s.fAllow64BitGuests) 1699 1699 { 1700 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);1701 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);1702 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);1703 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);1700 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE); 1701 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE); 1702 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX); 1703 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF); 1704 1704 } 1705 1705 /* Turn on NXE if PAE has been enabled. */ 1706 else if (CPUM GetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE))1707 CPUM SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);1706 else if (CPUMR3GetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE)) 1707 CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX); 1708 1708 1709 1709 LogRel(("HM: %s TPR patching\n", (pVM->hm.s.fTprPatchingAllowed) ? "Enabled" : "Disabled")); -
trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp
r61735 r61776 311 311 312 312 313 /** @interface_method_impl{PDMAPICHLPR3,pfnChangeFeature} */ 314 static DECLCALLBACK(void) pdmR3ApicHlp_ChangeFeature(PPDMDEVINS pDevIns, PDMAPICMODE enmMode) 315 { 316 #ifdef VBOX_WITH_NEW_APIC 317 /* 318 * The old code is also most likely incorrect with regards to changing the CPUID bits, 319 * see @bugref{8245#c32}. 320 * 321 * The new code should directly invoke APICUpdateCpuIdForMode() instead of using this 322 * indirect helper. 323 */ 324 AssertMsgFailed(("pdmR3ApicHlp_ChangeFeature unsupported in VBOX_WITH_NEW_APIC!")); 325 #else 326 PDMDEV_ASSERT_DEVINS(pDevIns); 327 LogFlow(("pdmR3ApicHlp_ChangeFeature: caller='%s'/%d: mode=%d\n", 313 /** @interface_method_impl{PDMAPICHLPR3,pfnSetFeatureLevel} */ 314 static DECLCALLBACK(void) pdmR3ApicHlp_SetFeatureLevel(PPDMDEVINS pDevIns, PDMAPICMODE enmMode) 315 { 316 PDMDEV_ASSERT_DEVINS(pDevIns); 317 LogFlow(("pdmR3ApicHlp_SetFeatureLevel: caller='%s'/%d: mode=%d\n", 328 318 pDevIns->pReg->szName, pDevIns->iInstance, (int)enmMode)); 329 319 switch (enmMode) 330 320 { 331 321 case PDMAPICMODE_NONE: 332 CPUM ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);333 CPUM ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);322 CPUMR3ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC); 323 CPUMR3ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC); 334 324 break; 335 325 case PDMAPICMODE_APIC: 336 CPUM SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);337 CPUM ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);326 CPUMR3ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC); 327 CPUMR3SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC); 338 328 break; 339 329 case PDMAPICMODE_X2APIC: 340 CPUM SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);341 CPUM SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);330 CPUMR3SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC); 331 CPUMR3SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC); 342 332 break; 343 333 default: 344 334 AssertMsgFailed(("Unknown APIC mode: %d\n", (int)enmMode)); 345 335 } 346 #endif347 336 } 348 337 … … 453 442 pdmR3ApicHlp_BusBroadcastEoi, 454 443 pdmR3ApicHlp_CalcIrqTag, 455 pdmR3ApicHlp_ ChangeFeature,444 pdmR3ApicHlp_SetFeatureLevel, 456 445 pdmR3ApicHlp_GetCpuId, 457 446 pdmR3ApicHlp_SendStartupIpi, -
trunk/src/VBox/VMM/VMMR3/cpus/AMD_Athlon_64_3200.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x68747541, 0x444d4163, 0x69746e65, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x00000f48, 0x00000800, 0x00000000, 0x078bfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x00000f48, 0x00000800, 0x00000000, 0x078bfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x80000000, 0x00000000, 0x00000000, 0x80000018, 0x68747541, 0x444d4163, 0x69746e65, 0 }, 32 { 0x80000001, 0x00000000, 0x00000000, 0x00000f48, 0x0000010a, 0x00000000, 0xe1d3fbff, 0 },32 { 0x80000001, 0x00000000, 0x00000000, 0x00000f48, 0x0000010a, 0x00000000, 0xe1d3fbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 33 33 { 0x80000002, 0x00000000, 0x00000000, 0x20444d41, 0x6c687441, 0x74286e6f, 0x3620296d, 0 }, 34 34 { 0x80000003, 0x00000000, 0x00000000, 0x72502034, 0x7365636f, 0x20726f73, 0x30303233, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/AMD_Athlon_64_X2_Dual_Core_4200.h
r54737 r61776 33 33 { 34 34 { 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x68747541, 0x444d4163, 0x69746e65, 0 }, 35 { 0x00000001, 0x00000000, 0x00000000, 0x00040fb2, 0x01020800, 0x00002001, 0x178bfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },35 { 0x00000001, 0x00000000, 0x00000000, 0x00040fb2, 0x01020800, 0x00002001, 0x178bfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 36 36 { 0x80000000, 0x00000000, 0x00000000, 0x80000018, 0x68747541, 0x444d4163, 0x69746e65, 0 }, 37 { 0x80000001, 0x00000000, 0x00000000, 0x00040fb2, 0x000008d1, 0x0000001f, 0xebd3fbff, 0 },37 { 0x80000001, 0x00000000, 0x00000000, 0x00040fb2, 0x000008d1, 0x0000001f, 0xebd3fbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 38 38 { 0x80000002, 0x00000000, 0x00000000, 0x20444d41, 0x6c687441, 0x74286e6f, 0x3620296d, 0 }, 39 39 { 0x80000003, 0x00000000, 0x00000000, 0x32582034, 0x61754420, 0x6f43206c, 0x50206572, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/AMD_FX_8150_Eight_Core.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x0000000d, 0x68747541, 0x444d4163, 0x69746e65, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x00600f12, 0x02080800, 0x1e98220b, 0x178bfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x00600f12, 0x02080800, 0x1e98220b, 0x178bfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, … … 43 43 { 0x0000000d, 0x00000001, UINT32_MAX, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, 44 44 { 0x80000000, 0x00000000, 0x00000000, 0x8000001e, 0x68747541, 0x444d4163, 0x69746e65, 0 }, 45 { 0x80000001, 0x00000000, 0x00000000, 0x00600f12, 0x10000000, 0x01c9bfff, 0x2fd3fbff, 0 },45 { 0x80000001, 0x00000000, 0x00000000, 0x00600f12, 0x10000000, 0x01c9bfff, 0x2fd3fbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 46 46 { 0x80000002, 0x00000000, 0x00000000, 0x20444d41, 0x74285846, 0x382d296d, 0x20303531, 0 }, 47 47 { 0x80000003, 0x00000000, 0x00000000, 0x68676945, 0x6f432d74, 0x50206572, 0x65636f72, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/AMD_Phenom_II_X6_1100T.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x00000006, 0x68747541, 0x444d4163, 0x69746e65, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x00100fa0, 0x01060800, 0x00802009, 0x178bfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x00100fa0, 0x01060800, 0x00802009, 0x178bfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, … … 35 35 { 0x00000006, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0 }, 36 36 { 0x80000000, 0x00000000, 0x00000000, 0x8000001b, 0x68747541, 0x444d4163, 0x69746e65, 0 }, 37 { 0x80000001, 0x00000000, 0x00000000, 0x00100fa0, 0x100000a1, 0x000837ff, 0xefd3fbff, 0 },37 { 0x80000001, 0x00000000, 0x00000000, 0x00100fa0, 0x100000a1, 0x000837ff, 0xefd3fbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 38 38 { 0x80000002, 0x00000000, 0x00000000, 0x20444d41, 0x6e656850, 0x74286d6f, 0x4920296d, 0 }, 39 39 { 0x80000003, 0x00000000, 0x00000000, 0x36582049, 0x30313120, 0x50205430, 0x65636f72, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Intel_Atom_330_1_60GHz.h
r58572 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x0000000a, 0x756e6547, 0x6c65746e, 0x49656e69, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x000106c2, 0x01040800, 0x0040e31d, 0xbfe9fbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x000106c2, 0x01040800, 0x0040e31d, 0xbfe9fbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x4fba5901, 0x0e3080c0, 0x00000000, 0x00000000, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i5_3570.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x0000000d, 0x756e6547, 0x6c65746e, 0x49656e69, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x000306a9, 0x04100800, 0x7fbae3ff, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x000306a9, 0x04100800, 0x7fbae3ff, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x76035a01, 0x00f0b0ff, 0x00000000, 0x00ca0000, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i7_2635QM.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x0000000d, 0x756e6547, 0x6c65746e, 0x49656e69, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x000206a7, 0x04100800, 0x1fbae3bf, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x000206a7, 0x04100800, 0x1fbae3bf, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x76035a01, 0x00f0b2ff, 0x00000000, 0x00ca0000, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i7_3820QM.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x0000000d, 0x756e6547, 0x6c65746e, 0x49656e69, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x000306a9, 0x02100800, 0x7fbae3ff, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x000306a9, 0x02100800, 0x7fbae3ff, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x76035a01, 0x00f0b2ff, 0x00000000, 0x00ca0000, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i7_3960X.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x0000000d, 0x756e6547, 0x6c65746e, 0x49656e69, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x000206d6, 0x02200800, 0x1fbee3bf, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x000206d6, 0x02200800, 0x1fbee3bf, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x76035a01, 0x00f0b2ff, 0x00000000, 0x00ca0000, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i7_5600U.h
r60762 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x00000014, 0x756e6547, 0x6c65746e, 0x49656e69, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x000306d4, 0x00100800, 0x7ffafbff, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x000306d4, 0x00100800, 0x7ffafbff, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x76036301, 0x00f0b5ff, 0x00000000, 0x00c30000, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i7_6700K.h
r60762 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x00000016, 0x756e6547, 0x6c65746e, 0x49656e69, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x000506e3, 0x02100800, 0x7ffafbbf, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x000506e3, 0x02100800, 0x7ffafbbf, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x76036301, 0x00f0b5ff, 0x00000000, 0x00c30000, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Intel_Pentium_4_3_00GHz.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x00000005, 0x756e6547, 0x6c65746e, 0x49656e69, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x00000f43, 0x00020800, 0x0000649d, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x00000f43, 0x00020800, 0x0000649d, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x605b5001, 0x00000000, 0x00000000, 0x007d7040, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Intel_Pentium_M_processor_2_00GHz.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x756e6547, 0x6c65746e, 0x49656e69, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x000006d6, 0x00000816, 0x00000180, 0xafe9f9bf, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x000006d6, 0x00000816, 0x00000180, 0xafe9f9bf, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x02b3b001, 0x000000f0, 0x00000000, 0x2c04307d, 0 }, 32 32 { 0x80000000, 0x00000000, 0x00000000, 0x80000004, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Intel_Pentium_N3530_2_16GHz.h
r60762 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x0000000b, 0x756e6547, 0x6c65746e, 0x49656e69, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x00030678, 0x02100800, 0x41d8e3bf, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x00030678, 0x02100800, 0x41d8e3bf, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x61b3a001, 0x0000ffc2, 0x00000000, 0x00000000, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Intel_Xeon_X5482_3_20GHz.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x0000000a, 0x756e6547, 0x6c65746e, 0x49656e69, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x00010676, 0x04040800, 0x000ce3bd, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x00010676, 0x04040800, 0x000ce3bd, 0xbfebfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x05b0b101, 0x005657f0, 0x00000000, 0x2cb4304e, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/Quad_Core_AMD_Opteron_2384.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x00000005, 0x68747541, 0x444d4163, 0x69746e65, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x00100f42, 0x06040800, 0x00802009, 0x178bfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x00100f42, 0x06040800, 0x00802009, 0x178bfbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, … … 34 34 { 0x00000005, 0x00000000, 0x00000000, 0x00000040, 0x00000040, 0x00000003, 0x00000000, 0 }, 35 35 { 0x80000000, 0x00000000, 0x00000000, 0x8000001b, 0x68747541, 0x444d4163, 0x69746e65, 0 }, 36 { 0x80000001, 0x00000000, 0x00000000, 0x00100f42, 0x00000d4f, 0x000037ff, 0xefd3fbff, 0 },36 { 0x80000001, 0x00000000, 0x00000000, 0x00100f42, 0x00000d4f, 0x000037ff, 0xefd3fbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 37 37 { 0x80000002, 0x00000000, 0x00000000, 0x64617551, 0x726f432d, 0x4d412065, 0x704f2044, 0 }, 38 38 { 0x80000003, 0x00000000, 0x00000000, 0x6f726574, 0x6d74286e, 0x72502029, 0x7365636f, 0 }, -
trunk/src/VBox/VMM/VMMR3/cpus/VIA_QuadCore_L4700_1_2_GHz.h
r54737 r61776 28 28 { 29 29 { 0x00000000, 0x00000000, 0x00000000, 0x0000000a, 0x746e6543, 0x736c7561, 0x48727561, 0 }, 30 { 0x00000001, 0x00000000, 0x00000000, 0x000006fd, 0x06080800, 0x008863a9, 0xbfc9fbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID },30 { 0x00000001, 0x00000000, 0x00000000, 0x000006fd, 0x06080800, 0x008863a9, 0xbfc9fbff, 0 | CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_CONTAINS_APIC }, 31 31 { 0x00000002, 0x00000000, 0x00000000, 0x02b3b001, 0x00000000, 0x00000000, 0x2c04307d, 0 }, 32 32 { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 }, -
trunk/src/VBox/VMM/VMMRC/CPUMRCPatchHlp.asm
r54763 r61776 24 24 %include "VBox/vmm/vm.mac" 25 25 %include "VMMRC.mac" 26 %include "iprt/x86.mac" 26 27 27 28 … … 69 70 ; Find the middle element 70 71 mov ebx, edx 71 cpuid_lookup_leaf_ebx_lo eaded:72 cpuid_lookup_leaf_ebx_loaded: 72 73 sub ebx, ecx 73 74 shr ebx, 1 + CPUMCPUIDLEAF_SIZE_LOG2 … … 83 84 cmp ecx, ebx ; start == middle? if so, we failed. 84 85 mov edx, ebx ; end = middle; 85 jne cpuid_lookup_leaf_ebx_lo eaded86 jne cpuid_lookup_leaf_ebx_loaded 86 87 jmp cpuid_unknown 87 88 … … 179 180 180 181 ; 181 ; Normal return .182 ; Normal return unless flags (we ignore APIC_ID as we only have a single CPU with ID 0). 182 183 ; 183 184 cpuid_fetch: 185 test dword [ss:ebx + CPUMCPUIDLEAF.fFlags], CPUMCPUIDLEAF_F_CONTAINS_APIC | CPUMCPUIDLEAF_F_CONTAINS_OSXSAVE 186 jnz cpuid_fetch_with_flags 184 187 mov edx, [ss:ebx + CPUMCPUIDLEAF.uEdx] 185 188 mov ecx, [ss:ebx + CPUMCPUIDLEAF.uEcx] … … 191 194 add esp, 12 192 195 ret 196 197 198 ; 199 ; Need to adjust the result according to VCpu state. 200 ; 201 ; APIC: CPUID[0x00000001].EDX[9] &= pVCpu->cpum.s.fCpuIdApicFeatureVisible; 202 ; CPUID[0x80000001].EDX[9] &= pVCpu->cpum.s.fCpuIdApicFeatureVisible; 203 ; 204 ; OSXSAVE: CPUID[0x00000001].ECX[27] = CR4.OSXSAVE; 205 ; 206 cpuid_fetch_with_flags: 207 mov edx, [ss:ebx + CPUMCPUIDLEAF.uEdx] 208 mov ecx, [ss:ebx + CPUMCPUIDLEAF.uEcx] 209 210 mov eax, [ss:edi + VM.offVMCPU] 211 212 ; APIC 213 test dword [ss:ebx + CPUMCPUIDLEAF.fFlags], CPUMCPUIDLEAF_F_CONTAINS_APIC 214 jz cpuid_fetch_with_flags_done_apic 215 test byte [ss:edi + eax + VMCPU.cpum + CPUMCPU.fCpuIdApicFeatureVisible], 0ffh 216 jnz cpuid_fetch_with_flags_done_apic 217 and edx, ~X86_CPUID_FEATURE_EDX_APIC 218 cpuid_fetch_with_flags_done_apic: 219 220 ; OSXSAVE 221 test dword [ss:ebx + CPUMCPUIDLEAF.fFlags], CPUMCPUIDLEAF_F_CONTAINS_OSXSAVE 222 jz cpuid_fetch_with_flags_done_osxsave 223 and ecx, ~X86_CPUID_FEATURE_ECX_OSXSAVE 224 test dword [ss:edi + eax + VMCPU.cpum + CPUMCPU.Guest.cr4], X86_CR4_OSXSAVE 225 jz cpuid_fetch_with_flags_done_osxsave 226 or ecx, X86_CPUID_FEATURE_ECX_OSXSAVE 227 cpuid_fetch_with_flags_done_osxsave: 228 229 ; Load the two remaining registers and jump to the common normal exit. 230 mov eax, [ss:ebx + CPUMCPUIDLEAF.uEax] 231 mov ebx, [ss:ebx + CPUMCPUIDLEAF.uEbx] 232 jmp cpuid_done 233 193 234 ENDPROC CPUMPatchHlpCpuId 194 235 -
trunk/src/VBox/VMM/VMMRC/PDMRCDevice.cpp
r61735 r61776 602 602 603 603 604 /** @interface_method_impl{PDMAPICHLPRC,pfnChangeFeature} */605 static DECLCALLBACK(void) pdmRCApicHlp_ChangeFeature(PPDMDEVINS pDevIns, PDMAPICMODE enmMode)606 {607 PDMDEV_ASSERT_DEVINS(pDevIns);608 LogFlow(("pdmRCApicHlp_ChangeFeature: caller=%p/%d: mode=%d\n", pDevIns, pDevIns->iInstance, (int)enmMode));609 switch (enmMode)610 {611 case PDMAPICMODE_NONE:612 CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_APIC);613 CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_X2APIC);614 break;615 case PDMAPICMODE_APIC:616 CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_APIC);617 CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_X2APIC);618 break;619 case PDMAPICMODE_X2APIC:620 CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_X2APIC);621 CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMRC, CPUMCPUIDFEATURE_APIC);622 break;623 default:624 AssertMsgFailed(("Unknown APIC mode: %d\n", (int)enmMode));625 }626 }627 628 629 604 /** @interface_method_impl{PDMAPICHLPRC,pfnLock} */ 630 605 static DECLCALLBACK(int) pdmRCApicHlp_Lock(PPDMDEVINS pDevIns, int rc) … … 661 636 pdmRCApicHlp_BusBroadcastEoi, 662 637 pdmRCApicHlp_CalcIrqTag, 663 pdmRCApicHlp_ChangeFeature,664 638 pdmRCApicHlp_Lock, 665 639 pdmRCApicHlp_Unlock, -
trunk/src/VBox/VMM/include/APICInternal.h
r61581 r61776 1230 1230 /** Alignment padding. */ 1231 1231 bool afAlignment0[7]; 1232 /** The original APIC mode from CFGM.*/1233 APICMODE enmOriginalMode;1232 /** The max supported APIC mode from CFGM. */ 1233 PDMAPICMODE enmMaxMode; 1234 1234 /** @} */ 1235 1235 } APIC; … … 1380 1380 1381 1381 /** 1382 * APIC operating modes as returned by apicGetMode(). 1383 * 1384 * The values match hardware states. 1385 * See Intel spec. 10.12.1 "Detecting and Enabling x2APIC Mode". 1386 */ 1387 typedef enum APICMODE 1388 { 1389 APICMODE_DISABLED = 0, 1390 APICMODE_INVALID, 1391 APICMODE_XAPIC, 1392 APICMODE_X2APIC 1393 } APICMODE; 1394 1395 /** 1382 1396 * Gets the timer shift value. 1383 1397 * … … 1423 1437 VMM_INT_DECL(void) APICStartTimer(PVMCPU pVCpu, uint32_t uInitialCount); 1424 1438 VMM_INT_DECL(void) APICStopTimer(PVMCPU pVCpu); 1425 VMM_INT_DECL(void) APICUpdateCpuIdForMode(PVM pVM, APICMODE enmMode);1426 1439 1427 1440 RT_C_DECLS_END -
trunk/src/VBox/VMM/include/CPUMInternal.h
r61317 r61776 494 494 /** Have we entered the recompiler? */ 495 495 bool fRemEntered; 496 /** Whether the X86_CPUID_FEATURE_EDX_APIC and X86_CPUID_AMD_FEATURE_EDX_APIC 497 * (?) bits are visible or not. (The APIC is responsible for setting this 498 * when loading state, so we won't save it.) */ 499 bool fCpuIdApicFeatureVisible; 496 500 497 501 /** Align the next member on a 64-bit boundrary. */ 498 uint8_t abPadding2[64 - 16 - (HC_ARCH_BITS == 64 ? 8 : 4) - 4 - 1 - 2];502 uint8_t abPadding2[64 - 16 - (HC_ARCH_BITS == 64 ? 8 : 4) - 4 - 1 - 3]; 499 503 500 504 /** Saved host context. Only valid while inside RC or HM contexts. -
trunk/src/VBox/VMM/include/CPUMInternal.mac
r61348 r61776 249 249 .fRawEntered resb 1 250 250 .fRemEntered resb 1 251 252 .abPadding2 resb (64 - 16 - RTR0PTR_CB - 4 - 1 - 2) 251 .fCpuIdApicFeatureVisible resb 1 252 253 .abPadding2 resb (64 - 16 - RTR0PTR_CB - 4 - 1 - 3) 253 254 254 255 ; -
trunk/src/VBox/VMM/testcase/tstVMStruct.h
r60847 r61776 1381 1381 GEN_CHECK_OFF(APIC, pvApicPibRC); 1382 1382 GEN_CHECK_OFF(APIC, cbApicPib); 1383 GEN_CHECK_OFF(APIC, enm OriginalMode);1383 GEN_CHECK_OFF(APIC, enmMaxMode); 1384 1384 GEN_CHECK_OFF(APICCPU, pvApicPageR0); 1385 1385 GEN_CHECK_OFF(APICCPU, pvApicPageR3); -
trunk/src/VBox/VMM/tools/VBoxCpuReport.cpp
r60762 r61776 4454 4454 fFlags &= ~CPUMCPUIDLEAF_F_CONTAINS_APIC_ID; 4455 4455 } 4456 if (paLeaves[i].fFlags & CPUMCPUIDLEAF_F_CONTAINS_APIC) 4457 { 4458 vbCpuRepPrintf(" | CPUMCPUIDLEAF_F_CONTAINS_APIC"); 4459 fFlags &= ~CPUMCPUIDLEAF_F_CONTAINS_APIC; 4460 } 4456 4461 if (fFlags) 4457 4462 {
Note:
See TracChangeset
for help on using the changeset viewer.