VirtualBox

Changeset 106743 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Oct 28, 2024 11:43:04 AM (4 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165627
Message:

VMM/ARM: Make the control flow graph generator work with ARMv8 A64 to some extent, bugref:10393

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/Makefile.kmk

    r106740 r106743  
    388388 VBoxVMMArm_SONAME.linux = VBoxVMMArm.so
    389389
    390  VBoxVMMArm_DEFS     = VBOX_VMM_TARGET_ARMV8 VBOX_IN_VMM IN_VMM_R3 IN_DIS IN_DBG IN_GMM_R3 \
     390 VBoxVMMArm_DEFS     = VBOX_VMM_TARGET_ARMV8 VBOX_DIS_WITH_ARMV8 VBOX_IN_VMM IN_VMM_R3 IN_DIS IN_DBG IN_GMM_R3 \
    391391        $(filter-out VBOX_WITH_IEM_RECOMPILER VBOX_WITH_IEM_NATIVE_RECOMPILER,$(VMM_COMMON_DEFS))
    392392 ifdef VBOX_WITH_VUSB
  • trunk/src/VBox/VMM/VMMR3/DBGFDisas.cpp

    r106061 r106743  
    651651        pDisState->Param3    = State.Dis.aParams[2];
    652652        pDisState->Param4    = State.Dis.aParams[3];
     653#if defined(VBOX_VMM_TARGET_ARMV8)
     654        memcpy(&pDisState->armv8, &State.Dis.armv8, sizeof(State.Dis.armv8));
     655#else
     656        memcpy(&pDisState->x86, &State.Dis.x86, sizeof(State.Dis.x86));
     657#endif
    653658    }
    654659
  • trunk/src/VBox/VMM/VMMR3/DBGFR3Flow.cpp

    r106061 r106743  
    213213
    214214/**
     215 * Returns whether the given opcode and disassembler state denote an unconditional jump instruction.
     216 *
     217 * @returns Flag whether the given instruction is an unconditional jump.
     218 * @param   uOpc        The opcode value from the disassembler.
     219 * @param   pDis        The disassembler state.
     220 */
     221DECL_FORCE_INLINE(bool) dbgfR3FlowDisOpcIsUncondJmp(uint16_t uOpc, PDBGFDISSTATE pDis)
     222{
     223#ifdef VBOX_VMM_TARGET_ARMV8
     224    if (   uOpc == OP_ARMV8_A64_BR
     225        || uOpc == OP_ARMV8_A64_BRAAZ
     226        || uOpc == OP_ARMV8_A64_BRABZ
     227        || uOpc == OP_ARMV8_A64_BRAA
     228        || uOpc == OP_ARMV8_A64_BRAB)
     229        return true;
     230
     231    /* B and BC are special because only the al condition is unconditional. */
     232    if (   uOpc == OP_ARMV8_A64_B
     233        || uOpc == OP_ARMV8_A64_BC)
     234    {
     235        return    pDis->armv8.enmCond == kDisArmv8InstrCond_Al
     236               || pDis->armv8.enmCond == kDisArmv8InstrCond_Al1;
     237    }
     238
     239    return false;
     240#else
     241    RT_NOREF(pDis);
     242
     243    return uOpc == OP_JMP;
     244#endif
     245}
     246
     247
     248/**
     249 * Returns whether the given opcode denotes a call/branch and link instruction.
     250 *
     251 * @returns Flag whether the given instruction is a call.
     252 * @param   uOpc        The opcode value from the disassembler.
     253 */
     254DECL_FORCE_INLINE(bool) dbgfR3FlowDisOpcIsCall(uint16_t uOpc)
     255{
     256#ifdef VBOX_VMM_TARGET_ARMV8
     257    if (   uOpc == OP_ARMV8_A64_BL
     258        || uOpc == OP_ARMV8_A64_BLR
     259        || uOpc == OP_ARMV8_A64_BLRAA
     260        || uOpc == OP_ARMV8_A64_BLRAB
     261        || uOpc == OP_ARMV8_A64_BLRAAZ
     262        || uOpc == OP_ARMV8_A64_BLRABZ)
     263        return true;
     264
     265    return false;
     266#else
     267    return uOpc == OP_CALL;
     268#endif
     269}
     270
     271
     272/**
     273 * Returns whether the given opcode denotes a function/exception return.
     274 *
     275 * @returns Flag whether the given instruction is a return.
     276 * @param   uOpc        The opcode value from the disassembler.
     277 */
     278DECL_FORCE_INLINE(bool) dbgfR3FlowDisOpcIsExit(uint16_t uOpc)
     279{
     280#ifdef VBOX_VMM_TARGET_ARMV8
     281    if (   uOpc == OP_ARMV8_A64_RET
     282        || uOpc == OP_ARMV8_A64_RETAA
     283        || uOpc == OP_ARMV8_A64_RETAB
     284        || uOpc == OP_ARMV8_A64_ERET
     285        || uOpc == OP_ARMV8_A64_ERETAA
     286        || uOpc == OP_ARMV8_A64_ERETAB)
     287        return true;
     288
     289    return false;
     290#else
     291    if (   uOpc == OP_RETN
     292        || uOpc == OP_RETF
     293        || uOpc == OP_IRET
     294        || uOpc == OP_SYSEXIT
     295        || uOpc == OP_SYSRET)
     296        return true;
     297
     298    return false;
     299#endif
     300}
     301
     302
     303/**
    215304 * Checks whether both addresses are equal.
    216305 *
     
    12291318                    uint16_t uOpc = DisState.pCurInstr->uOpcode;
    12301319
    1231                     if (uOpc == OP_CALL)
     1320                    if (dbgfR3FlowDisOpcIsCall(uOpc))
    12321321                        pThis->cCallInsns++;
    12331322
    1234                     if (   uOpc == OP_RETN || uOpc == OP_RETF || uOpc == OP_IRET
    1235                         || uOpc == OP_SYSEXIT || uOpc == OP_SYSRET)
     1323                    if (dbgfR3FlowDisOpcIsExit(uOpc))
    12361324                        pFlowBb->enmEndType = DBGFFLOWBBENDTYPE_EXIT;
    1237                     else if (uOpc == OP_JMP)
     1325                    else if (dbgfR3FlowDisOpcIsUncondJmp(uOpc, &DisState))
    12381326                    {
     1327#ifndef VBOX_VMM_TARGET_ARMV8 /* This is not true for B/BC on ARMv8 which can be both... */
    12391328                        Assert(DisState.pCurInstr->fOpType & DISOPTYPE_UNCOND_CONTROLFLOW);
     1329#endif
    12401330
    12411331                        if (dbgfR3FlowBranchTargetIsIndirect(&DisState.Param1))
     
    12791369                        }
    12801370                    }
    1281                     else if (uOpc != OP_CALL)
     1371                    else if (!dbgfR3FlowDisOpcIsCall(uOpc))
    12821372                    {
    12831373                        Assert(DisState.pCurInstr->fOpType & DISOPTYPE_COND_CONTROLFLOW);
    12841374                        pFlowBb->enmEndType = DBGFFLOWBBENDTYPE_COND;
     1375
     1376#ifdef VBOX_VMM_TARGET_ARMV8
     1377                        PDISOPPARAM pParam =   uOpc == OP_ARMV8_A64_B || uOpc == OP_ARMV8_A64_BC
     1378                                             ? &DisState.Param1
     1379                                             : uOpc == OP_ARMV8_A64_CBZ || uOpc == OP_ARMV8_A64_CBNZ
     1380                                             ? &DisState.Param2  /* cbz/cbnz. */
     1381                                             : &DisState.Param3; /* tbz/tbnz. */
     1382#else
     1383                        PDISOPPARAM pParam = &DisState.Param1;
     1384#endif
    12851385
    12861386                        /*
     
    12931393                        if (RT_SUCCESS(rc))
    12941394                        {
    1295                             rc = dbgfR3FlowQueryDirectBranchTarget(pUVM, idCpu, &DisState.Param1, &pInstr->AddrInstr, pInstr->cbInstr,
     1395                            rc = dbgfR3FlowQueryDirectBranchTarget(pUVM, idCpu, pParam, &pInstr->AddrInstr, pInstr->cbInstr,
    12961396                                                                   RT_BOOL(DisState.pCurInstr->fOpType & DISOPTYPE_RELATIVE_CONTROLFLOW),
    12971397                                                                   &pFlowBb->AddrTarget);
     
    13271427
    13281428                    /* Quit disassembling. */
    1329                     if (   (   uOpc != OP_CALL
     1429                    if (   (   !dbgfR3FlowDisOpcIsCall(uOpc)
    13301430                            || (pThis->fFlags & DBGF_FLOW_CREATE_F_CALL_INSN_SEPARATE_BB))
    13311431                        || RT_FAILURE(rc))
  • trunk/src/VBox/VMM/VMMR3/NEMR3Native-darwin-armv8.cpp

    r106667 r106743  
    3636#define LOG_GROUP LOG_GROUP_NEM
    3737#define VMCPU_INCL_CPUM_GST_CTX
    38 #define VBOX_DIS_WITH_ARMV8
    39 
    4038#include <VBox/vmm/nem.h>
    4139#include <VBox/vmm/iem.h>
  • trunk/src/VBox/VMM/include/DBGFInternal.h

    r106362 r106743  
    15101510    DISOPPARAM      Param3;
    15111511    DISOPPARAM      Param4;
     1512    /** Architecture specific state. */
     1513    RT_GCC_EXTENSION union
     1514    {
     1515        /** x86/AMD64 specific state. */
     1516        DIS_STATE_X86_T     x86;
     1517#if defined(VBOX_DIS_WITH_ARMV8)
     1518        /** ARMv8 specific state. */
     1519        DIS_STATE_ARMV8_T   armv8;
     1520#endif
     1521    };
    15121522} DBGFDISSTATE;
    15131523/** Pointer to a DBGF disassembler state. */
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