GNU Binutils with patches for OS216
修订版 | 653bc1ffddfbbe46d0551b83c37a63900661ce25 (tree) |
---|---|
时间 | 2020-06-26 01:23:38 |
作者 | Luis Machado <luis.machado@lina...> |
Commiter | Luis Machado |
AArch64: Add gdbserver MTE 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-mte-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-mte-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,12 +44,17 @@ | ||
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 |
50 | 51 | #include <sys/reg.h> |
51 | 52 | #endif |
52 | 53 | |
54 | +#ifdef HAVE_GETAUXVAL | |
55 | +#include <sys/auxv.h> | |
56 | +#endif | |
57 | + | |
53 | 58 | /* Linux target op definitions for the AArch64 architecture. */ |
54 | 59 | |
55 | 60 | class aarch64_target : public linux_process_target |
@@ -82,6 +87,14 @@ public: | ||
82 | 87 | |
83 | 88 | struct emit_ops *emit_ops () override; |
84 | 89 | |
90 | + bool supports_memory_tagging () override; | |
91 | + | |
92 | + int fetch_memtags (CORE_ADDR address, size_t len, | |
93 | + gdb::byte_vector &tags) override; | |
94 | + | |
95 | + int store_memtags (CORE_ADDR address, size_t len, | |
96 | + const gdb::byte_vector &tags) override; | |
97 | + | |
85 | 98 | protected: |
86 | 99 | |
87 | 100 | void low_arch_setup () override; |
@@ -3193,6 +3206,46 @@ aarch64_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr) | ||
3193 | 3206 | return arm_breakpoint_kind_from_current_state (pcptr); |
3194 | 3207 | } |
3195 | 3208 | |
3209 | +/* Returns true if memory tagging is supported. */ | |
3210 | +bool | |
3211 | +aarch64_target::supports_memory_tagging () | |
3212 | +{ | |
3213 | + if (current_thread == NULL) | |
3214 | + { | |
3215 | + /* We don't have any processes running, so don't attempt to | |
3216 | + use linux_get_hwcap2 as it will try to fetch the current | |
3217 | + thread id. Instead, just fetch the auxv from the self | |
3218 | + PID. */ | |
3219 | +#ifdef HAVE_GETAUXVAL | |
3220 | + return (getauxval (AT_HWCAP2) & HWCAP2_MTE) != 0; | |
3221 | +#else | |
3222 | + return true; | |
3223 | +#endif | |
3224 | + } | |
3225 | + | |
3226 | + return (linux_get_hwcap2 (8) & HWCAP2_MTE) != 0; | |
3227 | +} | |
3228 | + | |
3229 | +int | |
3230 | +aarch64_target::fetch_memtags (CORE_ADDR address, size_t len, | |
3231 | + gdb::byte_vector &tags) | |
3232 | +{ | |
3233 | + /* Allocation tags are per-process, so any tid is fine. */ | |
3234 | + int tid = lwpid_of (current_thread); | |
3235 | + | |
3236 | + return aarch64_mte_fetch_memtags (tid, address, len, tags); | |
3237 | +} | |
3238 | + | |
3239 | +int | |
3240 | +aarch64_target::store_memtags (CORE_ADDR address, size_t len, | |
3241 | + const gdb::byte_vector &tags) | |
3242 | +{ | |
3243 | + /* Allocation tags are per-process, so any tid is fine. */ | |
3244 | + int tid = lwpid_of (current_thread); | |
3245 | + | |
3246 | + return aarch64_mte_store_memtags (tid, address, len, tags); | |
3247 | +} | |
3248 | + | |
3196 | 3249 | /* The linux target ops object. */ |
3197 | 3250 | |
3198 | 3251 | linux_process_target *the_linux_target = &the_aarch64_target; |