]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/arch/aarch64-mte-linux.h
Fix typo in tui-data.h
[thirdparty/binutils-gdb.git] / gdb / arch / aarch64-mte-linux.h
1 /* Common Linux target-dependent definitions for AArch64 MTE
2
3 Copyright (C) 2021-2024 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 #ifndef ARCH_AARCH64_MTE_LINUX_H
21 #define ARCH_AARCH64_MTE_LINUX_H
22
23
24 /* Feature check for Memory Tagging Extension. */
25 #ifndef HWCAP2_MTE
26 #define HWCAP2_MTE (1 << 18)
27 #endif
28
29 /* The MTE regset consists of a single 64-bit register. */
30 #define AARCH64_LINUX_SIZEOF_MTE 8
31
32 /* We have one tag per 16 bytes of memory. */
33 #define AARCH64_MTE_GRANULE_SIZE 16
34 #define AARCH64_MTE_TAG_BIT_SIZE 4
35 #define AARCH64_MTE_LOGICAL_TAG_START_BIT 56
36 #define AARCH64_MTE_LOGICAL_MAX_VALUE 0xf
37
38 /* Memory tagging definitions. */
39 #ifndef SEGV_MTEAERR
40 # define SEGV_MTEAERR 8
41 # define SEGV_MTESERR 9
42 #endif
43
44 /* Memory tag types for AArch64. */
45 enum class aarch64_memtag_type
46 {
47 /* MTE logical tag contained in pointers. */
48 mte_logical = 0,
49 /* MTE allocation tag stored in memory tag granules. */
50 mte_allocation
51 };
52
53 /* Return the number of tag granules in the memory range
54 [ADDR, ADDR + LEN) given GRANULE_SIZE. */
55 extern size_t aarch64_mte_get_tag_granules (CORE_ADDR addr, size_t len,
56 size_t granule_size);
57
58 /* Return the 4-bit tag made from VALUE. */
59 extern CORE_ADDR aarch64_mte_make_ltag_bits (CORE_ADDR value);
60
61 /* Return the 4-bit tag that can be OR-ed to an address. */
62 extern CORE_ADDR aarch64_mte_make_ltag (CORE_ADDR value);
63
64 /* Helper to set the logical TAG for a 64-bit ADDRESS.
65
66 It is always possible to set the logical tag. */
67 extern CORE_ADDR aarch64_mte_set_ltag (CORE_ADDR address, CORE_ADDR tag);
68
69 /* Helper to get the logical tag from a 64-bit ADDRESS.
70
71 It is always possible to get the logical tag. */
72 extern CORE_ADDR aarch64_mte_get_ltag (CORE_ADDR address);
73
74 /* Given a TAGS vector containing 1 MTE tag per byte, pack the data as
75 2 tags per byte and resize the vector. */
76 extern void aarch64_mte_pack_tags (gdb::byte_vector &tags);
77
78 /* Given a TAGS vector containing 2 MTE tags per byte, unpack the data as
79 1 tag per byte and resize the vector. If SKIP_FIRST is TRUE, skip the
80 first unpacked element. Otherwise leave it in the unpacked vector. */
81 extern void aarch64_mte_unpack_tags (gdb::byte_vector &tags, bool skip_first);
82
83 #endif /* ARCH_AARCH64_MTE_LINUX_H */