VirtualBox

Changeset 104521 in vbox


Ignore:
Timestamp:
May 6, 2024 2:15:45 PM (9 months ago)
Author:
vboxsync
Message:

VMM/IEM: Corrected cvtps2pd memory access from 128 to 64 bits. bugref:9898 bugref:10683

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllAImpl.asm

    r104354 r104521  
    54645464        SSE_AVX_LD_MXCSR A0_32
    54655465
    5466         movdqu   xmm0, [A2]
    5467         movdqu   xmm1, [A3]
    5468         %1       xmm0, xmm1
    5469         movdqu   [A1], xmm0
     5466        movdqu  xmm0, [A2]
     5467        movdqu  xmm1, [A3]
     5468        %1      xmm0, xmm1
     5469        movdqu  [A1], xmm0
    54705470
    54715471        SSE_AVX_ST_MXCSR R0_32, A0_32
     
    54795479        SSE_AVX_LD_MXCSR A0_32
    54805480
    5481         vmovdqu   xmm0, [A2]
    5482         vmovdqu   xmm1, [A3]
    5483         v %+ %1   xmm0, xmm1
    5484         vmovdqu  [A1], xmm0
     5481        vmovdqu xmm0, [A2]
     5482        vmovdqu xmm1, [A3]
     5483        v %+ %1 xmm0, xmm1
     5484        vmovdqu [A1], xmm0
    54855485
    54865486        SSE_AVX_ST_MXCSR R0_32, A0_32
     
    54945494        SSE_AVX_LD_MXCSR A0_32
    54955495
    5496         vmovdqu    ymm0, [A2]
    5497         vmovdqu    ymm1, [A3]
     5496        vmovdqu ymm0, [A2]
     5497        vmovdqu ymm1, [A3]
    54985498 %if %2 == 0
    5499         v %+ %1    xmm0, ymm1
     5499        v %+ %1 xmm0, ymm1
    55005500 %else
    5501         v %+ %1    ymm0, xmm1
     5501        v %+ %1 ymm0, xmm1
    55025502 %endif
    5503         vmovdqu    [A1], ymm0
     5503        vmovdqu [A1], ymm0
    55045504
    55055505        SSE_AVX_ST_MXCSR R0_32, A0_32
     
    55105510
    55115511IEMIMPL_CVT_F2 cvtpd2ps, 0
    5512 IEMIMPL_CVT_F2 cvtps2pd, 1
     5512;IEMIMPL_CVT_F2 cvtps2pd, 1 - inefficient.
     5513
     5514BEGINPROC_FASTCALL iemAImpl_cvtps2pd_u128, 12
     5515        PROLOGUE_3_ARGS
     5516        IEMIMPL_SSE_PROLOGUE
     5517        SSE_AVX_LD_MXCSR A0_32
     5518
     5519        cvtps2pd xmm0, [A2]
     5520        movdqu   [A1], xmm0
     5521
     5522        SSE_AVX_ST_MXCSR R0_32, A0_32
     5523        IEMIMPL_SSE_EPILOGUE
     5524        EPILOGUE_3_ARGS
     5525ENDPROC iemAImpl_cvtps2pd_u128
     5526
    55135527
    55145528
  • trunk/src/VBox/VMM/VMMAll/IEMAllAImplC.cpp

    r104439 r104521  
    1684616846 */
    1684716847#ifdef IEM_WITHOUT_ASSEMBLY
    16848 static uint32_t iemAImpl_cvtps2pd_u128_worker(PRTFLOAT64U pr64Res, uint32_t fMxcsr, PCRTFLOAT32U pr32Val1)
    16849 {
    16850     RTFLOAT32U r32Src1;
    16851     fMxcsr |= iemSsePrepareValueR32(&r32Src1, fMxcsr, pr32Val1);
     16848static uint32_t iemAImpl_cvtps2pd_u128_worker(PRTFLOAT64U pr64Res, uint32_t fMxcsr, uint32_t u32SrcIn)
     16849{
     16850    RTFLOAT32U r32SrcConverted;
     16851    RTFLOAT32U r32SrcIn;
     16852    r32SrcIn.u = u32SrcIn;
     16853    fMxcsr |= iemSsePrepareValueR32(&r32SrcConverted, fMxcsr, &r32SrcIn);
    1685216854
    1685316855    softfloat_state_t SoftState = IEM_SOFTFLOAT_STATE_INITIALIZER_FROM_MXCSR(fMxcsr);
    16854     float64_t r64Result = f32_to_f64(iemFpSoftF32FromIprt(&r32Src1), &SoftState);
     16856    float64_t r64Result = f32_to_f64(iemFpSoftF32FromIprt(&r32SrcConverted), &SoftState);
    1685516857    return iemSseSoftStateAndR64ToMxcsrAndIprtResult(&SoftState, r64Result, pr64Res, fMxcsr);
    1685616858}
    1685716859
    1685816860
    16859 IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_cvtps2pd_u128,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2))
    16860 {
    16861     RT_NOREF(puSrc1);
    16862 
    16863     return   iemAImpl_cvtps2pd_u128_worker(&pResult->ar64[0], uMxCsrIn, &puSrc2->ar32[0])
    16864            | iemAImpl_cvtps2pd_u128_worker(&pResult->ar64[1], uMxCsrIn, &puSrc2->ar32[1]);
     16861IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_cvtps2pd_u128,(uint32_t fMxCsrIn, PX86XMMREG pResult, uint64_t const *pu64Src))
     16862{
     16863    uint64_t const u64Src = *pu64Src;
     16864    return   iemAImpl_cvtps2pd_u128_worker(&pResult->ar64[0], fMxCsrIn, RT_LO_U32(u64Src))
     16865           | iemAImpl_cvtps2pd_u128_worker(&pResult->ar64[1], fMxCsrIn, RT_HI_U32(u64Src));
    1686516866}
    1686616867#endif
  • trunk/src/VBox/VMM/VMMAll/IEMAllInstTwoByte0f.cpp.h

    r104439 r104521  
    758758 *
    759759 * Proper alignment of the 128-bit operand is enforced.
    760  * Exceptions type 2. SSE cpuid checks.
     760 * Exceptions type 3. SSE cpuid checks.
    761761 *
    762762 * @sa iemOpCommonSse41_FullFull_To_Full, iemOpCommonSse2_FullFull_To_Full
     
    886886 *
    887887 * Proper alignment of the 128-bit operand is enforced.
    888  * Exceptions type 2. SSE2 cpuid checks.
     888 * Exceptions type 3. SSE2 cpuid checks.
    889889 *
    890890 * @sa iemOpCommonSse41_FullFull_To_Full, iemOpCommonSse2_FullFull_To_Full
     
    54805480FNIEMOP_DEF(iemOp_cvtps2pd_Vpd_Wps)
    54815481{
    5482     IEMOP_MNEMONIC2(RM, CVTPS2PD, cvtps2pd, Vpd, Wps, DISOPTYPE_HARMLESS, 0);
    5483     return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvtps2pd_u128);
     5482    IEMOP_MNEMONIC2(RM, CVTPS2PD, cvtps2pd, Vpd_WO, Wps, DISOPTYPE_HARMLESS, 0);
     5483    uint8_t bRm; IEM_OPCODE_GET_NEXT_U8(&bRm);
     5484    if (IEM_IS_MODRM_REG_MODE(bRm))
     5485    {
     5486        /*
     5487         * XMM, XMM[63:0].
     5488         */
     5489        IEM_MC_BEGIN(IEM_MC_F_MIN_386, 0);
     5490        IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
     5491        IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
     5492        IEM_MC_PREPARE_SSE_USAGE();
     5493
     5494        IEM_MC_LOCAL(X86XMMREG,             SseRes);
     5495        IEM_MC_ARG_LOCAL_REF(PX86XMMREG,    pSseRes,        SseRes,     0);
     5496        IEM_MC_ARG(uint64_t const *,        pu64Src,                    1);  /* The input is actually two 32-bit float values, */
     5497        IEM_MC_REF_XREG_U64_CONST(pu64Src, IEM_GET_MODRM_RM(pVCpu, bRm));    /* but we've got no matching type or MC. */
     5498        IEM_MC_CALL_SSE_AIMPL_2(iemAImpl_cvtps2pd_u128, pSseRes, pu64Src);
     5499        IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
     5500        IEM_MC_STORE_XREG_XMM(IEM_GET_MODRM_REG(pVCpu, bRm), SseRes);
     5501
     5502        IEM_MC_ADVANCE_RIP_AND_FINISH();
     5503        IEM_MC_END();
     5504    }
     5505    else
     5506    {
     5507        /*
     5508         * XMM, [mem64].
     5509         */
     5510        IEM_MC_BEGIN(IEM_MC_F_MIN_386, 0);
     5511        IEM_MC_LOCAL(RTGCPTR, GCPtrEffSrc);
     5512        IEM_MC_CALC_RM_EFF_ADDR(GCPtrEffSrc, bRm, 0);
     5513        IEMOP_HLP_DONE_DECODING_NO_LOCK_PREFIX_EX(fSse2);
     5514        IEM_MC_MAYBE_RAISE_SSE_RELATED_XCPT();
     5515
     5516        IEM_MC_LOCAL(uint8_t,               bUnmapInfo);
     5517        IEM_MC_ARG(uint64_t const *,        pu64Src,                    1); /* (see comment above wrt type) */
     5518        IEM_MC_MEM_MAP_U64_RO(pu64Src, bUnmapInfo, pVCpu->iem.s.iEffSeg, GCPtrEffSrc);
     5519
     5520        IEM_MC_PREPARE_SSE_USAGE();
     5521        IEM_MC_LOCAL(X86XMMREG,             SseRes);
     5522        IEM_MC_ARG_LOCAL_REF(PX86XMMREG,    pSseRes,        SseRes,     0);
     5523        IEM_MC_CALL_SSE_AIMPL_2(iemAImpl_cvtps2pd_u128, pSseRes, pu64Src);
     5524        IEM_MC_MEM_COMMIT_AND_UNMAP_RO(bUnmapInfo);
     5525
     5526        IEM_MC_MAYBE_RAISE_SSE_AVX_SIMD_FP_OR_UD_XCPT();
     5527        IEM_MC_STORE_XREG_XMM(IEM_GET_MODRM_REG(pVCpu, bRm), SseRes);
     5528
     5529        IEM_MC_ADVANCE_RIP_AND_FINISH();
     5530        IEM_MC_END();
     5531    }
    54845532}
    54855533
     
    54885536FNIEMOP_DEF(iemOp_cvtpd2ps_Vps_Wpd)
    54895537{
    5490     IEMOP_MNEMONIC2(RM, CVTPD2PS, cvtpd2ps, Vps, Wpd, DISOPTYPE_HARMLESS, 0);
     5538    IEMOP_MNEMONIC2(RM, CVTPD2PS, cvtpd2ps, Vps_WO, Wpd, DISOPTYPE_HARMLESS, 0);
     5539    /** @todo inefficient as we don't need to fetch the destination (write-only). */
    54915540    return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvtpd2ps_u128);
    54925541}
     
    55125561FNIEMOP_DEF(iemOp_cvtdq2ps_Vps_Wdq)
    55135562{
    5514     IEMOP_MNEMONIC2(RM, CVTDQ2PS, cvtdq2ps, Vps, Wdq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
     5563    IEMOP_MNEMONIC2(RM, CVTDQ2PS, cvtdq2ps, Vps_WO, Wdq, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
     5564    /** @todo inefficient as we don't need to fetch the destination (write-only). */
    55155565    return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvtdq2ps_u128);
    55165566}
     
    55205570FNIEMOP_DEF(iemOp_cvtps2dq_Vdq_Wps)
    55215571{
    5522     IEMOP_MNEMONIC2(RM, CVTPS2DQ, cvtps2dq, Vdq, Wps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
     5572    IEMOP_MNEMONIC2(RM, CVTPS2DQ, cvtps2dq, Vdq_WO, Wps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
     5573    /** @todo inefficient as we don't need to fetch the destination (write-only). */
    55235574    return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvtps2dq_u128);
    55245575}
     
    55285579FNIEMOP_DEF(iemOp_cvttps2dq_Vdq_Wps)
    55295580{
    5530     IEMOP_MNEMONIC2(RM, CVTTPS2DQ, cvttps2dq, Vdq, Wps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
     5581    IEMOP_MNEMONIC2(RM, CVTTPS2DQ, cvttps2dq, Vdq_WO, Wps, DISOPTYPE_HARMLESS | DISOPTYPE_X86_SSE, 0);
     5582    /** @todo inefficient as we don't need to fetch the destination (write-only). */
    55315583    return FNIEMOP_CALL_1(iemOpCommonSse2Fp_FullFull_To_Full, iemAImpl_cvttps2dq_u128);
    55325584}
  • trunk/src/VBox/VMM/include/IEMInternal.h

    r104506 r104521  
    44444444FNIEMAIMPLFPSSEF2U128 iemAImpl_addsubps_u128;
    44454445FNIEMAIMPLFPSSEF2U128 iemAImpl_addsubpd_u128;
     4446
    44464447FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtpd2ps_u128;
    4447 FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtps2pd_u128;
     4448IEM_DECL_IMPL_PROTO(uint32_t, iemAImpl_cvtps2pd_u128,(uint32_t uMxCsrIn, PX86XMMREG pResult, uint64_t const *pu64Src));
    44484449
    44494450FNIEMAIMPLFPSSEF2U128 iemAImpl_cvtdq2ps_u128;
  • trunk/src/VBox/VMM/testcase/tstIEMAImpl.cpp

    r104269 r104521  
    55575557TYPEDEF_SUBTEST_TYPE(SSE_BINARY_R32_T, SSE_BINARY_TEST_T, PFNIEMAIMPLFPSSEF2U128);
    55585558
     5559/** Ugly hack to keep it working after changing function arguments! */
     5560IEM_DECL_IMPL_DEF(uint32_t, iemAImpl_cvtps2pd_u128x,(uint32_t uMxCsrIn, PX86XMMREG pResult, PCX86XMMREG puSrc1, PCX86XMMREG puSrc2))
     5561{
     5562    RT_NOREF(puSrc1);
     5563    return iemAImpl_cvtps2pd_u128(uMxCsrIn, pResult, &puSrc2->au64[0]);
     5564}
     5565
    55595566static SSE_BINARY_R32_T g_aSseBinaryR32[] =
    55605567{
     
    55695576    ENTRY_BIN(sqrtps_u128),
    55705577    ENTRY_BIN(addsubps_u128),
    5571     ENTRY_BIN(cvtps2pd_u128),
     5578    ENTRY_BIN(cvtps2pd_u128x), /* conversion hack */
    55725579};
    55735580
  • trunk/src/VBox/VMM/testcase/tstIEMAImpl.h

    r103064 r104521  
    944944TSTIEM_DECLARE_TEST_ARRAY_BIN(SseBinary,    SSE_BINARY_TEST_T,          sqrtps_u128              );
    945945TSTIEM_DECLARE_TEST_ARRAY_BIN(SseBinary,    SSE_BINARY_TEST_T,          addsubps_u128            );
    946 TSTIEM_DECLARE_TEST_ARRAY_BIN(SseBinary,    SSE_BINARY_TEST_T,          cvtps2pd_u128            );
     946TSTIEM_DECLARE_TEST_ARRAY_BIN(SseBinary,    SSE_BINARY_TEST_T,          cvtps2pd_u128x           );
    947947
    948948TSTIEM_DECLARE_TEST_ARRAY_BIN(SseBinary,    SSE_BINARY_U128_R32_TEST_T, addss_u128_r32           );
  • trunk/src/VBox/VMM/testcase/tstIEMAImplDataSseBinary.S

    r104022 r104521  
    7070IEM_TEST_DATA sqrtps_u128,       "tstIEMAImplDataSseBinary-sqrtps_u128.bin.gz"
    7171IEM_TEST_DATA addsubps_u128,     "tstIEMAImplDataSseBinary-addsubps_u128.bin.gz"
    72 IEM_TEST_DATA cvtps2pd_u128,     "tstIEMAImplDataSseBinary-cvtps2pd_u128.bin.gz"
     72IEM_TEST_DATA cvtps2pd_u128x,    "tstIEMAImplDataSseBinary-cvtps2pd_u128.bin.gz"
    7373
    7474IEM_TEST_DATA addss_u128_r32,    "tstIEMAImplDataSseBinary-addss_u128_r32.bin.gz"
  • trunk/src/VBox/VMM/testcase/tstIEMAImplDataSseBinary.asm

    r103075 r104521  
    6969IEM_TEST_DATA sqrtps_u128,          "tstIEMAImplDataSseBinary-sqrtps_u128.bin.gz"
    7070IEM_TEST_DATA addsubps_u128,        "tstIEMAImplDataSseBinary-addsubps_u128.bin.gz"
    71 IEM_TEST_DATA cvtps2pd_u128,        "tstIEMAImplDataSseBinary-cvtps2pd_u128.bin.gz"
     71IEM_TEST_DATA cvtps2pd_u128x,       "tstIEMAImplDataSseBinary-cvtps2pd_u128.bin.gz"
    7272
    7373IEM_TEST_DATA addss_u128_r32,       "tstIEMAImplDataSseBinary-addss_u128_r32.bin.gz"
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