VirtualBox

Changeset 61776 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Jun 20, 2016 11:25:06 PM (9 years ago)
Author:
vboxsync
Message:

CPUM,APIC: Per-CPU APIC CPUID feature bit and MSR_IA32_APICBASE GP mask adjustments.

  • Changed the PDMAPICHLPR3::pfnChangeFeature to pfnSetFeatureLevel, removing the RC and R0 versions.
  • Only use pfnSetFeatureLevel from the APIC constructor to communicate to CPUM the max APIC feature level, not to globally flip CPUID[1].EDX[9].
  • Renamed APIC enmOriginalMode to enmMaxMode, changing the type of it and the corresponding config values to PDMAPICMODE. This makes the above simpler and eliminates two conversion functions. It also makes APICMODE private to the APIC again.
  • Introduced CPUMSetGuestCpuIdPerCpuApicFeature for the per-CPU APIC feature bit management.
  • Introduced CPUMCPUIDLEAF_F_CONTAINS_APIC which works same as CPUMCPUIDLEAF_F_CONTAINS_OSXSAVE and CPUMCPUIDLEAF_F_CONTAINS_APIC_ID. Updated existing CPU profiles with this.
  • Made the patch manager helper function actually handle CPUMCPUIDLEAF_F_CONTAINS_APIC and CPUMCPUIDLEAF_F_CONTAINS_OSXSAVE (the latter previously relied on CPUMSetGuestCpuIdFeature/CPUMClearGuestCpuIdFeature from CPUMSetGuestCR4).
  • Pushed CPUMSetGuestCpuIdFeature, CPUMGetGuestCpuIdFeature and CPUMClearGuestCpuIdFeature down to ring-3 only (now CPUMR3*). The latter two function are deprecated.
  • Added call to CPUMSetGuestCpuIdPerCpuApicFeature from load function just in case the APIC is disabled by the guest at the time of saving.
  • CPUMSetGuestCpuIdFeature ensures we've got a MSR_IA32_APICBASE register when enabling the APIC.
  • CPUMSetGuestCpuIdFeature adjust the MSR_IA32_APICBASE GP mask when enabling x2APIC so setting MSR_IA32_APICBASE_EXTD does not trap.
