non-linux regtest: update cmdline expecteds
[valgrind.git] / VEX / pub / libvex_guest_amd64.h
blobc0520d2f6dd00c40366628f3a6f3e5fb32d0efd2
2 /*---------------------------------------------------------------*/
3 /*--- begin libvex_guest_amd64.h ---*/
4 /*---------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2004-2017 OpenWorks LLP
11 info@open-works.net
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
28 Neither the names of the U.S. Department of Energy nor the
29 University of California nor the names of its contributors may be
30 used to endorse or promote products derived from this software
31 without prior written permission.
34 #ifndef __LIBVEX_PUB_GUEST_AMD64_H
35 #define __LIBVEX_PUB_GUEST_AMD64_H
37 #include "libvex_basictypes.h"
38 #include "libvex_emnote.h"
41 /*---------------------------------------------------------------*/
42 /*--- Vex's representation of the AMD64 CPU state. ---*/
43 /*---------------------------------------------------------------*/
45 /* See detailed comments at the top of libvex_guest_x86.h for
46 further info. This representation closely follows the
47 x86 representation.
51 typedef
52 struct {
53 /* Event check fail addr, counter, and padding to make RAX 16
54 aligned. */
55 /* 0 */ ULong host_EvC_FAILADDR;
56 /* 8 */ UInt host_EvC_COUNTER;
57 /* 12 */ UInt pad0;
58 /* 16 */ ULong guest_RAX;
59 /* 24 */ ULong guest_RCX;
60 /* 32 */ ULong guest_RDX;
61 /* 40 */ ULong guest_RBX;
62 /* 48 */ ULong guest_RSP;
63 /* 56 */ ULong guest_RBP;
64 /* 64 */ ULong guest_RSI;
65 /* 72 */ ULong guest_RDI;
66 /* 80 */ ULong guest_R8;
67 /* 88 */ ULong guest_R9;
68 /* 96 */ ULong guest_R10;
69 /* 104 */ ULong guest_R11;
70 /* 112 */ ULong guest_R12;
71 /* 120 */ ULong guest_R13;
72 /* 128 */ ULong guest_R14;
73 /* 136 */ ULong guest_R15;
74 /* 4-word thunk used to calculate O S Z A C P flags. */
75 /* 144 */ ULong guest_CC_OP;
76 /* 152 */ ULong guest_CC_DEP1;
77 /* 160 */ ULong guest_CC_DEP2;
78 /* 168 */ ULong guest_CC_NDEP;
79 /* The D flag is stored here, encoded as either -1 or +1 */
80 /* 176 */ ULong guest_DFLAG;
81 /* 184 */ ULong guest_RIP;
82 /* Bit 18 (AC) of eflags stored here, as either 0 or 1. */
83 /* ... */ ULong guest_ACFLAG;
84 /* Bit 21 (ID) of eflags stored here, as either 0 or 1. */
85 /* 192 */ ULong guest_IDFLAG;
86 /* Probably a lot more stuff too.
87 D,ID flags
88 16 128-bit SSE registers
89 all the old x87 FPU gunk
90 segment registers */
92 /* HACK to e.g. make tls on amd64-linux/solaris work. %fs only ever seems
93 to hold a constant value (zero on linux main thread, 0x63 in other
94 threads), and so guest_FS_CONST holds
95 the 64-bit offset associated with this constant %fs value. */
96 /* 200 */ ULong guest_FS_CONST;
98 /* YMM registers. Note that these must be allocated
99 consecutively in order that the SSE4.2 PCMP{E,I}STR{I,M}
100 helpers can treat them as an array. YMM16 is a fake reg used
101 as an intermediary in handling aforementioned insns. */
102 /* 208 */ULong guest_SSEROUND;
103 /* 216 */U256 guest_YMM0;
104 U256 guest_YMM1;
105 U256 guest_YMM2;
106 U256 guest_YMM3;
107 U256 guest_YMM4;
108 U256 guest_YMM5;
109 U256 guest_YMM6;
110 U256 guest_YMM7;
111 U256 guest_YMM8;
112 U256 guest_YMM9;
113 U256 guest_YMM10;
114 U256 guest_YMM11;
115 U256 guest_YMM12;
116 U256 guest_YMM13;
117 U256 guest_YMM14;
118 U256 guest_YMM15;
119 U256 guest_YMM16;
121 /* FPU */
122 /* Note. Setting guest_FTOP to be ULong messes up the
123 delicately-balanced PutI/GetI optimisation machinery.
124 Therefore best to leave it as a UInt. */
125 UInt guest_FTOP;
126 UInt pad1;
127 ULong guest_FPREG[8];
128 UChar guest_FPTAG[8];
129 ULong guest_FPROUND;
130 ULong guest_FC3210;
132 /* Emulation notes */
133 UInt guest_EMNOTE;
134 /* Used by Darwin and FreeBSD when setting the carry flag from
135 * ML_(do_syscall_for_client_WRK). Needed to determine how
136 * to restart interrupted syscalls. */
137 UInt guest_SETC;
139 /* Translation-invalidation area description. Not used on amd64
140 (there is no invalidate-icache insn), but needed so as to
141 allow users of the library to uniformly assume that the guest
142 state contains these two fields -- otherwise there is
143 compilation breakage. On amd64, these two fields are set to
144 zero by LibVEX_GuestAMD64_initialise and then should be
145 ignored forever thereafter. */
146 ULong guest_CMSTART;
147 ULong guest_CMLEN;
149 /* Used to record the unredirected guest address at the start of
150 a translation whose start has been redirected. By reading
151 this pseudo-register shortly afterwards, the translation can
152 find out what the corresponding no-redirection address was.
153 Note, this is only set for wrap-style redirects, not for
154 replace-style ones. */
155 ULong guest_NRADDR;
157 /* Used for Darwin syscall dispatching. */
158 ULong guest_SC_CLASS;
160 /* HACK to make e.g. tls on darwin work, wine on linux work, ...
161 %gs only ever seems to hold a constant value (e.g. 0x60 on darwin,
162 0x6b on linux), and so guest_GS_CONST holds the 64-bit offset
163 associated with this constant %gs value. (A direct analogue
164 of the %fs-const hack for amd64-linux/solaris). */
165 ULong guest_GS_CONST;
167 /* Needed for Darwin (but mandated for all guest architectures):
168 RIP at the last syscall insn (int 0x80/81/82, sysenter,
169 syscall). Used when backing up to restart a syscall that has
170 been interrupted by a signal. */
171 ULong guest_IP_AT_SYSCALL;
173 /* Padding to make it have an 16-aligned size */
174 ULong pad3;
176 VexGuestAMD64State;
180 /*---------------------------------------------------------------*/
181 /*--- Utility functions for amd64 guest stuff. ---*/
182 /*---------------------------------------------------------------*/
184 /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */
186 /* Initialise all guest amd64 state. The FPU is put in default
187 mode. */
188 extern
189 void LibVEX_GuestAMD64_initialise ( /*OUT*/VexGuestAMD64State* vex_state );
192 /* Extract from the supplied VexGuestAMD64State structure the
193 corresponding native %rflags value. */
194 extern
195 ULong LibVEX_GuestAMD64_get_rflags ( /*IN*/const VexGuestAMD64State* vex_state );
197 /* Put rflags into the given state. */
198 extern
199 void LibVEX_GuestAMD64_put_rflags ( ULong rflags,
200 /*MOD*/VexGuestAMD64State* vex_state );
202 /* Set the carry flag in the given state to 'new_carry_flag', which
203 should be zero or one. */
204 extern
205 void
206 LibVEX_GuestAMD64_put_rflag_c ( ULong new_carry_flag,
207 /*MOD*/VexGuestAMD64State* vex_state );
209 #if defined(VGO_freebsd) || defined(VGO_darwin)
210 void _______VVVVVVVV_after_GuestAMD64_put_rflag_c_VVVVVVVV_______ (void);
211 extern Addr addr_amd64g_calculate_rflags_all_WRK;
212 extern Addr addr________VVVVVVVV_amd64g_calculate_rflags_all_WRK_VVVVVVVV_______;
213 #endif
216 /* Do FXSAVE from the supplied VexGuestAMD64tate structure and store the
217 result at the given address which represents a buffer of at least 416
218 bytes. */
219 extern
220 void LibVEX_GuestAMD64_fxsave ( /*IN*/VexGuestAMD64State* gst,
221 /*OUT*/HWord fp_state );
223 /* Do FXRSTOR from the supplied address and store read values to the given
224 VexGuestAMD64State structure. */
225 extern
226 VexEmNote LibVEX_GuestAMD64_fxrstor ( /*IN*/HWord fp_state,
227 /*MOD*/VexGuestAMD64State* gst );
229 #endif /* ndef __LIBVEX_PUB_GUEST_AMD64_H */
231 /*---------------------------------------------------------------*/
232 /*--- libvex_guest_amd64.h ---*/
233 /*---------------------------------------------------------------*/