VirtualBox

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


Ignore:
Timestamp:
Nov 2, 2007 11:10:07 AM (17 years ago)
Author:
vboxsync
Message:

Fixed boundary checks and support partial instruction updates (e.g. destination address of jmp instruction)

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

Legend:

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

    r5609 r5610  
    46924692            bool fValidPatchWrite = false;
    46934693
     4694            /* Quick check to see if the write is in the patched part of the page */
     4695            if (    pPatchPage->pLowestAddrGC  > (RTGCPTR)((RTGCUINTPTR)GCPtr + cbWrite - 1)
     4696                ||  pPatchPage->pHighestAddrGC < GCPtr)
     4697            {
     4698                break;
     4699            }
     4700
    46944701            for (i=0;i<pPatchPage->cCount;i++)
    46954702            {
     
    47194726                        }
    47204727
    4721                         pPatchInstrGC = patmGuestGCPtrToPatchGCPtr(pVM, pPatch, pGuestPtrGC);
     4728                        /* Find the closest instruction from below; the above quick check ensured that we are indeed in patched code */
     4729                        pPatchInstrGC = patmGuestGCPtrToClosestPatchGCPtr(pVM, pPatch, pGuestPtrGC);
     4730                        Assert(pPatchInstrGC);
    47224731                        if (pPatchInstrGC)
    47234732                        {
     
    56245633}
    56255634
     5635/* Converts Guest code GC ptr to Patch code GC ptr (or nearest from below if no identical match)
     5636 *
     5637 * @returns corresponding GC pointer in patch block
     5638 * @param   pVM         The VM to operate on.
     5639 * @param   pPatch      Current patch block pointer
     5640 * @param   pInstrGC    Guest context pointer to privileged instruction
     5641 *
     5642 */
     5643RTGCPTR patmGuestGCPtrToClosestPatchGCPtr(PVM pVM, PPATCHINFO pPatch, GCPTRTYPE(uint8_t*) pInstrGC)
     5644{
     5645        PRECGUESTTOPATCH pGuestToPatchRec = (PRECGUESTTOPATCH)RTAvlGCPtrGetBestFit(&pPatch->Guest2PatchAddrTree, pInstrGC, false);
     5646        if (pGuestToPatchRec)
     5647            return pVM->patm.s.pPatchMemGC + pGuestToPatchRec->PatchOffset;
     5648
     5649    return 0;
     5650}
     5651
    56265652/* Converts Guest code GC ptr to Patch code GC ptr (if found)
    56275653 *
  • trunk/src/VBox/VMM/PATM/PATMInternal.h

    r5605 r5610  
    524524RTGCPTR patmPatchGCPtr2GuestGCPtr(PVM pVM, PPATCHINFO pPatch, GCPTRTYPE(uint8_t *) pPatchGC);
    525525RTGCPTR patmGuestGCPtrToPatchGCPtr(PVM pVM, PPATCHINFO pPatch, GCPTRTYPE(uint8_t*) pInstrGC);
     526RTGCPTR patmGuestGCPtrToClosestPatchGCPtr(PVM pVM, PPATCHINFO pPatch, GCPTRTYPE(uint8_t*) pInstrGC);
    526527#endif
    527528
  • trunk/src/VBox/VMM/PATM/VMMGC/PATMGC.cpp

    r5609 r5610  
    108108    if (pPatchPage)
    109109    {
    110         if (    pPatchPage->pLowestAddrGC  <= (RTGCPTR)((RTGCUINTPTR)GCPtr + cbWrite)
    111             ||  pPatchPage->pHighestAddrGC > GCPtr)
     110        if (    pPatchPage->pLowestAddrGC  > (RTGCPTR)((RTGCUINTPTR)GCPtr + cbWrite - 1)
     111            ||  pPatchPage->pHighestAddrGC < GCPtr)
    112112        {
    113113            /* This part of the page was not patched; try to emulate the instruction. */
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