VirtualBox

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


Ignore:
Timestamp:
May 14, 2015 6:14:39 PM (10 years ago)
Author:
vboxsync
Message:

CPUMR3CpuId.cpp: Corrected XSAVE related CPUID handling loading old state.

File:
1 edited

Legend:

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

    r55740 r55862  
    30943094                        pCurLeaf->uEax &= RT_LO_U32(fGuestXcr0Mask);
    30953095                        pCurLeaf->uEdx &= RT_HI_U32(fGuestXcr0Mask);
     3096                        AssertLogRelMsgReturn((pCurLeaf->uEax & (XSAVE_C_X87 | XSAVE_C_SSE)) == (XSAVE_C_X87 | XSAVE_C_SSE),
     3097                                              ("CPUID(0xd/0).EAX missing mandatory X87 or SSE bits: %#RX32", pCurLeaf->uEax),
     3098                                              VERR_CPUM_IPE_1);
    30963099                        cbXSaveMax = pCurLeaf->uEcx;
    30973100                        AssertLogRelMsgReturn(cbXSaveMax <= CPUM_MAX_XSAVE_AREA_SIZE && cbXSaveMax >= CPUM_MIN_XSAVE_AREA_SIZE,
     
    48524855     *          EDX - Reserved, but is set to zero if invalid sub-leaf index.
    48534856     */
     4857    uint64_t fGuestXcr0Mask = 0;
    48544858    PCPUMCPUIDLEAF pCurLeaf = cpumR3CpuIdGetLeaf(paLeaves, cLeaves, UINT32_C(0x0000000d), 0);
    48554859    if (   pCurLeaf
     
    48604864            || pCurLeaf->uEdx) )
    48614865    {
    4862         uint64_t fGuestXcr0Mask = RT_MAKE_U64(pCurLeaf->uEax, pCurLeaf->uEdx);
     4866        fGuestXcr0Mask = RT_MAKE_U64(pCurLeaf->uEax, pCurLeaf->uEdx);
    48634867        if (fGuestXcr0Mask & ~pVM->cpum.s.fXStateHostMask)
    48644868            return SSMR3SetLoadError(pSSM, VERR_SSM_LOAD_CPUID_MISMATCH, RT_SRC_POS,
    48654869                                     N_("CPUID(0xd/0).EDX:EAX mismatch: %#llx saved, %#llx supported by the current host (XCR0 bits)"),
    48664870                                     fGuestXcr0Mask, pVM->cpum.s.fXStateHostMask);
     4871        if ((fGuestXcr0Mask & (XSAVE_C_X87 | XSAVE_C_SSE)) != (XSAVE_C_X87 | XSAVE_C_SSE))
     4872            return SSMR3SetLoadError(pSSM, VERR_SSM_LOAD_CPUID_MISMATCH, RT_SRC_POS,
     4873                                     N_("CPUID(0xd/0).EDX:EAX missing mandatory X87 or SSE bits: %#RX64"), fGuestXcr0Mask);
    48674874
    48684875        /* We don't support any additional features yet. */
     
    48764883                                     RT_MAKE_U64(pCurLeaf->uEdx, pCurLeaf->uEcx));
    48774884
    4878 
    4879         if (pVM->cpum.s.fXStateGuestMask != fGuestXcr0Mask)
    4880         {
    4881             LogRel(("CPUM: fXStateGuestMask=%#lx -> %#llx\n", pVM->cpum.s.fXStateGuestMask, fGuestXcr0Mask));
    4882             pVM->cpum.s.fXStateGuestMask = fGuestXcr0Mask;
    4883         }
    48844885
    48854886        for (uint32_t uSubLeaf = 2; uSubLeaf < 64; uSubLeaf++)
     
    49024903            }
    49034904        }
     4905    }
     4906    /* Clear leaf 0xd just in case we're loading an old state... */
     4907    else if (pCurLeaf)
     4908    {
     4909        AssertLogRel(uVersion <= CPUM_SAVED_STATE_VERSION_PUT_STRUCT);
     4910        for (uint32_t uSubLeaf = 0; uSubLeaf < 64; uSubLeaf++)
     4911        {
     4912            pCurLeaf = cpumR3CpuIdGetLeaf(paLeaves, cLeaves, UINT32_C(0x0000000d), uSubLeaf);
     4913            if (pCurLeaf)
     4914                pCurLeaf->uEax = pCurLeaf->uEbx = pCurLeaf->uEcx = pCurLeaf->uEdx = 0;
     4915        }
     4916    }
     4917
     4918    /* Update the fXStateGuestMask value for the VM. */
     4919    if (pVM->cpum.s.fXStateGuestMask != fGuestXcr0Mask)
     4920    {
     4921        LogRel(("CPUM: fXStateGuestMask=%#llx -> %#llx\n", pVM->cpum.s.fXStateGuestMask, fGuestXcr0Mask));
     4922        pVM->cpum.s.fXStateGuestMask = fGuestXcr0Mask;
     4923        if (!fGuestXcr0Mask && (aGuestCpuIdStd[1].uEcx & X86_CPUID_FEATURE_ECX_XSAVE))
     4924            return SSMR3SetLoadError(pSSM, VERR_SSM_LOAD_CPUID_MISMATCH, RT_SRC_POS,
     4925                                     N_("Internal Processing Error: XSAVE feature bit enabled, but leaf 0xd is empty."));
    49044926    }
    49054927
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