1 2 /*---------------------------------------------------------------*/ 3 /*--- begin libvex_guest_arm64.h ---*/ 4 /*---------------------------------------------------------------*/ 5 6 /* 7 This file is part of Valgrind, a dynamic binary instrumentation 8 framework. 9 10 Copyright (C) 2013-2013 OpenWorks 11 info (at) open-works.net 12 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. 17 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. 22 23 You should have received a copy of the GNU General Public License 24 along with this program; if not, write to the Free Software 25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 26 02110-1301, USA. 27 28 The GNU General Public License is contained in the file COPYING. 29 */ 30 31 #ifndef __LIBVEX_PUB_GUEST_ARM64_H 32 #define __LIBVEX_PUB_GUEST_ARM64_H 33 34 #include "libvex_basictypes.h" 35 36 37 /*---------------------------------------------------------------*/ 38 /*--- Vex's representation of the ARM64 CPU state. ---*/ 39 /*---------------------------------------------------------------*/ 40 41 typedef 42 struct { 43 /* Event check fail addr and counter. */ 44 /* 0 */ ULong host_EvC_FAILADDR; 45 /* 8 */ UInt host_EvC_COUNTER; 46 /* 12 */ UInt pad0; 47 /* 16 */ 48 ULong guest_X0; 49 ULong guest_X1; 50 ULong guest_X2; 51 ULong guest_X3; 52 ULong guest_X4; 53 ULong guest_X5; 54 ULong guest_X6; 55 ULong guest_X7; 56 ULong guest_X8; 57 ULong guest_X9; 58 ULong guest_X10; 59 ULong guest_X11; 60 ULong guest_X12; 61 ULong guest_X13; 62 ULong guest_X14; 63 ULong guest_X15; 64 ULong guest_X16; 65 ULong guest_X17; 66 ULong guest_X18; 67 ULong guest_X19; 68 ULong guest_X20; 69 ULong guest_X21; 70 ULong guest_X22; 71 ULong guest_X23; 72 ULong guest_X24; 73 ULong guest_X25; 74 ULong guest_X26; 75 ULong guest_X27; 76 ULong guest_X28; 77 ULong guest_X29; 78 ULong guest_X30; /* link register */ 79 ULong guest_XSP; 80 ULong guest_PC; 81 82 /* 4-word thunk used to calculate N(sign) Z(zero) C(carry, 83 unsigned overflow) and V(signed overflow) flags. */ 84 ULong guest_CC_OP; 85 ULong guest_CC_DEP1; 86 ULong guest_CC_DEP2; 87 ULong guest_CC_NDEP; 88 89 /* User-space thread register? */ 90 ULong guest_TPIDR_EL0; 91 92 /* FP/SIMD state */ 93 U128 guest_Q0; 94 U128 guest_Q1; 95 U128 guest_Q2; 96 U128 guest_Q3; 97 U128 guest_Q4; 98 U128 guest_Q5; 99 U128 guest_Q6; 100 U128 guest_Q7; 101 U128 guest_Q8; 102 U128 guest_Q9; 103 U128 guest_Q10; 104 U128 guest_Q11; 105 U128 guest_Q12; 106 U128 guest_Q13; 107 U128 guest_Q14; 108 U128 guest_Q15; 109 U128 guest_Q16; 110 U128 guest_Q17; 111 U128 guest_Q18; 112 U128 guest_Q19; 113 U128 guest_Q20; 114 U128 guest_Q21; 115 U128 guest_Q22; 116 U128 guest_Q23; 117 U128 guest_Q24; 118 U128 guest_Q25; 119 U128 guest_Q26; 120 U128 guest_Q27; 121 U128 guest_Q28; 122 U128 guest_Q29; 123 U128 guest_Q30; 124 U128 guest_Q31; 125 126 /* Various pseudo-regs mandated by Vex or Valgrind. */ 127 /* Emulation notes */ 128 UInt guest_EMNOTE; 129 130 /* For clflush/clinval: record start and length of area */ 131 ULong guest_CMSTART; 132 ULong guest_CMLEN; 133 134 /* Used to record the unredirected guest address at the start of 135 a translation whose start has been redirected. By reading 136 this pseudo-register shortly afterwards, the translation can 137 find out what the corresponding no-redirection address was. 138 Note, this is only set for wrap-style redirects, not for 139 replace-style ones. */ 140 ULong guest_NRADDR; 141 142 /* Needed for Darwin (but mandated for all guest architectures): 143 program counter at the last syscall insn (int 0x80/81/82, 144 sysenter, syscall, svc). Used when backing up to restart a 145 syscall that has been interrupted by a signal. */ 146 ULong guest_IP_AT_SYSCALL; 147 148 /* The complete FPCR. Default value seems to be zero. We 149 ignore all bits except 23 and 22, which are the rounding 150 mode. The guest is unconstrained in what values it can write 151 to and read from this register, but the emulation only takes 152 note of bits 23 and 22. */ 153 UInt guest_FPCR; 154 155 /* The complete FPSR. As with FPCR, the guest may write and 156 read any values here, and the emulation ignores it, with the 157 exception of bit 27 (QC, the sticky saturation bit) which 158 does get set when required. */ 159 UInt guest_FPSR; 160 161 /* Padding to make it have an 16-aligned size */ 162 UInt pad_end_0; 163 ULong pad_end_1; 164 } 165 VexGuestARM64State; 166 167 168 /*---------------------------------------------------------------*/ 169 /*--- Utility functions for ARM64 guest stuff. ---*/ 170 /*---------------------------------------------------------------*/ 171 172 /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */ 173 174 /* Initialise all guest ARM64 state. */ 175 176 extern 177 void LibVEX_GuestARM64_initialise ( /*OUT*/VexGuestARM64State* vex_state ); 178 179 /* Calculate the ARM64 flag state from the saved data, in the format 180 32x0:n:z:c:v:28x0. */ 181 extern 182 ULong LibVEX_GuestARM64_get_nzcv ( /*IN*/ 183 const VexGuestARM64State* vex_state ); 184 185 #endif /* ndef __LIBVEX_PUB_GUEST_ARM64_H */ 186 187 188 /*---------------------------------------------------------------*/ 189 /*--- libvex_guest_arm64.h ---*/ 190 /*---------------------------------------------------------------*/ 191