VirtualBox

Changeset 97564 in vbox


Ignore:
Timestamp:
Nov 16, 2022 9:33:28 AM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154596
Message:

IEM: Save/restore XMM8-15 based on CPU mode, not operand size in FXSAVE/FXRSTOR. Recalculate FSW.ES from FSW/FCW in FXRSTOR/XRSTOR to ensure consistency.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllCImpl.cpp

    r97524 r97564  
    85818581    }
    85828582
    8583     /* XMM registers. */
     8583    /* XMM registers. Skipped in 64-bit CPL0 if EFER.FFXSR (AMD only) is set. */
    85848584    if (   !(pVCpu->cpum.GstCtx.msrEFER & MSR_K6_EFER_FFXSR)
    85858585        || pVCpu->iem.s.enmCpuMode != IEMMODE_64BIT
    85868586        || pVCpu->iem.s.uCpl != 0)
    85878587    {
    8588         uint32_t cXmmRegs = enmEffOpSize == IEMMODE_64BIT ? 16 : 8;
     8588        uint32_t cXmmRegs = pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT ? 16 : 8;
    85898589        for (uint32_t i = 0; i < cXmmRegs; i++)
    85908590            pDst->aXMM[i] = pSrc->aXMM[i];
     
    86478647     */
    86488648    /** @todo CPU/VM detection possible! If CR4.OSFXSR=0 MXCSR it's
    8649      * implementation specific whether MXCSR and XMM0-XMM7 are restored. */
     8649     * implementation specific whether MXCSR and XMM0-XMM7 are
     8650     * restored according to Intel.
     8651     * AMD says MXCSR and XMM registers are never loaded if
     8652     * CR4.OSFXSR=0.
     8653     */
    86508654
    86518655    /* common for all formats */
     
    86658669
    86668670    /* FPU IP, CS, DP and DS. */
    8667     if (pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT)
     8671    /** @todo AMD says this is only done if FSW.ES is set after loading. */
     8672    if (enmEffOpSize == IEMMODE_64BIT)
    86688673    {
    86698674        pDst->FPUIP  = pSrc->FPUIP;
     
    86848689    }
    86858690
    8686     /* XMM registers. */
     8691    /* XMM registers. Skipped in 64-bit CPL0 if EFER.FFXSR (AMD only) is set.
     8692     * Does not affect MXCSR, only registers.
     8693     */
    86878694    if (   !(pVCpu->cpum.GstCtx.msrEFER & MSR_K6_EFER_FFXSR)
    86888695        || pVCpu->iem.s.enmCpuMode != IEMMODE_64BIT
    86898696        || pVCpu->iem.s.uCpl != 0)
    86908697    {
    8691         uint32_t cXmmRegs = enmEffOpSize == IEMMODE_64BIT ? 16 : 8;
     8698        uint32_t cXmmRegs = pVCpu->iem.s.enmCpuMode == IEMMODE_64BIT ? 16 : 8;
    86928699        for (uint32_t i = 0; i < cXmmRegs; i++)
    86938700            pDst->aXMM[i] = pSrc->aXMM[i];
    86948701    }
     8702
     8703    pDst->FCW &= ~X86_FCW_ZERO_MASK;
     8704    iemFpuRecalcExceptionStatus(pDst);
    86958705
    86968706    if (pDst->FSW & X86_FSW_ES)
     
    86998709
    87008710    /*
    8701      * Commit the memory.
     8711     * Unmap the memory.
    87028712     */
    87038713    rcStrict = iemMemCommitAndUnmap(pVCpu, pvMem512, IEM_ACCESS_DATA_R);
     
    89408950
    89418951    /*
    8942      * Store the X87 state.
     8952     * Load the X87 state.
    89438953     */
    89448954    if (fReqComponents & XSAVE_C_X87)
     
    89568966            if (enmEffOpSize == IEMMODE_64BIT)
    89578967            {
    8958                 /* Save upper 16-bits of FPUIP (IP:CS:Rsvd1) and FPUDP (DP:DS:Rsvd2). */
     8968                /* Load upper 16-bits of FPUIP (IP:CS:Rsvd1) and FPUDP (DP:DS:Rsvd2). */
    89598969                pDst->Rsrvd1 = pSrc->Rsrvd1;
    89608970                pDst->Rsrvd2 = pSrc->Rsrvd2;
     
    89728982                pDst->aRegs[i].au32[3] = 0;
    89738983            }
     8984
     8985            pDst->FCW &= ~X86_FCW_ZERO_MASK;
     8986            iemFpuRecalcExceptionStatus(pDst);
     8987
    89748988            if (pDst->FSW & X86_FSW_ES)
    89758989                Log11(("xrstor: %04x:%08RX64: loading state with pending FPU exception (FSW=%#x)\n",
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette