VirtualBox

Changeset 105656 in vbox for trunk


Ignore:
Timestamp:
Aug 13, 2024 7:27:02 AM (5 months ago)
Author:
vboxsync
Message:

VMM/IEM: Fix bound instruction emulation when running in the recompiler on ARM, ​bugref:10741 [Follow up fixes]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompFuncs.h

    r105655 r105656  
    37723772
    37733773#define IEM_MC_FETCH_GREG_I16(a_i16Dst, a_iGReg) \
    3774     off = iemNativeEmitFetchGregU16Sx(pReNative, off, a_i16Dst, a_iGReg, sizeof(uint32_t)) /* Note! ON ARM we use 32-bit registers for 16-bit. */
     3774    off = iemNativeEmitFetchGregI16(pReNative, off, a_i16Dst, a_iGReg)
     3775
     3776/** Emits code for IEM_MC_FETCH_GREG_I16. */
     3777DECL_INLINE_THROW(uint32_t)
     3778iemNativeEmitFetchGregI16(PIEMRECOMPILERSTATE pReNative, uint32_t off, uint8_t idxDstVar, uint8_t iGReg)
     3779{
     3780    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxDstVar);
     3781    IEMNATIVE_ASSERT_VAR_SIZE(pReNative, idxDstVar, sizeof(int16_t));
     3782    Assert(iGReg < 16);
     3783
     3784    /*
     3785     * We can either just load the low 16-bit of the GPR into a host register
     3786     * for the variable, or we can do so via a shadow copy host register. The
     3787     * latter will avoid having to reload it if it's being stored later, but
     3788     * will waste a host register if it isn't touched again.  Since we don't
     3789     * know what going to happen, we choose the latter for now.
     3790     */
     3791    uint8_t const idxGstFullReg = iemNativeRegAllocTmpForGuestReg(pReNative, &off, IEMNATIVEGSTREG_GPR(iGReg),
     3792                                                                  kIemNativeGstRegUse_ReadOnly);
     3793
     3794    iemNativeVarSetKindToStack(pReNative, idxDstVar);
     3795    uint8_t const idxVarReg = iemNativeVarRegisterAcquire(pReNative, idxDstVar, &off);
     3796#ifdef RT_ARCH_ARM64 /* Note! There are no 16-bit registers on ARM, we emulate that through 32-bit registers which requires sign extension. */
     3797    off = iemNativeEmitLoadGpr32SignExtendedFromGpr16(pReNative, off, idxVarReg, idxGstFullReg);
     3798#endif
     3799    iemNativeVarRegisterRelease(pReNative, idxDstVar);
     3800
     3801    iemNativeRegFreeTmp(pReNative, idxGstFullReg);
     3802    return off;
     3803}
     3804
    37753805
    37763806#define IEM_MC_FETCH_GREG_U16_SX_U32(a_u16Dst, a_iGReg) \
     
    69526982#define IEM_MC_FETCH_MEM_I16(a_i16Dst, a_iSeg, a_GCPtrMem) \
    69536983    off = iemNativeEmitMemFetchStoreDataCommon(pReNative, off, a_i16Dst, a_iSeg, a_GCPtrMem, \
    6954                                                sizeof(int16_t), sizeof(int16_t) - 1, kIemNativeEmitMemOp_Fetch, \
     6984                                               sizeof(int16_t), sizeof(int16_t) - 1, kIemNativeEmitMemOp_Fetch_Sx_U32, \
    69556985                                               (uintptr_t)iemNativeHlpMemFetchDataU16_Sx_U32, pCallEntry->idxInstr)
    69566986
    69576987#define IEM_MC_FETCH_MEM_I16_DISP(a_i16Dst, a_iSeg, a_GCPtrMem, a_offDisp) \
    69586988    off = iemNativeEmitMemFetchStoreDataCommon(pReNative, off, a_i16Dst, a_iSeg, a_GCPtrMem, \
    6959                                                sizeof(int16_t), sizeof(int16_t) - 1, kIemNativeEmitMemOp_Fetch, \
     6989                                               sizeof(int16_t), sizeof(int16_t) - 1, kIemNativeEmitMemOp_Fetch_Sx_U32, \
    69606990                                               (uintptr_t)iemNativeHlpMemFetchDataU16_Sx_U32, pCallEntry->idxInstr, a_offDisp)
    69616991
     
    70867116#define IEM_MC_FETCH_MEM_FLAT_I16(a_i16Dst, a_GCPtrMem) \
    70877117    off = iemNativeEmitMemFetchStoreDataCommon(pReNative, off, a_i16Dst, UINT8_MAX, a_GCPtrMem, \
    7088                                                sizeof(int16_t), sizeof(int16_t) - 1, kIemNativeEmitMemOp_Fetch, \
     7118                                               sizeof(int16_t), sizeof(int16_t) - 1, kIemNativeEmitMemOp_Fetch_Sx_U32, \
    70897119                                               (uintptr_t)iemNativeHlpMemFlatFetchDataU16_Sx_U32, pCallEntry->idxInstr)
    70907120
    70917121#define IEM_MC_FETCH_MEM_FLAT_I16_DISP(a_i16Dst, a_GCPtrMem, a_offDisp) \
    70927122    off = iemNativeEmitMemFetchStoreDataCommon(pReNative, off, a_i16Dst, UINT8_MAX, a_GCPtrMem, \
    7093                                                sizeof(int16_t), sizeof(int16_t) - 1, kIemNativeEmitMemOp_Fetch, \
     7123                                               sizeof(int16_t), sizeof(int16_t) - 1, kIemNativeEmitMemOp_Fetch_Sx_U32, \
    70947124                                               (uintptr_t)iemNativeHlpMemFlatFetchDataU16_Sx_U32, pCallEntry->idxInstr, a_offDisp)
    70957125
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