Location:
trunk/src/VBox/VMM
Files:
35 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/APICAll.cpp

    r61736 r61776  
    20682068
    20692069    /* Don't allow enabling xAPIC/x2APIC if the VM is configured with the APIC disabled. */
    2070     if (pApic->enmOriginalMode == APICMODE_DISABLED)
     2070    if (pApic->enmMaxMode == PDMAPICMODE_NONE)
    20712071    {
    20722072        LogRel(("APIC%u: Disallowing APIC base MSR write as the VM is configured with APIC disabled!\n",
    2073                pVCpu->idCpu));
     2073                pVCpu->idCpu));
    20742074        return apicMsrAccessError(pVCpu, MSR_IA32_APICBASE, APICMSRACCESS_WRITE_DISALLOWED_CONFIG);
    20752075    }
     
    20782078     * Act on state transition.
    20792079     */
    2080     /** @todo We need to update the CPUID according to the state, which we
    2081      *        currently don't do as CPUMSetGuestCpuIdFeature() is setting
    2082      *        per-VM CPUID bits while we need per-VCPU specific bits. */
    20832080    if (enmNewMode != enmOldMode)
    20842081    {
     
    20992096                APICR3Reset(pVCpu, false /* fResetApicBaseMsr */);
    21002097                uBaseMsr &= ~(MSR_IA32_APICBASE_EN | MSR_IA32_APICBASE_EXTD);
    2101                 CPUMClearGuestCpuIdFeature(pVCpu->CTX_SUFF(pVM), CPUMCPUIDFEATURE_APIC);
     2098                CPUMSetGuestCpuIdPerCpuApicFeature(pVCpu, false /*fVisible*/);
    21022099                LogRel(("APIC%u: Switched mode to disabled\n", pVCpu->idCpu));
    21032100                break;
     
    21132110
    21142111                uBaseMsr |= MSR_IA32_APICBASE_EN;
    2115                 CPUMSetGuestCpuIdFeature(pVCpu->CTX_SUFF(pVM), CPUMCPUIDFEATURE_APIC);
     2112                CPUMSetGuestCpuIdPerCpuApicFeature(pVCpu, true /*fVisible*/);
    21162113                LogRel(("APIC%u: Switched mode to xAPIC\n", pVCpu->idCpu));
    21172114                break;
     
    21202117            case APICMODE_X2APIC:
    21212118            {
    2122                 if (pApic->enmOriginalMode != APICMODE_X2APIC)
     2119                if (pApic->enmMaxMode != PDMAPICMODE_X2APIC)
    21232120                {
    21242121                    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  
    734734VMMDECL(int) CPUMSetGuestCR4(PVMCPU pVCpu, uint64_t cr4)
    735735{
    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. */
    748737
    749738    if (   (cr4                     & (X86_CR4_PGE | X86_CR4_PAE | X86_CR4_PSE))
     
    12881277
    12891278            /*
    1290              * Deal with CPU specific information (currently only APIC ID).
     1279             * Deal with CPU specific information.
    12911280             */
    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 ))
    12931284            {
    12941285                if (uLeaf == 1)
     
    12981289                    AssertMsg((pLeaf->uEbx >> 24) == 0, ("%#x\n", pLeaf->uEbx)); /* raw-mode assumption */
    12991290                    *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;
    13001295
    13011296                    /* ECX: Bit 27: CR4.OSXSAVE mirror. */
     
    13081303                    AssertMsg(pLeaf->uEdx == 0, ("%#x\n", pLeaf->uEdx)); /* raw-mode assumption */
    13091304                    *pEdx = pVCpu->idCpu;
     1305                    Assert(!(pLeaf->fFlags & ~(CPUMCPUIDLEAF_F_CONTAINS_APIC_ID | CPUMCPUIDLEAF_F_INTEL_TOPOLOGY_SUBLEAVES)));
    13101306                }
    13111307                else if (uLeaf == UINT32_C(0x8000001e))
     
    13141310                    AssertMsg(pLeaf->uEax == 0, ("%#x\n", pLeaf->uEax)); /* raw-mode assumption */
    13151311                    *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));
    13161320                }
    13171321                else
     
    13631367
    13641368/**
    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 */
     1377VMM_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)
    13751389    {
    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    }
    14361404#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;
    17891407}
    17901408
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r60915 r61776  
    12741274    uint32_t uCR4 = CPUMGetGuestCR4(pVCpu);
    12751275
    1276     if (!CPUMGetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_RDTSCP))
     1276    if (!pVM->cpum.ro.GuestFeatures.fRdTscP)
    12771277    {
    12781278        AssertFailed();
  • trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp

    r61735 r61776  
    647647
    648648
    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 
    674649/** @interface_method_impl{PDMAPICHLPR0,pfnLock} */
    675650static DECLCALLBACK(int) pdmR0ApicHlp_Lock(PPDMDEVINS pDevIns, int rc)
     
    706681    pdmR0ApicHlp_BusBroadcastEoi,
    707682    pdmR0ApicHlp_CalcIrqTag,
    708     pdmR0ApicHlp_ChangeFeature,
    709683    pdmR0ApicHlp_Lock,
    710684    pdmR0ApicHlp_Unlock,
  • trunk/src/VBox/VMM/VMMR3/APIC.cpp

    r61769 r61776  
    262262    PAPICCPU pApicCpu     = VMCPU_TO_APICCPU(pVCpu);
    263263    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;
    265265    if (pVCpu->idCpu == 0)
    266266        uApicBaseMsr |= MSR_IA32_APICBASE_BSP;
    267267
    268     /* If the VM was configured with disabled mode, don't enable xAPIC mode. */
    269     if (pApic->enmOriginalMode != APICMODE_DISABLED)
     268    /* If the VM was configured with no APIC, don't enable xAPIC mode, obviously. */
     269    if (pApic->enmMaxMode != PDMAPICMODE_NONE)
    270270    {
    271271        uApicBaseMsr |= MSR_IA32_APICBASE_EN;
     
    276276         * See Intel spec. 10.12.5.1 "x2APIC States".
    277277         */
    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)
    281279            LogRel(("APIC%u: Resetting mode to xAPIC\n", pVCpu->idCpu));
    282             CPUMSetGuestCpuIdFeature(pVCpu->CTX_SUFF(pVM), CPUMCPUIDFEATURE_APIC);
    283         }
    284280    }
    285281
     
    773769
    774770
    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 
    815771#ifdef APIC_FUZZY_SSM_COMPAT_TEST
     772
    816773/**
    817774 * Reads a 32-bit register at a specified offset.
     
    923880    }
    924881}
     882
    925883#endif  /* APIC_FUZZY_SSM_COMPAT_TEST */
    926 
    927884
    928885/**
     
    938895    SSMR3PutU32(pSSM,  pVM->cCpus);
    939896    SSMR3PutBool(pSSM, pApic->fIoApicPresent);
    940     return SSMR3PutU32(pSSM, apicR3ConvertToLegacyApicMode(pApic->enmOriginalMode));
     897    return SSMR3PutU32(pSSM, pApic->enmMaxMode);
    941898}
    942899
     
    968925                                fIoApicPresent, pApic->fIoApicPresent);
    969926
    970     /* Load and verify configured APIC mode. */
    971     uint32_t uLegacyApicMode;
    972     rc = SSMR3GetU32(pSSM, &uLegacyApicMode);
     927    /* Load and verify configured max APIC mode. */
     928    uint32_t uSavedMaxApicMode;
     929    rc = SSMR3GetU32(pSSM, &uSavedMaxApicMode);
    973930    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);
    979934    return VINF_SUCCESS;
    980935}
     
    12051160        PAPICCPU pApicCpu = VMCPU_TO_APICCPU(pVCpu);
    12061161
     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 */
    12071165        if (   uVersion == APIC_SAVED_STATE_VERSION
    12081166            || uVersion == APIC_SAVED_STATE_VERSION_VBOX_51_BETA2)
     
    12431201            AssertRCReturn(rc, rc);
    12441202        }
     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));
    12451210
    12461211#if defined(APIC_FUZZY_SSM_COMPAT_TEST) || defined(DEBUG_ramshankar)
     
    16291594
    16301595    /*
     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    /*
    16311607     * Validate APIC settings.
    16321608     */
     
    16461622    AssertLogRelRCReturn(rc, rc);
    16471623
    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);
    16501627    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
    16581632            /** @todo permanently disabling the APIC won't really work (needs
    16591633             *        fixing in HM, CPUM, PDM and possibly other places). See
    16601634             *        @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:
    16651639            break;
    1666 #else
    1667             return VMR3SetError(pVM->pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS, "APIC mode 'disabled' is not supported yet.");
    1668 #endif
    1669         }
    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 
    16871640        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;
    17041644
    17051645    /*
     
    17101650
    17111651    /*
    1712      * Register the APIC.
     1652     * Register the APIC with PDM.
    17131653     */
    17141654    PDMAPICREG ApicReg;
     
    17581698    AssertLogRelRCReturn(rc, rc);
    17591699    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);
    17601717
    17611718    /*
  • trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp

    r60996 r61776  
    11881188                    fFlags |= CPUMCPUIDLEAF_F_CONTAINS_APIC_ID;
    11891189
     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;
    11901197
    11911198                /* Check three times here to reduce the chance of CPU migration
     
    31443151     * Clear them all as we don't currently implement extended CPU state.
    31453152     */
    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. */
    31473154    uint64_t fGuestXcr0Mask = 0;
    31483155    pStdFeatureLeaf = cpumR3CpuIdGetExactLeaf(pCpum, 1, 0);
     
    31563163            fGuestXcr0Mask |= XSAVE_C_ZMM_16HI | XSAVE_C_ZMM_HI256 | XSAVE_C_OPMASK;
    31573164        fGuestXcr0Mask &= pCpum->fXStateHostMask;
     3165
     3166        pStdFeatureLeaf->fFlags |= CPUMCPUIDLEAF_F_CONTAINS_OSXSAVE;
    31583167    }
    31593168    pStdFeatureLeaf = NULL;
     
    39573966
    39583967    /*
     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    /*
    39593975     * Read the configuration.
    39603976     */
     
    40724088        AssertRCReturn(rc, rc);
    40734089        if (fEnable)
    4074             CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
     4090            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
    40754091
    40764092        /* We don't normally enable NX for raw-mode, so give the user a chance to force it on. */
     
    40784094        AssertRCReturn(rc, rc);
    40794095        if (fEnable)
    4080             CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
     4096            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
    40814097
    40824098        /* We don't enable the Hypervisor Present bit by default, but it may be needed by some guests. */
     
    40844100        AssertRCReturn(rc, rc);
    40854101        if (fEnable)
    4086             CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
     4102            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
    40874103
    40884104        return VINF_SUCCESS;
     
    40974113    pCpum->GuestInfo.paMsrRangesR3 = NULL;
    40984114    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 */
     4127VMMR3_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);
     4161RTLogPrintf("XXXX: CPUMCPUIDFEATURE_APIC !!!\n");
     4162            }
     4163else 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 */
     4408VMMR3_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 */
     4443VMMR3_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    }
    40994546}
    41004547
  • trunk/src/VBox/VMM/VMMR3/GIMHv.cpp

    r61771 r61776  
    330330     * Expose HVP (Hypervisor Present) bit to the guest.
    331331     */
    332     CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
     332    CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
    333333
    334334    /*
  • trunk/src/VBox/VMM/VMMR3/GIMKvm.cpp

    r61632 r61776  
    121121     * Expose HVP (Hypervisor Present) bit to the guest.
    122122     */
    123     CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
     123    CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
    124124
    125125    /*
  • trunk/src/VBox/VMM/VMMR3/GIMMinimal.cpp

    r61632 r61776  
    5252     * Enable the Hypervisor Present.
    5353     */
    54     CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
     54    CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
    5555
    5656    return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r61763 r61776  
    14041404     */
    14051405    if (   !(pVM->hm.s.vmx.Msrs.VmxProcCtls.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC_USE_SECONDARY_EXEC_CTRL)
    1406         && CPUMGetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_RDTSCP))
    1407     {
    1408         CPUMClearGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_RDTSCP);
     1406        && CPUMR3GetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_RDTSCP))
     1407    {
     1408        CPUMR3ClearGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_RDTSCP);
    14091409        LogRel(("HM: Disabled RDTSCP\n"));
    14101410    }
     
    15001500     * Change the CPU features.
    15011501     */
    1502     CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);
     1502    CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);
    15031503    if (pVM->hm.s.fAllow64BitGuests)
    15041504    {
    1505         CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
    1506         CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);
    1507         CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);            /* 64 bits only on Intel CPUs */
    1508         CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
    1509         CPUMSetGuestCpuIdFeature(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);
    15101510    }
    15111511    /* Turn on NXE if PAE has been enabled *and* the host has turned on NXE
    15121512       (we reuse the host EFER in the switcher). */
    15131513    /** @todo this needs to be fixed properly!! */
    1514     else if (CPUMGetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE))
     1514    else if (CPUMR3GetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE))
    15151515    {
    15161516        if (pVM->hm.s.vmx.u64HostEfer & MSR_K6_EFER_NXE)
    1517             CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
     1517            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
    15181518        else
    15191519            LogRel(("HM: NX not enabled on the host, unavailable to PAE guest\n"));
     
    16941694     * Change the CPU features.
    16951695     */
    1696     CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);
    1697     CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);
     1696    CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);
     1697    CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);
    16981698    if (pVM->hm.s.fAllow64BitGuests)
    16991699    {
    1700         CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
    1701         CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);
    1702         CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
    1703         CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
     1700        CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
     1701        CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);
     1702        CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
     1703        CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
    17041704    }
    17051705    /* Turn on NXE if PAE has been enabled. */
    1706     else if (CPUMGetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE))
    1707         CPUMSetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
     1706    else if (CPUMR3GetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE))
     1707        CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
    17081708
    17091709    LogRel(("HM: %s TPR patching\n", (pVM->hm.s.fTprPatchingAllowed) ? "Enabled" : "Disabled"));
  • trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp

    r61735 r61776  
    311311
    312312
    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} */
     314static DECLCALLBACK(void) pdmR3ApicHlp_SetFeatureLevel(PPDMDEVINS pDevIns, PDMAPICMODE enmMode)
     315{
     316    PDMDEV_ASSERT_DEVINS(pDevIns);
     317    LogFlow(("pdmR3ApicHlp_SetFeatureLevel: caller='%s'/%d: mode=%d\n",
    328318             pDevIns->pReg->szName, pDevIns->iInstance, (int)enmMode));
    329319    switch (enmMode)
    330320    {
    331321        case PDMAPICMODE_NONE:
    332             CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);
    333             CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);
     322            CPUMR3ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);
     323            CPUMR3ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);
    334324            break;
    335325        case PDMAPICMODE_APIC:
    336             CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);
    337             CPUMClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);
     326            CPUMR3ClearGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);
     327            CPUMR3SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);
    338328            break;
    339329        case PDMAPICMODE_X2APIC:
    340             CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);
    341             CPUMSetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);
     330            CPUMR3SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_APIC);
     331            CPUMR3SetGuestCpuIdFeature(pDevIns->Internal.s.pVMR3, CPUMCPUIDFEATURE_X2APIC);
    342332            break;
    343333        default:
    344334            AssertMsgFailed(("Unknown APIC mode: %d\n", (int)enmMode));
    345335    }
    346 #endif
    347336}
    348337
     
    453442    pdmR3ApicHlp_BusBroadcastEoi,
    454443    pdmR3ApicHlp_CalcIrqTag,
    455     pdmR3ApicHlp_ChangeFeature,
     444    pdmR3ApicHlp_SetFeatureLevel,
    456445    pdmR3ApicHlp_GetCpuId,
    457446    pdmR3ApicHlp_SendStartupIpi,
  • trunk/src/VBox/VMM/VMMR3/cpus/AMD_Athlon_64_3200.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 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 },
    3333    { 0x80000002, 0x00000000, 0x00000000, 0x20444d41, 0x6c687441, 0x74286e6f, 0x3620296d, 0 },
    3434    { 0x80000003, 0x00000000, 0x00000000, 0x72502034, 0x7365636f, 0x20726f73, 0x30303233, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/AMD_Athlon_64_X2_Dual_Core_4200.h

    r54737 r61776  
    3333{
    3434    { 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 },
    3636    { 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 },
    3838    { 0x80000002, 0x00000000, 0x00000000, 0x20444d41, 0x6c687441, 0x74286e6f, 0x3620296d, 0 },
    3939    { 0x80000003, 0x00000000, 0x00000000, 0x32582034, 0x61754420, 0x6f43206c, 0x50206572, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/AMD_FX_8150_Eight_Core.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
     
    4343    { 0x0000000d, 0x00000001, UINT32_MAX, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
    4444    { 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 },
    4646    { 0x80000002, 0x00000000, 0x00000000, 0x20444d41, 0x74285846, 0x382d296d, 0x20303531, 0 },
    4747    { 0x80000003, 0x00000000, 0x00000000, 0x68676945, 0x6f432d74, 0x50206572, 0x65636f72, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/AMD_Phenom_II_X6_1100T.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
     
    3535    { 0x00000006, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0 },
    3636    { 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 },
    3838    { 0x80000002, 0x00000000, 0x00000000, 0x20444d41, 0x6e656850, 0x74286d6f, 0x4920296d, 0 },
    3939    { 0x80000003, 0x00000000, 0x00000000, 0x36582049, 0x30313120, 0x50205430, 0x65636f72, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Atom_330_1_60GHz.h

    r58572 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x4fba5901, 0x0e3080c0, 0x00000000, 0x00000000, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i5_3570.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x76035a01, 0x00f0b0ff, 0x00000000, 0x00ca0000, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i7_2635QM.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x76035a01, 0x00f0b2ff, 0x00000000, 0x00ca0000, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i7_3820QM.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x76035a01, 0x00f0b2ff, 0x00000000, 0x00ca0000, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i7_3960X.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x76035a01, 0x00f0b2ff, 0x00000000, 0x00ca0000, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i7_5600U.h

    r60762 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x76036301, 0x00f0b5ff, 0x00000000, 0x00c30000, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i7_6700K.h

    r60762 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x76036301, 0x00f0b5ff, 0x00000000, 0x00c30000, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Pentium_4_3_00GHz.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x605b5001, 0x00000000, 0x00000000, 0x007d7040, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Pentium_M_processor_2_00GHz.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x02b3b001, 0x000000f0, 0x00000000, 0x2c04307d, 0 },
    3232    { 0x80000000, 0x00000000, 0x00000000, 0x80000004, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Pentium_N3530_2_16GHz.h

    r60762 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x61b3a001, 0x0000ffc2, 0x00000000, 0x00000000, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Xeon_X5482_3_20GHz.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x05b0b101, 0x005657f0, 0x00000000, 0x2cb4304e, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/Quad_Core_AMD_Opteron_2384.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
     
    3434    { 0x00000005, 0x00000000, 0x00000000, 0x00000040, 0x00000040, 0x00000003, 0x00000000, 0 },
    3535    { 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 },
    3737    { 0x80000002, 0x00000000, 0x00000000, 0x64617551, 0x726f432d, 0x4d412065, 0x704f2044, 0 },
    3838    { 0x80000003, 0x00000000, 0x00000000, 0x6f726574, 0x6d74286e, 0x72502029, 0x7365636f, 0 },
  • trunk/src/VBox/VMM/VMMR3/cpus/VIA_QuadCore_L4700_1_2_GHz.h

    r54737 r61776  
    2828{
    2929    { 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 },
    3131    { 0x00000002, 0x00000000, 0x00000000, 0x02b3b001, 0x00000000, 0x00000000, 0x2c04307d, 0 },
    3232    { 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0 },
  • trunk/src/VBox/VMM/VMMRC/CPUMRCPatchHlp.asm

    r54763 r61776  
    2424%include "VBox/vmm/vm.mac"
    2525%include "VMMRC.mac"
     26%include "iprt/x86.mac"
    2627
    2728
     
    6970    ; Find the middle element
    7071    mov     ebx, edx
    71 cpuid_lookup_leaf_ebx_loeaded:
     72cpuid_lookup_leaf_ebx_loaded:
    7273    sub     ebx, ecx
    7374    shr     ebx, 1 + CPUMCPUIDLEAF_SIZE_LOG2
     
    8384    cmp     ecx, ebx                    ; start == middle? if so, we failed.
    8485    mov     edx, ebx                    ; end = middle;
    85     jne     cpuid_lookup_leaf_ebx_loeaded
     86    jne     cpuid_lookup_leaf_ebx_loaded
    8687    jmp     cpuid_unknown
    8788
     
    179180
    180181    ;
    181     ; Normal return.
     182    ; Normal return unless flags (we ignore APIC_ID as we only have a single CPU with ID 0).
    182183    ;
    183184cpuid_fetch:
     185    test    dword [ss:ebx + CPUMCPUIDLEAF.fFlags], CPUMCPUIDLEAF_F_CONTAINS_APIC | CPUMCPUIDLEAF_F_CONTAINS_OSXSAVE
     186    jnz     cpuid_fetch_with_flags
    184187    mov     edx, [ss:ebx + CPUMCPUIDLEAF.uEdx]
    185188    mov     ecx, [ss:ebx + CPUMCPUIDLEAF.uEcx]
     
    191194    add     esp, 12
    192195    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    ;
     206cpuid_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
     218cpuid_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
     227cpuid_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
    193234ENDPROC CPUMPatchHlpCpuId
    194235
  • trunk/src/VBox/VMM/VMMRC/PDMRCDevice.cpp

    r61735 r61776  
    602602
    603603
    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 
    629604/** @interface_method_impl{PDMAPICHLPRC,pfnLock} */
    630605static DECLCALLBACK(int) pdmRCApicHlp_Lock(PPDMDEVINS pDevIns, int rc)
     
    661636    pdmRCApicHlp_BusBroadcastEoi,
    662637    pdmRCApicHlp_CalcIrqTag,
    663     pdmRCApicHlp_ChangeFeature,
    664638    pdmRCApicHlp_Lock,
    665639    pdmRCApicHlp_Unlock,
  • trunk/src/VBox/VMM/include/APICInternal.h

    r61581 r61776  
    12301230    /** Alignment padding. */
    12311231    bool                        afAlignment0[7];
    1232     /** The original APIC mode from CFGM. */
    1233     APICMODE                    enmOriginalMode;
     1232    /** The max supported APIC mode from CFGM. */
     1233    PDMAPICMODE                 enmMaxMode;
    12341234    /** @} */
    12351235} APIC;
     
    13801380
    13811381/**
     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 */
     1387typedef enum APICMODE
     1388{
     1389    APICMODE_DISABLED = 0,
     1390    APICMODE_INVALID,
     1391    APICMODE_XAPIC,
     1392    APICMODE_X2APIC
     1393} APICMODE;
     1394
     1395/**
    13821396 * Gets the timer shift value.
    13831397 *
     
    14231437VMM_INT_DECL(void)      APICStartTimer(PVMCPU pVCpu, uint32_t uInitialCount);
    14241438VMM_INT_DECL(void)      APICStopTimer(PVMCPU pVCpu);
    1425 VMM_INT_DECL(void)      APICUpdateCpuIdForMode(PVM pVM, APICMODE enmMode);
    14261439
    14271440RT_C_DECLS_END
  • trunk/src/VBox/VMM/include/CPUMInternal.h

    r61317 r61776  
    494494    /** Have we entered the recompiler? */
    495495    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;
    496500
    497501    /** 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];
    499503
    500504    /** Saved host context.  Only valid while inside RC or HM contexts.
  • trunk/src/VBox/VMM/include/CPUMInternal.mac

    r61348 r61776  
    249249    .fRawEntered          resb    1
    250250    .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)
    253254
    254255    ;
  • trunk/src/VBox/VMM/testcase/tstVMStruct.h

    r60847 r61776  
    13811381    GEN_CHECK_OFF(APIC, pvApicPibRC);
    13821382    GEN_CHECK_OFF(APIC, cbApicPib);
    1383     GEN_CHECK_OFF(APIC, enmOriginalMode);
     1383    GEN_CHECK_OFF(APIC, enmMaxMode);
    13841384    GEN_CHECK_OFF(APICCPU, pvApicPageR0);
    13851385    GEN_CHECK_OFF(APICCPU, pvApicPageR3);
  • trunk/src/VBox/VMM/tools/VBoxCpuReport.cpp

    r60762 r61776  
    44544454                fFlags &= ~CPUMCPUIDLEAF_F_CONTAINS_APIC_ID;
    44554455            }
     4456            if (paLeaves[i].fFlags & CPUMCPUIDLEAF_F_CONTAINS_APIC)
     4457            {
     4458                vbCpuRepPrintf(" | CPUMCPUIDLEAF_F_CONTAINS_APIC");
     4459                fFlags &= ~CPUMCPUIDLEAF_F_CONTAINS_APIC;
     4460            }
    44564461            if (fFlags)
    44574462            {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette