VirtualBox

Changeset 31437 in vbox


Ignore:
Timestamp:
Aug 6, 2010 12:01:55 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64503
Message:

patmR3HandleDirtyInstr: Don't access the record after it has been freed.

File:
1 edited

Legend:

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

    r31064 r31437  
    138138     *
    139139     */
    140     Assert(sizeof(PATMGCSTATE) < PAGE_SIZE);    /** @note hardcoded dependencies on this exist. */
     140    Assert(sizeof(PATMGCSTATE) < PAGE_SIZE);    /* Note: hardcoded dependencies on this exist. */
    141141    pVM->patm.s.pGCStateHC  = (PPATMGCSTATE)((uint8_t *)pVM->patm.s.pGCStackHC + PATM_STACK_TOTAL_SIZE);
    142142    pVM->patm.s.pGCStateGC  = MMHyperR3ToRC(pVM, pVM->patm.s.pGCStateHC);
     
    15771577        return rc;
    15781578
    1579     /** @note Never do a direct return unless a failure is encountered! */
     1579    /* Note: Never do a direct return unless a failure is encountered! */
    15801580
    15811581    /* Clear recompilation of next instruction flag; we are doing that right here. */
     
    18881888
    18891889    case OP_MOV_DR:
    1890         /** @note: currently we let DRx writes cause a trap d; our trap handler will decide to interpret it or not. */
     1890        /* Note: currently we let DRx writes cause a trap d; our trap handler will decide to interpret it or not. */
    18911891        if (pCpu->pCurInstr->param2 == OP_PARM_Dd)
    18921892        {
     
    18991899
    19001900    case OP_MOV_CR:
    1901         /** @note: currently we let CRx writes cause a trap d; our trap handler will decide to interpret it or not. */
     1901        /* Note: currently we let CRx writes cause a trap d; our trap handler will decide to interpret it or not. */
    19021902        if (pCpu->pCurInstr->param2 == OP_PARM_Cd)
    19031903        {
     
    23452345                }
    23462346
    2347                 /** @note after a cli we must continue to a proper exit point */
     2347                /* Note: after a cli we must continue to a proper exit point */
    23482348                if (cpunext.pCurInstr->opcode != OP_CLI)
    23492349                {
     
    26682668    case OP_PUSHF:
    26692669        /* We can 'call' a cli or pushf patch. It will either return to the original guest code when IF is set again, or fault. */
    2670         /** @note special precautions are taken when disabling and enabling such patches. */
     2670        /* Note: special precautions are taken when disabling and enabling such patches. */
    26712671        pPatch->flags |= PATMFL_CALLABLE_AS_FUNCTION;
    26722672        break;
     
    27172717
    27182718    /***************************************************************************************************************************/
    2719     /** @note We can't insert *any* code before a sysenter handler; some linux guests have an invalid stack at this point!!!!! */
     2719    /* Note: We can't insert *any* code before a sysenter handler; some linux guests have an invalid stack at this point!!!!! */
    27202720    /***************************************************************************************************************************/
    27212721#ifdef VBOX_WITH_STATISTICS
     
    31523152    cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
    31533153
    3154     /** @note Set the PATM interrupt flag here; it was cleared before the patched call. (!!!) */
     3154    /* Note: Set the PATM interrupt flag here; it was cleared before the patched call. (!!!) */
    31553155    rc = patmPatchGenSetPIF(pVM, pPatch, pInstrGC);
    31563156    if (RT_FAILURE(rc))
     
    33033303    pPatch->uCurPatchOffset   = 0;
    33043304
    3305     /** @note Set the PATM interrupt flag here; it was cleared before the patched call. (!!!) */
     3305    /* Note: Set the PATM interrupt flag here; it was cleared before the patched call. (!!!) */
    33063306    rc = patmPatchGenSetPIF(pVM, pPatch, pInstrGC);
    33073307    if (RT_FAILURE(rc))
     
    37753775    int rc;
    37763776
    3777     /** @note Do not use patch memory here! It might called during patch installation too. */
     3777    /* Note: Do not use patch memory here! It might called during patch installation too. */
    37783778
    37793779#ifdef LOG_ENABLED
     
    40294029    }
    40304030
    4031     /** @note the OpenBSD specific check will break if we allow additional patches to be installed (int 3)) */
     4031    /* Note: the OpenBSD specific check will break if we allow additional patches to be installed (int 3)) */
    40324032    if (!(flags & PATMFL_GUEST_SPECIFIC))
    40334033    {
     
    40364036    }
    40374037
    4038     /** @note obsolete */
     4038    /* Note: obsolete */
    40394039    if (    PATMIsPatchGCAddr(pVM, pInstrGC)
    40404040        && (flags & PATMFL_MMIO_ACCESS))
     
    47734773                            int rc = PATMR3RemovePatch(pVM, pPatch->pPrivInstrGC);
    47744774                            if (rc == VINF_SUCCESS)
    4775                                 /** @note jump back to the start as the pPatchPage has been deleted or changed */
     4775                                /* Note: jump back to the start as the pPatchPage has been deleted or changed */
    47764776                                goto loop_start;
    47774777
     
    48154815                                    PATMR3MarkDirtyPatch(pVM, pPatch);
    48164816
    4817                                     /** @note jump back to the start as the pPatchPage has been deleted or changed */
     4817                                    /* Note: jump back to the start as the pPatchPage has been deleted or changed */
    48184818                                    goto loop_start;
    48194819                                }
     
    48544854                        if (pPatch->cInvalidWrites > PATM_MAX_INVALID_WRITES)
    48554855                        {
    4856                             /** @note possibly dangerous assumption that all future writes will be harmless. */
     4856                            /* Note: possibly dangerous assumption that all future writes will be harmless. */
    48574857                            if (pPatch->flags & PATMFL_IDTHANDLER)
    48584858                            {
     
    48684868                                PATMR3MarkDirtyPatch(pVM, pPatch);
    48694869                            }
    4870                             /** @note jump back to the start as the pPatchPage has been deleted or changed */
     4870                            /* Note: jump back to the start as the pPatchPage has been deleted or changed */
    48714871                            goto invalid_write_loop_start;
    48724872                        }
     
    50025002
    50035003        /* Clear the IDT entries for the patch we're disabling. */
    5004         /** @note very important as we clear IF in the patch itself */
     5004        /* Note: very important as we clear IF in the patch itself */
    50055005        /** @todo this needs to be changed */
    50065006        if (pPatch->flags & PATMFL_IDTHANDLER)
     
    53635363    Log(("PATMRemovePatch %RRv\n", pPatch->pPrivInstrGC));
    53645364
    5365     /** @note NEVER EVER REUSE PATCH MEMORY */
    5366     /** @note PATMR3DisablePatch puts a breakpoint (0xCC) at the entry of this patch */
     5365    /* Note: NEVER EVER REUSE PATCH MEMORY */
     5366    /* Note: PATMR3DisablePatch puts a breakpoint (0xCC) at the entry of this patch */
    53675367
    53685368    if (pPatchRec->patch.pPatchBlockOffset)
     
    54035403#endif
    54045404
    5405     /** @note no need to free Guest2PatchAddrTree as those records share memory with Patch2GuestAddrTree records. */
     5405    /* Note: no need to free Guest2PatchAddrTree as those records share memory with Patch2GuestAddrTree records. */
    54065406    patmEmptyTreeU32(pVM, &pPatch->Patch2GuestAddrTree);
    54075407    pPatch->nrPatch2GuestRecs = 0;
     
    54155415        MMR3HeapFree(pPatchRec->patch.pTempInfo);
    54165416
    5417     /** @note might fail, because it has already been removed (e.g. during reset). */
     5417    /* Note: might fail, because it has already been removed (e.g. during reset). */
    54185418    RTAvloU32Remove(&pVM->patm.s.PatchLookupTreeHC->PatchTree, pPatchRec->Core.Key);
    54195419
     
    56575657        return VINF_SUCCESS;
    56585658
    5659     /** @note we don't restore patch pages for patches that are not enabled! */
    5660     /** @note be careful when changing this behaviour!! */
     5659    /* Note: we don't restore patch pages for patches that are not enabled! */
     5660    /* Note: be careful when changing this behaviour!! */
    56615661
    56625662    /* The patch pages are no longer marked for self-modifying code detection */
     
    58525852    uint32_t     cbDirty;
    58535853    PRECPATCHTOGUEST pRec;
     5854    RTRCPTR const pOrgInstrGC = pPatchToGuestRec->pOrgInstrGC;
    58545855    PVMCPU       pVCpu = VMMGetCpu0(pVM);
    5855 
    5856     Log(("patmR3HandleDirtyInstr: dirty instruction at %RRv (%RRv)\n", pEip, pPatchToGuestRec->pOrgInstrGC));
     5856    Log(("patmR3HandleDirtyInstr: dirty instruction at %RRv (%RRv)\n", pEip, pOrgInstrGC));
    58575857
    58585858    pRec             = pPatchToGuestRec;
    5859     pCurInstrGC      = pPatchToGuestRec->pOrgInstrGC;
     5859    pCurInstrGC      = pOrgInstrGC;
    58605860    pCurPatchInstrGC = pEip;
    58615861    cbDirty          = 0;
     
    58675867        if (pRec->fJumpTarget)
    58685868        {
    5869             LogRel(("PATM: patmR3HandleDirtyInstr: dirty instruction at %RRv (%RRv) ignored, because instruction in function was reused as target of jump\n", pEip, pPatchToGuestRec->pOrgInstrGC));
     5869            LogRel(("PATM: patmR3HandleDirtyInstr: dirty instruction at %RRv (%RRv) ignored, because instruction in function was reused as target of jump\n", pEip, pOrgInstrGC));
    58705870            pRec->fDirty = false;
    58715871            return VERR_PATCHING_REFUSED;
     
    58985898        pRec->fDirty      = false;
    58995899
    5900         /** Remove old lookup record. */
     5900        /* Remove old lookup record. */
    59015901        patmr3RemoveP2GLookupRecord(pVM, &pPatch->patch, pCurPatchInstrGC);
     5902        pCurPatchInstrGC = NULL;
    59025903
    59035904        pCurPatchInstrGC += CpuOld.opsize;
     
    59365937                RTRCPTR pTargetGC = PATMResolveBranch(&CpuNew, pCurInstrGC);
    59375938
    5938                 if (    pTargetGC >= pPatchToGuestRec->pOrgInstrGC
    5939                     &&  pTargetGC <= pPatchToGuestRec->pOrgInstrGC + cbDirty
     5939                if (    pTargetGC >= pOrgInstrGC
     5940                    &&  pTargetGC <= pOrgInstrGC + cbDirty
    59405941                   )
    59415942                {
     
    60876088
    60886089    /* Find the patch record. */
    6089     /** @note there might not be a patch to guest translation record (global function) */
     6090    /* Note: there might not be a patch to guest translation record (global function) */
    60906091    offset = pEip - pVM->patm.s.pPatchMemGC;
    60916092    pvPatchCoreOffset = RTAvloU32GetBestFit(&pVM->patm.s.PatchLookupTreeHC->PatchTreeByPatchAddr, offset, false);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette