GDBserver
Loading...
Searching...
No Matches
aarch64-scalable-linux-ptrace.h
Go to the documentation of this file.
1/* Common native Linux definitions for the AArch64 scalable
2 extensions: SVE and SME.
3
4 Copyright (C) 2018-2023 Free Software Foundation, Inc.
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20
21#ifndef NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
22#define NAT_AARCH64_SCALABLE_LINUX_PTRACE_H
23
24#include <signal.h>
25#include <sys/utsname.h>
26
27/* The order in which <sys/ptrace.h> and <asm/ptrace.h> are included
28 can be important. <sys/ptrace.h> often declares various PTRACE_*
29 enums. <asm/ptrace.h> often defines preprocessor constants for
30 these very same symbols. When that's the case, build errors will
31 result when <asm/ptrace.h> is included before <sys/ptrace.h>. */
32#include <sys/ptrace.h>
33#include <asm/ptrace.h>
34#include <stdarg.h>
36
37/* Indicates whether a SVE ptrace header is followed by SVE registers or a
38 fpsimd structure. */
39#define HAS_SVE_STATE(header) ((header).flags & SVE_PT_REGS_SVE)
40
41/* Return true if there is an active SVE state in TID.
42 Return false otherwise. */
43bool aarch64_has_sve_state (int tid);
44
45/* Return true if there is an active SSVE state in TID.
46 Return false otherwise. */
47bool aarch64_has_ssve_state (int tid);
48
49/* Return true if there is an active ZA state in TID.
50 Return false otherwise. */
51bool aarch64_has_za_state (int tid);
52
53/* Given TID, read the SVE header into HEADER.
54
55 Return true if successful, false otherwise. */
56bool read_sve_header (int tid, struct user_sve_header &header);
57
58/* Given TID, store the SVE HEADER.
59
60 Return true if successful, false otherwise. */
61bool write_sve_header (int tid, const struct user_sve_header &header);
62
63/* Given TID, read the SSVE header into HEADER.
64
65 Return true if successful, false otherwise. */
66bool read_ssve_header (int tid, struct user_sve_header &header);
67
68/* Given TID, store the SSVE HEADER.
69
70 Return true if successful, false otherwise. */
71bool write_ssve_header (int tid, const struct user_sve_header &header);
72
73/* Given TID, read the ZA header into HEADER.
74
75 Return true if successful, false otherwise. */
76bool read_za_header (int tid, struct user_za_header &header);
77
78/* Given TID, store the ZA HEADER.
79
80 Return true if successful, false otherwise. */
81bool write_za_header (int tid, const struct user_za_header &header);
82
83/* Read VQ for the given tid using ptrace. If SVE is not supported then zero
84 is returned (on a system that supports SVE, then VQ cannot be zero). */
85uint64_t aarch64_sve_get_vq (int tid);
86
87/* Set VQ in the kernel for the given tid, using either the value VQ or
88 reading from the register VG in the register buffer. */
89
90bool aarch64_sve_set_vq (int tid, uint64_t vq);
91bool aarch64_sve_set_vq (int tid, struct reg_buffer_common *reg_buf);
92
93/* Read the streaming mode vq (svq) for the given TID. If the ZA state is not
94 supported or active, return 0. */
95uint64_t aarch64_za_get_svq (int tid);
96
97/* Set the vector quotient (vq) in the kernel for the given TID using the
98 value VQ.
99
100 Return true if successful, false otherwise. */
101bool aarch64_za_set_svq (int tid, uint64_t vq);
102bool aarch64_za_set_svq (int tid, const struct reg_buffer_common *reg_buf,
103 int svg_regnum);
104
105/* Given TID, return the SVE/SSVE data as a vector of bytes. */
106extern gdb::byte_vector aarch64_fetch_sve_regset (int tid);
107
108/* Write the SVE/SSVE contents from SVE_STATE to TID. */
109extern void aarch64_store_sve_regset (int tid,
110 const gdb::byte_vector &sve_state);
111
112/* Given TID, return the ZA data as a vector of bytes. */
113extern gdb::byte_vector aarch64_fetch_za_regset (int tid);
114
115/* Write ZA_STATE for TID. */
116extern void aarch64_store_za_regset (int tid, const gdb::byte_vector &za_state);
117
118/* Given TID, initialize the ZA register set so the header contains the right
119 size. The bytes of the ZA register are initialized to zero. */
120extern void aarch64_initialize_za_regset (int tid);
121
122/* Given TID, return the NT_ARM_ZT register set data as a vector of bytes. */
123extern gdb::byte_vector aarch64_fetch_zt_regset (int tid);
124
125/* Write ZT_STATE for TID. */
126extern void aarch64_store_zt_regset (int tid, const gdb::byte_vector &zt_state);
127
128/* Return TRUE if thread TID supports the NT_ARM_ZT register set.
129 Return FALSE otherwise. */
130extern bool supports_zt_registers (int tid);
131
132/* Given a register buffer REG_BUF, update it with SVE/SSVE register data
133 from SVE_STATE. */
134extern void
135aarch64_sve_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf);
136
137/* Given a thread id TID and a register buffer REG_BUF containing SVE/SSVE
138 register data, write the SVE data to thread TID. */
139extern void
141 struct reg_buffer_common *reg_buf);
142
143/* Given a thread id TID and a register buffer REG_BUF, update the register
144 buffer with the ZA state from thread TID.
145
146 ZA_REGNUM, SVG_REGNUM and SVCR_REGNUM are the register numbers for ZA,
147 SVG and SVCR registers. */
148extern void aarch64_za_regs_copy_to_reg_buf (int tid,
149 struct reg_buffer_common *reg_buf,
150 int za_regnum, int svg_regnum,
151 int svcr_regnum);
152
153/* Given a thread id TID and a register buffer REG_BUF containing ZA register
154 data, write the ZA data to thread TID.
155
156 ZA_REGNUM, SVG_REGNUM and SVCR_REGNUM are the register numbers for ZA,
157 SVG and SVCR registers. */
158extern void
160 struct reg_buffer_common *reg_buf,
161 int za_regnum, int svg_regnum,
162 int svcr_regnum);
163
164/* Given a thread id TID and a register buffer REG_BUF, update the register
165 buffer with the ZT register set state from thread TID.
166
167 ZT_REGNUM is the register number for ZT0. */
168extern void
169aarch64_zt_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf,
170 int zt_regnum);
171
172/* Given a thread id TID and a register buffer REG_BUF containing the ZT
173 register set state, write the ZT data to thread TID.
174
175 ZT_REGNUM is the register number for ZT0. */
176extern void
177aarch64_zt_regs_copy_from_reg_buf (int tid, struct reg_buffer_common *reg_buf,
178 int zt_regnum);
179#endif /* NAT_AARCH64_SCALABLE_LINUX_PTRACE_H */
gdb::byte_vector aarch64_fetch_sve_regset(int tid)
bool supports_zt_registers(int tid)
void aarch64_store_za_regset(int tid, const gdb::byte_vector &za_state)
void aarch64_sve_regs_copy_from_reg_buf(int tid, struct reg_buffer_common *reg_buf)
bool write_sve_header(int tid, const struct user_sve_header &header)
void aarch64_za_regs_copy_from_reg_buf(int tid, struct reg_buffer_common *reg_buf, int za_regnum, int svg_regnum, int svcr_regnum)
bool aarch64_za_set_svq(int tid, uint64_t vq)
bool aarch64_has_za_state(int tid)
uint64_t aarch64_za_get_svq(int tid)
bool read_za_header(int tid, struct user_za_header &header)
void aarch64_zt_regs_copy_from_reg_buf(int tid, struct reg_buffer_common *reg_buf, int zt_regnum)
void aarch64_za_regs_copy_to_reg_buf(int tid, struct reg_buffer_common *reg_buf, int za_regnum, int svg_regnum, int svcr_regnum)
bool aarch64_has_sve_state(int tid)
bool read_ssve_header(int tid, struct user_sve_header &header)
void aarch64_sve_regs_copy_to_reg_buf(int tid, struct reg_buffer_common *reg_buf)
void aarch64_store_zt_regset(int tid, const gdb::byte_vector &zt_state)
uint64_t aarch64_sve_get_vq(int tid)
gdb::byte_vector aarch64_fetch_zt_regset(int tid)
bool aarch64_has_ssve_state(int tid)
gdb::byte_vector aarch64_fetch_za_regset(int tid)
bool write_ssve_header(int tid, const struct user_sve_header &header)
bool read_sve_header(int tid, struct user_sve_header &header)
bool aarch64_sve_set_vq(int tid, uint64_t vq)
bool write_za_header(int tid, const struct user_za_header &header)
void aarch64_zt_regs_copy_to_reg_buf(int tid, struct reg_buffer_common *reg_buf, int zt_regnum)
void aarch64_store_sve_regset(int tid, const gdb::byte_vector &sve_state)
void aarch64_initialize_za_regset(int tid)