VirtualBox

Changeset 105785 in vbox for trunk/src


Ignore:
Timestamp:
Aug 21, 2024 5:23:15 PM (3 months ago)
Author:
vboxsync
Message:

Disassembler/ARMv8: Updates, decode basic ldr/str (unsigned with immediate) instructions, add them to the testcase, bugref:10394

Location:
trunk/src/VBox/Disassembler
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Disassembler/DisasmCore-armv8.cpp

    r105779 r105785  
    8888static FNDISPARSEARMV8 disArmV8ParseShift;
    8989static FNDISPARSEARMV8 disArmV8ParseShiftAmount;
     90static FNDISPARSEARMV8 disArmV8ParseImmMemOff;
    9091/** @}  */
    9192
     
    119120    disArmV8ParseImmTbz,
    120121    disArmV8ParseShift,
    121     disArmV8ParseShiftAmount
     122    disArmV8ParseShiftAmount,
     123    disArmV8ParseImmMemOff
    122124};
    123125
     
    242244    pParam->armv8.Reg.idxGenReg = disArmV8ExtractBitVecFromInsn(u32Insn, pInsnParm->idxBitStart, pInsnParm->cBits);
    243245    pParam->armv8.cb            = *pf64Bit ? sizeof(uint64_t) : sizeof(uint32_t);
    244     pParam->fUse |=   (*pf64Bit || (pInsnParm->fFlags & (DIS_ARMV8_INSN_PARAM_F_ADDR_BEGIN | DIS_ARMV8_INSN_PARAM_F_ADDR_END) ))
     246    pParam->fUse |=   (*pf64Bit || (pParam->armv8.enmType == kDisArmv8OpParmAddrInGpr))
    245247                    ? DISUSE_REG_GEN64
    246248                    : DISUSE_REG_GEN32;
     
    420422
    421423
     424static int disArmV8ParseImmMemOff(PDISSTATE pDis, uint32_t u32Insn, PCDISARMV8INSNCLASS pInsnClass, PDISOPPARAM pParam, PCDISARMV8INSNPARAM pInsnParm, bool *pf64Bit)
     425{
     426    RT_NOREF(pDis, pInsnClass, pf64Bit);
     427
     428    AssertReturn(pInsnParm->cBits <= 12, VERR_INTERNAL_ERROR_2);
     429
     430    uint8_t const uScale = *pf64Bit ? 8 : 4;
     431    pParam->armv8.offBase = disArmV8ExtractBitVecFromInsn(u32Insn, pInsnParm->idxBitStart, pInsnParm->cBits) * uScale;
     432    pParam->armv8.cb = sizeof(uint16_t);
     433    return VINF_SUCCESS;
     434}
     435
     436
    422437static uint32_t disArmV8DecodeIllegal(PDISSTATE pDis, uint32_t u32Insn, PCDISARMV8INSNCLASS pInsnClass)
    423438{
  • trunk/src/VBox/Disassembler/DisasmFormatArmV8.cpp

    r105779 r105785  
    713713                    break;
    714714                }
     715                case kDisArmv8OpParmAddrInGpr:
     716                {
     717                    PUT_C('[');
     718
     719                    size_t cchReg;
     720                    const char *pszReg = disasmFormatArmV8Reg(pDis, pParam, &cchReg);
     721                    PUT_STR(pszReg, cchReg);
     722
     723                    if (pParam->armv8.offBase)
     724                    {
     725                        PUT_SZ(", #");
     726                        PUT_NUM_16(pParam->armv8.offBase);
     727                    }
     728
     729                    PUT_C(']');
     730                    break;
     731                }
    715732                default:
    716733                    AssertFailed();
  • trunk/src/VBox/Disassembler/DisasmInternal-armv8.h

    r105779 r105785  
    6666    kDisParmParseShift,
    6767    kDisParmParseShiftAmount,
     68    kDisParmParseImmMemOff,
    6869    kDisParmParseMax
    6970} DISPARMPARSEIDX;
     
    9192    /** The parser to use for the parameter. */
    9293    DISPARMPARSEIDX     idxParse;
    93     /** Additional flags for the parameter. */
    94     uint32_t            fFlags;
    9594    /** Bit index at which the field starts. */
    9695    uint8_t             idxBitStart;
     
    103102typedef const DISARMV8INSNPARAM *PCDISARMV8INSNPARAM;
    104103
    105 #define DIS_ARMV8_INSN_PARAM_NONE { kDisParmParseNop, 0, 0, 0, DIS_ARMV8_INSN_PARAM_UNSET }
     104#define DIS_ARMV8_INSN_PARAM_NONE { kDisParmParseNop, 0, 0, DIS_ARMV8_INSN_PARAM_UNSET }
    106105#define DIS_ARMV8_INSN_PARAM_CREATE(a_idxParse, a_idxBitStart, a_cBits, a_idxParam) \
    107     { a_idxParse, 0, a_idxBitStart, a_cBits, a_idxParam }
    108 #define DIS_ARMV8_INSN_PARAM_CREATE_EX(a_idxParse, a_idxBitStart, a_cBits, a_idxParam, a_fFlags) \
    109     { a_idxParse, a_fFlags, a_idxBitStart, a_cBits, a_idxParam }
     106    { a_idxParse, a_idxBitStart, a_cBits, a_idxParam }
    110107
    111108#define DIS_ARMV8_INSN_PARAM_UNSET        UINT8_MAX
    112 
    113 #define DIS_ARMV8_INSN_PARAM_F_ADDR_BEGIN RT_BIT_32(0)
    114 #define DIS_ARMV8_INSN_PARAM_F_ADDR_END   RT_BIT_32(1)
    115109
    116110/**
  • trunk/src/VBox/Disassembler/DisasmTables-armv8-a64.cpp

    r105779 r105785  
    522522                                            kDisArmV8OpcDecodeLookup, 0xbfc00000, 0,
    523523                                            kDisArmv8OpParmGpr, kDisArmv8OpParmAddrInGpr)
    524     DIS_ARMV8_INSN_PARAM_CREATE(   kDisParmParseIs32Bit,       30,  1, DIS_ARMV8_INSN_PARAM_UNSET),
    525     DIS_ARMV8_INSN_PARAM_CREATE(   kDisParmParseReg,            0,  5, 0 /*idxParam*/),
    526     DIS_ARMV8_INSN_PARAM_CREATE_EX(kDisParmParseReg,            5,  5, 1 /*idxParam*/, DIS_ARMV8_INSN_PARAM_F_ADDR_BEGIN),
    527     DIS_ARMV8_INSN_PARAM_CREATE_EX(kDisParmParseImm,           10, 12, 2 /*idxParam*/, DIS_ARMV8_INSN_PARAM_F_ADDR_END),
     524    DIS_ARMV8_INSN_PARAM_CREATE(kDisParmParseIs32Bit,       30,  1, DIS_ARMV8_INSN_PARAM_UNSET),
     525    DIS_ARMV8_INSN_PARAM_CREATE(kDisParmParseReg,            0,  5, 0 /*idxParam*/),
     526    DIS_ARMV8_INSN_PARAM_CREATE(kDisParmParseReg,            5,  5, 1 /*idxParam*/),
     527    DIS_ARMV8_INSN_PARAM_CREATE(kDisParmParseImmMemOff,     10, 12, 1 /*idxParam*/),
    528528    DIS_ARMV8_INSN_PARAM_NONE
    529529DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_END;
  • trunk/src/VBox/Disassembler/testcase/tstDisasmArmv8-1-asm.S

    r105779 r105785  
    280280        bics x0, x1, x28, ROR #63
    281281
     282        ; Memory loads
     283        ldr x0, [x28]
     284        ldr x0, [x28, #8]
     285        ldr x0, [x28, #32760]
     286
     287        ldr w0, [x28]
     288        ldr w0, [x28, #4]
     289        ldr w0, [x28, #16380]
     290
     291        ; Memory stores
     292        str x0, [x28]
     293        str x0, [x28, #8]
     294        str x0, [x28, #32760]
     295
     296        str w0, [x28]
     297        str w0, [x28, #4]
     298        str w0, [x28, #16380]
     299
    282300        ;
    283301        ; Keep last so the testcase can catch errors in
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