patm.h revision 5a7df607b64bfcec6cf547263957ca6db6a20a34
/** @file
* PATM - Dynamic Guest OS Patching Manager.
*/
/*
* Copyright (C) 2006-2015 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_vmm_patm_h
#define ___VBox_vmm_patm_h
#if defined(VBOX_WITH_RAW_MODE) || defined(DOXYGEN_RUNNING)
/** @defgroup grp_patm The Patch Manager API
* @{
*/
#define MAX_PATCHES 512
/**
* Flags for specifying the type of patch to install with PATMR3InstallPatch
* @{
*/
#define PATMFL_CODE32 RT_BIT_64(0)
/* no more room -> change PATMInternal.h if more is needed!! */
/*
* Flags above 1024 are reserved for internal use!
*/
/** @} */
/** Enable to activate sysenter emulation in GC. */
/* #define PATM_EMULATE_SYSENTER */
/**
* Maximum number of cached VGA writes
*/
#define MAX_VGA_WRITE_CACHE 64
typedef struct PATMGCSTATE
{
/** Virtual Flags register (IF + more later on) */
/** Pending PATM actions (internal use only) */
/** Records the number of times all patches are called (indicating how many exceptions we managed to avoid) */
/** Scratchpad dword */
/** Debugging info */
/** PATM stack pointer */
/** PATM interrupt flag */
/** PATM inhibit irq address (used by sti) */
/** Scratch room for call patch */
/** Temporary storage for guest registers. */
struct
{
} Restore;
} PATMGCSTATE, *PPATMGCSTATE;
typedef struct PATMTRAPREC
{
/** pointer to original guest code instruction (for emulation) */
/** pointer to the next guest code instruction */
/** pointer to the corresponding next instruction in the patch block */
} PATMTRAPREC, *PPATMTRAPREC;
/**
* Translation state (currently patch to GC ptr)
*/
typedef enum
{
PATMTRANS_SAFE, /**< Safe translation */
PATMTRANS_PATCHSTART, /**< Instruction starts a patch block */
PATMTRANS_OVERWRITTEN, /**< Instruction overwritten by patchjump */
PATMTRANS_INHIBITIRQ /**< Instruction must be executed due to instruction fusing */
/**
*
* @returns 0 - disabled, 1 - enabled
* @param pVM The VM to operate on.
* @internal
*/
VMM_INT_DECL(int) PATMReadPatchCode(PVM pVM, RTGCPTR GCPtrPatchCode, void *pvDst, size_t cbToRead, size_t *pcbRead);
#ifdef PATM_EMULATE_SYSENTER
#endif
#ifdef IN_RC
/** @defgroup grp_patm_rc The Patch Manager Raw-mode Context API
* @{
*/
VMMRC_INT_DECL(int) PATMRCHandleWriteToPatchPage(PVM pVM, PCPUMCTXCORE pRegFrame, RTRCPTR GCPtr, uint32_t cbWrite);
/** @} */
#endif
#ifdef IN_RING3
/** @defgroup grp_patm_r3 The Patch Manager Host Ring-3 Context API
* @{
*/
VMMR3_INT_DECL(int) PATMR3ReadOrgInstr(PVM pVM, RTGCPTR32 GCPtrInstr, uint8_t *pbDst, size_t cbToRead, size_t *pcbRead);
/** @} */
#endif
/** @} */
#endif /* VBOX_WITH_RAW_MODE */
#endif