• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修订版653bc1ffddfbbe46d0551b83c37a63900661ce25 (tree)
时间2020-06-26 01:23:38
作者Luis Machado <luis.machado@lina...>
CommiterLuis Machado

Log Message

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.

更改概述

差异

--- a/gdbserver/Makefile.in
+++ b/gdbserver/Makefile.in
@@ -212,6 +212,7 @@ SFILES = \
212212 $(srcdir)/../gdb/arch/ppc-linux-common.c \
213213 $(srcdir)/../gdb/arch/riscv.c \
214214 $(srcdir)/../gdb/nat/aarch64-sve-linux-ptrace.c \
215+ $(srcdir)/../gdb/nat/aarch64-mte-linux-ptrace.c \
215216 $(srcdir)/../gdb/nat/linux-btrace.c \
216217 $(srcdir)/../gdb/nat/linux-namespaces.c \
217218 $(srcdir)/../gdb/nat/linux-osdata.c \
--- a/gdbserver/configure.srv
+++ b/gdbserver/configure.srv
@@ -52,8 +52,10 @@ case "${gdbserver_host}" in
5252 srv_tgtobj="$srv_tgtobj nat/aarch64-linux.o"
5353 srv_tgtobj="$srv_tgtobj arch/aarch64-insn.o"
5454 srv_tgtobj="$srv_tgtobj arch/aarch64.o"
55+ srv_tgtobj="$srv_tgtobj arch/aarch64-mte-linux.o"
5556 srv_tgtobj="$srv_tgtobj linux-aarch64-tdesc.o"
5657 srv_tgtobj="$srv_tgtobj nat/aarch64-sve-linux-ptrace.o"
58+ srv_tgtobj="$srv_tgtobj nat/aarch64-mte-linux-ptrace.o"
5759 srv_tgtobj="${srv_tgtobj} $srv_linux_obj"
5860 srv_linux_regsets=yes
5961 srv_linux_thread_db=yes
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -44,12 +44,17 @@
4444 #include "linux-aarch32-tdesc.h"
4545 #include "linux-aarch64-tdesc.h"
4646 #include "nat/aarch64-sve-linux-ptrace.h"
47+#include "nat/aarch64-mte-linux-ptrace.h"
4748 #include "tdesc.h"
4849
4950 #ifdef HAVE_SYS_REG_H
5051 #include <sys/reg.h>
5152 #endif
5253
54+#ifdef HAVE_GETAUXVAL
55+#include <sys/auxv.h>
56+#endif
57+
5358 /* Linux target op definitions for the AArch64 architecture. */
5459
5560 class aarch64_target : public linux_process_target
@@ -82,6 +87,14 @@ public:
8287
8388 struct emit_ops *emit_ops () override;
8489
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+
8598 protected:
8699
87100 void low_arch_setup () override;
@@ -3193,6 +3206,46 @@ aarch64_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
31933206 return arm_breakpoint_kind_from_current_state (pcptr);
31943207 }
31953208
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+
31963249 /* The linux target ops object. */
31973250
31983251 linux_process_target *the_linux_target = &the_aarch64_target;