VirtualBox

Changeset 49019 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
Oct 10, 2013 8:45:11 AM (11 years ago)
Author:
vboxsync
Message:

VMM: FPU cleanup.

File:
1 edited

Legend:

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

    r48814 r49019  
    535535
    536536/**
     537 * Checks for partial/leaky FXSAVE/FXRSTOR handling on AMD CPUs.
     538 *
     539 * AMD K7, K8 and newer AMD CPUs do not save/restore the x87 error
     540 * pointers (last instruction pointer, last data pointer, last opcode)
     541 * except when the ES bit (Exception Summary) in x87 FSW (FPU Status
     542 * Word) is set. Thus if we don't clear these registers there is
     543 * potential, local FPU leakage from a process using the FPU to
     544 * another.
     545 *
     546 * See AMD Instruction Reference for FXSAVE, FXRSTOR.
     547 *
     548 * @param   pVM     Pointer to the VM.
     549 */
     550static void cpumR3CheckLeakyFpu(PVM pVM)
     551{
     552    uint32_t u32CpuVersion;
     553    uint32_t u32Dummy;
     554    ASMCpuId(1, &u32CpuVersion, &u32Dummy, &u32Dummy, &u32Dummy);
     555    uint32_t const u32Family = u32CpuVersion >> 8;
     556    if (   u32Family >= 6      /* K7 and higher */
     557        && ASMIsAmdCpu())
     558    {
     559        uint32_t cExt = 0;
     560        ASMCpuId(0x80000000, &cExt, &u32Dummy, &u32Dummy, &u32Dummy);
     561        if (ASMIsValidExtRange(cExt))
     562        {
     563            uint32_t fExtFeaturesEDX = ASMCpuId_EDX(0x80000001);
     564            if (fExtFeaturesEDX & X86_CPUID_AMD_FEATURE_EDX_FFXSR)
     565            {
     566                for (VMCPUID i = 0; i < pVM->cCpus; i++)
     567                    pVM->aCpus[i].cpum.s.fUseFlags |= CPUM_USE_FFXSR_LEAKY;
     568                Log(("CPUMR3Init: host CPU has leaky fxsave/fxrstor behaviour\n"));
     569            }
     570        }
     571    }
     572}
     573
     574
     575/**
    537576 * Initializes the CPUM.
    538577 *
     
    646685    if (RT_FAILURE(rc))
    647686        return rc;
     687
     688    /*
     689     * Check if we need to workaround partial/leaky FPU handling.
     690     */
     691    cpumR3CheckLeakyFpu(pVM);
    648692
    649693    /*
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