VirtualBox

Changeset 106739 in vbox for trunk/src/VBox/Disassembler


Ignore:
Timestamp:
Oct 28, 2024 9:38:32 AM (3 months ago)
Author:
vboxsync
Message:

Disassembler: Decode more barrier and addg/subg instructions, bugref:10394

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

Legend:

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

    r106662 r106739  
    109109static FNDISPARSEARMV8 disArmV8ParseImmHImmB;
    110110static FNDISPARSEARMV8 disArmV8ParseSf;
     111static FNDISPARSEARMV8 disArmV8ParseImmX16;
    111112/** @}  */
    112113
     
    162163    disArmV8ParseSimdRegScalar,
    163164    disArmV8ParseImmHImmB,
    164     disArmV8ParseSf
     165    disArmV8ParseSf,
     166    disArmV8ParseImmX16
    165167};
    166168
     
    915917
    916918
     919static int disArmV8ParseImmX16(PDISSTATE pDis, uint32_t u32Insn, PCDISARMV8OPCODE pOp, PCDISARMV8INSNCLASS pInsnClass, PDISOPPARAM pParam, PCDISARMV8INSNPARAM pInsnParm, bool *pf64Bit)
     920{
     921    RT_NOREF(pDis, pOp, pInsnClass, pf64Bit);
     922
     923    AssertReturn(pInsnParm->idxBitStart + pInsnParm->cBits < 32, VERR_INTERNAL_ERROR_2);
     924    Assert(pParam->armv8.enmType == kDisArmv8OpParmNone);
     925
     926    pParam->armv8.enmType = kDisArmv8OpParmImm;
     927    pParam->uValue = disArmV8ExtractBitVecFromInsn(u32Insn, pInsnParm->idxBitStart, pInsnParm->cBits) * 16;
     928    if (pParam->uValue <= UINT8_MAX)
     929    {
     930        pParam->armv8.cb = sizeof(uint8_t);
     931        pParam->fUse |= DISUSE_IMMEDIATE8;
     932    }
     933    else if (pParam->uValue <= UINT16_MAX)
     934    {
     935        pParam->armv8.cb = sizeof(uint16_t);
     936        pParam->fUse |= DISUSE_IMMEDIATE16;
     937    }
     938    else if (pParam->uValue <= UINT32_MAX)
     939    {
     940        pParam->armv8.cb = sizeof(uint32_t);
     941        pParam->fUse |= DISUSE_IMMEDIATE32;
     942    }
     943    else
     944        AssertReleaseFailed();
     945
     946    return VINF_SUCCESS;
     947}
     948
     949
    917950static uint32_t disArmV8DecodeIllegal(PDISSTATE pDis, uint32_t u32Insn, PCDISARMV8INSNCLASS pInsnClass)
    918951{
  • trunk/src/VBox/Disassembler/DisasmInternal-armv8.h

    r106649 r106739  
    8787    kDisParmParseImmHImmB,
    8888    kDisParmParseSf,
     89    kDisParmParseImmX16,
    8990    kDisParmParseMax
    9091} DISPARMPARSEIDX;
  • trunk/src/VBox/Disassembler/DisasmTables-armv8-a64.cpp

    r106737 r106739  
    177177
    178178
     179/* ADD/ADDS/SUB/SUBS - shifted immediate variant */
     180DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_DECODER(AddSubImmTags)
     181    DIS_ARMV8_INSN_DECODE(kDisParmParseGprSp,   0,  5, 0 /*idxParam*/),
     182    DIS_ARMV8_INSN_DECODE(kDisParmParseGprSp,   5,  5, 1 /*idxParam*/),
     183    DIS_ARMV8_INSN_DECODE(kDisParmParseImmX16, 16,  6, 2 /*idxParam*/),
     184    DIS_ARMV8_INSN_DECODE(kDisParmParseImm,    10,  4, 3 /*idxParam*/),
     185DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_BEGIN(AddSubImmTags)
     186    DIS_ARMV8_OP(0x91800000, "addg",            OP_ARMV8_A64_ADDG,      DISOPTYPE_HARMLESS), /* FEAT_MTE */
     187    DIS_ARMV8_OP(0xd1800000, "subg" ,           OP_ARMV8_A64_SUBG,      DISOPTYPE_HARMLESS), /* FEAT_MTE */
     188DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_END(AddSubImmTags, 0xffc0c000 /*fFixedInsn*/,
     189                                       kDisArmV8OpcDecodeNop, RT_BIT_32(30), 30);
     190
     191
    179192/*
    180193 * C4.1.65 of the ARMv8 architecture reference manual has the following table for the
     
    195208    DIS_ARMV8_DECODE_MAP_ENTRY(Adr),
    196209    DIS_ARMV8_DECODE_MAP_ENTRY(AddSubImm),
    197     DIS_ARMV8_DECODE_MAP_INVALID_ENTRY,                 /** @todo Add/subtract immediate with tags. */
     210    DIS_ARMV8_DECODE_MAP_ENTRY(AddSubImmTags),
    198211    DIS_ARMV8_DECODE_MAP_ENTRY(LogicalImm),
    199212    DIS_ARMV8_DECODE_MAP_ENTRY(MoveWide),
     
    297310    DIS_ARMV8_OP(0xd503304f, "clrex",           OP_ARMV8_A64_CLREX,     DISOPTYPE_HARMLESS),
    298311    INVALID_OPCODE,
    299     DIS_ARMV8_OP(0xD503309f, "dsb",             OP_ARMV8_A64_DSB,       DISOPTYPE_HARMLESS),
     312    DIS_ARMV8_OP(0xd503309f, "dsb",             OP_ARMV8_A64_DSB,       DISOPTYPE_HARMLESS),
    300313    DIS_ARMV8_OP(0xd50330bf, "dmb",             OP_ARMV8_A64_DMB,       DISOPTYPE_HARMLESS),
    301314DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_END(DecBarriers, 0xfffff0ff /*fFixedInsn*/,
     
    303316
    304317
     318/* ISB */
     319DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_DECODER(Isb)
     320    DIS_ARMV8_INSN_DECODE(kDisParmParseImm,            8,  4, 0 /*idxParam*/),
     321DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_BEGIN(Isb)
     322    DIS_ARMV8_OP(0xd50330df, "isb",             OP_ARMV8_A64_ISB,      DISOPTYPE_HARMLESS),
     323DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_END(Isb, 0xfffff0ff /*fFixedInsn*/,
     324                                       kDisArmV8OpcDecodeNop, 0, 0);
     325
     326
     327/* SB */
     328DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_DECODER(Sb)
     329DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_BEGIN(Sb)
     330    DIS_ARMV8_OP(0xd50330ff, "sb",              OP_ARMV8_A64_SB,       DISOPTYPE_HARMLESS), /* FEAT_SB */
     331DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_END(Sb, 0xffffffff /*fFixedInsn*/,
     332                                       kDisArmV8OpcDecodeNop, 0, 0);
     333
     334
     335/* TCOMMIT */
     336DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_DECODER(TCommit)
     337DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_BEGIN(TCommit)
     338    DIS_ARMV8_OP(0xd503307f, "tcommit",         OP_ARMV8_A64_TCOMMIT,  DISOPTYPE_HARMLESS), /* FEAT_TME */
     339DIS_ARMV8_DECODE_INSN_CLASS_DEFINE_END(TCommit, 0xffffffff /*fFixedInsn*/,
     340                                       kDisArmV8OpcDecodeNop, 0, 0);
     341
     342
    305343/* Barrier instructions, we divide these instructions further based on the op2 field. */
    306344DIS_ARMV8_DECODE_MAP_DEFINE_BEGIN(DecodeBarriers)
    307345    DIS_ARMV8_DECODE_MAP_INVALID_ENTRY,
    308     DIS_ARMV8_DECODE_MAP_INVALID_ENTRY,                     /** @todo DSB - Encoding */
     346    DIS_ARMV8_DECODE_MAP_INVALID_ENTRY,                     /** @todo DSB - Encoding (FEAT_XS) */
    309347    DIS_ARMV8_DECODE_MAP_ENTRY(DecBarriers),                /* CLREX */
    310     DIS_ARMV8_DECODE_MAP_INVALID_ENTRY,                     /** @todo TCOMMIT */
     348    DIS_ARMV8_DECODE_MAP_ENTRY(TCommit),
    311349    DIS_ARMV8_DECODE_MAP_ENTRY(DecBarriers),                /* DSB - Encoding */
    312350    DIS_ARMV8_DECODE_MAP_ENTRY(DecBarriers),                /* DMB */
    313     DIS_ARMV8_DECODE_MAP_INVALID_ENTRY,                     /** @todo ISB */
    314     DIS_ARMV8_DECODE_MAP_INVALID_ENTRY                      /** @todo SB */
     351    DIS_ARMV8_DECODE_MAP_ENTRY(Isb),
     352    DIS_ARMV8_DECODE_MAP_ENTRY(Sb),
    315353DIS_ARMV8_DECODE_MAP_DEFINE_END(DecodeBarriers, RT_BIT_32(5) | RT_BIT_32(6) | RT_BIT_32(7), 5);
    316354
  • trunk/src/VBox/Disassembler/testcase/tstDisasmArmv8-1-asm.S

    r106737 r106739  
    6464
    6565        ;chkfeat x16 - Not supported by buildbox toolchain
     66
     67        ; Barrier instructions
     68
     69        isb #0
     70        isb #8
     71        isb #15
     72
     73        sb
     74
     75        ;tcommit - Requires FEAT_TME
    6676
    6777        ; Control flow instructions
     
    15231533        ; msr svcrsma, #0 Not supported by the toolchain
    15241534
     1535        ; Add/subtract immediate with tags
     1536
     1537        ;addg x0, x1, #0, #0       - Requires FEAT_MTE
     1538        ;addg sp, sp, #1008, #0x0f - Requires FEAT_MTE
     1539
     1540        ;subg x0, x1, #0, #0       - Requires FEAT_MTE
     1541        ;subg sp, sp, #1008, #0x0f - Requires FEAT_MTE
     1542
    15251543        ; Floating Point instructions.
    15261544        fmadd  s0, s1, s3, s31
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