VirtualBox

Changeset 10567 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 12, 2008 3:29:13 PM (16 years ago)
Author:
vboxsync
Message:

Expose cpuid 0x80000007 (AMD - Advanced Power Management (TSC invariant)) and 0x80000008 (virtual & physical address size) to the guest.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/CPUM.cpp

    r10353 r10567  
    348348     * Intel returns values of the highest standard function, while AMD
    349349     * returns zeros. VIA on the other hand seems to returning nothing or
    350      * perhaps some random garbage, we don't try duplicate this behavior.
     350     * perhaps some random garbage, we don't try to duplicate this behavior.
    351351     */
    352352    ASMCpuId(pCPUM->aGuestCpuIdStd[0].eax + 10,
     
    363363     */
    364364
     365    /* Cpuid 0x800000007:
     366     * AMD:               EAX, EBX, ECX - reserved
     367     *                    EDX: Advanced Power Management Information
     368     * Intel:             Reserved
     369     */
     370    if (pCPUM->aGuestCpuIdExt[0].eax >= UINT32_C(0x80000007))
     371    {
     372        Assert(pVM->cpum.s.enmCPUVendor != CPUMCPUVENDOR_INVALID);
     373
     374        pCPUM->aGuestCpuIdExt[7].eax = pCPUM->aGuestCpuIdExt[7].ebx = pCPUM->aGuestCpuIdExt[7].ecx = 0;
     375
     376        if (pVM->cpum.s.enmCPUVendor == CPUMCPUVENDOR_AMD)
     377        {
     378            /* Only expose the TSC invariant capability bit to the guest. */
     379            pCPUM->aGuestCpuIdExt[7].edx    &= 0
     380                                            //| X86_CPUID_AMD_ADVPOWER_EDX_TS
     381                                            //| X86_CPUID_AMD_ADVPOWER_EDX_FID
     382                                            //| X86_CPUID_AMD_ADVPOWER_EDX_VID
     383                                            //| X86_CPUID_AMD_ADVPOWER_EDX_TTP
     384                                            //| X86_CPUID_AMD_ADVPOWER_EDX_TM
     385                                            //| X86_CPUID_AMD_ADVPOWER_EDX_STC
     386                                            //| X86_CPUID_AMD_ADVPOWER_EDX_MC
     387                                            //| X86_CPUID_AMD_ADVPOWER_EDX_HWPSTATE
     388                                            | X86_CPUID_AMD_ADVPOWER_EDX_TSCINVAR
     389                                            | 0;
     390        }
     391        else
     392            pCPUM->aGuestCpuIdExt[7].edx    = 0;
     393    }
     394
     395    /* Cpuid 0x800000008:
     396     * AMD:               EBX, EDX - reserved
     397     *                    EAX: Virtual/Physical address Size
     398     *                    ECX: Number of cores + APICIdCoreIdSize
     399     * Intel:             EAX: Virtual/Physical address Size
     400     *                    EBX, ECX, EDX - reserved
     401     */
     402    if (pCPUM->aGuestCpuIdExt[0].eax >= UINT32_C(0x80000008))
     403    {
     404        /* Only expose the virtual and physical address sizes to the guest. (EAX completely) */
     405        pCPUM->aGuestCpuIdExt[8].ebx = pCPUM->aGuestCpuIdExt[8].edx = 0;  /* reserved */
     406        /* Set APICIdCoreIdSize to zero (use legacy method to determine the number of cores per cpu)
     407         * NC (0-7) Number of cores; 0 equals 1 core */
     408        pCPUM->aGuestCpuIdExt[8].ecx = 0;
     409    }
     410
    365411    /*
    366412     * Limit it the number of entries and fill the remaining with the defaults.
     
    375421        pCPUM->aGuestCpuIdStd[i] = pCPUM->GuestCpuIdDef;
    376422
    377     if (pCPUM->aGuestCpuIdExt[0].eax > UINT32_C(0x80000006))
    378         pCPUM->aGuestCpuIdExt[0].eax = UINT32_C(0x80000006);
     423    if (pCPUM->aGuestCpuIdExt[0].eax > UINT32_C(0x80000008))
     424        pCPUM->aGuestCpuIdExt[0].eax = UINT32_C(0x80000008);
    379425    for (i = pCPUM->aGuestCpuIdExt[0].eax >= UINT32_C(0x80000000)
    380426           ? pCPUM->aGuestCpuIdExt[0].eax - UINT32_C(0x80000000) + 1
  • trunk/src/VBox/VMM/TM.cpp

    r9445 r10567  
    567567
    568568                ASMCpuId(0x80000007, &uEAX, &uEBX, &uECX, &uEDX);
    569                 if (   (uEDX & RT_BIT(8)) /* TscInvariant */
     569                if (   (uEDX & X86_CPUID_AMD_ADVPOWER_EDX_TSCINVAR) /* TscInvariant */
    570570                    && pGip->u32Mode == SUPGIPMODE_SYNC_TSC /* no fixed tsc if the gip timer is in async mode */)
    571571                    return true;
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