VirtualBox

Changeset 5197 in vbox


Ignore:
Timestamp:
Oct 9, 2007 12:31:32 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
25124
Message:

Experiment with call recording for CSAM

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/REMInternal.h

    r4787 r5197  
    266266void    remR3TrapStat(CPUState *env, uint32_t uTrap);
    267267void    remR3CpuId(CPUState *env, unsigned uOperator, void *pvEAX, void *pvEBX, void *pvECX, void *pvEDX);
     268void    remR3RecordCall(CPUState *env);
    268269#endif
    269270void    remR3TrapClear(PVM pVM);
  • trunk/src/recompiler/VBoxREMWrapper.cpp

    r5181 r5197  
    489489    { REMPARMDESC_FLAGS_INT,        sizeof(CSAMTAG), NULL }
    490490};
     491
     492static const REMPARMDESC g_aArgsCSAMR3RecordCallAddress[] =
     493{
     494    { REMPARMDESC_FLAGS_INT,        sizeof(PVM), NULL },
     495    { REMPARMDESC_FLAGS_INT,        sizeof(RTGCPTR), NULL }
     496};
     497
    491498#if !(defined(RT_OS_WINDOWS) && defined(RT_ARCH_AMD64)) /* the callbacks are problematic */
    492499static const REMPARMDESC g_aArgsDBGCRegisterCommands[] =
     
    990997    { "CPUMQueryGuestCtxPtr",                   (void *)(uintptr_t)&CPUMQueryGuestCtxPtr,           &g_aArgsCPUMQueryGuestCtxPtr[0],            ELEMENTS(g_aArgsCPUMQueryGuestCtxPtr),              REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
    991998    { "CSAMR3MonitorPage",                      (void *)(uintptr_t)&CSAMR3MonitorPage,              &g_aArgsCSAMR3MonitorPage[0],               ELEMENTS(g_aArgsCSAMR3MonitorPage),                 REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
     999    { "CSAMR3RecordCallAddress",                (void *)(uintptr_t)&CSAMR3RecordCallAddress,        &g_aArgsCSAMR3RecordCallAddress[0],         ELEMENTS(g_aArgsCSAMR3RecordCallAddress),           REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
    9921000#if !(defined(RT_OS_WINDOWS) && defined(RT_ARCH_AMD64)) /* the callbacks are problematic */
    9931001    { "DBGCRegisterCommands",                   (void *)(uintptr_t)&DBGCRegisterCommands,           &g_aArgsDBGCRegisterCommands[0],            ELEMENTS(g_aArgsDBGCRegisterCommands),              REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
  • trunk/src/recompiler/VBoxRecompiler.c

    r4986 r5197  
    427427    pVM->rem.s.cInvalidatedPages = 0;
    428428    pVM->rem.s.fIgnoreAll = false;
     429
     430    /* Clear raw ring 0 init state */
     431    pVM->rem.s.Env.state &= ~CPU_RAW_RING0;
    429432}
    430433
     
    15461549}
    15471550
     1551/*
     1552 * Record previous call instruction addresses
     1553 *
     1554 * @param   env             Pointer to the CPU environment.
     1555 */
     1556void remR3RecordCall(CPUState *env)
     1557{
     1558    CSAMR3RecordCallAddress((PVM)env->pVM, env->eip);
     1559}
    15481560
    15491561/**
  • trunk/src/recompiler/target-i386/exec.h

    r2422 r5197  
    215215#ifdef VBOX
    216216void helper_external_event(void);
     217void helper_record_call(void);
    217218
    218219/* in helper.c */
  • trunk/src/recompiler/target-i386/helper.c

    r3727 r5197  
    12221222        remR3TimersRun(env);
    12231223    }
     1224}
     1225/* helper for recording call instruction addresses for later scanning */
     1226void helper_record_call()
     1227{
     1228    if (    !(env->state & CPU_RAW_RING0)
     1229        &&  (env->cr[0] & CR0_PG_MASK)
     1230        &&  !(env->eflags & X86_EFL_IF))
     1231        remR3RecordCall(env);
    12241232}
    12251233#endif /* VBOX */
     
    22482256    uint32_t val, limit, old_sp_mask;
    22492257    target_ulong ssp, old_ssp, next_eip, new_eip;
    2250    
     2258
    22512259    new_cs = T0;
    22522260    new_eip = T1;
  • trunk/src/recompiler/target-i386/op.c

    r2841 r5197  
    821821    }
    822822}
     823
     824void OPPROTO op_record_call(void)
     825{
     826    helper_record_call();
     827}
     828
    823829#endif /* VBOX */
    824830
  • trunk/src/recompiler/target-i386/translate.c

    r3952 r5197  
    123123#ifdef VBOX
    124124    int vme;    /* CR4.VME */
     125    int record_call;    /* record calls for CSAM or not? */
    125126#endif
    126127    int cpl;
     
    36743675        case 2: /* call Ev */
    36753676            /* XXX: optimize if memory (no 'and' is necessary) */
     3677#ifdef VBOX_WITH_CALL_RECORD
     3678            if (s->record_call)
     3679                gen_op_record_call();
     3680#endif
    36763681            if (s->dflag == 0)
    36773682                gen_op_andl_T0_ffff();
     
    65966601    dc->f_st = 0;
    65976602    dc->vm86 = (flags >> VM_SHIFT) & 1;
    6598 #ifdef VBOX
     6603#ifdef VBOX_WITH_CALL_RECORD
    65996604    dc->vme = !!(env->cr[4] & CR4_VME_MASK);
     6605    if (    !(env->state & CPU_RAW_RING0)
     6606        &&  (env->cr[0] & CR0_PG_MASK)
     6607        &&  !(env->eflags & X86_EFL_IF)
     6608        &&  dc->code32)
     6609        dc->record_call = 1;
     6610    else
     6611        dc->record_call = 0;
    66006612#endif
    66016613    dc->cpl = (flags >> HF_CPL_SHIFT) & 3;
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