Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  *  S390 version
0004  *    Copyright IBM Corp. 1999, 2000
0005  *    Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
0006  */
0007 
0008 #ifndef _UAPI_S390_PTRACE_H
0009 #define _UAPI_S390_PTRACE_H
0010 
0011 /*
0012  * Offsets in the user_regs_struct. They are used for the ptrace
0013  * system call and in entry.S
0014  */
0015 #ifndef __s390x__
0016 
0017 #define PT_PSWMASK  0x00
0018 #define PT_PSWADDR  0x04
0019 #define PT_GPR0     0x08
0020 #define PT_GPR1     0x0C
0021 #define PT_GPR2     0x10
0022 #define PT_GPR3     0x14
0023 #define PT_GPR4     0x18
0024 #define PT_GPR5     0x1C
0025 #define PT_GPR6     0x20
0026 #define PT_GPR7     0x24
0027 #define PT_GPR8     0x28
0028 #define PT_GPR9     0x2C
0029 #define PT_GPR10    0x30
0030 #define PT_GPR11    0x34
0031 #define PT_GPR12    0x38
0032 #define PT_GPR13    0x3C
0033 #define PT_GPR14    0x40
0034 #define PT_GPR15    0x44
0035 #define PT_ACR0     0x48
0036 #define PT_ACR1     0x4C
0037 #define PT_ACR2     0x50
0038 #define PT_ACR3     0x54
0039 #define PT_ACR4     0x58
0040 #define PT_ACR5     0x5C
0041 #define PT_ACR6     0x60
0042 #define PT_ACR7     0x64
0043 #define PT_ACR8     0x68
0044 #define PT_ACR9     0x6C
0045 #define PT_ACR10    0x70
0046 #define PT_ACR11    0x74
0047 #define PT_ACR12    0x78
0048 #define PT_ACR13    0x7C
0049 #define PT_ACR14    0x80
0050 #define PT_ACR15    0x84
0051 #define PT_ORIGGPR2 0x88
0052 #define PT_FPC      0x90
0053 /*
0054  * A nasty fact of life that the ptrace api
0055  * only supports passing of longs.
0056  */
0057 #define PT_FPR0_HI  0x98
0058 #define PT_FPR0_LO  0x9C
0059 #define PT_FPR1_HI  0xA0
0060 #define PT_FPR1_LO  0xA4
0061 #define PT_FPR2_HI  0xA8
0062 #define PT_FPR2_LO  0xAC
0063 #define PT_FPR3_HI  0xB0
0064 #define PT_FPR3_LO  0xB4
0065 #define PT_FPR4_HI  0xB8
0066 #define PT_FPR4_LO  0xBC
0067 #define PT_FPR5_HI  0xC0
0068 #define PT_FPR5_LO  0xC4
0069 #define PT_FPR6_HI  0xC8
0070 #define PT_FPR6_LO  0xCC
0071 #define PT_FPR7_HI  0xD0
0072 #define PT_FPR7_LO  0xD4
0073 #define PT_FPR8_HI  0xD8
0074 #define PT_FPR8_LO  0XDC
0075 #define PT_FPR9_HI  0xE0
0076 #define PT_FPR9_LO  0xE4
0077 #define PT_FPR10_HI 0xE8
0078 #define PT_FPR10_LO 0xEC
0079 #define PT_FPR11_HI 0xF0
0080 #define PT_FPR11_LO 0xF4
0081 #define PT_FPR12_HI 0xF8
0082 #define PT_FPR12_LO 0xFC
0083 #define PT_FPR13_HI 0x100
0084 #define PT_FPR13_LO 0x104
0085 #define PT_FPR14_HI 0x108
0086 #define PT_FPR14_LO 0x10C
0087 #define PT_FPR15_HI 0x110
0088 #define PT_FPR15_LO 0x114
0089 #define PT_CR_9     0x118
0090 #define PT_CR_10    0x11C
0091 #define PT_CR_11    0x120
0092 #define PT_IEEE_IP  0x13C
0093 #define PT_LASTOFF  PT_IEEE_IP
0094 #define PT_ENDREGS  0x140-1
0095 
0096 #define GPR_SIZE    4
0097 #define CR_SIZE     4
0098 
0099 #define STACK_FRAME_OVERHEAD    96  /* size of minimum stack frame */
0100 
0101 #else /* __s390x__ */
0102 
0103 #define PT_PSWMASK  0x00
0104 #define PT_PSWADDR  0x08
0105 #define PT_GPR0     0x10
0106 #define PT_GPR1     0x18
0107 #define PT_GPR2     0x20
0108 #define PT_GPR3     0x28
0109 #define PT_GPR4     0x30
0110 #define PT_GPR5     0x38
0111 #define PT_GPR6     0x40
0112 #define PT_GPR7     0x48
0113 #define PT_GPR8     0x50
0114 #define PT_GPR9     0x58
0115 #define PT_GPR10    0x60
0116 #define PT_GPR11    0x68
0117 #define PT_GPR12    0x70
0118 #define PT_GPR13    0x78
0119 #define PT_GPR14    0x80
0120 #define PT_GPR15    0x88
0121 #define PT_ACR0     0x90
0122 #define PT_ACR1     0x94
0123 #define PT_ACR2     0x98
0124 #define PT_ACR3     0x9C
0125 #define PT_ACR4     0xA0
0126 #define PT_ACR5     0xA4
0127 #define PT_ACR6     0xA8
0128 #define PT_ACR7     0xAC
0129 #define PT_ACR8     0xB0
0130 #define PT_ACR9     0xB4
0131 #define PT_ACR10    0xB8
0132 #define PT_ACR11    0xBC
0133 #define PT_ACR12    0xC0
0134 #define PT_ACR13    0xC4
0135 #define PT_ACR14    0xC8
0136 #define PT_ACR15    0xCC
0137 #define PT_ORIGGPR2 0xD0
0138 #define PT_FPC      0xD8
0139 #define PT_FPR0     0xE0
0140 #define PT_FPR1     0xE8
0141 #define PT_FPR2     0xF0
0142 #define PT_FPR3     0xF8
0143 #define PT_FPR4     0x100
0144 #define PT_FPR5     0x108
0145 #define PT_FPR6     0x110
0146 #define PT_FPR7     0x118
0147 #define PT_FPR8     0x120
0148 #define PT_FPR9     0x128
0149 #define PT_FPR10    0x130
0150 #define PT_FPR11    0x138
0151 #define PT_FPR12    0x140
0152 #define PT_FPR13    0x148
0153 #define PT_FPR14    0x150
0154 #define PT_FPR15    0x158
0155 #define PT_CR_9     0x160
0156 #define PT_CR_10    0x168
0157 #define PT_CR_11    0x170
0158 #define PT_IEEE_IP  0x1A8
0159 #define PT_LASTOFF  PT_IEEE_IP
0160 #define PT_ENDREGS  0x1B0-1
0161 
0162 #define GPR_SIZE    8
0163 #define CR_SIZE     8
0164 
0165 #define STACK_FRAME_OVERHEAD    160  /* size of minimum stack frame */
0166 
0167 #endif /* __s390x__ */
0168 
0169 #define NUM_GPRS    16
0170 #define NUM_FPRS    16
0171 #define NUM_CRS     16
0172 #define NUM_ACRS    16
0173 
0174 #define NUM_CR_WORDS    3
0175 
0176 #define FPR_SIZE    8
0177 #define FPC_SIZE    4
0178 #define FPC_PAD_SIZE    4 /* gcc insists on aligning the fpregs */
0179 #define ACR_SIZE    4
0180 
0181 
0182 #define PTRACE_OLDSETOPTIONS        21
0183 #define PTRACE_SYSEMU           31
0184 #define PTRACE_SYSEMU_SINGLESTEP    32
0185 #ifndef __ASSEMBLY__
0186 #include <linux/stddef.h>
0187 #include <linux/types.h>
0188 
0189 typedef union {
0190     float   f;
0191     double  d;
0192     __u64   ui;
0193     struct
0194     {
0195         __u32 hi;
0196         __u32 lo;
0197     } fp;
0198 } freg_t;
0199 
0200 typedef struct {
0201     __u32   fpc;
0202     __u32   pad;
0203     freg_t  fprs[NUM_FPRS];
0204 } s390_fp_regs;
0205 
0206 #define FPC_EXCEPTION_MASK  0xF8000000
0207 #define FPC_FLAGS_MASK      0x00F80000
0208 #define FPC_DXC_MASK        0x0000FF00
0209 #define FPC_RM_MASK     0x00000003
0210 
0211 /* this typedef defines how a Program Status Word looks like */
0212 typedef struct {
0213     unsigned long mask;
0214     unsigned long addr;
0215 } __attribute__ ((aligned(8))) psw_t;
0216 
0217 #ifndef __s390x__
0218 
0219 #define PSW_MASK_PER        0x40000000UL
0220 #define PSW_MASK_DAT        0x04000000UL
0221 #define PSW_MASK_IO     0x02000000UL
0222 #define PSW_MASK_EXT        0x01000000UL
0223 #define PSW_MASK_KEY        0x00F00000UL
0224 #define PSW_MASK_BASE       0x00080000UL    /* always one */
0225 #define PSW_MASK_MCHECK     0x00040000UL
0226 #define PSW_MASK_WAIT       0x00020000UL
0227 #define PSW_MASK_PSTATE     0x00010000UL
0228 #define PSW_MASK_ASC        0x0000C000UL
0229 #define PSW_MASK_CC     0x00003000UL
0230 #define PSW_MASK_PM     0x00000F00UL
0231 #define PSW_MASK_RI     0x00000000UL
0232 #define PSW_MASK_EA     0x00000000UL
0233 #define PSW_MASK_BA     0x00000000UL
0234 
0235 #define PSW_MASK_USER       0x0000FF00UL
0236 
0237 #define PSW_ADDR_AMODE      0x80000000UL
0238 #define PSW_ADDR_INSN       0x7FFFFFFFUL
0239 
0240 #define PSW_DEFAULT_KEY     (((unsigned long) PAGE_DEFAULT_ACC) << 20)
0241 
0242 #define PSW_ASC_PRIMARY     0x00000000UL
0243 #define PSW_ASC_ACCREG      0x00004000UL
0244 #define PSW_ASC_SECONDARY   0x00008000UL
0245 #define PSW_ASC_HOME        0x0000C000UL
0246 
0247 #else /* __s390x__ */
0248 
0249 #define PSW_MASK_PER        0x4000000000000000UL
0250 #define PSW_MASK_DAT        0x0400000000000000UL
0251 #define PSW_MASK_IO     0x0200000000000000UL
0252 #define PSW_MASK_EXT        0x0100000000000000UL
0253 #define PSW_MASK_BASE       0x0000000000000000UL
0254 #define PSW_MASK_KEY        0x00F0000000000000UL
0255 #define PSW_MASK_MCHECK     0x0004000000000000UL
0256 #define PSW_MASK_WAIT       0x0002000000000000UL
0257 #define PSW_MASK_PSTATE     0x0001000000000000UL
0258 #define PSW_MASK_ASC        0x0000C00000000000UL
0259 #define PSW_MASK_CC     0x0000300000000000UL
0260 #define PSW_MASK_PM     0x00000F0000000000UL
0261 #define PSW_MASK_RI     0x0000008000000000UL
0262 #define PSW_MASK_EA     0x0000000100000000UL
0263 #define PSW_MASK_BA     0x0000000080000000UL
0264 
0265 #define PSW_MASK_USER       0x0000FF0180000000UL
0266 
0267 #define PSW_ADDR_AMODE      0x0000000000000000UL
0268 #define PSW_ADDR_INSN       0xFFFFFFFFFFFFFFFFUL
0269 
0270 #define PSW_DEFAULT_KEY     (((unsigned long) PAGE_DEFAULT_ACC) << 52)
0271 
0272 #define PSW_ASC_PRIMARY     0x0000000000000000UL
0273 #define PSW_ASC_ACCREG      0x0000400000000000UL
0274 #define PSW_ASC_SECONDARY   0x0000800000000000UL
0275 #define PSW_ASC_HOME        0x0000C00000000000UL
0276 
0277 #endif /* __s390x__ */
0278 
0279 
0280 /*
0281  * The s390_regs structure is used to define the elf_gregset_t.
0282  */
0283 typedef struct {
0284     psw_t psw;
0285     unsigned long gprs[NUM_GPRS];
0286     unsigned int  acrs[NUM_ACRS];
0287     unsigned long orig_gpr2;
0288 } s390_regs;
0289 
0290 /*
0291  * The user_pt_regs structure exports the beginning of
0292  * the in-kernel pt_regs structure to user space.
0293  */
0294 typedef struct {
0295     unsigned long args[1];
0296     psw_t psw;
0297     unsigned long gprs[NUM_GPRS];
0298 } user_pt_regs;
0299 
0300 /*
0301  * Now for the user space program event recording (trace) definitions.
0302  * The following structures are used only for the ptrace interface, don't
0303  * touch or even look at it if you don't want to modify the user-space
0304  * ptrace interface. In particular stay away from it for in-kernel PER.
0305  */
0306 typedef struct {
0307     unsigned long cr[NUM_CR_WORDS];
0308 } per_cr_words;
0309 
0310 #define PER_EM_MASK 0xE8000000UL
0311 
0312 typedef struct {
0313 #ifdef __s390x__
0314     unsigned               : 32;
0315 #endif /* __s390x__ */
0316     unsigned em_branching          : 1;
0317     unsigned em_instruction_fetch  : 1;
0318     /*
0319      * Switching on storage alteration automatically fixes
0320      * the storage alteration event bit in the users std.
0321      */
0322     unsigned em_storage_alteration : 1;
0323     unsigned em_gpr_alt_unused     : 1;
0324     unsigned em_store_real_address : 1;
0325     unsigned               : 3;
0326     unsigned branch_addr_ctl       : 1;
0327     unsigned               : 1;
0328     unsigned storage_alt_space_ctl : 1;
0329     unsigned               : 21;
0330     unsigned long starting_addr;
0331     unsigned long ending_addr;
0332 } per_cr_bits;
0333 
0334 typedef struct {
0335     unsigned short perc_atmid;
0336     unsigned long address;
0337     unsigned char access_id;
0338 } per_lowcore_words;
0339 
0340 typedef struct {
0341     unsigned perc_branching      : 1;
0342     unsigned perc_instruction_fetch  : 1;
0343     unsigned perc_storage_alteration : 1;
0344     unsigned perc_gpr_alt_unused     : 1;
0345     unsigned perc_store_real_address : 1;
0346     unsigned             : 3;
0347     unsigned atmid_psw_bit_31    : 1;
0348     unsigned atmid_validity_bit  : 1;
0349     unsigned atmid_psw_bit_32    : 1;
0350     unsigned atmid_psw_bit_5     : 1;
0351     unsigned atmid_psw_bit_16    : 1;
0352     unsigned atmid_psw_bit_17    : 1;
0353     unsigned si          : 2;
0354     unsigned long address;
0355     unsigned             : 4;
0356     unsigned access_id       : 4;
0357 } per_lowcore_bits;
0358 
0359 typedef struct {
0360     union {
0361         per_cr_words   words;
0362         per_cr_bits    bits;
0363     } control_regs;
0364     /*
0365      * The single_step and instruction_fetch bits are obsolete,
0366      * the kernel always sets them to zero. To enable single
0367      * stepping use ptrace(PTRACE_SINGLESTEP) instead.
0368      */
0369     unsigned  single_step       : 1;
0370     unsigned  instruction_fetch : 1;
0371     unsigned            : 30;
0372     /*
0373      * These addresses are copied into cr10 & cr11 if single
0374      * stepping is switched off
0375      */
0376     unsigned long starting_addr;
0377     unsigned long ending_addr;
0378     union {
0379         per_lowcore_words words;
0380         per_lowcore_bits  bits;
0381     } lowcore;
0382 } per_struct;
0383 
0384 typedef struct {
0385     unsigned int  len;
0386     unsigned long kernel_addr;
0387     unsigned long process_addr;
0388 } ptrace_area;
0389 
0390 /*
0391  * S/390 specific non posix ptrace requests. I chose unusual values so
0392  * they are unlikely to clash with future ptrace definitions.
0393  */
0394 #define PTRACE_PEEKUSR_AREA       0x5000
0395 #define PTRACE_POKEUSR_AREA       0x5001
0396 #define PTRACE_PEEKTEXT_AREA          0x5002
0397 #define PTRACE_PEEKDATA_AREA          0x5003
0398 #define PTRACE_POKETEXT_AREA          0x5004
0399 #define PTRACE_POKEDATA_AREA          0x5005
0400 #define PTRACE_GET_LAST_BREAK         0x5006
0401 #define PTRACE_PEEK_SYSTEM_CALL       0x5007
0402 #define PTRACE_POKE_SYSTEM_CALL       0x5008
0403 #define PTRACE_ENABLE_TE          0x5009
0404 #define PTRACE_DISABLE_TE         0x5010
0405 #define PTRACE_TE_ABORT_RAND          0x5011
0406 
0407 /*
0408  * The numbers chosen here are somewhat arbitrary but absolutely MUST
0409  * not overlap with any of the number assigned in <linux/ptrace.h>.
0410  */
0411 #define PTRACE_SINGLEBLOCK  12  /* resume execution until next branch */
0412 
0413 /*
0414  * PT_PROT definition is loosely based on hppa bsd definition in
0415  * gdb/hppab-nat.c
0416  */
0417 #define PTRACE_PROT           21
0418 
0419 typedef enum {
0420     ptprot_set_access_watchpoint,
0421     ptprot_set_write_watchpoint,
0422     ptprot_disable_watchpoint
0423 } ptprot_flags;
0424 
0425 typedef struct {
0426     unsigned long lowaddr;
0427     unsigned long hiaddr;
0428     ptprot_flags prot;
0429 } ptprot_area;
0430 
0431 /* Sequence of bytes for breakpoint illegal instruction.  */
0432 #define S390_BREAKPOINT     {0x0,0x1}
0433 #define S390_BREAKPOINT_U16 ((__u16)0x0001)
0434 #define S390_SYSCALL_OPCODE ((__u16)0x0a00)
0435 #define S390_SYSCALL_SIZE   2
0436 
0437 /*
0438  * The user_regs_struct defines the way the user registers are
0439  * store on the stack for signal handling.
0440  */
0441 struct user_regs_struct {
0442     psw_t psw;
0443     unsigned long gprs[NUM_GPRS];
0444     unsigned int  acrs[NUM_ACRS];
0445     unsigned long orig_gpr2;
0446     s390_fp_regs fp_regs;
0447     /*
0448      * These per registers are in here so that gdb can modify them
0449      * itself as there is no "official" ptrace interface for hardware
0450      * watchpoints. This is the way intel does it.
0451      */
0452     per_struct per_info;
0453     unsigned long ieee_instruction_pointer; /* obsolete, always 0 */
0454 };
0455 
0456 #endif /* __ASSEMBLY__ */
0457 
0458 #endif /* _UAPI_S390_PTRACE_H */