VirtualBox

Changeset 23099 in vbox for trunk/src/VBox/VMM/PATM


Ignore:
Timestamp:
Sep 17, 2009 2:39:06 PM (15 years ago)
Author:
vboxsync
Message:

PATM: implemented couple tweaks to make NetBSD bootable (still some spurious segfaults)

Location:
trunk/src/VBox/VMM/PATM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PATM/PATM.cpp

    r22890 r23099  
    167167# endif
    168168#endif
     169    pVM->patm.s.uPATMFlags = 0;
     170    bool fSearchBackward;
     171    CFGMR3QueryBoolDef(CFGMR3GetChild(CFGMR3GetRoot(pVM), "PATM"), "SearchImmediatesBackward", &fSearchBackward, false);
     172    if (fSearchBackward)
     173        pVM->patm.s.uPATMFlags |= PATMGFL_SEARCH_IMM_BACKWARD;
    169174
    170175    rc = patmReinit(pVM);
     
    15461551
    15471552/**
     1553 * Checks if few instructions before patch contain something
     1554 * which looks like immediate referring potential patch instruction
     1555 *
     1556 * @returns boolean
     1557 * @param   pVM         The VM to operate on.
     1558 * @param   pInstrGC    Guest context pointer to instruction
     1559 */
     1560static bool patmHasImmsReferringPatch(PVM pVM, RCPTRTYPE(uint8_t *) pInstrGC)
     1561{
     1562    int rc;
     1563    uint32_t value;
     1564
     1565    if (!(pVM->patm.s.uPATMFlags & PATMGFL_SEARCH_IMM_BACKWARD))
     1566        return false;
     1567
     1568    PVMCPU pCpu = VMMGetCpu0(pVM);
     1569    for (int i = 4; i < 12; i++)
     1570    {
     1571        rc = PGMPhysSimpleReadGCPtr(pCpu, &value, pInstrGC - i, 4);
     1572        if (rc == VINF_SUCCESS)
     1573        {
     1574            if ((uint32_t)(value-(uint32_t)pInstrGC) < 6)
     1575                return true;
     1576        }
     1577        else
     1578            break;
     1579    }
     1580    return false;
     1581}
     1582
     1583/**
    15481584 * Recompiles the instructions in a code block
    15491585 *
     
    15731609        Log(("patmRecompileCallback: jump to code we've recompiled before %RRv!\n", pCurInstrGC));
    15741610        return patmPatchGenRelJump(pVM, pPatch, pCurInstrGC, OP_JMP, !!(pCpu->prefix & PREFIX_OPSIZE));
     1611    }
     1612
     1613
     1614    if (patmHasImmsReferringPatch(pVM, pInstrGC))
     1615    {
     1616        pPatch->flags |= PATMFL_INT3_REPLACEMENT_BLOCK;
    15751617    }
    15761618
  • trunk/src/VBox/VMM/PATM/PATMInternal.h

    r22793 r23099  
    7979#define PATMFL_EXTERNAL_JUMP_INSIDE         RT_BIT_64(33) /** A trampoline patch was created that jumps to an instruction in the patch block */
    8080#define PATMFL_CODE_REFERENCED              RT_BIT_64(34) /** patch block referenced (called, jumped to) by another patch. */
     81
     82/* Global flags, affect PATM behavior */
     83#define PATMGFL_SEARCH_IMM_BACKWARD         RT_BIT_32(0)  /** search backward from priveledged insn for immediates referring inside patch */
    8184
    8285#define SIZEOF_NEARJUMP8                   2 //opcode byte + 1 byte relative offset
     
    520523    STAMCOUNTER             StatFunctionLookupInsert;
    521524    uint32_t                StatU32FunctionMaxSlotsUsed;
    522     uint32_t                Alignment0; /**< Align the structure size on a 8-byte boundrary. */
     525    uint32_t                uPATMFlags;
    523526} PATM, *PPATM;
    524527
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