VirtualBox

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


Ignore:
Timestamp:
Feb 25, 2014 4:06:26 PM (11 years ago)
Author:
vboxsync
Message:

CPUM,DevEFI: Bus vs cpu clock ratio fixes for more recent CPUs. Older CPUs (<=Core2) still need some more work.

Location:
trunk/src/VBox/VMM
Files:
5 edited

Legend:

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

    r50158 r50584  
    15711571    *puValue = ((uint32_t)uTsc133MHz << 8)   /* TSC invariant frequency. */
    15721572             | ((uint64_t)uTsc133MHz << 40); /* The max turbo frequency. */
     1573    return VINF_SUCCESS;
     1574}
     1575
     1576
     1577/** @callback_method_impl{FNCPUMRDMSR} */
     1578static DECLCALLBACK(int) cpumMsrRd_IntelFlexRatio100MHz(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
     1579{
     1580    uint64_t uValue = pRange->uValue & ~UINT64_C(0x1ff00);
     1581
     1582    uint64_t uTscHz = TMCpuTicksPerSecond(pVCpu->CTX_SUFF(pVM));
     1583    uint8_t  uTsc100MHz = (uint8_t)(uTscHz / UINT32_C(100000000));
     1584    uValue |= (uint32_t)uTsc100MHz << 8;
     1585
     1586    *puValue = uValue;
     1587    return VINF_SUCCESS;
     1588}
     1589
     1590
     1591/** @callback_method_impl{FNCPUMWRMSR} */
     1592static DECLCALLBACK(int) cpumMsrWr_IntelFlexRatio100MHz(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
     1593{
     1594    /** @todo implement writing MSR_FLEX_RATIO. */
     1595    return VINF_SUCCESS;
     1596}
     1597
     1598
     1599/** @callback_method_impl{FNCPUMRDMSR} */
     1600static DECLCALLBACK(int) cpumMsrRd_IntelFlexRatio133MHz(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
     1601{
     1602    uint64_t uValue = pRange->uValue & ~UINT64_C(0x1ff00);
     1603
     1604    uint64_t uTscHz = TMCpuTicksPerSecond(pVCpu->CTX_SUFF(pVM));
     1605    uint8_t  uTsc133MHz = (uint8_t)(uTscHz / UINT32_C(133333333));
     1606    uValue |= (uint32_t)uTsc133MHz << 8;
     1607
     1608    *puValue = uValue;
     1609    return VINF_SUCCESS;
     1610}
     1611
     1612
     1613/** @callback_method_impl{FNCPUMWRMSR} */
     1614static DECLCALLBACK(int) cpumMsrWr_IntelFlexRatio133MHz(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
     1615{
     1616    /** @todo implement writing MSR_FLEX_RATIO. */
    15731617    return VINF_SUCCESS;
    15741618}
     
    43464390    cpumMsrRd_IntelPlatformInfo100MHz,
    43474391    cpumMsrRd_IntelPlatformInfo133MHz,
     4392    cpumMsrRd_IntelFlexRatio100MHz,
     4393    cpumMsrRd_IntelFlexRatio133MHz,
    43484394    cpumMsrRd_IntelPkgCStConfigControl,
    43494395    cpumMsrRd_IntelPmgIoCaptureBase,
     
    45814627    cpumMsrWr_IntelP4EbcSoftPowerOn,
    45824628    cpumMsrWr_IntelP4EbcFrequencyId,
     4629    cpumMsrWr_IntelFlexRatio100MHz,
     4630    cpumMsrWr_IntelFlexRatio133MHz,
    45834631    cpumMsrWr_IntelPkgCStConfigControl,
    45844632    cpumMsrWr_IntelPmgIoCaptureBase,
     
    50325080    CPUM_ASSERT_RD_MSR_FN(IntelPlatformInfo100MHz);
    50335081    CPUM_ASSERT_RD_MSR_FN(IntelPlatformInfo133MHz);
     5082    CPUM_ASSERT_RD_MSR_FN(IntelFlexRatio100MHz);
     5083    CPUM_ASSERT_RD_MSR_FN(IntelFlexRatio133MHz);
    50345084    CPUM_ASSERT_RD_MSR_FN(IntelPkgCStConfigControl);
    50355085    CPUM_ASSERT_RD_MSR_FN(IntelPmgIoCaptureBase);
     
    52565306    CPUM_ASSERT_WR_MSR_FN(IntelP4EbcSoftPowerOn);
    52575307    CPUM_ASSERT_WR_MSR_FN(IntelP4EbcFrequencyId);
     5308    CPUM_ASSERT_WR_MSR_FN(IntelFlexRatio100MHz);
     5309    CPUM_ASSERT_WR_MSR_FN(IntelFlexRatio133MHz);
    52585310    CPUM_ASSERT_WR_MSR_FN(IntelPkgCStConfigControl);
    52595311    CPUM_ASSERT_WR_MSR_FN(IntelPmgIoCaptureBase);
     
    54005452
    54015453
     5454/**
     5455 * Gets the bus frequency.
     5456 *
     5457 * The bus frequency is used as a base in several MSRs that gives the CPU and
     5458 * other frequency ratios.
     5459 *
     5460 * @returns Bus frequency in Hz.
     5461 * @param   pVM                 Pointer to the shared VM structure.
     5462 */
     5463VMMDECL(uint64_t) CPUMGetGuestBusFrequency(PVM pVM)
     5464{
     5465    if (CPUMMICROARCH_IS_INTEL_CORE7(pVM->cpum.s.GuestFeatures.enmMicroarch))
     5466    {
     5467        return pVM->cpum.s.GuestFeatures.enmMicroarch >= kCpumMicroarch_Intel_Core7_SandyBridge
     5468            ? UINT64_C(100000000)  /* 100MHz */
     5469            : UINT64_C(133333333); /* 133MHz */
     5470    }
     5471
     5472    /* 133MHz */
     5473    return UINT64_C(133333333);
     5474}
     5475
     5476
    54025477#ifdef IN_RING0
    54035478
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i5_3570.h

    r49922 r50584  
    7878    MFO(0x0000009b, "IA32_SMM_MONITOR_CTL", Ia32SmmMonitorCtl), /* value=0x0 */
    7979    RSN(0x000000c1, 0x000000c8, "IA32_PMCn", Ia32PmcN, Ia32PmcN, 0x0, ~(uint64_t)UINT32_MAX, 0),
    80     MVO(0x000000ce, "P6_UNK_0000_00ce", UINT64_C(0x81010e0012200)),
     80    MFO(0x000000ce, "MSR_PLATFORM_INFO", IntelPlatformInfo100MHz), /* value=0x81010'e0012200*/
    8181    MFX(0x000000e2, "MSR_PKG_CST_CONFIG_CONTROL", IntelPkgCStConfigControl, IntelPkgCStConfigControl, 0, 0, UINT64_C(0xffffffffe1ffffff)), /* value=0x1e008403 */
    8282    MFX(0x000000e4, "MSR_PMG_IO_CAPTURE_BASE", IntelPmgIoCaptureBase, IntelPmgIoCaptureBase, 0, 0, UINT64_C(0xfffffffffff80000)), /* value=0x10414 */
     
    9999    MFX(0x0000017a, "IA32_MCG_STATUS", Ia32McgStatus, Ia32McgStatus, 0, 0, UINT64_C(0xfffffffffffffff8)), /* value=0x0 */
    100100    RSN(0x00000186, 0x0000018d, "IA32_PERFEVTSELn", Ia32PerfEvtSelN, Ia32PerfEvtSelN, 0x0, 0, UINT64_C(0xffffffff00080000)),
    101     MVX(0x00000194, "CLOCK_FLEX_MAX", 0x190000, 0x1e00ff, UINT64_C(0xffffffffffe00000)),
     101    MFX(0x00000194, "CLOCK_FLEX_MAX", IntelFlexRatio100MHz, IntelFlexRatio100MHz, 0x190000, 0x1e00ff, UINT64_C(0xffffffffffe00000)),
    102102    MFX(0x00000198, "IA32_PERF_STATUS", Ia32PerfStatus, ReadOnly, UINT64_C(0x1d2400001000), 0, 0), /* value=0x1d24`00001000 */
    103103    MFX(0x00000199, "IA32_PERF_CTL", Ia32PerfCtl, Ia32PerfCtl, 0x1000, 0, 0), /* Might bite. value=0x1000 */
  • trunk/src/VBox/VMM/VMMR3/cpus/Intel_Core_i7_3960X.h

    r49922 r50584  
    8686    MFO(0x0000009b, "IA32_SMM_MONITOR_CTL", Ia32SmmMonitorCtl), /* value=0x0 */
    8787    RSN(0x000000c1, 0x000000c4, "IA32_PMCn", Ia32PmcN, Ia32PmcN, 0x0, ~(uint64_t)UINT32_MAX, 0),
    88     MVO(0x000000ce, "P6_UNK_0000_00ce", UINT64_C(0xc0070012100)),
     88    MFO(0x000000ce, "MSR_PLATFORM_INFO", IntelPlatformInfo100MHz), /* value=0xc00'70012100*/
    8989    MFX(0x000000e2, "MSR_PKG_CST_CONFIG_CONTROL", IntelPkgCStConfigControl, IntelPkgCStConfigControl, 0, 0, UINT64_C(0xffffffffe1ffffff)), /* value=0x1e008400 */
    9090    MFX(0x000000e4, "MSR_PMG_IO_CAPTURE_BASE", IntelPmgIoCaptureBase, IntelPmgIoCaptureBase, 0, 0, UINT64_C(0xfffffffffff80000)), /* value=0x20414 */
     
    103103    MFX(0x0000017f, "I7_SB_ERROR_CONTROL", IntelI7SandyErrorControl, IntelI7SandyErrorControl, 0, 0xc, UINT64_C(0xffffffffffffffe1)), /* value=0x0 */
    104104    RSN(0x00000186, 0x00000189, "IA32_PERFEVTSELn", Ia32PerfEvtSelN, Ia32PerfEvtSelN, 0x0, 0, UINT64_C(0xffffffff00080000)),
    105     MVX(0x00000194, "CLOCK_FLEX_MAX", 0xf2100, 0xe0000, UINT64_C(0xfffffffffff00000)),
     105    MFX(0x00000194, "CLOCK_FLEX_MAX", IntelFlexRatio100MHz, IntelFlexRatio100MHz, 0xf2100, 0xe0000, UINT64_C(0xfffffffffff00000)),
    106106    MFX(0x00000198, "IA32_PERF_STATUS", Ia32PerfStatus, ReadOnly, UINT64_C(0x288300002400), 0, 0), /* value=0x2883`00002400 */
    107107    MFX(0x00000199, "IA32_PERF_CTL", Ia32PerfCtl, Ia32PerfCtl, 0x2700, 0, 0), /* Might bite. value=0x2700 */
  • trunk/src/VBox/VMM/include/CPUMInternal.h

    r49977 r50584  
    211211    kCpumMsrRdFn_IntelPlatformInfo100MHz,
    212212    kCpumMsrRdFn_IntelPlatformInfo133MHz,
     213    kCpumMsrRdFn_IntelFlexRatio100MHz,      /**< Takes real value as reference. */
     214    kCpumMsrRdFn_IntelFlexRatio133MHz,      /**< Takes real value as reference. */
    213215    kCpumMsrRdFn_IntelPkgCStConfigControl,
    214216    kCpumMsrRdFn_IntelPmgIoCaptureBase,
     
    454456    kCpumMsrWrFn_IntelP4EbcSoftPowerOn,
    455457    kCpumMsrWrFn_IntelP4EbcFrequencyId,
     458    kCpumMsrWrFn_IntelFlexRatio100MHz,
     459    kCpumMsrWrFn_IntelFlexRatio133MHz,
    456460    kCpumMsrWrFn_IntelPkgCStConfigControl,
    457461    kCpumMsrWrFn_IntelPmgIoCaptureBase,
  • trunk/src/VBox/VMM/tools/VBoxCpuReport.cpp

    r49993 r50584  
    695695        case 0x000000c8: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_First ? "IA32_PMC7" : NULL;
    696696        case 0x000000cd: return "P6_UNK_0000_00cd"; /* P6_M_Dothan. */
    697         case 0x000000ce: return "P6_UNK_0000_00ce"; /* P6_M_Dothan. */
     697        case 0x000000ce: return g_enmMicroarch >= kCpumMicroarch_Intel_Core7_First ? "IA32_PLATFORM_INFO" : "P6_UNK_0000_00ce"; /* P6_M_Dothan. */
    698698        case 0x000000cf: return "C2_UNK_0000_00cf"; /* Core2_Penryn. */
    699699        case 0x000000e0: return "C2_UNK_0000_00e0"; /* Core2_Penryn. */
     
    18431843            return NULL;
    18441844
     1845        case 0x000000ce: return CPUMMICROARCH_IS_INTEL_CORE7(g_enmMicroarch)
     1846                              ? (g_enmMicroarch >= kCpumMicroarch_Intel_Core7_SandyBridge
     1847                                 ? "IntelPlatformInfo100MHz" : "IntelPlatformInfo133MHz")
     1848                              : NULL;
     1849
    18451850        case 0x000000e2: return "IntelPkgCStConfigControl";
    18461851        case 0x000000e3: return "IntelCore2SmmCStMiscInfo";
     
    18771882        case 0x00000187: return "Ia32PerfEvtSelN";
    18781883        case 0x00000193: return /*g_fIntelNetBurst ? NULL :*/ NULL /* Core2_Penryn. */;
     1884        case 0x00000194:
     1885            if (g_fIntelNetBurst)
     1886                break;
     1887            *pfTakesValue = true;
     1888            return CPUMMICROARCH_IS_INTEL_CORE7(g_enmMicroarch) && g_enmMicroarch >= kCpumMicroarch_Intel_Core7_SandyBridge
     1889                 ? "IntelFlexRatio100MHz" : "IntelFlexRatio133MHz";
    18791890        case 0x00000198: *pfTakesValue = true; return "Ia32PerfStatus";
    18801891        case 0x00000199: *pfTakesValue = true; return "Ia32PerfCtl";
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