master
h 169 lines 4.01 KB
Raw
1 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
2 /*
3 * Copyright (C) 2012 Regents of the University of California
4 */
5
6 #ifndef _ASM_RISCV_PTRACE_H
7 #define _ASM_RISCV_PTRACE_H
8
9 #ifndef __ASSEMBLER__
10
11 #include <linux/types.h>
12 #include <linux/const.h>
13
14 #define PTRACE_GETFDPIC 33
15
16 #define PTRACE_GETFDPIC_EXEC 0
17 #define PTRACE_GETFDPIC_INTERP 1
18
19 /*
20 * User-mode register state for core dumps, ptrace, sigcontext
21 *
22 * This decouples struct pt_regs from the userspace ABI.
23 * struct user_regs_struct must form a prefix of struct pt_regs.
24 */
25 struct user_regs_struct {
26 unsigned long pc;
27 unsigned long ra;
28 unsigned long sp;
29 unsigned long gp;
30 unsigned long tp;
31 unsigned long t0;
32 unsigned long t1;
33 unsigned long t2;
34 unsigned long s0;
35 unsigned long s1;
36 unsigned long a0;
37 unsigned long a1;
38 unsigned long a2;
39 unsigned long a3;
40 unsigned long a4;
41 unsigned long a5;
42 unsigned long a6;
43 unsigned long a7;
44 unsigned long s2;
45 unsigned long s3;
46 unsigned long s4;
47 unsigned long s5;
48 unsigned long s6;
49 unsigned long s7;
50 unsigned long s8;
51 unsigned long s9;
52 unsigned long s10;
53 unsigned long s11;
54 unsigned long t3;
55 unsigned long t4;
56 unsigned long t5;
57 unsigned long t6;
58 };
59
60 struct __riscv_f_ext_state {
61 __u32 f[32];
62 __u32 fcsr;
63 };
64
65 struct __riscv_d_ext_state {
66 __u64 f[32];
67 __u32 fcsr;
68 };
69
70 struct __riscv_q_ext_state {
71 __u64 f[64] __attribute__((aligned(16)));
72 __u32 fcsr;
73 /*
74 * Reserved for expansion of sigcontext structure. Currently zeroed
75 * upon signal, and must be zero upon sigreturn.
76 */
77 __u32 reserved[3];
78 };
79
80 struct __riscv_ctx_hdr {
81 __u32 magic;
82 __u32 size;
83 };
84
85 struct __riscv_extra_ext_header {
86 __u32 __padding[129] __attribute__((aligned(16)));
87 /*
88 * Reserved for expansion of sigcontext structure. Currently zeroed
89 * upon signal, and must be zero upon sigreturn.
90 */
91 __u32 reserved;
92 struct __riscv_ctx_hdr hdr;
93 };
94
95 union __riscv_fp_state {
96 struct __riscv_f_ext_state f;
97 struct __riscv_d_ext_state d;
98 struct __riscv_q_ext_state q;
99 };
100
101 struct __riscv_v_ext_state {
102 unsigned long vstart;
103 unsigned long vl;
104 unsigned long vtype;
105 unsigned long vcsr;
106 unsigned long vlenb;
107 void *datap;
108 /*
109 * In signal handler, datap will be set a correct user stack offset
110 * and vector registers will be copied to the address of datap
111 * pointer.
112 */
113 };
114
115 struct __riscv_v_regset_state {
116 unsigned long vstart;
117 unsigned long vl;
118 unsigned long vtype;
119 unsigned long vcsr;
120 unsigned long vlenb;
121 char vreg[];
122 };
123
124 /*
125 * According to spec: The number of bits in a single vector register,
126 * VLEN >= ELEN, which must be a power of 2, and must be no greater than
127 * 2^16 = 65536bits = 8192bytes
128 */
129 #define RISCV_MAX_VLENB (8192)
130
131 struct __sc_riscv_cfi_state {
132 unsigned long ss_ptr; /* shadow stack pointer */
133 };
134
135 #define PTRACE_CFI_BRANCH_LANDING_PAD_EN_BIT 0
136 #define PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_BIT 1
137 #define PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_BIT 2
138 #define PTRACE_CFI_SHADOW_STACK_EN_BIT 3
139 #define PTRACE_CFI_SHADOW_STACK_LOCK_BIT 4
140 #define PTRACE_CFI_SHADOW_STACK_PTR_BIT 5
141
142 #define PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE _BITUL(PTRACE_CFI_BRANCH_LANDING_PAD_EN_BIT)
143 #define PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE \
144 _BITUL(PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_BIT)
145 #define PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE \
146 _BITUL(PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_BIT)
147 #define PTRACE_CFI_SHADOW_STACK_EN_STATE _BITUL(PTRACE_CFI_SHADOW_STACK_EN_BIT)
148 #define PTRACE_CFI_SHADOW_STACK_LOCK_STATE _BITUL(PTRACE_CFI_SHADOW_STACK_LOCK_BIT)
149 #define PTRACE_CFI_SHADOW_STACK_PTR_STATE _BITUL(PTRACE_CFI_SHADOW_STACK_PTR_BIT)
150
151 #define PTRACE_CFI_STATE_INVALID_MASK ~(PTRACE_CFI_BRANCH_LANDING_PAD_EN_STATE | \
152 PTRACE_CFI_BRANCH_LANDING_PAD_LOCK_STATE | \
153 PTRACE_CFI_BRANCH_EXPECTED_LANDING_PAD_STATE | \
154 PTRACE_CFI_SHADOW_STACK_EN_STATE | \
155 PTRACE_CFI_SHADOW_STACK_LOCK_STATE | \
156 PTRACE_CFI_SHADOW_STACK_PTR_STATE)
157
158 struct __cfi_status {
159 __u64 cfi_state;
160 };
161
162 struct user_cfi_state {
163 struct __cfi_status cfi_status;
164 __u64 shstk_ptr;
165 };
166
167 #endif /* __ASSEMBLER__ */
168
169 #endif /* _ASM_RISCV_PTRACE_H */