![]() |
|
|||
File indexing completed on 2025-09-17 09:17:47
0001 0002 /*---------------------------------------------------------------*/ 0003 /*--- begin libvex_guest_amd64.h ---*/ 0004 /*---------------------------------------------------------------*/ 0005 0006 /* 0007 This file is part of Valgrind, a dynamic binary instrumentation 0008 framework. 0009 0010 Copyright (C) 2004-2017 OpenWorks LLP 0011 info@open-works.net 0012 0013 This program is free software; you can redistribute it and/or 0014 modify it under the terms of the GNU General Public License as 0015 published by the Free Software Foundation; either version 2 of the 0016 License, or (at your option) any later version. 0017 0018 This program is distributed in the hope that it will be useful, but 0019 WITHOUT ANY WARRANTY; without even the implied warranty of 0020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0021 General Public License for more details. 0022 0023 You should have received a copy of the GNU General Public License 0024 along with this program; if not, see <http://www.gnu.org/licenses/>. 0025 0026 The GNU General Public License is contained in the file COPYING. 0027 0028 Neither the names of the U.S. Department of Energy nor the 0029 University of California nor the names of its contributors may be 0030 used to endorse or promote products derived from this software 0031 without prior written permission. 0032 */ 0033 0034 #ifndef __LIBVEX_PUB_GUEST_AMD64_H 0035 #define __LIBVEX_PUB_GUEST_AMD64_H 0036 0037 #include "libvex_basictypes.h" 0038 #include "libvex_emnote.h" 0039 0040 0041 /*---------------------------------------------------------------*/ 0042 /*--- Vex's representation of the AMD64 CPU state. ---*/ 0043 /*---------------------------------------------------------------*/ 0044 0045 /* See detailed comments at the top of libvex_guest_x86.h for 0046 further info. This representation closely follows the 0047 x86 representation. 0048 */ 0049 0050 0051 typedef 0052 struct { 0053 /* Event check fail addr, counter, and padding to make RAX 16 0054 aligned. */ 0055 /* 0 */ ULong host_EvC_FAILADDR; 0056 /* 8 */ UInt host_EvC_COUNTER; 0057 /* 12 */ UInt pad0; 0058 /* 16 */ ULong guest_RAX; 0059 /* 24 */ ULong guest_RCX; 0060 /* 32 */ ULong guest_RDX; 0061 /* 40 */ ULong guest_RBX; 0062 /* 48 */ ULong guest_RSP; 0063 /* 56 */ ULong guest_RBP; 0064 /* 64 */ ULong guest_RSI; 0065 /* 72 */ ULong guest_RDI; 0066 /* 80 */ ULong guest_R8; 0067 /* 88 */ ULong guest_R9; 0068 /* 96 */ ULong guest_R10; 0069 /* 104 */ ULong guest_R11; 0070 /* 112 */ ULong guest_R12; 0071 /* 120 */ ULong guest_R13; 0072 /* 128 */ ULong guest_R14; 0073 /* 136 */ ULong guest_R15; 0074 /* 4-word thunk used to calculate O S Z A C P flags. */ 0075 /* 144 */ ULong guest_CC_OP; 0076 /* 152 */ ULong guest_CC_DEP1; 0077 /* 160 */ ULong guest_CC_DEP2; 0078 /* 168 */ ULong guest_CC_NDEP; 0079 /* The D flag is stored here, encoded as either -1 or +1 */ 0080 /* 176 */ ULong guest_DFLAG; 0081 /* 184 */ ULong guest_RIP; 0082 /* Bit 18 (AC) of eflags stored here, as either 0 or 1. */ 0083 /* ... */ ULong guest_ACFLAG; 0084 /* Bit 21 (ID) of eflags stored here, as either 0 or 1. */ 0085 /* 192 */ ULong guest_IDFLAG; 0086 /* Probably a lot more stuff too. 0087 D,ID flags 0088 16 128-bit SSE registers 0089 all the old x87 FPU gunk 0090 segment registers */ 0091 0092 /* HACK to e.g. make tls on amd64-linux/solaris work. %fs only ever seems 0093 to hold a constant value (zero on linux main thread, 0x63 in other 0094 threads), and so guest_FS_CONST holds 0095 the 64-bit offset associated with this constant %fs value. */ 0096 /* 200 */ ULong guest_FS_CONST; 0097 0098 /* YMM registers. Note that these must be allocated 0099 consecutively in order that the SSE4.2 PCMP{E,I}STR{I,M} 0100 helpers can treat them as an array. YMM16 is a fake reg used 0101 as an intermediary in handling aforementioned insns. */ 0102 /* 208 */ULong guest_SSEROUND; 0103 /* 216 */U256 guest_YMM0; 0104 U256 guest_YMM1; 0105 U256 guest_YMM2; 0106 U256 guest_YMM3; 0107 U256 guest_YMM4; 0108 U256 guest_YMM5; 0109 U256 guest_YMM6; 0110 U256 guest_YMM7; 0111 U256 guest_YMM8; 0112 U256 guest_YMM9; 0113 U256 guest_YMM10; 0114 U256 guest_YMM11; 0115 U256 guest_YMM12; 0116 U256 guest_YMM13; 0117 U256 guest_YMM14; 0118 U256 guest_YMM15; 0119 U256 guest_YMM16; 0120 0121 /* FPU */ 0122 /* Note. Setting guest_FTOP to be ULong messes up the 0123 delicately-balanced PutI/GetI optimisation machinery. 0124 Therefore best to leave it as a UInt. */ 0125 UInt guest_FTOP; 0126 UInt pad1; 0127 ULong guest_FPREG[8]; 0128 UChar guest_FPTAG[8]; 0129 ULong guest_FPROUND; 0130 ULong guest_FC3210; 0131 0132 /* Emulation notes */ 0133 UInt guest_EMNOTE; 0134 /* Used by Darwin and FreeBSD when setting the carry flag from 0135 * ML_(do_syscall_for_client_WRK). Needed to determine how 0136 * to restart interrupted syscalls. */ 0137 UInt guest_SETC; 0138 0139 /* Translation-invalidation area description. Not used on amd64 0140 (there is no invalidate-icache insn), but needed so as to 0141 allow users of the library to uniformly assume that the guest 0142 state contains these two fields -- otherwise there is 0143 compilation breakage. On amd64, these two fields are set to 0144 zero by LibVEX_GuestAMD64_initialise and then should be 0145 ignored forever thereafter. */ 0146 ULong guest_CMSTART; 0147 ULong guest_CMLEN; 0148 0149 /* Used to record the unredirected guest address at the start of 0150 a translation whose start has been redirected. By reading 0151 this pseudo-register shortly afterwards, the translation can 0152 find out what the corresponding no-redirection address was. 0153 Note, this is only set for wrap-style redirects, not for 0154 replace-style ones. */ 0155 ULong guest_NRADDR; 0156 0157 /* Used for Darwin syscall dispatching. */ 0158 ULong guest_SC_CLASS; 0159 0160 /* HACK to make e.g. tls on darwin work, wine on linux work, ... 0161 %gs only ever seems to hold a constant value (e.g. 0x60 on darwin, 0162 0x6b on linux), and so guest_GS_CONST holds the 64-bit offset 0163 associated with this constant %gs value. (A direct analogue 0164 of the %fs-const hack for amd64-linux/solaris). */ 0165 ULong guest_GS_CONST; 0166 0167 /* Needed for Darwin (but mandated for all guest architectures): 0168 RIP at the last syscall insn (int 0x80/81/82, sysenter, 0169 syscall). Used when backing up to restart a syscall that has 0170 been interrupted by a signal. */ 0171 ULong guest_IP_AT_SYSCALL; 0172 0173 /* Padding to make it have an 16-aligned size */ 0174 ULong pad3; 0175 } 0176 VexGuestAMD64State; 0177 0178 0179 0180 /*---------------------------------------------------------------*/ 0181 /*--- Utility functions for amd64 guest stuff. ---*/ 0182 /*---------------------------------------------------------------*/ 0183 0184 /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */ 0185 0186 /* Initialise all guest amd64 state. The FPU is put in default 0187 mode. */ 0188 extern 0189 void LibVEX_GuestAMD64_initialise ( /*OUT*/VexGuestAMD64State* vex_state ); 0190 0191 0192 /* Extract from the supplied VexGuestAMD64State structure the 0193 corresponding native %rflags value. */ 0194 extern 0195 ULong LibVEX_GuestAMD64_get_rflags ( /*IN*/const VexGuestAMD64State* vex_state ); 0196 0197 /* Put rflags into the given state. */ 0198 extern 0199 void LibVEX_GuestAMD64_put_rflags ( ULong rflags, 0200 /*MOD*/VexGuestAMD64State* vex_state ); 0201 0202 /* Set the carry flag in the given state to 'new_carry_flag', which 0203 should be zero or one. */ 0204 extern 0205 void 0206 LibVEX_GuestAMD64_put_rflag_c ( ULong new_carry_flag, 0207 /*MOD*/VexGuestAMD64State* vex_state ); 0208 0209 /* Do FXSAVE from the supplied VexGuestAMD64tate structure and store the 0210 result at the given address which represents a buffer of at least 416 0211 bytes. */ 0212 extern 0213 void LibVEX_GuestAMD64_fxsave ( /*IN*/VexGuestAMD64State* gst, 0214 /*OUT*/HWord fp_state ); 0215 0216 /* Do FXRSTOR from the supplied address and store read values to the given 0217 VexGuestAMD64State structure. */ 0218 extern 0219 VexEmNote LibVEX_GuestAMD64_fxrstor ( /*IN*/HWord fp_state, 0220 /*MOD*/VexGuestAMD64State* gst ); 0221 0222 #endif /* ndef __LIBVEX_PUB_GUEST_AMD64_H */ 0223 0224 /*---------------------------------------------------------------*/ 0225 /*--- libvex_guest_amd64.h ---*/ 0226 /*---------------------------------------------------------------*/
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |