Commit | Line | Data |
---|---|---|
122394f1 AH |
1 | /* Common target dependent for AArch64 systems. |
2 | ||
3 | Copyright (C) 2018 Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | #include <sys/utsname.h> | |
21 | #include <sys/uio.h> | |
22 | #include "common-defs.h" | |
23 | #include "elf/external.h" | |
24 | #include "elf/common.h" | |
25 | #include "aarch64-sve-linux-ptrace.h" | |
26 | #include "arch/aarch64.h" | |
27 | ||
28 | /* See nat/aarch64-sve-linux-ptrace.h. */ | |
29 | ||
39bfb937 | 30 | uint64_t |
122394f1 AH |
31 | aarch64_sve_get_vq (int tid) |
32 | { | |
33 | struct iovec iovec; | |
34 | struct user_sve_header header; | |
35 | ||
36 | iovec.iov_len = sizeof (header); | |
37 | iovec.iov_base = &header; | |
38 | ||
39 | /* Ptrace gives the vector length in bytes. Convert it to VQ, the number of | |
40 | 128bit chunks in a Z register. We use VQ because 128bits is the minimum | |
41 | a Z register can increase in size. */ | |
42 | ||
43 | if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_SVE, &iovec) < 0) | |
44 | { | |
45 | /* SVE is not supported. */ | |
46 | return 0; | |
47 | } | |
48 | ||
49 | long vq = sve_vq_from_vl (header.vl); | |
50 | ||
51 | if (!sve_vl_valid (header.vl)) | |
52 | { | |
53 | warning (_("Invalid SVE state from kernel; SVE disabled.")); | |
54 | return 0; | |
55 | } | |
56 | ||
57 | return vq; | |
58 | } |