VirtualBox

Changeset 44362 in vbox for trunk/src/VBox/VMM/include


Ignore:
Timestamp:
Jan 24, 2013 9:11:05 PM (12 years ago)
Author:
vboxsync
Message:

PATM: Changed two Main APIs to use PUVM instead of PVM (one of them directly accessed it). Lot's of function scope cleanups.

Location:
trunk/src/VBox/VMM/include
Files:
2 edited

Legend:

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

    r43394 r44362  
    55
    66/*
    7  * Copyright (C) 2006-2009 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
  • trunk/src/VBox/VMM/include/PATMInternal.h

    r41897 r44362  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3030
    3131
    32 
     32/** @name Saved state version numbers.
     33 * @{ */
    3334#define PATM_SSM_VERSION                    55
    3435#define PATM_SSM_VERSION_FIXUP_HACK         54
    3536#define PATM_SSM_VERSION_FIXUP_HACK         54
    3637#define PATM_SSM_VERSION_VER16              53
     38/** @}  */
    3739
    3840/* Enable for call patching. */
     
    554556
    555557#ifdef IN_RING3
    556 RTRCPTR patmPatchGCPtr2GuestGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t *) pPatchGC);
    557 RTRCPTR patmGuestGCPtrToPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC);
    558 RTRCPTR patmGuestGCPtrToClosestPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC);
    559 #endif
    560 
    561 /* Add a patch to guest lookup record
    562  *
    563  * @param   pVM             Pointer to the VM.
    564  * @param   pPatch          Patch structure ptr
    565  * @param   pPatchInstrHC   Guest context pointer to patch block
    566  * @param   pInstrGC        Guest context pointer to privileged instruction
    567  * @param   enmType         Lookup type
    568  * @param   fDirty          Dirty flag
    569  *
    570  */
    571 void patmr3AddP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, uint8_t *pPatchInstrHC, RTRCPTR pInstrGC, PATM_LOOKUP_TYPE enmType, bool fDirty=false);
    572 
    573 /**
    574  * Insert page records for all guest pages that contain instructions that were recompiled for this patch
    575  *
    576  * @returns VBox status code.
    577  * @param   pVM         Pointer to the VM.
    578  * @param   pPatch      Patch record
    579  */
    580 int patmInsertPatchPages(PVM pVM, PPATCHINFO pPatch);
    581 
    582 /**
    583  * Remove page records for all guest pages that contain instructions that were recompiled for this patch
    584  *
    585  * @returns VBox status code.
    586  * @param   pVM         Pointer to the VM.
    587  * @param   pPatch      Patch record
    588  */
    589 int patmRemovePatchPages(PVM pVM, PPATCHINFO pPatch);
    590 
    591 /**
    592  * Returns the GC address of the corresponding patch statistics counter
    593  *
    594  * @returns Stat address
    595  * @param   pVM         Pointer to the VM.
    596  * @param   pPatch      Patch structure
    597  */
    598 RTRCPTR patmPatchQueryStatAddress(PVM pVM, PPATCHINFO pPatch);
    599 
    600 /**
    601  * Remove patch for privileged instruction at specified location
    602  *
    603  * @returns VBox status code.
    604  * @param   pVM             Pointer to the VM.
    605  * @param   pPatchRec       Patch record
    606  * @param   fForceRemove    Remove *all* patches
    607  */
    608 int PATMRemovePatch(PVM pVM, PPATMPATCHREC pPatchRec, bool fForceRemove);
     558RTRCPTR         patmPatchGCPtr2GuestGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t *) pPatchGC);
     559RTRCPTR         patmGuestGCPtrToPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC);
     560RTRCPTR         patmGuestGCPtrToClosestPatchGCPtr(PVM pVM, PPATCHINFO pPatch, RCPTRTYPE(uint8_t*) pInstrGC);
     561#endif
     562
     563void            patmR3AddP2GLookupRecord(PVM pVM, PPATCHINFO pPatch, uint8_t *pPatchInstrHC, RTRCPTR pInstrGC,
     564                                         PATM_LOOKUP_TYPE enmType, bool fDirty = false);
     565int             patmInsertPatchPages(PVM pVM, PPATCHINFO pPatch);
     566RTRCPTR         patmPatchQueryStatAddress(PVM pVM, PPATCHINFO pPatch);
     567int             patmR3RemovePatch(PVM pVM, PPATMPATCHREC pPatchRec, bool fForceRemove);
    609568
    610569/**
     
    621580typedef int (VBOXCALL *PFN_PATMR3ANALYSE)(PVM pVM, DISCPUSTATE *pCpu, RCPTRTYPE(uint8_t *) pInstrGC, RCPTRTYPE(uint8_t *) pCurInstrGC, PPATMP2GLOOKUPREC pCacheRec);
    622581
    623 /**
    624  * Install guest OS specific patch
    625  *
    626  * @returns VBox status code.
    627  * @param   pVM         Pointer to the VM.
    628  * @param   pCpu        Disassembly state of instruction.
    629  * @param   pInstrGC    GC Instruction pointer for instruction
    630  * @param   pInstrHC    GC Instruction pointer for instruction
    631  * @param   pPatchRec   Patch structure
    632  *
    633  */
    634 int PATMInstallGuestSpecificPatch(PVM pVM, PDISCPUSTATE pCpu, RTRCPTR pInstrGC, uint8_t *pInstrHC, PPATMPATCHREC pPatchRec);
    635 
    636 
    637 /**
    638  * Check if the instruction is patched as a duplicated function
    639  *
    640  * @returns patch record
    641  * @param   pVM         Pointer to the VM.
    642  * @param   pInstrGC    Guest context point to the instruction
    643  *
    644  */
    645 VMMDECL(PPATMPATCHREC) PATMQueryFunctionPatch(PVM pVM, RTRCPTR pInstrGC);
    646 
    647 
    648 /**
    649  * Empty the specified tree (PV tree, MMR3 heap)
    650  *
    651  * @param   pVM             Pointer to the VM.
    652  * @param   ppTree          Tree to empty
    653  */
    654 void patmEmptyTree(PVM pVM, PPAVLPVNODECORE ppTree);
    655 
    656 
    657 /**
    658  * Empty the specified tree (U32 tree, MMR3 heap)
    659  *
    660  * @param   pVM             Pointer to the VM.
    661  * @param   ppTree          Tree to empty
    662  */
    663 void patmEmptyTreeU32(PVM pVM, PPAVLU32NODECORE ppTree);
    664 
    665 
    666 /**
    667  * Return the name of the patched instruction
    668  *
    669  * @returns instruction name
    670  *
    671  * @param   opcode      DIS instruction opcode
    672  * @param   fPatchFlags Patch flags
    673  */
    674 VMMDECL(const char *) patmGetInstructionString(uint32_t opcode, uint32_t fPatchFlags);
    675 
    676 
     582int             patmR3InstallGuestSpecificPatch(PVM pVM, PDISCPUSTATE pCpu, RTRCPTR pInstrGC, uint8_t *pInstrHC, PPATMPATCHREC pPatchRec);
     583PPATMPATCHREC   patmQueryFunctionPatch(PVM pVM, RTRCPTR pInstrGC);
     584const char     *patmGetInstructionString(uint32_t opcode, uint32_t fPatchFlags);
     585
     586PPATCHINFO      patmFindActivePatchByEntrypoint(PVM pVM, RTRCPTR pInstrGC, bool fIncludeHints = false);
     587int             patmR3PatchInstrInt3(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATCHINFO pPatch);
     588int             patmAddBranchToLookupCache(PVM pVM, RTRCPTR pJumpTableGC, RTRCPTR pBranchTarget, RTRCUINTPTR pRelBranchPatch);
     589R3PTRTYPE(uint8_t *) patmR3GCVirtToHCVirt(PVM pVM, PPATMP2GLOOKUPREC pCacheRec, RCPTRTYPE(uint8_t *) pGCPtr);
    677590
    678591RT_C_DECLS_BEGIN
     
    691604VMMRCDECL(int) PATMGCMonitorPage(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange);
    692605
    693 /**
    694  * Find patch for privileged instruction at specified location
    695  *
    696  * @returns Patch structure pointer if found; else NULL
    697  * @param   pVM           Pointer to the VM.
    698  * @param   pInstr        Guest context point to instruction that might lie within 5 bytes of an existing patch jump
    699  * @param   fIncludeHints Include hinted patches or not
    700  *
    701  */
    702 PPATCHINFO PATMFindActivePatchByEntrypoint(PVM pVM, RTRCPTR pInstrGC, bool fIncludeHints=false);
    703 
    704 /**
    705  * Patch cli/sti pushf/popf instruction block at specified location
    706  *
    707  * @returns VBox status code.
    708  * @param   pVM         Pointer to the VM.
    709  * @param   pInstrGC    Guest context point to privileged instruction
    710  * @param   pInstrHC    Host context point to privileged instruction
    711  * @param   uOpcode     Instruction opcodee
    712  * @param   uOpSize     Size of starting instruction
    713  * @param   pPatchRec   Patch record
    714  *
    715  * @note    returns failure if patching is not allowed or possible
    716  *
    717  */
    718 VMMR3DECL(int) PATMR3PatchBlock(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC,
    719                                  uint32_t uOpcode, uint32_t uOpSize, PPATMPATCHREC pPatchRec);
    720 
    721 
    722 /**
    723  * Replace an instruction with a breakpoint (0xCC), that is handled dynamically in the guest context.
    724  *
    725  * @returns VBox status code.
    726  * @param   pVM         Pointer to the VM.
    727  * @param   pInstrGC    Guest context point to privileged instruction
    728  * @param   pInstrHC    Host context point to privileged instruction
    729  * @param   pCpu        Disassembly CPU structure ptr
    730  * @param   pPatch      Patch record
    731  *
    732  * @note    returns failure if patching is not allowed or possible
    733  *
    734  */
    735 VMMR3DECL(int) PATMR3PatchInstrInt3(PVM pVM, RTRCPTR pInstrGC, R3PTRTYPE(uint8_t *) pInstrHC, DISCPUSTATE *pCpu, PPATCHINFO pPatch);
    736 
    737 /**
    738  * Mark patch as dirty
    739  *
    740  * @returns VBox status code.
    741  * @param   pVM         Pointer to the VM.
    742  * @param   pPatch      Patch record
    743  *
    744  * @note    returns failure if patching is not allowed or possible
    745  *
    746  */
    747 VMMR3DECL(int) PATMR3MarkDirtyPatch(PVM pVM, PPATCHINFO pPatch);
    748 
    749 R3PTRTYPE(uint8_t *) PATMGCVirtToHCVirt(PVM pVM, PPATMP2GLOOKUPREC pCacheRec, RCPTRTYPE(uint8_t *) pGCPtr);
     606RT_C_DECLS_END
    750607
    751608/**
     
    756613 * @param   pBranchInstrGC  GC pointer of branch instruction
    757614 */
    758 inline RTRCPTR PATMResolveBranch(PDISCPUSTATE pCpu, RTRCPTR pBranchInstrGC)
     615DECLINLINE(RTRCPTR) PATMResolveBranch(PDISCPUSTATE pCpu, RTRCPTR pBranchInstrGC)
    759616{
    760617    uint32_t disp;
     
    785642}
    786643
    787 RT_C_DECLS_END
    788 
    789644#ifdef LOG_ENABLED
    790645int patmr3DisasmCallback(PVM pVM, DISCPUSTATE *pCpu, RCPTRTYPE(uint8_t *) pInstrGC, RCPTRTYPE(uint8_t *) pCurInstrGC, PPATMP2GLOOKUPREC pCacheRec);
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