GNU Binutils with patches for OS216
修订版 | de52b1c3dd23f6c9a39097fada99f6d55c6b000e (tree) |
---|---|
时间 | 2020-06-16 21:58:32 |
作者 | Luis Machado <luis.machado@lina...> |
Commiter | Luis Machado |
Add gdbserver memory tagging support
Adds the AArch64-specific memory tagging support (MTE) by implementing the
required hooks and checks.
gdbserver/ChangeLog:
YYYY-MM-DD Luis Machado <luis.machado@linaro.org>
* Makefile.in (SFILES): Add /../gdb/nat/aarch64-mte-linux-ptrace.c.
* configure.srv (aarch64*-*-linux*): Add arch/aarch64-linux.o and
nat/aarch64-mte-linux-ptrace.o.
* linux-aarch64-low.cc: Include nat/aarch64-mte-linux-ptrace.h.
(class aarch64_target) <supports_memory_tagging>
<fetch_memtags, store_memtags>: New method overrides.
(aarch64_target::supports_memory_tagging)
(aarch64_target::fetch_memtags)
(aarch64_target::store_memtags): New methods.
@@ -212,6 +212,7 @@ SFILES = \ | ||
212 | 212 | $(srcdir)/../gdb/arch/ppc-linux-common.c \ |
213 | 213 | $(srcdir)/../gdb/arch/riscv.c \ |
214 | 214 | $(srcdir)/../gdb/nat/aarch64-sve-linux-ptrace.c \ |
215 | + $(srcdir)/../gdb/nat/aarch64-mte-linux-ptrace.c \ | |
215 | 216 | $(srcdir)/../gdb/nat/linux-btrace.c \ |
216 | 217 | $(srcdir)/../gdb/nat/linux-namespaces.c \ |
217 | 218 | $(srcdir)/../gdb/nat/linux-osdata.c \ |
@@ -52,8 +52,10 @@ case "${gdbserver_host}" in | ||
52 | 52 | srv_tgtobj="$srv_tgtobj nat/aarch64-linux.o" |
53 | 53 | srv_tgtobj="$srv_tgtobj arch/aarch64-insn.o" |
54 | 54 | srv_tgtobj="$srv_tgtobj arch/aarch64.o" |
55 | + srv_tgtobj="$srv_tgtobj arch/aarch64-linux.o" | |
55 | 56 | srv_tgtobj="$srv_tgtobj linux-aarch64-tdesc.o" |
56 | 57 | srv_tgtobj="$srv_tgtobj nat/aarch64-sve-linux-ptrace.o" |
58 | + srv_tgtobj="$srv_tgtobj nat/aarch64-mte-linux-ptrace.o" | |
57 | 59 | srv_tgtobj="${srv_tgtobj} $srv_linux_obj" |
58 | 60 | srv_linux_regsets=yes |
59 | 61 | srv_linux_thread_db=yes |
@@ -44,6 +44,7 @@ | ||
44 | 44 | #include "linux-aarch32-tdesc.h" |
45 | 45 | #include "linux-aarch64-tdesc.h" |
46 | 46 | #include "nat/aarch64-sve-linux-ptrace.h" |
47 | +#include "nat/aarch64-mte-linux-ptrace.h" | |
47 | 48 | #include "tdesc.h" |
48 | 49 | |
49 | 50 | #ifdef HAVE_SYS_REG_H |
@@ -82,6 +83,14 @@ public: | ||
82 | 83 | |
83 | 84 | struct emit_ops *emit_ops () override; |
84 | 85 | |
86 | + bool supports_memory_tagging () override; | |
87 | + | |
88 | + int fetch_memtags (CORE_ADDR address, size_t len, | |
89 | + gdb::byte_vector &tags) override; | |
90 | + | |
91 | + int store_memtags (CORE_ADDR address, size_t len, | |
92 | + const gdb::byte_vector &tags) override; | |
93 | + | |
85 | 94 | protected: |
86 | 95 | |
87 | 96 | void low_arch_setup () override; |
@@ -3193,6 +3202,36 @@ aarch64_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr) | ||
3193 | 3202 | return arm_breakpoint_kind_from_current_state (pcptr); |
3194 | 3203 | } |
3195 | 3204 | |
3205 | +/* Returns true if memory tagging is supported. */ | |
3206 | +bool | |
3207 | +aarch64_target::supports_memory_tagging () | |
3208 | +{ | |
3209 | + if (current_thread == NULL) | |
3210 | + return false; | |
3211 | + | |
3212 | + return (linux_get_hwcap2 (8) & HWCAP2_MTE) != 0; | |
3213 | +} | |
3214 | + | |
3215 | +int | |
3216 | +aarch64_target::fetch_memtags (CORE_ADDR address, size_t len, | |
3217 | + gdb::byte_vector &tags) | |
3218 | +{ | |
3219 | + /* Allocation tags are per-process, so any tid is fine. */ | |
3220 | + int tid = lwpid_of (current_thread); | |
3221 | + | |
3222 | + return aarch64_mte_fetch_memtags (tid, address, len, tags); | |
3223 | +} | |
3224 | + | |
3225 | +int | |
3226 | +aarch64_target::store_memtags (CORE_ADDR address, size_t len, | |
3227 | + const gdb::byte_vector &tags) | |
3228 | +{ | |
3229 | + /* Allocation tags are per-process, so any tid is fine. */ | |
3230 | + int tid = lwpid_of (current_thread); | |
3231 | + | |
3232 | + return aarch64_mte_store_memtags (tid, address, len, tags); | |
3233 | +} | |
3234 | + | |
3196 | 3235 | /* The linux target ops object. */ |
3197 | 3236 | |
3198 | 3237 | linux_process_target *the_linux_target = &the_aarch64_target; |