VirtualBox

Ignore:
Timestamp:
Jul 24, 2024 2:23:13 PM (6 months ago)
Author:
vboxsync
Message:

VMM/IEM: Better fix for the pmov* emitters when the guest source register == guest destination register, bugref:10652

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/target-x86/IEMAllN8veEmit-x86.h

    r105407 r105484  
    24512451                                                uint8_t const idxSimdGstRegDst, uint8_t const idxSimdGstRegSrc) \
    24522452    { \
    2453         /* \
    2454          * The order of register allocation is important here when idxSimdGstRegSrc == idxSimdGstRegDst, \
    2455          * if _ForFullWrite is allocated first the register won't be initialized. \
    2456          */ \
    2457         uint8_t const idxSimdRegSrc = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegSrc), \
    2458                                                                               kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ReadOnly); \
    2459         uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegDst), \
    2460                                                                               kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForFullWrite); \
    2461         PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 6); \
    2462         pCodeBuf[off++] = X86_OP_PRF_SIZE_OP; \
    2463         if (idxSimdRegDst >= 8 || idxSimdRegSrc >= 8) \
    2464             pCodeBuf[off++] =   (idxSimdRegSrc >= 8 ? X86_OP_REX_B : 0) \
    2465                               | (idxSimdRegDst >= 8 ? X86_OP_REX_R : 0); \
    2466         pCodeBuf[off++] = 0x0f; \
    2467         pCodeBuf[off++] = 0x38; \
    2468         pCodeBuf[off++] = (a_bOpcX86); \
    2469         pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, idxSimdRegDst & 7, idxSimdRegSrc & 7); \
    2470         iemNativeSimdRegFreeTmp(pReNative, idxSimdRegDst); \
    2471         iemNativeSimdRegFreeTmp(pReNative, idxSimdRegSrc); \
     2453        if (idxSimdGstRegDst == idxSimdGstRegSrc) \
     2454        { \
     2455            uint8_t const idxSimdReg = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegSrc), \
     2456                                                                                  kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForUpdate); \
     2457            PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 6); \
     2458            pCodeBuf[off++] = X86_OP_PRF_SIZE_OP; \
     2459            if (idxSimdReg >= 8) \
     2460                pCodeBuf[off++] = (idxSimdReg >= 8 ? X86_OP_REX_B | X86_OP_REX_R : 0); \
     2461            pCodeBuf[off++] = 0x0f; \
     2462            pCodeBuf[off++] = 0x38; \
     2463            pCodeBuf[off++] = (a_bOpcX86); \
     2464            pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, idxSimdReg & 7, idxSimdReg & 7); \
     2465            iemNativeSimdRegFreeTmp(pReNative, idxSimdReg); \
     2466        } \
     2467        else \
     2468        { \
     2469            uint8_t const idxSimdRegSrc = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegSrc), \
     2470                                                                                  kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ReadOnly); \
     2471            uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegDst), \
     2472                                                                                  kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForFullWrite); \
     2473            PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 6); \
     2474            pCodeBuf[off++] = X86_OP_PRF_SIZE_OP; \
     2475            if (idxSimdRegDst >= 8 || idxSimdRegSrc >= 8) \
     2476                pCodeBuf[off++] =   (idxSimdRegSrc >= 8 ? X86_OP_REX_B : 0) \
     2477                                  | (idxSimdRegDst >= 8 ? X86_OP_REX_R : 0); \
     2478            pCodeBuf[off++] = 0x0f; \
     2479            pCodeBuf[off++] = 0x38; \
     2480            pCodeBuf[off++] = (a_bOpcX86); \
     2481            pCodeBuf[off++] = X86_MODRM_MAKE(X86_MOD_REG, idxSimdRegDst & 7, idxSimdRegSrc & 7); \
     2482            iemNativeSimdRegFreeTmp(pReNative, idxSimdRegDst); \
     2483            iemNativeSimdRegFreeTmp(pReNative, idxSimdRegSrc); \
     2484        } \
    24722485        IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); \
    24732486        return off; \
     
    25102523                                                uint8_t const idxSimdGstRegDst, uint8_t const idxSimdGstRegSrc) \
    25112524    { \
    2512         /* \
    2513          * The order of register allocation is important here when idxSimdGstRegSrc == idxSimdGstRegDst, \
    2514          * if _ForFullWrite is allocated first the register won't be initialized. \
    2515          */ \
    2516         uint8_t const idxSimdRegSrc = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegSrc), \
    2517                                                                               kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ReadOnly); \
    2518         uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegDst), \
    2519                                                                               kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForFullWrite); \
    2520         PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); \
    2521         pCodeBuf[off++] = Armv8A64MkVecInstrUShll(idxSimdRegDst, idxSimdRegSrc, 0, (a_ArmElemSz), (a_fArmUnsigned)); \
    2522         iemNativeSimdRegFreeTmp(pReNative, idxSimdRegDst); \
    2523         iemNativeSimdRegFreeTmp(pReNative, idxSimdRegSrc); \
     2525        if (idxSimdGstRegDst == idxSimdGstRegSrc) \
     2526        { \
     2527            uint8_t const idxSimdReg = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegSrc), \
     2528                                                                               kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForUpdate); \
     2529            PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); \
     2530            pCodeBuf[off++] = Armv8A64MkVecInstrUShll(idxSimdReg, idxSimdReg, 0, (a_ArmElemSz), (a_fArmUnsigned)); \
     2531            iemNativeSimdRegFreeTmp(pReNative, idxSimdReg); \
     2532        } \
     2533        else \
     2534        { \
     2535            uint8_t const idxSimdRegSrc = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegSrc), \
     2536                                                                                  kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ReadOnly); \
     2537            uint8_t const idxSimdRegDst = iemNativeSimdRegAllocTmpForGuestSimdReg(pReNative, &off, IEMNATIVEGSTSIMDREG_SIMD(idxSimdGstRegDst), \
     2538                                                                                  kIemNativeGstSimdRegLdStSz_Low128, kIemNativeGstRegUse_ForFullWrite); \
     2539            PIEMNATIVEINSTR const pCodeBuf = iemNativeInstrBufEnsure(pReNative, off, 1); \
     2540            pCodeBuf[off++] = Armv8A64MkVecInstrUShll(idxSimdRegDst, idxSimdRegSrc, 0, (a_ArmElemSz), (a_fArmUnsigned)); \
     2541            iemNativeSimdRegFreeTmp(pReNative, idxSimdRegDst); \
     2542            iemNativeSimdRegFreeTmp(pReNative, idxSimdRegSrc); \
     2543        } \
    25242544        IEMNATIVE_ASSERT_INSTR_BUF_ENSURE(pReNative, off); \
    25252545        return off; \
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