VirtualBox

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


Ignore:
Timestamp:
Mar 8, 2015 8:51:01 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
98841
Message:

PATM: Added some comments and formalized the reloc array type (instead of having two anonymous uint32_t's).

File:
1 edited

Legend:

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

    r45276 r54686  
    11/* $Id$ */
    22/** @file
    3  * PATM macros & definitions (identical to PATMA.mac!!)
     3 * PATM macros & definitions (identical to PATMA.mac!).
    44 */
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919#define ___PATMA_H
    2020
    21 
     21/** @name Patch Fixup Types
     22 * @{ */
    2223#define PATM_VMFLAGS                            0xF1ABCD00
    2324#ifdef VBOX_WITH_STATISTICS
    24 #define PATM_ALLPATCHCALLS                      0xF1ABCD01
    25 #define PATM_PERPATCHCALLS                      0xF1ABCD02
     25# define PATM_ALLPATCHCALLS                     0xF1ABCD01
     26# define PATM_PERPATCHCALLS                     0xF1ABCD02
    2627#endif
    2728#define PATM_JUMPDELTA                          0xF1ABCD03
    2829#ifdef VBOX_WITH_STATISTICS
    29 #define PATM_IRETEFLAGS                         0xF1ABCD04
    30 #define PATM_IRETCS                             0xF1ABCD05
    31 #define PATM_IRETEIP                            0xF1ABCD06
     30# define PATM_IRETEFLAGS                        0xF1ABCD04
     31# define PATM_IRETCS                            0xF1ABCD05
     32# define PATM_IRETEIP                           0xF1ABCD06
    3233#endif
    3334#define PATM_FIXUP                              0xF1ABCD07
     
    3637#define PATM_CPUID_EXT_PTR                      0xF1ABCD0a
    3738#define PATM_CPUID_DEF_PTR                      0xF1ABCD0b
    38 #define PATM_STACKBASE                          0xF1ABCD0c    /** Stack to store our private patch return addresses */
    39 #define PATM_STACKBASE_GUEST                    0xF1ABCD0d    /** Stack to store guest return addresses */
     39#define PATM_STACKBASE                          0xF1ABCD0c  /**< Stack to store our private patch return addresses */
     40#define PATM_STACKBASE_GUEST                    0xF1ABCD0d  /**< Stack to store guest return addresses */
    4041#define PATM_STACKPTR                           0xF1ABCD0e
    4142#define PATM_PATCHBASE                          0xF1ABCD0f
     
    4344#define PATM_INHIBITIRQADDR                     0xF1ABCD11
    4445#define PATM_VM_FORCEDACTIONS                   0xF1ABCD12
    45 #define PATM_TEMP_EAX                           0xF1ABCD13      /** Location for original EAX register */
    46 #define PATM_TEMP_ECX                           0xF1ABCD14      /** Location for original ECX register */
    47 #define PATM_TEMP_EDI                           0xF1ABCD15      /** Location for original EDI register */
    48 #define PATM_TEMP_EFLAGS                        0xF1ABCD16      /** Location for original eflags */
    49 #define PATM_TEMP_RESTORE_FLAGS                 0xF1ABCD17      /** Which registers to restore */
     46#define PATM_TEMP_EAX                           0xF1ABCD13  /**< Location for original EAX register */
     47#define PATM_TEMP_ECX                           0xF1ABCD14  /**< Location for original ECX register */
     48#define PATM_TEMP_EDI                           0xF1ABCD15  /**< Location for original EDI register */
     49#define PATM_TEMP_EFLAGS                        0xF1ABCD16  /**< Location for original eflags */
     50#define PATM_TEMP_RESTORE_FLAGS                 0xF1ABCD17  /**< Which registers to restore */
    5051#define PATM_CALL_PATCH_TARGET_ADDR             0xF1ABCD18
    5152#define PATM_CALL_RETURN_ADDR                   0xF1ABCD19
     
    5859#define PATM_RETURNADDR                         0xF1ABCE02
    5960#define PATM_PATCHNEXTBLOCK                     0xF1ABCE03
    60 #define PATM_CALLTARGET                         0xF1ABCE04    /** relative call target */
    61 #define PATM_NEXTINSTRADDR                      0xF1ABCE05    /** absolute guest address of the next instruction */
    62 #define PATM_CURINSTRADDR                       0xF1ABCE06    /** absolute guest address of the current instruction */
    63 #define PATM_LOOKUP_AND_CALL_FUNCTION           0xF1ABCE07    /** Relative address of global PATM lookup and call function. */
    64 #define PATM_RETURN_FUNCTION                    0xF1ABCE08    /** Relative address of global PATM return function. */
    65 #define PATM_LOOKUP_AND_JUMP_FUNCTION           0xF1ABCE09    /** Relative address of global PATM lookup and jump function. */
    66 #define PATM_IRET_FUNCTION                      0xF1ABCE0A    /** Relative address of global PATM iret function. */
     61#define PATM_CALLTARGET                         0xF1ABCE04  /**< relative call target */
     62#define PATM_NEXTINSTRADDR                      0xF1ABCE05  /**< absolute guest address of the next instruction */
     63#define PATM_CURINSTRADDR                       0xF1ABCE06  /**< absolute guest address of the current instruction */
     64#define PATM_LOOKUP_AND_CALL_FUNCTION           0xF1ABCE07  /**< Relative address of global PATM lookup and call function. */
     65#define PATM_RETURN_FUNCTION                    0xF1ABCE08  /**< Relative address of global PATM return function. */
     66#define PATM_LOOKUP_AND_JUMP_FUNCTION           0xF1ABCE09  /**< Relative address of global PATM lookup and jump function. */
     67#define PATM_IRET_FUNCTION                      0xF1ABCE0A  /**< Relative address of global PATM iret function. */
    6768#define PATM_CPUID_CENTAUR_MAX                  0xF1ABCE0B
    68 
    69 // everything except IOPL, NT, IF, VM, VIF, VIP and RF
    70 #define PATM_FLAGS_MASK                         (X86_EFL_CF|X86_EFL_PF|X86_EFL_AF|X86_EFL_ZF|X86_EFL_SF|X86_EFL_TF|X86_EFL_DF|X86_EFL_OF|X86_EFL_AC|X86_EFL_ID)
    71 
    72 // currently only IF & IOPL
    73 #define PATM_VIRTUAL_FLAGS_MASK                 (X86_EFL_IF|X86_EFL_IOPL)
     69/** @} */
     70
     71
     72/** Everything except IOPL, NT, IF, VM, VIF, VIP and RF */
     73#define PATM_FLAGS_MASK                         (  X86_EFL_CF | X86_EFL_PF | X86_EFL_AF | X86_EFL_ZF | X86_EFL_SF \
     74                                                 | X86_EFL_TF | X86_EFL_DF | X86_EFL_OF | X86_EFL_AC | X86_EFL_ID)
     75
     76/** Flags that PATM virtualizes. Currently only IF & IOPL. */
     77#define PATM_VIRTUAL_FLAGS_MASK                 (X86_EFL_IF | X86_EFL_IOPL)
    7478
    7579/* PATM stack size (identical in PATMA.mac!!) */
    76 #define PATM_STACK_SIZE                         (PAGE_SIZE)
    77 #define PATM_STACK_TOTAL_SIZE                   (2*PATM_STACK_SIZE)
     80#define PATM_STACK_SIZE                         (4096)
     81#define PATM_STACK_TOTAL_SIZE                   (2 * PATM_STACK_SIZE)
    7882#define PATM_MAX_STACK                          (PATM_STACK_SIZE/sizeof(RTRCPTR))
    7983
    80 /* Patch Manager pending actions (in GCSTATE). */
     84/** @name Patch Manager pending actions (in GCSTATE).
     85 * @{  */
    8186#define PATM_ACTION_LOOKUP_ADDRESS              1
    8287#define PATM_ACTION_DISPATCH_PENDING_IRQ        2
     
    9398#define PATM_ACTION_LOG_CALL                    13
    9499#define PATM_ACTION_LOG_GATE_ENTRY              14
    95 
    96 /* Magic dword found in ecx for patm pending actions. */
     100/** @} */
     101
     102/** Magic dword found in ecx for patm pending actions. */
    97103#define PATM_ACTION_MAGIC                       0xABCD4321
    98104
    99 /** PATM_TEMP_RESTORE_FLAGS */
     105/** @name PATM_TEMP_RESTORE_FLAGS
     106 * @{ */
    100107#define PATM_RESTORE_EAX                        RT_BIT(0)
    101108#define PATM_RESTORE_ECX                        RT_BIT(1)
    102109#define PATM_RESTORE_EDI                        RT_BIT(2)
    103 
     110/** @} */
     111
     112/** Relocation entry for PATCHASMRECORD. */
     113typedef struct PATCHASMRELOC
     114{
     115    /** The relocation type. */
     116    uint32_t uType;
     117    /** Additional information specific to the relocation type. */
     118    uint32_t uInfo;
     119} PATCHASMRELOC;
     120typedef PATCHASMRELOC const *PCPATCHASMRELOC;
     121
     122/**
     123 * Assembly patch descriptor record.
     124 */
    104125typedef struct
    105126{
    106     uint8_t *pFunction;
    107     uint32_t offJump;
    108     uint32_t offRelJump;        //used only by loop/loopz/loopnz
    109     uint32_t offSizeOverride;   //size override byte position
    110     uint32_t size;
    111     uint32_t nrRelocs;
    112     uint32_t uReloc[1];
    113 } PATCHASMRECORD, *PPATCHASMRECORD;
     127    /** Pointer to the patch code. */
     128    uint8_t        *pbFunction;
     129    /** Offset of the jump table? */
     130    uint32_t        offJump;
     131    /** Used only by loop/loopz/loopnz. */
     132    uint32_t        offRelJump;
     133    /** Size override byte position. */
     134    uint32_t        offSizeOverride;
     135    /** The size of the patch function. */
     136    uint32_t        cbFunction;
     137    /** The number of relocations in aRelocs. */
     138    uint32_t        cRelocs;
     139    /** Variable sized relocation table. */
     140    PATCHASMRELOC   aRelocs[1];
     141} PATCHASMRECORD;
     142/** Pointer to a const patch descriptor record. */
     143typedef PATCHASMRECORD const *PCPATCHASMRECORD;
     144
    114145
    115146/* For indirect calls/jump (identical in PATMA.h & PATMA.mac!) */
     
    137168RT_C_DECLS_BEGIN
    138169
     170/** @name Patch Descriptor Records (in PATMA.asm)
     171 * @{ */
    139172extern PATCHASMRECORD PATMCliRecord;
    140173extern PATCHASMRECORD PATMStiRecord;
     
    181214
    182215extern PATCHASMRECORD PATMMovFromSSRecord;
     216/** @} */
    183217
    184218extern const uint32_t PATMInterruptFlag;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette