VirtualBox

Changeset 23797 in vbox


Ignore:
Timestamp:
Oct 15, 2009 12:54:48 PM (15 years ago)
Author:
vboxsync
Message:

More synthetic cpu work

File:
1 edited

Legend:

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

    r23794 r23797  
    411411        pCPUM->enmGuestCpuVendor = CPUMCPUVENDOR_SYNTHETIC;
    412412
    413         /* Vendor */
     413        /* Limit the nr of standard leaves; 5 for monitor/mwait */
     414        pCPUM->aGuestCpuIdStd[0].eax = RT_MIN(pCPUM->aGuestCpuIdStd[0].eax, 5);
     415
     416        /* 0: Vendor */
    414417        pCPUM->aGuestCpuIdStd[0].ebx = pCPUM->aGuestCpuIdExt[0].ebx = ((uint32_t *)szVendor)[0];
    415418        pCPUM->aGuestCpuIdStd[0].ecx = pCPUM->aGuestCpuIdExt[0].ecx = ((uint32_t *)szVendor)[2];
    416419        pCPUM->aGuestCpuIdStd[0].edx = pCPUM->aGuestCpuIdExt[0].edx = ((uint32_t *)szVendor)[1];
    417420
    418         /* Processor Name String Identifier. */
     421        /* 1.eax: Version information.  family : model : stepping */
     422        pCPUM->aGuestCpuIdStd[0].eax = (0xf << 8) + (0x1 << 4) + 1;
     423
     424        /* Leaves 2 - 4 are Intel only - zero them out */
     425        memset(&pCPUM->aGuestCpuIdStd[2], 0, sizeof(pCPUM->aGuestCpuIdStd[2]));
     426        memset(&pCPUM->aGuestCpuIdStd[3], 0, sizeof(pCPUM->aGuestCpuIdStd[3]));
     427        memset(&pCPUM->aGuestCpuIdStd[4], 0, sizeof(pCPUM->aGuestCpuIdStd[4]));
     428
     429        /* Leaf 5 = monitor/mwait */
     430
     431        /* Limit the nr of extended leaves: 0x80000008 to include the max virtual and physical address size (64 bits guests). */
     432        pCPUM->aGuestCpuIdExt[0].eax = RT_MIN(pCPUM->aGuestCpuIdExt[0].eax, 0x80000008);
     433        /* AMD only - set to zero. */
     434        pCPUM->aGuestCpuIdExt[0].ebx = pCPUM->aGuestCpuIdExt[0].ecx = pCPUM->aGuestCpuIdExt[0].edx = 0;
     435
     436        /* 0x800000001: AMD only; shared feature bits are set dynamically. */
     437        memset(&pCPUM->aGuestCpuIdExt[1], 0, sizeof(pCPUM->aGuestCpuIdExt[1]));
     438
     439        /* 0x800000002-4: Processor Name String Identifier. */
    419440        pCPUM->aGuestCpuIdExt[2].eax = ((uint32_t *)szProcessor)[0];
    420441        pCPUM->aGuestCpuIdExt[2].ebx = ((uint32_t *)szProcessor)[1];
     
    430451        pCPUM->aGuestCpuIdExt[4].edx = ((uint32_t *)szProcessor)[11];
    431452
    432         /* AMD only; shared feature bits are set dynamically. */
    433         pCPUM->aGuestCpuIdExt[1].edx = 0;
    434         pCPUM->aGuestCpuIdExt[1].ecx = 0;
     453        /* 0x800000005-7 - reserved -> zero */
     454        memset(&pCPUM->aGuestCpuIdExt[5], 0, sizeof(pCPUM->aGuestCpuIdExt[5]));
     455        memset(&pCPUM->aGuestCpuIdExt[6], 0, sizeof(pCPUM->aGuestCpuIdExt[6]));
     456        memset(&pCPUM->aGuestCpuIdExt[7], 0, sizeof(pCPUM->aGuestCpuIdExt[7]));
     457
     458        /* 0x800000008: only the max virtual and physical address size. */
     459        pCPUM->aGuestCpuIdExt[8].ecx = pCPUM->aGuestCpuIdExt[8].ebx = pCPUM->aGuestCpuIdExt[8].edx = 0;  /* reserved */
    435460
    436461        /** @todo fill in the rest of the cpu leaves. */
     
    443468    pCPUM->aGuestCpuIdStd[1].ebx &= 0x0000ffff;
    444469#ifdef VBOX_WITH_MULTI_CORE
    445     if (pVM->cCpus > 1)
     470    if (    pVM->cCpus > 1
     471        &&  pCPUM->enmGuestCpuVendor != CPUMCPUVENDOR_SYNTHETIC)
    446472    {
    447473        /* If CPUID Fn0000_0001_EDX[HTT] = 1 then LogicalProcessorCount is the number of threads per CPU core times the number of CPU cores per processor */
     
    584610
    585611    /** @cfgm{/CPUM/NT4LeafLimit, boolean, false}
    586      * Limit the number of standard CPUID leafs to 0..2 to prevent NT4 from
     612     * Limit the number of standard CPUID leaves to 0..3 to prevent NT4 from
    587613     * bugchecking with MULTIPROCESSOR_CONFIGURATION_NOT_SUPPORTED (0x3e).
    588614     * This option corrsponds somewhat to IA32_MISC_ENABLES.BOOT_NT4[bit 22].
    589      * @todo r=bird: The intel docs states that leafs 3 is included, why don't we?
    590615     */
    591616    bool fNt4LeafLimit;
    592617    CFGMR3QueryBoolDef(CFGMR3GetChild(CFGMR3GetRoot(pVM), "CPUM"), "NT4LeafLimit", &fNt4LeafLimit, false);
    593618    if (fNt4LeafLimit)
    594         pCPUM->aGuestCpuIdStd[0].eax = 2;
     619        pCPUM->aGuestCpuIdStd[0].eax = 3;
    595620
    596621    /*
     
    906931{
    907932    /*
    908      * Save all the CPU ID leafs here so we can check them for compatability
     933     * Save all the CPU ID leaves here so we can check them for compatability
    909934     * upon loading.
    910935     */
     
    939964
    940965/**
    941  * Loads the CPU ID leafs saved by pass 0.
     966 * Loads the CPU ID leaves saved by pass 0.
    942967 *
    943968 * @returns VBox status code.
     
    10311056
    10321057    /*
    1033      * We're good, commit the CPU ID leafs.
     1058     * We're good, commit the CPU ID leaves.
    10341059     */
    10351060    memcmp(&pVM->cpum.s.aGuestCpuIdStd[0],     &aGuestCpuIdStd[0],     sizeof(aGuestCpuIdStd));
     
    27832808
    27842809/**
    2785  * Gets a pointer to the array of standard CPUID leafs.
     2810 * Gets a pointer to the array of standard CPUID leaves.
    27862811 *
    27872812 * CPUMR3GetGuestCpuIdStdMax() give the size of the array.
    27882813 *
    2789  * @returns Pointer to the standard CPUID leafs (read-only).
     2814 * @returns Pointer to the standard CPUID leaves (read-only).
    27902815 * @param   pVM         The VM handle.
    27912816 * @remark  Intended for PATM.
     
    27982823
    27992824/**
    2800  * Gets a pointer to the array of extended CPUID leafs.
     2825 * Gets a pointer to the array of extended CPUID leaves.
    28012826 *
    28022827 * CPUMGetGuestCpuIdExtMax() give the size of the array.
    28032828 *
    2804  * @returns Pointer to the extended CPUID leafs (read-only).
     2829 * @returns Pointer to the extended CPUID leaves (read-only).
    28052830 * @param   pVM         The VM handle.
    28062831 * @remark  Intended for PATM.
     
    28132838
    28142839/**
    2815  * Gets a pointer to the array of centaur CPUID leafs.
     2840 * Gets a pointer to the array of centaur CPUID leaves.
    28162841 *
    28172842 * CPUMGetGuestCpuIdCentaurMax() give the size of the array.
    28182843 *
    2819  * @returns Pointer to the centaur CPUID leafs (read-only).
     2844 * @returns Pointer to the centaur CPUID leaves (read-only).
    28202845 * @param   pVM         The VM handle.
    28212846 * @remark  Intended for PATM.
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