Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:29

0001 
0002 /*---------------------------------------------------------------*/
0003 /*--- begin                              libvex_guest_arm64.h ---*/
0004 /*---------------------------------------------------------------*/
0005 
0006 /*
0007    This file is part of Valgrind, a dynamic binary instrumentation
0008    framework.
0009 
0010    Copyright (C) 2013-2017 OpenWorks
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 
0029 #ifndef __LIBVEX_PUB_GUEST_ARM64_H
0030 #define __LIBVEX_PUB_GUEST_ARM64_H
0031 
0032 #include "libvex_basictypes.h"
0033 
0034 
0035 /*---------------------------------------------------------------*/
0036 /*--- Vex's representation of the ARM64 CPU state.            ---*/
0037 /*---------------------------------------------------------------*/
0038 
0039 typedef
0040    struct {
0041       /* Event check fail addr and counter. */
0042       /* 0 */  ULong host_EvC_FAILADDR;
0043       /* 8 */  UInt  host_EvC_COUNTER;
0044       /* 12 */ UInt  pad0;
0045       /* 16 */
0046       ULong guest_X0;
0047       ULong guest_X1;
0048       ULong guest_X2;
0049       ULong guest_X3;
0050       ULong guest_X4;
0051       ULong guest_X5;
0052       ULong guest_X6;
0053       ULong guest_X7;
0054       ULong guest_X8;
0055       ULong guest_X9;
0056       ULong guest_X10;
0057       ULong guest_X11;
0058       ULong guest_X12;
0059       ULong guest_X13;
0060       ULong guest_X14;
0061       ULong guest_X15;
0062       ULong guest_X16;
0063       ULong guest_X17;
0064       ULong guest_X18;
0065       ULong guest_X19;
0066       ULong guest_X20;
0067       ULong guest_X21;
0068       ULong guest_X22;
0069       ULong guest_X23;
0070       ULong guest_X24;
0071       ULong guest_X25;
0072       ULong guest_X26;
0073       ULong guest_X27;
0074       ULong guest_X28;
0075       ULong guest_X29;
0076       ULong guest_X30;     /* link register */
0077       ULong guest_XSP;
0078       ULong guest_PC;
0079 
0080       /* 4-word thunk used to calculate N(sign) Z(zero) C(carry,
0081          unsigned overflow) and V(signed overflow) flags. */
0082       ULong guest_CC_OP;
0083       ULong guest_CC_DEP1;
0084       ULong guest_CC_DEP2;
0085       ULong guest_CC_NDEP;
0086 
0087       /* User-space thread register? */
0088       ULong guest_TPIDR_EL0;
0089 
0090       /* FP/SIMD state */
0091       U128 guest_Q0;
0092       U128 guest_Q1;
0093       U128 guest_Q2;
0094       U128 guest_Q3;
0095       U128 guest_Q4;
0096       U128 guest_Q5;
0097       U128 guest_Q6;
0098       U128 guest_Q7;
0099       U128 guest_Q8;
0100       U128 guest_Q9;
0101       U128 guest_Q10;
0102       U128 guest_Q11;
0103       U128 guest_Q12;
0104       U128 guest_Q13;
0105       U128 guest_Q14;
0106       U128 guest_Q15;
0107       U128 guest_Q16;
0108       U128 guest_Q17;
0109       U128 guest_Q18;
0110       U128 guest_Q19;
0111       U128 guest_Q20;
0112       U128 guest_Q21;
0113       U128 guest_Q22;
0114       U128 guest_Q23;
0115       U128 guest_Q24;
0116       U128 guest_Q25;
0117       U128 guest_Q26;
0118       U128 guest_Q27;
0119       U128 guest_Q28;
0120       U128 guest_Q29;
0121       U128 guest_Q30;
0122       U128 guest_Q31;
0123 
0124       /* A 128-bit value which is used to represent the FPSR.QC (sticky
0125          saturation) flag, when necessary.  If the value stored here
0126          is zero, FPSR.QC is currently zero.  If it is any other value,
0127          FPSR.QC is currently one.  We don't currently represent any 
0128          other bits of FPSR, so this is all that that is for FPSR. */
0129       U128 guest_QCFLAG;
0130 
0131       /* Various pseudo-regs mandated by Vex or Valgrind. */
0132       /* Emulation notes */
0133       UInt guest_EMNOTE;
0134 
0135       /* For clflush/clinval: record start and length of area */
0136       ULong guest_CMSTART;
0137       ULong guest_CMLEN;
0138 
0139       /* Used to record the unredirected guest address at the start of
0140          a translation whose start has been redirected.  By reading
0141          this pseudo-register shortly afterwards, the translation can
0142          find out what the corresponding no-redirection address was.
0143          Note, this is only set for wrap-style redirects, not for
0144          replace-style ones. */
0145       ULong guest_NRADDR;
0146 
0147       /* Needed for Darwin (but mandated for all guest architectures):
0148          program counter at the last syscall insn (int 0x80/81/82,
0149          sysenter, syscall, svc).  Used when backing up to restart a
0150          syscall that has been interrupted by a signal. */
0151       ULong guest_IP_AT_SYSCALL;
0152 
0153       /* The complete FPCR.  Default value seems to be zero.  We
0154          ignore all bits except 23 and 22, which are the rounding
0155          mode.  The guest is unconstrained in what values it can write
0156          to and read from this register, but the emulation only takes
0157          note of bits 23 and 22. */
0158       UInt  guest_FPCR;
0159 
0160       /* Fallback LL/SC support.  See bugs 344524 and 369459.  _LO64 and _HI64
0161          contain the original contents of _ADDR+0 .. _ADDR+15, but only _SIZE
0162          number of bytes of it.  The remaining 16-_SIZE bytes of them must be
0163          zero. */
0164       ULong guest_LLSC_SIZE; // 0==no current transaction, else 1,2,4,8 or 16.
0165       ULong guest_LLSC_ADDR; // Address of transaction.
0166       ULong guest_LLSC_DATA_LO64; // Original value at _ADDR+0.
0167       ULong guest_LLSC_DATA_HI64; // Original value at _ADDR+8.
0168 
0169       /* Padding to make it have an 16-aligned size */
0170       /* UInt  pad_end_0; */
0171       /* ULong pad_end_1; */
0172    }
0173    VexGuestARM64State;
0174 
0175 
0176 /*---------------------------------------------------------------*/
0177 /*--- Utility functions for ARM64 guest stuff.                ---*/
0178 /*---------------------------------------------------------------*/
0179 
0180 /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */
0181 
0182 /* Initialise all guest ARM64 state. */
0183 
0184 extern
0185 void LibVEX_GuestARM64_initialise ( /*OUT*/VexGuestARM64State* vex_state );
0186 
0187 /* Calculate the ARM64 flag state from the saved data, in the format
0188    32x0:n:z:c:v:28x0. */
0189 extern
0190 ULong LibVEX_GuestARM64_get_nzcv ( /*IN*/
0191                                    const VexGuestARM64State* vex_state );
0192 
0193 /* Calculate the ARM64 FPSR state from the saved data, in the format
0194    36x0:qc:27x0 */
0195 extern
0196 ULong LibVEX_GuestARM64_get_fpsr ( /*IN*/
0197                                    const VexGuestARM64State* vex_state );
0198 
0199 /* Set the ARM64 FPSR representation from the given FPSR value. */
0200 extern
0201 void LibVEX_GuestARM64_set_fpsr ( /*MOD*/VexGuestARM64State* vex_state,
0202                                   ULong fpsr );
0203                                   
0204 
0205 #endif /* ndef __LIBVEX_PUB_GUEST_ARM64_H */
0206 
0207 
0208 /*---------------------------------------------------------------*/
0209 /*---                                    libvex_guest_arm64.h ---*/
0210 /*---------------------------------------------------------------*/