VirtualBox

Changeset 1352 in vbox for trunk/src/VBox/VMM/PATM/VMMGC


Ignore:
Timestamp:
Mar 9, 2007 9:35:15 AM (18 years ago)
Author:
vboxsync
Message:

Only check for patch writes in supervisor mode. Otherwise assume the monitored code page has been invalidated.

File:
1 edited

Legend:

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

    r23 r1352  
    7676    Assert(pPATMGCState->fPIF || fPatchCode);
    7777    /** When patch code is executing instructions that must complete, then we must *never* interrupt it. */
    78     if (!pPATMGCState->fPIF && fPatchCode)
     78    if (!pPATMGCState->fPIF && fPatchCode)       
    7979    {
    8080        Log(("CSAMGCCodePageWriteHandler: fPIF=0 -> stack fault in patch generated code at %VGv!\n", pRegFrame->eip));
     
    9191    }
    9292
    93     Log(("CSAMGCCodePageWriteHandler: code page write at %VGv original address %VGv\n", pvFault, (RTGCUINTPTR)pvRange + offRange));
    94     rc = PATMGCHandleWriteToPatchPage(pVM, pRegFrame, (RTGCPTR)((RTGCUINTPTR)pvRange + offRange), 4 /** @todo */);
    95     if (rc == VINF_SUCCESS)
    96         return rc;
    97     if (rc == VINF_EM_RAW_EMULATE_INSTR)
     93    uint32_t cpl;
     94   
     95    if (pRegFrame->eflags.Bits.u1VM)
     96        cpl = 3;
     97    else
     98        cpl = (pRegFrame->ss & X86_SEL_RPL);
     99
     100    Log(("CSAMGCCodePageWriteHandler: code page write at %VGv original address %VGv (cpl=%d)\n", pvFault, (RTGCUINTPTR)pvRange + offRange, cpl));
     101
     102    /* If user code is modifying one of our monitored pages, then we can safely make it r/w as it's no longer being used for supervisor code. */
     103    if (cpl != 3)
    98104    {
    99         STAM_COUNTER_INC(&pVM->csam.s.StatDangerousWrite);
    100         return VINF_EM_RAW_EMULATE_INSTR;
     105        rc = PATMGCHandleWriteToPatchPage(pVM, pRegFrame, (RTGCPTR)((RTGCUINTPTR)pvRange + offRange), 4 /** @todo */);
     106        if (rc == VINF_SUCCESS)
     107            return rc;
     108        if (rc == VINF_EM_RAW_EMULATE_INSTR)
     109        {
     110            STAM_COUNTER_INC(&pVM->csam.s.StatDangerousWrite);
     111            return VINF_EM_RAW_EMULATE_INSTR;
     112        }
     113        Assert(rc == VERR_PATCH_NOT_FOUND);
    101114    }
    102     Assert(rc == VERR_PATCH_NOT_FOUND);
     115
    103116    VM_FF_SET(pVM, VM_FF_CSAM_FLUSH_DIRTY_PAGE);
    104117
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