VirtualBox

Changeset 30164 in vbox for trunk


Ignore:
Timestamp:
Jun 11, 2010 2:16:09 PM (15 years ago)
Author:
vboxsync
Message:

CPUM: Added /CPUM/PortableCpuIdLevel={0..3} for automatically stripping CPUID features that can cause trouble with teleportation and cold migration.

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

Legend:

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

    r29250 r30164  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2010 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    134134
    135135    /* Calculate the offset from CPUM to CPUMCPU for the first CPU. */
    136     pVM->cpum.s.ulOffCPUMCPU = RT_OFFSETOF(VM, aCpus[0].cpum) - RT_OFFSETOF(VM, cpum);
    137     Assert((uintptr_t)&pVM->cpum + pVM->cpum.s.ulOffCPUMCPU == (uintptr_t)&pVM->aCpus[0].cpum);
     136    pVM->cpum.s.offCPUMCPU0 = RT_OFFSETOF(VM, aCpus[0].cpum) - RT_OFFSETOF(VM, cpum);
     137    Assert((uintptr_t)&pVM->cpum + pVM->cpum.s.offCPUMCPU0 == (uintptr_t)&pVM->aCpus[0].cpum);
    138138
    139139    /* Calculate the offset from CPUMCPU to CPUM. */
     
    148148        pVCpu->cpum.s.pHyperCoreR0 = VM_R0_ADDR(pVM, CPUMCTX2CORE(&pVCpu->cpum.s.Hyper));
    149149
    150         pVCpu->cpum.s.ulOffCPUM   = RT_OFFSETOF(VM, aCpus[i].cpum) - RT_OFFSETOF(VM, cpum);
    151         Assert((uintptr_t)&pVCpu->cpum - pVCpu->cpum.s.ulOffCPUM == (uintptr_t)&pVM->cpum);
     150        pVCpu->cpum.s.offCPUM      = RT_OFFSETOF(VM, aCpus[i].cpum) - RT_OFFSETOF(VM, cpum);
     151        Assert((uintptr_t)&pVCpu->cpum - pVCpu->cpum.s.offCPUM == (uintptr_t)&pVM->cpum);
    152152    }
    153153
     
    322322
    323323/**
    324  * Load the overrides for a set of CPUID leafs.
     324 * Load the overrides for a set of CPUID leaves.
    325325 *
    326326 * @returns VBox status code.
    327  * @param   paLeafs             The leaf array.
    328  * @param   cLeafs              The number of leafs.
     327 * @param   paLeaves            The leaf array.
     328 * @param   cLeaves             The number of leaves.
    329329 * @param   uStart              The start leaf number.
    330330 * @param   pCfgNode            The CFGM node containing the overrides
    331331 *                              (/CPUM/HostCPUID/ or /CPUM/CPUID/).
    332332 */
    333 static int cpumR3CpuIdInitLoadOverrideSet(uint32_t uStart, PCPUMCPUID paLeafs, uint32_t cLeafs, PCFGMNODE pCfgNode)
    334 {
    335     for (uint32_t i = 0; i < cLeafs; i++)
    336     {
    337         int rc = cpumR3CpuIdFetchLeafOverride(&paLeafs[i], pCfgNode, uStart + i);
     333static int cpumR3CpuIdInitLoadOverrideSet(uint32_t uStart, PCPUMCPUID paLeaves, uint32_t cLeaves, PCFGMNODE pCfgNode)
     334{
     335    for (uint32_t i = 0; i < cLeaves; i++)
     336    {
     337        int rc = cpumR3CpuIdFetchLeafOverride(&paLeaves[i], pCfgNode, uStart + i);
    338338        if (RT_FAILURE(rc))
    339339            return rc;
     
    344344
    345345/**
    346  * Init a set of host CPUID leafs.
     346 * Init a set of host CPUID leaves.
    347347 *
    348348 * @returns VBox status code.
    349  * @param   paLeafs             The leaf array.
    350  * @param   cLeafs              The number of leafs.
     349 * @param   paLeaves            The leaf array.
     350 * @param   cLeaves             The number of leaves.
    351351 * @param   uStart              The start leaf number.
    352352 * @param   pCfgNode            The /CPUM/HostCPUID/ node.
    353353 */
    354 static int cpumR3CpuIdInitHostSet(uint32_t uStart, PCPUMCPUID paLeafs, uint32_t cLeafs, PCFGMNODE pCfgNode)
     354static int cpumR3CpuIdInitHostSet(uint32_t uStart, PCPUMCPUID paLeaves, uint32_t cLeaves, PCFGMNODE pCfgNode)
    355355{
    356356    /* Using the ECX variant for all of them can't hurt... */
    357     for (uint32_t i = 0; i < cLeafs; i++)
    358         ASMCpuId_Idx_ECX(uStart + i, 0, &paLeafs[i].eax, &paLeafs[i].ebx, &paLeafs[i].ecx, &paLeafs[i].edx);
    359 
    360     /* Load CPUID leaf override; we currently don't care if the caller
     357    for (uint32_t i = 0; i < cLeaves; i++)
     358        ASMCpuId_Idx_ECX(uStart + i, 0, &paLeaves[i].eax, &paLeaves[i].ebx, &paLeaves[i].ecx, &paLeaves[i].edx);
     359
     360    /* Load CPUID leaf override; we currently don't care if the user
    361361       specifies features the host CPU doesn't support. */
    362     return cpumR3CpuIdInitLoadOverrideSet(uStart, paLeafs, cLeafs, pCfgNode);
     362    return cpumR3CpuIdInitLoadOverrideSet(uStart, paLeaves, cLeaves, pCfgNode);
    363363}
    364364
     
    377377    int         rc;
    378378
    379     /*
    380      * Get the host CPUIDs and redetect the guest CPU vendor (could've been overridden).
     379#define PORTABLE_CLEAR_BITS_WHEN(Lvl, LeafSuffReg, FeatNm, fMask, uValue) \
     380    if (pCPUM->u8PortableCpuIdLevel >= (Lvl) && (pCPUM->aGuestCpuId##LeafSuffReg & (fMask)) == (uValue) ) \
     381    { \
     382        LogRel(("PortableCpuId: " #LeafSuffReg "[" #FeatNm "]: %#x -> 0\n", pCPUM->aGuestCpuId##LeafSuffReg & (fMask))); \
     383        pCPUM->aGuestCpuId##LeafSuffReg &= ~(uint32_t)(fMask); \
     384    }
     385#define PORTABLE_DISABLE_FEATURE_BIT(Lvl, LeafSuffReg, FeatNm, fBitMask) \
     386    if (pCPUM->u8PortableCpuIdLevel >= (Lvl) && (pCPUM->aGuestCpuId##LeafSuffReg & (fBitMask)) ) \
     387    { \
     388        LogRel(("PortableCpuId: " #LeafSuffReg "[" #FeatNm "]: 1 -> 0\n")); \
     389        pCPUM->aGuestCpuId##LeafSuffReg &= ~(uint32_t)(fBitMask); \
     390    }
     391
     392    /*
     393     * Read the configuration.
     394     */
     395    /** @cfgm{CPUM/SyntheticCpu, boolean, false}
     396     * Enables the Synthetic CPU.  The Vendor ID and Processor Name are
     397     * completely overridden by VirtualBox custom strings.  Some
     398     * CPUID information is withheld, like the cache info. */
     399    rc = CFGMR3QueryBoolDef(pCpumCfg, "SyntheticCpu",  &pCPUM->fSyntheticCpu,  false);
     400    AssertRCReturn(rc, rc);
     401
     402    /** @cfgm{CPUM/PortableCpuIdLevel, 8-bit, 0, 3, 0}
     403     * When non-zero CPUID features that could cause portability issues will be
     404     * stripped.  The higher the value the more features gets stripped.  Higher
     405     * values should only be used when older CPUs are involved since it may
     406     * harm performance and maybe also cause problems with specific guests. */
     407    rc = CFGMR3QueryU8Def(pCpumCfg, "PortableCpuIdLevel", &pCPUM->u8PortableCpuIdLevel, 0);
     408    AssertRCReturn(rc, rc);
     409
     410    AssertLogRelReturn(!pCPUM->fSyntheticCpu || !pCPUM->u8PortableCpuIdLevel, VERR_INTERNAL_ERROR_2);
     411
     412    /*
     413     * Get the host CPUID leaves and redetect the guest CPU vendor (could've
     414     * been overridden).
    381415     */
    382416    /** @cfgm{CPUM/HostCPUID/[000000xx|800000xx|c000000x]/[eax|ebx|ecx|edx],32-bit}
    383417     * Overrides the host CPUID leaf values used for calculating the guest CPUID
    384      * leafs.  This can be used to preserve the CPUID values when moving a VM to
    385      * a different machine.  Another use is restricting (or extending) the
     418     * leaves.  This can be used to preserve the CPUID values when moving a VM
     419     * to a different machine.  Another use is restricting (or extending) the
    386420     * feature set exposed to the guest. */
    387421    PCFGMNODE pHostOverrideCfg = CFGMR3GetChild(pCpumCfg, "HostCPUID");
     
    397431
    398432    /*
     433     * Determine the default leaf.
     434     *
     435     * Intel returns values of the highest standard function, while AMD
     436     * returns zeros. VIA on the other hand seems to returning nothing or
     437     * perhaps some random garbage, we don't try to duplicate this behavior.
     438     */
     439    ASMCpuId(pCPUM->aGuestCpuIdStd[0].eax + 10, /** @todo r=bird: Use the host value here in case of overrides and more than 10 leaves being stripped already. */
     440             &pCPUM->GuestCpuIdDef.eax, &pCPUM->GuestCpuIdDef.ebx,
     441             &pCPUM->GuestCpuIdDef.ecx, &pCPUM->GuestCpuIdDef.edx);
     442
     443
     444    /* Cpuid 1 & 0x80000001:
    399445     * Only report features we can support.
    400      */
    401     pCPUM->aGuestCpuIdStd[1].edx      &= X86_CPUID_FEATURE_EDX_FPU
    402                                        | X86_CPUID_FEATURE_EDX_VME
    403                                        | X86_CPUID_FEATURE_EDX_DE
    404                                        | X86_CPUID_FEATURE_EDX_PSE
    405                                        | X86_CPUID_FEATURE_EDX_TSC
    406                                        | X86_CPUID_FEATURE_EDX_MSR
    407                                        //| X86_CPUID_FEATURE_EDX_PAE   - not implemented yet.
    408                                        | X86_CPUID_FEATURE_EDX_MCE
    409                                        | X86_CPUID_FEATURE_EDX_CX8
    410                                        //| X86_CPUID_FEATURE_EDX_APIC  - set by the APIC device if present.
    411                                        /* Note! we don't report sysenter/sysexit support due to our inability to keep the IOPL part of eflags in sync while in ring 1 (see #1757) */
    412                                        //| X86_CPUID_FEATURE_EDX_SEP
    413                                        | X86_CPUID_FEATURE_EDX_MTRR
    414                                        | X86_CPUID_FEATURE_EDX_PGE
    415                                        | X86_CPUID_FEATURE_EDX_MCA
    416                                        | X86_CPUID_FEATURE_EDX_CMOV
    417                                        | X86_CPUID_FEATURE_EDX_PAT
    418                                        | X86_CPUID_FEATURE_EDX_PSE36
    419                                        //| X86_CPUID_FEATURE_EDX_PSN   - no serial number.
    420                                        | X86_CPUID_FEATURE_EDX_CLFSH
    421                                        //| X86_CPUID_FEATURE_EDX_DS    - no debug store.
    422                                        //| X86_CPUID_FEATURE_EDX_ACPI  - not virtualized yet.
    423                                        | X86_CPUID_FEATURE_EDX_MMX
    424                                        | X86_CPUID_FEATURE_EDX_FXSR
    425                                        | X86_CPUID_FEATURE_EDX_SSE
    426                                        | X86_CPUID_FEATURE_EDX_SSE2
    427                                        //| X86_CPUID_FEATURE_EDX_SS    - no self snoop.
    428                                        //| X86_CPUID_FEATURE_EDX_HTT   - no hyperthreading.
    429                                        //| X86_CPUID_FEATURE_EDX_TM    - no thermal monitor.
    430                                        //| X86_CPUID_FEATURE_EDX_PBE   - no pending break enabled.
    431                                        | 0;
    432     pCPUM->aGuestCpuIdStd[1].ecx      &= 0
    433                                        | X86_CPUID_FEATURE_ECX_SSE3
    434                                        /* Can't properly emulate monitor & mwait with guest SMP; force the guest to use hlt for idling VCPUs. */
    435                                        | ((pVM->cCpus == 1) ? X86_CPUID_FEATURE_ECX_MONITOR : 0)
    436                                        //| X86_CPUID_FEATURE_ECX_CPLDS - no CPL qualified debug store.
    437                                        //| X86_CPUID_FEATURE_ECX_VMX   - not virtualized.
    438                                        //| X86_CPUID_FEATURE_ECX_EST   - no extended speed step.
    439                                        //| X86_CPUID_FEATURE_ECX_TM2   - no thermal monitor 2.
    440                                          | X86_CPUID_FEATURE_ECX_SSSE3
    441                                        //| X86_CPUID_FEATURE_ECX_CNTXID - no L1 context id (MSR++).
    442                                        //| X86_CPUID_FEATURE_ECX_CX16  - no cmpxchg16b
    443                                        /* ECX Bit 14 - xTPR Update Control. Processor supports changing IA32_MISC_ENABLES[bit 23]. */
    444                                        //| X86_CPUID_FEATURE_ECX_TPRUPDATE
    445                                        /* ECX Bit 21 - x2APIC support - not yet. */
    446                                        // | X86_CPUID_FEATURE_ECX_X2APIC
    447                                        /* ECX Bit 23 - POPCNT instruction. */
    448                                        //| X86_CPUID_FEATURE_ECX_POPCNT
    449                                        | 0;
    450 
    451     /* ASSUMES that this is ALWAYS the AMD define feature set if present. */
    452     pCPUM->aGuestCpuIdExt[1].edx      &= X86_CPUID_AMD_FEATURE_EDX_FPU
    453                                        | X86_CPUID_AMD_FEATURE_EDX_VME
    454                                        | X86_CPUID_AMD_FEATURE_EDX_DE
    455                                        | X86_CPUID_AMD_FEATURE_EDX_PSE
    456                                        | X86_CPUID_AMD_FEATURE_EDX_TSC
    457                                        | X86_CPUID_AMD_FEATURE_EDX_MSR //?? this means AMD MSRs..
    458                                        //| X86_CPUID_AMD_FEATURE_EDX_PAE    - not implemented yet.
    459                                        //| X86_CPUID_AMD_FEATURE_EDX_MCE    - not virtualized yet.
    460                                        | X86_CPUID_AMD_FEATURE_EDX_CX8
    461                                        //| X86_CPUID_AMD_FEATURE_EDX_APIC   - set by the APIC device if present.
    462                                        /* Note! we don't report sysenter/sysexit support due to our inability to keep the IOPL part of eflags in sync while in ring 1 (see #1757) */
    463                                        //| X86_CPUID_AMD_FEATURE_EDX_SEP
    464                                        | X86_CPUID_AMD_FEATURE_EDX_MTRR
    465                                        | X86_CPUID_AMD_FEATURE_EDX_PGE
    466                                        | X86_CPUID_AMD_FEATURE_EDX_MCA
    467                                        | X86_CPUID_AMD_FEATURE_EDX_CMOV
    468                                        | X86_CPUID_AMD_FEATURE_EDX_PAT
    469                                        | X86_CPUID_AMD_FEATURE_EDX_PSE36
    470                                        //| X86_CPUID_AMD_FEATURE_EDX_NX     - not virtualized, requires PAE.
    471                                        //| X86_CPUID_AMD_FEATURE_EDX_AXMMX
    472                                        | X86_CPUID_AMD_FEATURE_EDX_MMX
    473                                        | X86_CPUID_AMD_FEATURE_EDX_FXSR
    474                                        | X86_CPUID_AMD_FEATURE_EDX_FFXSR
    475                                        //| X86_CPUID_AMD_FEATURE_EDX_PAGE1GB
    476                                        //| X86_CPUID_AMD_FEATURE_EDX_RDTSCP - AMD only; turned on when necessary
    477                                        //| X86_CPUID_AMD_FEATURE_EDX_LONG_MODE - turned on when necessary
    478                                        | X86_CPUID_AMD_FEATURE_EDX_3DNOW_EX
    479                                        | X86_CPUID_AMD_FEATURE_EDX_3DNOW
    480                                        | 0;
    481     pCPUM->aGuestCpuIdExt[1].ecx      &= 0
    482                                        //| X86_CPUID_AMD_FEATURE_ECX_LAHF_SAHF
    483                                        //| X86_CPUID_AMD_FEATURE_ECX_CMPL
    484                                        //| X86_CPUID_AMD_FEATURE_ECX_SVM    - not virtualized.
    485                                        //| X86_CPUID_AMD_FEATURE_ECX_EXT_APIC
    486                                        /* Note: This could prevent teleporting from AMD to Intel CPUs! */
    487                                        | X86_CPUID_AMD_FEATURE_ECX_CR8L         /* expose lock mov cr0 = mov cr8 hack for guests that can use this feature to access the TPR. */
    488                                        //| X86_CPUID_AMD_FEATURE_ECX_ABM
    489                                        //| X86_CPUID_AMD_FEATURE_ECX_SSE4A
    490                                        //| X86_CPUID_AMD_FEATURE_ECX_MISALNSSE
    491                                        //| X86_CPUID_AMD_FEATURE_ECX_3DNOWPRF
    492                                        //| X86_CPUID_AMD_FEATURE_ECX_OSVW
    493                                        //| X86_CPUID_AMD_FEATURE_ECX_IBS
    494                                        //| X86_CPUID_AMD_FEATURE_ECX_SSE5
    495                                        //| X86_CPUID_AMD_FEATURE_ECX_SKINIT
    496                                        //| X86_CPUID_AMD_FEATURE_ECX_WDT
    497                                        | 0;
    498 
    499     rc = CFGMR3QueryBoolDef(pCpumCfg, "SyntheticCpu", &pCPUM->fSyntheticCpu, false); AssertRCReturn(rc, rc);
     446     *
     447     * Note! When enabling new features the Synthetic CPU and Portable CPUID
     448     *       options may require adjusting (i.e. stripping what was enabled).
     449     */
     450    pCPUM->aGuestCpuIdStd[1].edx &= X86_CPUID_FEATURE_EDX_FPU
     451                                  | X86_CPUID_FEATURE_EDX_VME
     452                                  | X86_CPUID_FEATURE_EDX_DE
     453                                  | X86_CPUID_FEATURE_EDX_PSE
     454                                  | X86_CPUID_FEATURE_EDX_TSC
     455                                  | X86_CPUID_FEATURE_EDX_MSR
     456                                  //| X86_CPUID_FEATURE_EDX_PAE   - set later if configured.
     457                                  | X86_CPUID_FEATURE_EDX_MCE
     458                                  | X86_CPUID_FEATURE_EDX_CX8
     459                                  //| X86_CPUID_FEATURE_EDX_APIC  - set by the APIC device if present.
     460                                  /* Note! we don't report sysenter/sysexit support due to our inability to keep the IOPL part of eflags in sync while in ring 1 (see #1757) */
     461                                  //| X86_CPUID_FEATURE_EDX_SEP
     462                                  | X86_CPUID_FEATURE_EDX_MTRR
     463                                  | X86_CPUID_FEATURE_EDX_PGE
     464                                  | X86_CPUID_FEATURE_EDX_MCA
     465                                  | X86_CPUID_FEATURE_EDX_CMOV
     466                                  | X86_CPUID_FEATURE_EDX_PAT
     467                                  | X86_CPUID_FEATURE_EDX_PSE36
     468                                  //| X86_CPUID_FEATURE_EDX_PSN   - no serial number.
     469                                  | X86_CPUID_FEATURE_EDX_CLFSH
     470                                  //| X86_CPUID_FEATURE_EDX_DS    - no debug store.
     471                                  //| X86_CPUID_FEATURE_EDX_ACPI  - not virtualized yet.
     472                                  | X86_CPUID_FEATURE_EDX_MMX
     473                                  | X86_CPUID_FEATURE_EDX_FXSR
     474                                  | X86_CPUID_FEATURE_EDX_SSE
     475                                  | X86_CPUID_FEATURE_EDX_SSE2
     476                                  //| X86_CPUID_FEATURE_EDX_SS    - no self snoop.
     477                                  //| X86_CPUID_FEATURE_EDX_HTT   - no hyperthreading.
     478                                  //| X86_CPUID_FEATURE_EDX_TM    - no thermal monitor.
     479                                  //| X86_CPUID_FEATURE_EDX_PBE   - no pending break enabled.
     480                                  | 0;
     481    pCPUM->aGuestCpuIdStd[1].ecx &= 0
     482                                  | X86_CPUID_FEATURE_ECX_SSE3
     483                                  /* Can't properly emulate monitor & mwait with guest SMP; force the guest to use hlt for idling VCPUs. */
     484                                  | ((pVM->cCpus == 1) ? X86_CPUID_FEATURE_ECX_MONITOR : 0)
     485                                  //| X86_CPUID_FEATURE_ECX_CPLDS - no CPL qualified debug store.
     486                                  //| X86_CPUID_FEATURE_ECX_VMX   - not virtualized.
     487                                  //| X86_CPUID_FEATURE_ECX_EST   - no extended speed step.
     488                                  //| X86_CPUID_FEATURE_ECX_TM2   - no thermal monitor 2.
     489                                    | X86_CPUID_FEATURE_ECX_SSSE3
     490                                  //| X86_CPUID_FEATURE_ECX_CNTXID - no L1 context id (MSR++).
     491                                  //| X86_CPUID_FEATURE_ECX_CX16  - no cmpxchg16b
     492                                  /* ECX Bit 14 - xTPR Update Control. Processor supports changing IA32_MISC_ENABLES[bit 23]. */
     493                                  //| X86_CPUID_FEATURE_ECX_TPRUPDATE
     494                                  /* ECX Bit 21 - x2APIC support - not yet. */
     495                                  // | X86_CPUID_FEATURE_ECX_X2APIC
     496                                  /* ECX Bit 23 - POPCNT instruction. */
     497                                  //| X86_CPUID_FEATURE_ECX_POPCNT
     498                                  | 0;
     499    if (pCPUM->u8PortableCpuIdLevel > 0)
     500    {
     501        PORTABLE_CLEAR_BITS_WHEN(1, Std[1].eax, ProcessorType, (UINT32_C(3) << 12), (UINT32_C(2) << 12));
     502        PORTABLE_DISABLE_FEATURE_BIT(1, Std[1].ecx, SSSE3, X86_CPUID_FEATURE_ECX_SSSE3);
     503        PORTABLE_DISABLE_FEATURE_BIT(1, Std[1].ecx, SSE3,  X86_CPUID_FEATURE_ECX_SSE3);
     504        PORTABLE_DISABLE_FEATURE_BIT(2, Std[1].edx, SSE2,  X86_CPUID_FEATURE_EDX_SSE2);
     505        PORTABLE_DISABLE_FEATURE_BIT(3, Std[1].edx, SSE,   X86_CPUID_FEATURE_EDX_SSE);
     506        PORTABLE_DISABLE_FEATURE_BIT(3, Std[1].edx, CLFSH, X86_CPUID_FEATURE_EDX_CLFSH);
     507        PORTABLE_DISABLE_FEATURE_BIT(3, Std[1].edx, CMOV,  X86_CPUID_FEATURE_EDX_CMOV);
     508
     509        Assert(!(pCPUM->aGuestCpuIdStd[1].edx & (  X86_CPUID_FEATURE_EDX_SEP
     510                                                 | X86_CPUID_FEATURE_EDX_PSN
     511                                                 | X86_CPUID_FEATURE_EDX_DS
     512                                                 | X86_CPUID_FEATURE_EDX_ACPI
     513                                                 | X86_CPUID_FEATURE_EDX_SS
     514                                                 | X86_CPUID_FEATURE_EDX_TM
     515                                                 | X86_CPUID_FEATURE_EDX_PBE
     516                                                 )));
     517        Assert(!(pCPUM->aGuestCpuIdStd[1].ecx & (  X86_CPUID_FEATURE_ECX_PCLMUL
     518                                                 | X86_CPUID_FEATURE_ECX_DTES64
     519                                                 | X86_CPUID_FEATURE_ECX_CPLDS
     520                                                 | X86_CPUID_FEATURE_ECX_VMX
     521                                                 | X86_CPUID_FEATURE_ECX_SMX
     522                                                 | X86_CPUID_FEATURE_ECX_EST
     523                                                 | X86_CPUID_FEATURE_ECX_TM2
     524                                                 | X86_CPUID_FEATURE_ECX_CNTXID
     525                                                 | X86_CPUID_FEATURE_ECX_FMA
     526                                                 | X86_CPUID_FEATURE_ECX_CX16
     527                                                 | X86_CPUID_FEATURE_ECX_TPRUPDATE
     528                                                 | X86_CPUID_FEATURE_ECX_PDCM
     529                                                 | X86_CPUID_FEATURE_ECX_DCA
     530                                                 | X86_CPUID_FEATURE_ECX_MOVBE
     531                                                 | X86_CPUID_FEATURE_ECX_AES
     532                                                 | X86_CPUID_FEATURE_ECX_POPCNT
     533                                                 | X86_CPUID_FEATURE_ECX_XSAVE
     534                                                 | X86_CPUID_FEATURE_ECX_OSXSAVE
     535                                                 | X86_CPUID_FEATURE_ECX_AVX
     536                                                 )));
     537    }
     538
     539    /* Cpuid 0x80000001:
     540     * Only report features we can support.
     541     *
     542     * Note! When enabling new features the Synthetic CPU and Portable CPUID
     543     *       options may require adjusting (i.e. stripping what was enabled).
     544     *
     545     * ASSUMES that this is ALWAYS the AMD defined feature set if present.
     546     */
     547    pCPUM->aGuestCpuIdExt[1].edx &= X86_CPUID_AMD_FEATURE_EDX_FPU
     548                                  | X86_CPUID_AMD_FEATURE_EDX_VME
     549                                  | X86_CPUID_AMD_FEATURE_EDX_DE
     550                                  | X86_CPUID_AMD_FEATURE_EDX_PSE
     551                                  | X86_CPUID_AMD_FEATURE_EDX_TSC
     552                                  | X86_CPUID_AMD_FEATURE_EDX_MSR //?? this means AMD MSRs..
     553                                  //| X86_CPUID_AMD_FEATURE_EDX_PAE    - not implemented yet.
     554                                  //| X86_CPUID_AMD_FEATURE_EDX_MCE    - not virtualized yet.
     555                                  | X86_CPUID_AMD_FEATURE_EDX_CX8
     556                                  //| X86_CPUID_AMD_FEATURE_EDX_APIC   - set by the APIC device if present.
     557                                  /* Note! we don't report sysenter/sysexit support due to our inability to keep the IOPL part of eflags in sync while in ring 1 (see #1757) */
     558                                  //| X86_CPUID_AMD_FEATURE_EDX_SEP
     559                                  | X86_CPUID_AMD_FEATURE_EDX_MTRR
     560                                  | X86_CPUID_AMD_FEATURE_EDX_PGE
     561                                  | X86_CPUID_AMD_FEATURE_EDX_MCA
     562                                  | X86_CPUID_AMD_FEATURE_EDX_CMOV
     563                                  | X86_CPUID_AMD_FEATURE_EDX_PAT
     564                                  | X86_CPUID_AMD_FEATURE_EDX_PSE36
     565                                  //| X86_CPUID_AMD_FEATURE_EDX_NX     - not virtualized, requires PAE.
     566                                  //| X86_CPUID_AMD_FEATURE_EDX_AXMMX
     567                                  | X86_CPUID_AMD_FEATURE_EDX_MMX
     568                                  | X86_CPUID_AMD_FEATURE_EDX_FXSR
     569                                  | X86_CPUID_AMD_FEATURE_EDX_FFXSR
     570                                  //| X86_CPUID_AMD_FEATURE_EDX_PAGE1GB
     571                                  //| X86_CPUID_AMD_FEATURE_EDX_RDTSCP - AMD only; turned on when necessary
     572                                  //| X86_CPUID_AMD_FEATURE_EDX_LONG_MODE - turned on when necessary
     573                                  | X86_CPUID_AMD_FEATURE_EDX_3DNOW_EX
     574                                  | X86_CPUID_AMD_FEATURE_EDX_3DNOW
     575                                  | 0;
     576    pCPUM->aGuestCpuIdExt[1].ecx &= 0
     577                                  //| X86_CPUID_AMD_FEATURE_ECX_LAHF_SAHF
     578                                  //| X86_CPUID_AMD_FEATURE_ECX_CMPL
     579                                  //| X86_CPUID_AMD_FEATURE_ECX_SVM    - not virtualized.
     580                                  //| X86_CPUID_AMD_FEATURE_ECX_EXT_APIC
     581                                  /* Note: This could prevent teleporting from AMD to Intel CPUs! */
     582                                  | X86_CPUID_AMD_FEATURE_ECX_CR8L         /* expose lock mov cr0 = mov cr8 hack for guests that can use this feature to access the TPR. */
     583                                  //| X86_CPUID_AMD_FEATURE_ECX_ABM
     584                                  //| X86_CPUID_AMD_FEATURE_ECX_SSE4A
     585                                  //| X86_CPUID_AMD_FEATURE_ECX_MISALNSSE
     586                                  //| X86_CPUID_AMD_FEATURE_ECX_3DNOWPRF
     587                                  //| X86_CPUID_AMD_FEATURE_ECX_OSVW
     588                                  //| X86_CPUID_AMD_FEATURE_ECX_IBS
     589                                  //| X86_CPUID_AMD_FEATURE_ECX_SSE5
     590                                  //| X86_CPUID_AMD_FEATURE_ECX_SKINIT
     591                                  //| X86_CPUID_AMD_FEATURE_ECX_WDT
     592                                  | 0;
     593    if (pCPUM->u8PortableCpuIdLevel > 0)
     594    {
     595        PORTABLE_DISABLE_FEATURE_BIT(1, Ext[1].ecx, CR8L,       X86_CPUID_AMD_FEATURE_ECX_CR8L);
     596        PORTABLE_DISABLE_FEATURE_BIT(1, Ext[1].edx, 3DNOW,      X86_CPUID_AMD_FEATURE_EDX_3DNOW);
     597        PORTABLE_DISABLE_FEATURE_BIT(1, Ext[1].edx, 3DNOW_EX,   X86_CPUID_AMD_FEATURE_EDX_3DNOW_EX);
     598        PORTABLE_DISABLE_FEATURE_BIT(1, Ext[1].edx, FFXSR,      X86_CPUID_AMD_FEATURE_EDX_FFXSR);
     599        PORTABLE_DISABLE_FEATURE_BIT(1, Ext[1].edx, RDTSCP,     X86_CPUID_AMD_FEATURE_EDX_RDTSCP);
     600        PORTABLE_DISABLE_FEATURE_BIT(2, Ext[1].ecx, LAHF_SAHF,  X86_CPUID_AMD_FEATURE_ECX_LAHF_SAHF);
     601        PORTABLE_DISABLE_FEATURE_BIT(3, Ext[1].ecx, CMOV,       X86_CPUID_AMD_FEATURE_EDX_CMOV);
     602
     603        Assert(!(pCPUM->aGuestCpuIdExt[1].ecx & (  X86_CPUID_AMD_FEATURE_ECX_CMPL
     604                                                 | X86_CPUID_AMD_FEATURE_ECX_SVM
     605                                                 | X86_CPUID_AMD_FEATURE_ECX_EXT_APIC
     606                                                 | X86_CPUID_AMD_FEATURE_ECX_CR8L
     607                                                 | X86_CPUID_AMD_FEATURE_ECX_ABM
     608                                                 | X86_CPUID_AMD_FEATURE_ECX_SSE4A
     609                                                 | X86_CPUID_AMD_FEATURE_ECX_MISALNSSE
     610                                                 | X86_CPUID_AMD_FEATURE_ECX_3DNOWPRF
     611                                                 | X86_CPUID_AMD_FEATURE_ECX_OSVW
     612                                                 | X86_CPUID_AMD_FEATURE_ECX_IBS
     613                                                 | X86_CPUID_AMD_FEATURE_ECX_SSE5
     614                                                 | X86_CPUID_AMD_FEATURE_ECX_SKINIT
     615                                                 | X86_CPUID_AMD_FEATURE_ECX_WDT
     616                                                 | UINT32_C(0xffffc000)
     617                                                 )));
     618        Assert(!(pCPUM->aGuestCpuIdExt[1].edx & (  RT_BIT(10)
     619                                                 | X86_CPUID_AMD_FEATURE_EDX_SEP
     620                                                 | RT_BIT(18)
     621                                                 | RT_BIT(19)
     622                                                 | RT_BIT(21)
     623                                                 | X86_CPUID_AMD_FEATURE_EDX_AXMMX
     624                                                 | X86_CPUID_AMD_FEATURE_EDX_PAGE1GB
     625                                                 | RT_BIT(28)
     626                                                 )));
     627    }
     628
     629    /*
     630     * Apply the Synthetic CPU modifications. (TODO: move this up)
     631     */
    500632    if (pCPUM->fSyntheticCpu)
    501633    {
    502         const char szVendor[13]    = "VirtualBox  ";
    503         const char szProcessor[48] = "VirtualBox SPARCx86 Processor v1000            "; /* includes null terminator */
     634        static const char s_szVendor[13]    = "VirtualBox  ";
     635        static const char s_szProcessor[48] = "VirtualBox SPARCx86 Processor v1000            "; /* includes null terminator */
    504636
    505637        pCPUM->enmGuestCpuVendor = CPUMCPUVENDOR_SYNTHETIC;
     
    509641
    510642        /* 0: Vendor */
    511         pCPUM->aGuestCpuIdStd[0].ebx = pCPUM->aGuestCpuIdExt[0].ebx = ((uint32_t *)szVendor)[0];
    512         pCPUM->aGuestCpuIdStd[0].ecx = pCPUM->aGuestCpuIdExt[0].ecx = ((uint32_t *)szVendor)[2];
    513         pCPUM->aGuestCpuIdStd[0].edx = pCPUM->aGuestCpuIdExt[0].edx = ((uint32_t *)szVendor)[1];
     643        pCPUM->aGuestCpuIdStd[0].ebx = pCPUM->aGuestCpuIdExt[0].ebx = ((uint32_t *)s_szVendor)[0];
     644        pCPUM->aGuestCpuIdStd[0].ecx = pCPUM->aGuestCpuIdExt[0].ecx = ((uint32_t *)s_szVendor)[2];
     645        pCPUM->aGuestCpuIdStd[0].edx = pCPUM->aGuestCpuIdExt[0].edx = ((uint32_t *)s_szVendor)[1];
    514646
    515647        /* 1.eax: Version information.  family : model : stepping */
     
    532664
    533665        /* 0x800000002-4: Processor Name String Identifier. */
    534         pCPUM->aGuestCpuIdExt[2].eax = ((uint32_t *)szProcessor)[0];
    535         pCPUM->aGuestCpuIdExt[2].ebx = ((uint32_t *)szProcessor)[1];
    536         pCPUM->aGuestCpuIdExt[2].ecx = ((uint32_t *)szProcessor)[2];
    537         pCPUM->aGuestCpuIdExt[2].edx = ((uint32_t *)szProcessor)[3];
    538         pCPUM->aGuestCpuIdExt[3].eax = ((uint32_t *)szProcessor)[4];
    539         pCPUM->aGuestCpuIdExt[3].ebx = ((uint32_t *)szProcessor)[5];
    540         pCPUM->aGuestCpuIdExt[3].ecx = ((uint32_t *)szProcessor)[6];
    541         pCPUM->aGuestCpuIdExt[3].edx = ((uint32_t *)szProcessor)[7];
    542         pCPUM->aGuestCpuIdExt[4].eax = ((uint32_t *)szProcessor)[8];
    543         pCPUM->aGuestCpuIdExt[4].ebx = ((uint32_t *)szProcessor)[9];
    544         pCPUM->aGuestCpuIdExt[4].ecx = ((uint32_t *)szProcessor)[10];
    545         pCPUM->aGuestCpuIdExt[4].edx = ((uint32_t *)szProcessor)[11];
     666        pCPUM->aGuestCpuIdExt[2].eax = ((uint32_t *)s_szProcessor)[0];
     667        pCPUM->aGuestCpuIdExt[2].ebx = ((uint32_t *)s_szProcessor)[1];
     668        pCPUM->aGuestCpuIdExt[2].ecx = ((uint32_t *)s_szProcessor)[2];
     669        pCPUM->aGuestCpuIdExt[2].edx = ((uint32_t *)s_szProcessor)[3];
     670        pCPUM->aGuestCpuIdExt[3].eax = ((uint32_t *)s_szProcessor)[4];
     671        pCPUM->aGuestCpuIdExt[3].ebx = ((uint32_t *)s_szProcessor)[5];
     672        pCPUM->aGuestCpuIdExt[3].ecx = ((uint32_t *)s_szProcessor)[6];
     673        pCPUM->aGuestCpuIdExt[3].edx = ((uint32_t *)s_szProcessor)[7];
     674        pCPUM->aGuestCpuIdExt[4].eax = ((uint32_t *)s_szProcessor)[8];
     675        pCPUM->aGuestCpuIdExt[4].ebx = ((uint32_t *)s_szProcessor)[9];
     676        pCPUM->aGuestCpuIdExt[4].ecx = ((uint32_t *)s_szProcessor)[10];
     677        pCPUM->aGuestCpuIdExt[4].edx = ((uint32_t *)s_szProcessor)[11];
    546678
    547679        /* 0x800000005-7 - reserved -> zero */
     
    572704     * Intel: Cache and TLB information
    573705     * AMD:   Reserved
    574      * Safe to expose
    575      */
     706     * Safe to expose; restrict the number of calls to 1 for the portable case.
     707     */
     708    if (    pCPUM->u8PortableCpuIdLevel > 0
     709        &&  pCPUM->aGuestCpuIdStd[0].eax >= 2
     710        && (pCPUM->aGuestCpuIdStd[2].eax & 0xff) > 1)
     711    {
     712        LogRel(("PortableCpuId: Std[2].al: %d -> 1\n", pCPUM->aGuestCpuIdStd[2].eax & 0xff));
     713        pCPUM->aGuestCpuIdStd[2].eax &= UINT32_C(0xfffffffe);
     714    }
    576715
    577716    /* Cpuid 3:
    578      * Intel: EAX, EBX - reserved
     717     * Intel: EAX, EBX - reserved (transmeta uses these)
    579718     *        ECX, EDX - Processor Serial Number if available, otherwise reserved
    580719     * AMD:   Reserved
     
    582721     */
    583722    if (!(pCPUM->aGuestCpuIdStd[1].edx & X86_CPUID_FEATURE_EDX_PSN))
     723    {
    584724        pCPUM->aGuestCpuIdStd[3].ecx = pCPUM->aGuestCpuIdStd[3].edx = 0;
     725        if (pCPUM->u8PortableCpuIdLevel > 0)
     726            pCPUM->aGuestCpuIdStd[3].eax = pCPUM->aGuestCpuIdStd[3].ebx = 0;
     727    }
    585728
    586729    /* Cpuid 4:
     
    619762    pCPUM->aGuestCpuIdStd[5].ecx = pCPUM->aGuestCpuIdStd[5].edx = 0;
    620763    /** @cfgm{/CPUM/MWaitExtensions, boolean, false}
    621      * Expose MWAIT extended features to the guest.
    622      * For now we expose just MWAIT break on interrupt feature (bit 1)
     764     * Expose MWAIT extended features to the guest.  For now we expose
     765     * just MWAIT break on interrupt feature (bit 1).
    623766     */
    624767    bool fMWaitExtensions;
     
    643786        pCPUM->aGuestCpuIdStd[5].ecx = pCPUM->aGuestCpuIdStd[5].edx = 0;
    644787
    645     /*
    646      * Determine the default.
    647      *
    648      * Intel returns values of the highest standard function, while AMD
    649      * returns zeros. VIA on the other hand seems to returning nothing or
    650      * perhaps some random garbage, we don't try to duplicate this behavior.
    651      */
    652     ASMCpuId(pCPUM->aGuestCpuIdStd[0].eax + 10,
    653              &pCPUM->GuestCpuIdDef.eax, &pCPUM->GuestCpuIdDef.ebx,
    654              &pCPUM->GuestCpuIdDef.ecx, &pCPUM->GuestCpuIdDef.edx);
    655 
    656788    /* Cpuid 0x800000005 & 0x800000006 contain information about L1, L2 & L3 cache and TLB identifiers.
    657789     * Safe to pass on to the guest.
     
    686818                                            //| X86_CPUID_AMD_ADVPOWER_EDX_MC
    687819                                            //| X86_CPUID_AMD_ADVPOWER_EDX_HWPSTATE
    688 #if 1
    689             /* We don't expose X86_CPUID_AMD_ADVPOWER_EDX_TSCINVAR, because newer Linux kernels blindly assume
    690              * that the AMD performance counters work if this is set for 64 bits guests. (can't really find a CPUID feature bit for them though)
    691              */
    692 #else
     820#if 0 /* We don't expose X86_CPUID_AMD_ADVPOWER_EDX_TSCINVAR, because newer
     821       * Linux kernels blindly assume that the AMD performance counters work
     822       * if this is set for 64 bits guests. (Can't really find a CPUID feature
     823       * bit for them though.) */
    693824                                            | X86_CPUID_AMD_ADVPOWER_EDX_TSCINVAR
    694825#endif
     
    701832    /* Cpuid 0x800000008:
    702833     * AMD:               EBX, EDX - reserved
    703      *                    EAX: Virtual/Physical address Size
     834     *                    EAX: Virtual/Physical/Guest address Size
    704835     *                    ECX: Number of cores + APICIdCoreIdSize
    705836     * Intel:             EAX: Virtual/Physical address Size
     
    709840    {
    710841        /* Only expose the virtual and physical address sizes to the guest. (EAX completely) */
     842        pCPUM->aGuestCpuIdExt[8].eax &= UINT32_C(0x0000ffff);
    711843        pCPUM->aGuestCpuIdExt[8].ebx = pCPUM->aGuestCpuIdExt[8].edx = 0;  /* reserved */
    712844        /* Set APICIdCoreIdSize to zero (use legacy method to determine the number of cores per cpu)
     
    733865    rc = CFGMR3QueryBoolDef(pCpumCfg, "NT4LeafLimit", &fNt4LeafLimit, false); AssertRCReturn(rc, rc);
    734866    if (fNt4LeafLimit)
    735         pCPUM->aGuestCpuIdStd[0].eax = 3;
     867        pCPUM->aGuestCpuIdStd[0].eax = 3; /** @todo r=bird: shouldn't we check if pCPUM->aGuestCpuIdStd[0].eax > 3 before setting it 3 here? */
    736868
    737869    /*
     
    744876    if (pCPUM->aGuestCpuIdStd[0].eax > 5)
    745877        pCPUM->aGuestCpuIdStd[0].eax = 5;
    746 
    747878    for (i = pCPUM->aGuestCpuIdStd[0].eax + 1; i < RT_ELEMENTS(pCPUM->aGuestCpuIdStd); i++)
    748879        pCPUM->aGuestCpuIdStd[i] = pCPUM->GuestCpuIdDef;
     
    753884           ? pCPUM->aGuestCpuIdExt[0].eax - UINT32_C(0x80000000) + 1
    754885           : 0;
    755          i < RT_ELEMENTS(pCPUM->aGuestCpuIdExt); i++)
     886         i < RT_ELEMENTS(pCPUM->aGuestCpuIdExt);
     887         i++)
    756888        pCPUM->aGuestCpuIdExt[i] = pCPUM->GuestCpuIdDef;
    757889
     
    812944    DBGFR3InfoLog(pVM, "cpuid", "verbose"); /* macro */
    813945    LogRel(("******************** End of CPUID dump **********************\n"));
     946
     947#undef PORTABLE_DISABLE_FEATURE_BIT
     948#undef PORTABLE_CLEAR_BITS_WHEN
     949
    814950    return VINF_SUCCESS;
    815951}
    816 
    817 
    818952
    819953
     
    9231057     * Initialize everything to ZERO first.
    9241058     */
    925     uint32_t    fUseFlags =  pVCpu->cpum.s.fUseFlags & ~CPUM_USED_FPU_SINCE_REM;
     1059    uint32_t fUseFlags =  pVCpu->cpum.s.fUseFlags & ~CPUM_USED_FPU_SINCE_REM;
    9261060    memset(pCtx, 0, sizeof(*pCtx));
    9271061    pVCpu->cpum.s.fUseFlags  = fUseFlags;
     
    13271461     * Get the host and guest overrides so we don't reject the state because
    13281462     * some feature was enabled thru these interfaces.
    1329      * Note! We currently only need the feature leafs, so skip rest.
     1463     * Note! We currently only need the feature leaves, so skip rest.
    13301464     */
    13311465    PCFGMNODE   pOverrideCfg = CFGMR3GetChild(CFGMR3GetRoot(pVM), "CPUM/CPUID");
     
    14801614        CPUID_CHECK_RET(   (aHostRawExt[0].eax >= UINT32_C(0x80000001) && aHostRawExt[0].eax <= UINT32_C(0x8000007f))
    14811615                        || !(aRawExt[0].eax    >= UINT32_C(0x80000001) && aRawExt[0].eax     <= UINT32_C(0x8000007f)),
    1482                         (N_("Extended leafs was present on saved state host, but is missing on the current\n")));
     1616                        (N_("Extended leaves was present on saved state host, but is missing on the current\n")));
    14831617        if (aRawExt[0].eax >= UINT32_C(0x80000001) && aRawExt[0].eax     <= UINT32_C(0x8000007f))
    14841618        {
     
    27462880    if (cStdMax >= 1 && iVerbosity)
    27472881    {
     2882        static const char * const s_apszTypes[4] = { "primary", "overdrive", "MP", "reserved" };
     2883
    27482884        Guest = pVM->cpum.s.aGuestCpuIdStd[1];
    27492885        uint32_t uEAX = Guest.eax;
     
    27532889                        "Model:                           %d  \tExtended: %d \tEffective: %d\n"
    27542890                        "Stepping:                        %d\n"
    2755                         "Type:                            %d\n"
     2891                        "Type:                            %d (%s)\n"
    27562892                        "APIC ID:                         %#04x\n"
    27572893                        "Logical CPUs:                    %d\n"
     
    27612897                        (uEAX >> 4) & 0xf, (uEAX >> 16) & 0x0f, ASMGetCpuModel(uEAX, fIntel),
    27622898                        ASMGetCpuStepping(uEAX),
    2763                         (uEAX >> 12) & 3,
     2899                        (uEAX >> 12) & 3, s_apszTypes[(uEAX >> 12) & 3],
    27642900                        (Guest.ebx >> 24) & 0xff,
    27652901                        (Guest.ebx >> 16) & 0xff,
     
    32003336                        "Physical Address Width:          %d bits\n"
    32013337                        "Virtual Address Width:           %d bits\n",
     3338                        "Guest Physical Address Width:    %d bits\n",
    32023339                        (uEAX >> 0) & 0xff,
    3203                         (uEAX >> 8) & 0xff);
     3340                        (uEAX >> 8) & 0xff,
     3341                        (uEAX >> 16) & 0xff);
    32043342        pHlp->pfnPrintf(pHlp,
    32053343                        "Physical Core Count:             %d\n",
  • trunk/src/VBox/VMM/CPUMInternal.h

    r28800 r30164  
    257257typedef struct CPUM
    258258{
    259     /* Offset from CPUM to CPUMCPU for the first CPU. */
    260     uint32_t                ulOffCPUMCPU;
     259    /** Offset from CPUM to CPUMCPU for the first CPU. */
     260    uint32_t                offCPUMCPU0;
    261261
    262262    /** Use flags.
     
    282282    } CPUFeaturesExt;
    283283
    284     /* Host CPU manufacturer. */
     284    /** Host CPU manufacturer. */
    285285    CPUMCPUVENDOR           enmHostCpuVendor;
    286     /* Guest CPU manufacturer. */
     286    /** Guest CPU manufacturer. */
    287287    CPUMCPUVENDOR           enmGuestCpuVendor;
    288288
     
    298298    /** Synthetic CPU type? */
    299299    bool                    fSyntheticCpu;
     300    /** The (more) portable CPUID level.  */
     301    uint8_t                 u8PortableCpuIdLevel;
    300302    /** Indiciates that a state restore is pending.
    301303     * This is used to verify load order dependencies (PGM). */
    302304    bool                    fPendingRestore;
    303     uint8_t                 abPadding[1 + (HC_ARCH_BITS == 64) * 4];
     305#if HC_ARCH_BITS == 64
     306    uint8_t                 abPadding[4];
     307#endif
    304308
    305309    /** The standard set of CpuId leafs. */
     
    379383    uint32_t                fChanged;
    380384
    381     /* Offset to CPUM. (subtract from the pointer to get to CPUM) */
    382     uint32_t                ulOffCPUM;
    383 
    384     /* Temporary storage for the return code of the function called in the 32-64 switcher. */
     385    /** Offset from CPUM to CPUMCPU. */
     386    uint32_t                offCPUM;
     387
     388    /** Temporary storage for the return code of the function called in the
     389     * 32-64 switcher. */
    385390    uint32_t                u32RetCode;
    386391
    387     /** Align the next member, and thereby the structure, on a 64-byte boundrary. */
     392    /** Align the structure on a 64-byte boundrary. */
    388393    uint8_t                 abPadding2[HC_ARCH_BITS == 32 ? 36 : 28];
    389394} CPUMCPU, *PCPUMCPU;
  • trunk/src/VBox/VMM/CPUMInternal.mac

    r28800 r30164  
    55
    66;
    7 ; Copyright (C) 2006-2007 Oracle Corporation
     7; Copyright (C) 2006-2010 Oracle Corporation
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    4949struc CPUM
    5050    ;...
    51     .ulOffCPUMCPU         resd    1
     51    .offCPUMCPU0          resd    1
    5252    .fHostUseFlags        resd    1
    5353
     
    6969    .fRawEntered          resb    1
    7070    .fSyntheticCpu        resb    1
     71    .u8PortableCpuIdLevel resb    1
    7172    .fPendingRestore      resb    1
    7273%if RTHCPTR_CB == 8
    73     .abPadding            resb    5
     74    .abPadding            resb    4
    7475%else
    75     .abPadding            resb    1
     76;    .abPadding            resb    0
    7677%endif
    7778
     
    415416    .fUseFlags            resd    1
    416417    .fChanged             resd    1
    417     .ulOffCPUM            resd    1
     418    .offCPUM              resd    1
    418419    .u32RetCode           resd    1
    419420
     
    431432; @param   %1   register name
    432433%macro CPUMCPU_FROM_CPUM 1
    433     add     %1, dword [%1 + CPUM.ulOffCPUMCPU]
     434    add     %1, dword [%1 + CPUM.offCPUMCPU0]
    434435%endmacro
    435436
     
    438439; @param   %1   register name
    439440%macro CPUM_FROM_CPUMCPU 1
    440     sub     %1, dword [%1 + CPUMCPU.ulOffCPUM]
     441    sub     %1, dword [%1 + CPUMCPU.offCPUM]
    441442%endmacro
  • trunk/src/VBox/VMM/VMMAll/CPUMAllA.asm

    r28800 r30164  
    153153%ifndef RT_ARCH_AMD64
    154154    mov     eax, edx                            ; Calculate the PCPUM pointer
    155     sub     eax, [edx + CPUMCPU.ulOffCPUM]
     155    sub     eax, [edx + CPUMCPU.offCPUM]
    156156    test    dword [eax + CPUM.CPUFeatures.edx], X86_CPUID_FEATURE_EDX_FXSR
    157157    jz short hlfpua_no_fxsave
  • trunk/src/VBox/VMM/VMMAll/CPUMAllRegs.cpp

    r30145 r30164  
    13801380        {
    13811381            if (    pVM->cpum.s.aGuestCpuIdExt[0].eax < 0x80000001
    1382                 ||  !(ASMCpuId_EDX(0x80000001) & X86_CPUID_AMD_FEATURE_EDX_RDTSCP))
     1382                ||  !(ASMCpuId_EDX(0x80000001) & X86_CPUID_AMD_FEATURE_EDX_RDTSCP)
     1383                ||  pVM->cpum.s.u8PortableCpuIdLevel > 0)
    13831384            {
    1384                 LogRel(("WARNING: Can't turn on RDTSCP when the host doesn't support it!!\n"));
     1385                if (!pVM->cpum.s.u8PortableCpuIdLevel)
     1386                    LogRel(("WARNING: Can't turn on RDTSCP when the host doesn't support it!!\n"));
    13851387                return;
    13861388            }
  • trunk/src/VBox/VMM/VMMGC/CPUMGCA.asm

    r28800 r30164  
    7070    mov     edx, IMP(g_CPUM)
    7171    ; Convert to CPUMCPU pointer
    72     add     edx, [edx + CPUM.ulOffCPUMCPU]
     72    add     edx, [edx + CPUM.offCPUMCPU0]
    7373
    7474    mov     ecx, [edx + CPUMCPU.Guest.eip]
     
    249249BEGINPROC_EXPORTED CPUMGCResumeGuest
    250250    ; Convert to CPUMCPU pointer
    251     add     edx, [edx + CPUM.ulOffCPUMCPU]
     251    add     edx, [edx + CPUM.offCPUMCPU0]
    252252    ;
    253253    ; Setup iretd
     
    327327BEGINPROC_EXPORTED CPUMGCResumeGuestV86
    328328    ; Convert to CPUMCPU pointer
    329     add     edx, [edx + CPUM.ulOffCPUMCPU]
     329    add     edx, [edx + CPUM.offCPUMCPU0]
    330330    ;
    331331    ; Setup iretd
  • trunk/src/VBox/VMM/VMMSwitcher/AMD64andLegacy.mac

    r28800 r30164  
    196196BEGINPROC vmmR0HostToGuestAsm
    197197    ;; Store the offset from CPUM to CPUMCPU in r8
    198     mov     r8d, [rdx + CPUM.ulOffCPUMCPU]
     198    mov     r8d, [rdx + CPUM.offCPUMCPU0]
    199199
    200200    ;;
     
    943943    mov     rdx, [NAME(pCpumHC) wrt rip]
    944944    ; Load the CPUMCPU offset.
    945     mov     r8d, [rdx + CPUM.ulOffCPUMCPU]
     945    mov     r8d, [rdx + CPUM.offCPUMCPU0]
    946946
    947947    ; activate host gdt and idt
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