VirtualBox

Ignore:
Timestamp:
Mar 1, 2024 12:42:36 AM (11 months ago)
Author:
vboxsync
Message:

VMM/IEM: Obfuscate most variable indexes we pass around in strict builds so we easily catch register/variable index mixups. bugref:10371

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/IEMN8veRecompilerEmit.h

    r103613 r103622  
    67206720{
    67216721    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
    6722     AssertStmt(pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Stack,
    6723               IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND));
    6724 
    6725     uint8_t const idxRegVar = pReNative->Core.aVars[idxVar].idxReg;
     6722    PIEMNATIVEVAR const pVar = &pReNative->Core.aVars[IEMNATIVE_VAR_IDX_UNPACK(idxVar)];
     6723    AssertStmt(pVar->enmKind == kIemNativeVarKind_Stack, IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND));
     6724
     6725    uint8_t const idxRegVar = pVar->idxReg;
    67266726    if (   idxRegVar < RT_ELEMENTS(pReNative->Core.aHstRegs)
    67276727        && (   (RT_BIT_32(idxRegVar) & (~IEMNATIVE_CALL_VOLATILE_GREG_MASK | fHstVolatileRegsAllowed))
     
    67416741    else
    67426742    {
    6743         uint8_t const idxStackSlot = pReNative->Core.aVars[idxVar].idxStackSlot;
     6743        uint8_t const idxStackSlot = pVar->idxStackSlot;
    67446744        AssertStmt(idxStackSlot != UINT8_MAX, IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_NOT_INITIALIZED));
    67456745        off = iemNativeEmitLoadGprByBp(pReNative, off, idxRegArg, iemNativeStackCalcBpDisp(idxStackSlot));
     
    67626762{
    67636763    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
    6764     if (pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Immediate)
    6765         off = iemNativeEmitLoadGprImm64(pReNative, off, idxRegArg, pReNative->Core.aVars[idxVar].u.uValue + offAddend);
     6764    PIEMNATIVEVAR const pVar = &pReNative->Core.aVars[IEMNATIVE_VAR_IDX_UNPACK(idxVar)];
     6765    if (pVar->enmKind == kIemNativeVarKind_Immediate)
     6766        off = iemNativeEmitLoadGprImm64(pReNative, off, idxRegArg, pVar->u.uValue + offAddend);
    67666767    else
    67676768        off = iemNativeEmitLoadArgGregFromStackVar(pReNative, off, idxRegArg, idxVar, offAddend,
     
    67816782{
    67826783    IEMNATIVE_ASSERT_VAR_IDX(pReNative, idxVar);
    6783     AssertStmt(   pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Invalid
    6784                || pReNative->Core.aVars[idxVar].enmKind == kIemNativeVarKind_Stack,
     6784    PIEMNATIVEVAR const pVar = &pReNative->Core.aVars[IEMNATIVE_VAR_IDX_UNPACK(idxVar)];
     6785    AssertStmt(   pVar->enmKind == kIemNativeVarKind_Invalid
     6786               || pVar->enmKind == kIemNativeVarKind_Stack,
    67856787               IEMNATIVE_DO_LONGJMP(pReNative, VERR_IEM_VAR_UNEXPECTED_KIND));
    67866788
     
    67886790    int32_t const offBpDisp      = iemNativeStackCalcBpDisp(idxStackSlot);
    67896791
    6790     uint8_t const idxRegVar      = pReNative->Core.aVars[idxVar].idxReg;
     6792    uint8_t const idxRegVar      = pVar->idxReg;
    67916793    if (idxRegVar < RT_ELEMENTS(pReNative->Core.aHstRegs))
    67926794    {
    67936795        off = iemNativeEmitStoreGprByBp(pReNative, off, offBpDisp, idxRegVar);
    67946796        iemNativeRegFreeVar(pReNative, idxRegVar, fFlushShadows);
    6795         Assert(pReNative->Core.aVars[idxVar].idxReg == UINT8_MAX);
    6796     }
    6797     Assert(   pReNative->Core.aVars[idxVar].idxStackSlot != UINT8_MAX
    6798            && pReNative->Core.aVars[idxVar].idxReg       == UINT8_MAX);
     6797        Assert(pVar->idxReg == UINT8_MAX);
     6798    }
     6799    Assert(   pVar->idxStackSlot != UINT8_MAX
     6800           && pVar->idxReg       == UINT8_MAX);
    67996801
    68006802    return iemNativeEmitLeaGprByBp(pReNative, off, idxRegArg, offBpDisp);
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