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_ppc64.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_PPC64_H
0035 #define __LIBVEX_PUB_GUEST_PPC64_H
0036 
0037 #include "libvex_basictypes.h"
0038 
0039 /*
0040     volatile ==  caller-saved (not preserved across function calls)
0041 non-volatile ==  callee-saved (preserved across function calls)
0042 
0043 r0        Volatile register used in function prologs
0044 r1        Stack frame pointer
0045 r2        TOC pointer
0046 r3        Volatile parameter and return value register
0047 r4-r10    Volatile registers used for function parameters
0048 r11       Volatile register used in calls by pointer and as an
0049           environment pointer for languages which require one
0050 r12       Volatile register used for exception handling and glink code
0051 r13       Reserved for use as system thread ID
0052 r14-r31   Nonvolatile registers used for local variables
0053 
0054 f0        Volatile scratch register
0055 f1-f4     Volatile floating point parameter and return value registers
0056 f5-f13    Volatile floating point parameter registers
0057 f14-f31   Nonvolatile registers
0058 
0059 LR        Link register (volatile)
0060 CTR       Loop counter register (volatile)
0061 XER       Fixed point exception register (volatile)
0062 FPSCR     Floating point status and control register (volatile)
0063 
0064 CR0-CR1   Volatile condition code register fields
0065 CR2-CR4   Nonvolatile condition code register fields
0066 CR5-CR7   Volatile condition code register fields
0067 
0068 On processors with the VMX feature.
0069 
0070 v0-v1     Volatile scratch registers
0071 v2-v13    Volatile vector parameters registers
0072 v14-v19   Volatile scratch registers
0073 v20-v31   Non-volatile registers
0074 vrsave    Non-volatile 32-bit register
0075 */
0076 
0077 
0078 /*---------------------------------------------------------------*/
0079 /*--- Vex's representation of the PPC64 CPU state             ---*/
0080 /*---------------------------------------------------------------*/
0081 
0082 #define VEX_GUEST_PPC64_REDIR_STACK_SIZE (16/*entries*/ * 2/*words per entry*/)
0083 
0084 typedef
0085    struct {
0086      /* Event check fail addr, counter, and padding to make GPR0 16
0087         aligned. */
0088       /*   0 */ ULong  host_EvC_FAILADDR;
0089       /*   8 */ UInt   host_EvC_COUNTER;
0090       /*  12 */ UInt   pad0;
0091       /* Add 16 to all of the offsets below .. */
0092       /* General Purpose Registers */
0093       /*   0 */ ULong guest_GPR0;
0094       /*   8 */ ULong guest_GPR1;
0095       /*  16 */ ULong guest_GPR2;
0096       /*  24 */ ULong guest_GPR3;
0097       /*  32 */ ULong guest_GPR4;
0098       /*  40 */ ULong guest_GPR5;
0099       /*  48 */ ULong guest_GPR6;
0100       /*  56 */ ULong guest_GPR7;
0101       /*  64 */ ULong guest_GPR8;
0102       /*  72 */ ULong guest_GPR9;
0103       /*  80 */ ULong guest_GPR10;
0104       /*  88 */ ULong guest_GPR11;
0105       /*  96 */ ULong guest_GPR12;
0106       /* 104 */ ULong guest_GPR13;
0107       /* 112 */ ULong guest_GPR14;
0108       /* 120 */ ULong guest_GPR15;
0109       /* 128 */ ULong guest_GPR16;
0110       /* 136 */ ULong guest_GPR17;
0111       /* 144 */ ULong guest_GPR18;
0112       /* 152 */ ULong guest_GPR19;
0113       /* 160 */ ULong guest_GPR20;
0114       /* 168 */ ULong guest_GPR21;
0115       /* 176 */ ULong guest_GPR22;
0116       /* 184 */ ULong guest_GPR23;
0117       /* 192 */ ULong guest_GPR24;
0118       /* 200 */ ULong guest_GPR25;
0119       /* 208 */ ULong guest_GPR26;
0120       /* 216 */ ULong guest_GPR27;
0121       /* 224 */ ULong guest_GPR28;
0122       /* 232 */ ULong guest_GPR29;
0123       /* 240 */ ULong guest_GPR30;
0124       /* 248 */ ULong guest_GPR31;
0125 
0126       // Vector Registers, Floating Point Registers, and VSX Registers
0127       // With ISA 2.06, the "Vector-Scalar Floating-point" category
0128       // provides facilities to support vector and scalar binary floating-
0129       // point operations.  A unified register file is an integral part
0130       // of this new facility, combining floating point and vector registers
0131       // using a 64x128-bit vector.  These are referred to as VSR[0..63].
0132       // The floating point registers are now mapped into double word element 0
0133       // of VSR[0..31]. The 32x128-bit vector registers defined by the "Vector
0134       // Facility [Category: Vector]" are now mapped to VSR[32..63].
0135 
0136       // IMPORTANT: the user of libvex must place the guest state so as
0137       // to ensure that guest_VSR{0..63}, and any shadows thereof, are
0138       // 16-aligned.
0139 
0140       /*  256 */ U128 guest_VSR0;
0141       /*  272 */ U128 guest_VSR1;
0142       /*  288 */ U128 guest_VSR2;
0143       /*  304 */ U128 guest_VSR3;
0144       /*  320 */ U128 guest_VSR4;
0145       /*  336 */ U128 guest_VSR5;
0146       /*  352 */ U128 guest_VSR6;
0147       /*  368 */ U128 guest_VSR7;
0148       /*  384 */ U128 guest_VSR8;
0149       /*  400 */ U128 guest_VSR9;
0150       /*  416 */ U128 guest_VSR10;
0151       /*  432 */ U128 guest_VSR11;
0152       /*  448 */ U128 guest_VSR12;
0153       /*  464 */ U128 guest_VSR13;
0154       /*  480 */ U128 guest_VSR14;
0155       /*  496 */ U128 guest_VSR15;
0156       /*  512 */ U128 guest_VSR16;
0157       /*  528 */ U128 guest_VSR17;
0158       /*  544 */ U128 guest_VSR18;
0159       /*  560 */ U128 guest_VSR19;
0160       /*  576 */ U128 guest_VSR20;
0161       /*  592 */ U128 guest_VSR21;
0162       /*  608 */ U128 guest_VSR22;
0163       /*  624 */ U128 guest_VSR23;
0164       /*  640 */ U128 guest_VSR24;
0165       /*  656 */ U128 guest_VSR25;
0166       /*  672 */ U128 guest_VSR26;
0167       /*  688 */ U128 guest_VSR27;
0168       /*  704 */ U128 guest_VSR28;
0169       /*  720 */ U128 guest_VSR29;
0170       /*  736 */ U128 guest_VSR30;
0171       /*  752 */ U128 guest_VSR31;
0172       /*  768 */ U128 guest_VSR32;
0173       /*  784 */ U128 guest_VSR33;
0174       /*  800 */ U128 guest_VSR34;
0175       /*  816 */ U128 guest_VSR35;
0176       /*  832 */ U128 guest_VSR36;
0177       /*  848 */ U128 guest_VSR37;
0178       /*  864 */ U128 guest_VSR38;
0179       /*  880 */ U128 guest_VSR39;
0180       /*  896 */ U128 guest_VSR40;
0181       /*  912 */ U128 guest_VSR41;
0182       /*  928 */ U128 guest_VSR42;
0183       /*  944 */ U128 guest_VSR43;
0184       /*  960 */ U128 guest_VSR44;
0185       /*  976 */ U128 guest_VSR45;
0186       /*  992 */ U128 guest_VSR46;
0187       /* 1008 */ U128 guest_VSR47;
0188       /* 1024 */ U128 guest_VSR48;
0189       /* 1040 */ U128 guest_VSR49;
0190       /* 1056 */ U128 guest_VSR50;
0191       /* 1072 */ U128 guest_VSR51;
0192       /* 1088 */ U128 guest_VSR52;
0193       /* 1104 */ U128 guest_VSR53;
0194       /* 1120 */ U128 guest_VSR54;
0195       /* 1136 */ U128 guest_VSR55;
0196       /* 1152 */ U128 guest_VSR56;
0197       /* 1168 */ U128 guest_VSR57;
0198       /* 1184 */ U128 guest_VSR58;
0199       /* 1200 */ U128 guest_VSR59;
0200       /* 1216 */ U128 guest_VSR60;
0201       /* 1232 */ U128 guest_VSR61;
0202       /* 1248 */ U128 guest_VSR62;
0203       /* 1264 */ U128 guest_VSR63;
0204 
0205       /* 1280 */ ULong guest_CIA;    // IP (no arch visible register)
0206       /* 1288 */ ULong guest_LR;     // Link Register
0207       /* 1296 */ ULong guest_CTR;    // Count Register
0208 
0209       /* XER pieces */
0210       /* 1304 */ UChar guest_XER_SO; /* in lsb */
0211       /* 1305 */ UChar guest_XER_OV; /* in lsb */
0212       /* 1306 */ UChar guest_XER_OV32; /* in lsb */
0213       /* 1307 */ UChar guest_XER_CA; /* in lsb */
0214       /* 1308 */ UChar guest_XER_CA32; /* in lsb */
0215       /* 1309 */ UChar guest_XER_BC; /* all bits */
0216 
0217       /* CR pieces */
0218       /* 1310 */ UChar guest_CR0_321; /* in [3:1] */
0219       /* 1311 */ UChar guest_CR0_0;   /* in lsb */
0220       /* 1312 */ UChar guest_CR1_321; /* in [3:1] */
0221       /* 1313 */ UChar guest_CR1_0;   /* in lsb */
0222       /* 1314 */ UChar guest_CR2_321; /* in [3:1] */
0223       /* 1315 */ UChar guest_CR2_0;   /* in lsb */
0224       /* 1316 */ UChar guest_CR3_321; /* in [3:1] */
0225       /* 1317 */ UChar guest_CR3_0;   /* in lsb */
0226       /* 1318 */ UChar guest_CR4_321; /* in [3:1] */
0227       /* 1319 */ UChar guest_CR4_0;   /* in lsb */
0228       /* 1320 */ UChar guest_CR5_321; /* in [3:1] */
0229       /* 1321 */ UChar guest_CR5_0;   /* in lsb */
0230       /* 1322 */ UChar guest_CR6_321; /* in [3:1] */
0231       /* 1323 */ UChar guest_CR6_0;   /* in lsb */
0232       /* 1324 */ UChar guest_CR7_321; /* in [3:1] */
0233       /* 1325 */ UChar guest_CR7_0;   /* in lsb */
0234 
0235       /* FP Status and  Control Register fields. Only rounding mode fields
0236        * and Floating-point Condition Code (FPCC) fields are supported.
0237        */
0238       /* 1326 */ UChar guest_FPROUND; // Binary Floating Point Rounding Mode
0239       /* 1327 */ UChar guest_DFPROUND; // Decimal Floating Point Rounding Mode
0240       /* 1328 */ UChar guest_C_FPCC;   // Floating-point Condition Code
0241                                        // and Floating-point Condition Code
0242 
0243       /* 1329 */ UChar pad2;
0244       /* 1330 */ UChar pad3;
0245       /* 1331 */ UChar pad4;
0246 
0247       /* Vector Save/Restore Register */
0248       /* 1332 */ UInt guest_VRSAVE;
0249 
0250       /* Vector Status and Control Register */
0251       /* 1336 */ UInt guest_VSCR;
0252 
0253       /* Emulation notes */
0254       /* 1340 */ UInt guest_EMNOTE;
0255 
0256       /* gcc adds 4 bytes padding here: pre-empt it. */
0257       /* 1344 */ UInt  padding;
0258 
0259       /* For icbi: record start and length of area to invalidate */
0260       /* 1348 */ ULong guest_CMSTART;
0261       /* 1356 */ ULong guest_CMLEN;
0262 
0263       /* Used to record the unredirected guest address at the start of
0264          a translation whose start has been redirected.  By reading
0265          this pseudo-register shortly afterwards, the translation can
0266          find out what the corresponding no-redirection address was.
0267          Note, this is only set for wrap-style redirects, not for
0268          replace-style ones. */
0269       /* 1364 */ ULong guest_NRADDR;
0270       /* 1372 */ ULong guest_NRADDR_GPR2;
0271 
0272      /* A grows-upwards stack for hidden saves/restores of LR and R2
0273         needed for function interception and wrapping on ppc64-linux.
0274         A horrible hack.  REDIR_SP points to the highest live entry,
0275         and so starts at -1. */
0276       /* 1380 */ ULong guest_REDIR_SP;
0277       /* 1388 */ ULong guest_REDIR_STACK[VEX_GUEST_PPC64_REDIR_STACK_SIZE];
0278 
0279       /* Needed for Darwin: CIA at the last SC insn.  Used when backing up
0280          to restart a syscall that has been interrupted by a signal. */
0281       /* 1648 */ ULong guest_IP_AT_SYSCALL;
0282 
0283       /* SPRG3, which AIUI is readonly in user space.  Needed for
0284          threading on AIX. */
0285       /* 1656 */ ULong guest_SPRG3_RO;
0286 
0287       /* 1664 */ ULong guest_TFHAR;     // Transaction Failure Handler Address Register
0288       /* 1672 */ ULong guest_TEXASR;    // Transaction EXception And Summary Register
0289       /* 1680 */ ULong guest_TFIAR;     // Transaction Failure Instruction Address Register
0290       /* 1688 */ ULong guest_PPR;       // Program Priority register
0291       /* 1696 */ UInt  guest_TEXASRU;   // Transaction EXception And Summary Register Upper
0292       /* 1700 */ UInt  guest_PSPB;      // Problem State Priority Boost register
0293       /* 1704 */ ULong guest_DSCR;      // Data Stream Control register
0294 
0295       /* Historical note, Initial ACC support was implemented to use a separate
0296          register file, but in practice (ISA 3.1) the hardware implementation
0297          logically overlays over the existing VSR registers. This may change
0298          in future hardware, so the current implementation assumes ACC and VSRs
0299          logically contain the same data, but code remains in place to support
0300          future implementations that may require a separate register file.
0301          02/08/2022. */
0302       /* The guest_ACC_entries must be in order and sequential.  The helper
0303          routines get_ACC_entry(), write_ACC_entry() calculate the offset of
0304          the ACC entry based on a address of guest_ACC_0_r0.  */
0305       /* 1712 */   U128  guest_ACC_0_r0;
0306       /* 1728 */   U128  guest_ACC_0_r1;
0307       /* 1744 */   U128  guest_ACC_0_r2;
0308       /* 1760 */   U128  guest_ACC_0_r3;
0309       /* 1776 */   U128  guest_ACC_1_r0;
0310       /* 1792 */   U128  guest_ACC_1_r1;
0311       /* 1808 */   U128  guest_ACC_1_r2;
0312       /* 1824 */   U128  guest_ACC_1_r3;
0313       /* 1840 */   U128  guest_ACC_2_r0;
0314       /* 1856 */   U128  guest_ACC_2_r1;
0315       /* 1872 */   U128  guest_ACC_2_r2;
0316       /* 1888 */   U128  guest_ACC_2_r3;
0317       /* 1904 */   U128  guest_ACC_3_r0;
0318       /* 1920 */   U128  guest_ACC_3_r1;
0319       /* 1936 */   U128  guest_ACC_3_r2;
0320       /* 1952 */   U128  guest_ACC_3_r3;
0321       /* 1968 */   U128  guest_ACC_4_r0;
0322       /* 1984 */   U128  guest_ACC_4_r1;
0323       /* 2000 */   U128  guest_ACC_4_r2;
0324       /* 2016 */   U128  guest_ACC_4_r3;
0325       /* 2032 */   U128  guest_ACC_5_r0;
0326       /* 2048 */   U128  guest_ACC_5_r1;
0327       /* 2064 */   U128  guest_ACC_5_r2;
0328       /* 2080 */   U128  guest_ACC_5_r3;
0329       /* 2096 */   U128  guest_ACC_6_r0;
0330       /* 2112 */   U128  guest_ACC_6_r1;
0331       /* 2128 */   U128  guest_ACC_6_r2;
0332       /* 2144 */   U128  guest_ACC_6_r3;
0333       /* 2160 */   U128  guest_ACC_7_r0;
0334       /* 2176 */   U128  guest_ACC_7_r1;
0335       /* 2192 */   U128  guest_ACC_7_r2;
0336       /* 2208 */   U128  guest_ACC_7_r3;
0337 
0338       /* 2224 */   UInt guest_syscall_flag;
0339       /* 2228 */   UInt padding1;
0340       /* 2232 */   UInt padding2;
0341       /* 2236 */   UInt padding3;
0342       /* Padding to make it have an 16-aligned size */
0343       /* 2222    UInt  padding0; */
0344    }
0345    VexGuestPPC64State;
0346 
0347 
0348 /*---------------------------------------------------------------*/
0349 /*--- Utility functions for PPC64 guest stuff.                ---*/
0350 /*---------------------------------------------------------------*/
0351 
0352 /* ALL THE FOLLOWING ARE VISIBLE TO LIBRARY CLIENT */
0353 
0354 /* Initialise all guest PPC64 state. */
0355 extern
0356 void LibVEX_GuestPPC64_initialise ( /*OUT*/VexGuestPPC64State* vex_state );
0357 
0358 
0359 /* Write the given native %CR value to the supplied VexGuestPPC64State
0360    structure.  Note, %CR is 32-bits even for ppc64. */
0361 extern
0362 void LibVEX_GuestPPC64_put_CR ( UInt cr_native,
0363                                 /*OUT*/VexGuestPPC64State* vex_state );
0364 
0365 /* Extract from the supplied VexGuestPPC64State structure the
0366    corresponding native %CR value.  Note, %CR is 32-bits even for
0367    ppc64. */
0368 extern
0369 UInt LibVEX_GuestPPC64_get_CR ( /*IN*/const VexGuestPPC64State* vex_state );
0370 
0371 
0372 /* Write the given native %XER value to the supplied
0373    VexGuestPPC64State structure.  Note, %XER is 32-bits even for
0374    ppc64. */
0375 extern
0376 void LibVEX_GuestPPC64_put_XER ( UInt xer_native,
0377                                  /*OUT*/VexGuestPPC64State* vex_state );
0378 
0379 /* Extract from the supplied VexGuestPPC64State structure the
0380    corresponding native %XER value.  Note, %CR is 32-bits even for
0381    ppc64. */
0382 extern
0383 UInt LibVEX_GuestPPC64_get_XER ( /*IN*/const VexGuestPPC64State* vex_state );
0384 
0385 #endif /* ndef __LIBVEX_PUB_GUEST_PPC64_H */
0386 
0387 
0388 /*---------------------------------------------------------------*/
0389 /*---                                    libvex_guest_ppc64.h ---*/
0390 /*---------------------------------------------------------------*/