• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

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

Révisiond7212f00a4fedc86e4edb72067735be6a8c08a68 (tree)
l'heure2020-06-16 21:58:32
AuteurLuis Machado <luis.machado@lina...>
CommiterLuis Machado

Message de Log

Add target description/feature for MTE registers

This patch adds a target description and feature "mte" for aarch64.

It includes a couple registers: sctlr and gcr. Both 64-bit in size.

The patch also adjusts the code that creates the target descriptions at
runtime based on CPU feature checks.

gdb/ChangeLog:

YYYY-MM-DD Luis Machado <luis.machado@linaro.org>

* aarch64-linux-nat.c
(aarch64_linux_nat_target::read_description): Take MTE flag into
account.
* aarch64-linux-tdep.c
(aarch64_linux_core_read_description): Likewise.
* aarch64-tdep.c (tdesc_aarch64_list): Add one more dimension for
MTE.
(aarch64_read_description): Add mte_p parameter and update to use it.
Update the documentation.
(aarch64_gdbarch_init): Update call to aarch64_read_description.
* aarch64-tdep.h (aarch64_read_description): Add mte_p parameter.
* arch/aarch64.c: Include ../features/aarch64-mte.c.
(aarch64_create_target_description): Add mte_p parameter and update
the code to use it.
* arch/aarch64.h (aarch64_create_target_description): Add mte_p
parameter.
* features/Makefile (FEATURE_XMLFILES): Add aarch64-mte.xml.
* features/aarch64-mte.c: New file, generated.
* features/aarch64-mte.xml: New file.

gdbserver/ChangeLog:

YYYY-MM-DD Luis Machado <luis.machado@linaro.org>

* linux-aarch64-ipa.cc (get_ipa_tdesc): Update call to
aarch64_linux_read_description.
(initialize_low_tracepoint): Likewise.
* linux-aarch64-low.cc (aarch64_target::low_arch_setup): Take MTE flag
into account.
* linux-aarch64-tdesc.cc (tdesc_aarch64_list): Add one more dimension
for MTE.
(aarch64_linux_read_description): Add mte_p parameter and update to
use it.
* linux-aarch64-tdesc.h (aarch64_linux_read_description): Add mte_p
parameter.

Change Summary

Modification

--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -653,9 +653,12 @@ aarch64_linux_nat_target::read_description ()
653653 return aarch32_read_description ();
654654
655655 CORE_ADDR hwcap = linux_get_hwcap (this);
656+ CORE_ADDR hwcap2 = linux_get_hwcap2 (this);
657+
658+ bool mte_p = hwcap2 & HWCAP2_MTE;
656659
657660 return aarch64_read_description (aarch64_sve_get_vq (tid),
658- hwcap & AARCH64_HWCAP_PACA);
661+ hwcap & AARCH64_HWCAP_PACA, mte_p);
659662 }
660663
661664 /* Convert a native/host siginfo object, into/from the siginfo in the
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -654,9 +654,11 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
654654 struct target_ops *target, bfd *abfd)
655655 {
656656 CORE_ADDR hwcap = linux_get_hwcap (target);
657+ CORE_ADDR hwcap2 = linux_get_hwcap2 (target);
657658
659+ bool mte_p = (hwcap2 & HWCAP2_MTE)? true : false;
658660 return aarch64_read_description (aarch64_linux_core_read_vq (gdbarch, abfd),
659- hwcap & AARCH64_HWCAP_PACA);
661+ hwcap & AARCH64_HWCAP_PACA, mte_p);
660662 }
661663
662664 /* Implementation of `gdbarch_stap_is_single_operand', as defined in
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -62,7 +62,7 @@
6262 #define HA_MAX_NUM_FLDS 4
6363
6464 /* All possible aarch64 target descriptors. */
65-struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/];
65+struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/][2 /* mte */];
6666
6767 /* The standard register names, and all the valid aliases for them. */
6868 static const struct
@@ -3139,21 +3139,23 @@ aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch,
31393139
31403140 /* Get the correct target description for the given VQ value.
31413141 If VQ is zero then it is assumed SVE is not supported.
3142- (It is not possible to set VQ to zero on an SVE system). */
3142+ (It is not possible to set VQ to zero on an SVE system).
3143+
3144+ MTE_P indicates the presence of the Memory Tagging Extension feature. */
31433145
31443146 const target_desc *
3145-aarch64_read_description (uint64_t vq, bool pauth_p)
3147+aarch64_read_description (uint64_t vq, bool pauth_p, bool mte_p)
31463148 {
31473149 if (vq > AARCH64_MAX_SVE_VQ)
31483150 error (_("VQ is %" PRIu64 ", maximum supported value is %d"), vq,
31493151 AARCH64_MAX_SVE_VQ);
31503152
3151- struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p];
3153+ struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p][mte_p];
31523154
31533155 if (tdesc == NULL)
31543156 {
3155- tdesc = aarch64_create_target_description (vq, pauth_p);
3156- tdesc_aarch64_list[vq][pauth_p] = tdesc;
3157+ tdesc = aarch64_create_target_description (vq, pauth_p, mte_p);
3158+ tdesc_aarch64_list[vq][pauth_p][mte_p] = tdesc;
31573159 }
31583160
31593161 return tdesc;
@@ -3253,7 +3255,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
32533255 value. */
32543256 const struct target_desc *tdesc = info.target_desc;
32553257 if (!tdesc_has_registers (tdesc) || vq != aarch64_get_tdesc_vq (tdesc))
3256- tdesc = aarch64_read_description (vq, false);
3258+ tdesc = aarch64_read_description (vq, false, false);
32573259 gdb_assert (tdesc);
32583260
32593261 feature_core = tdesc_find_feature (tdesc,"org.gnu.gdb.aarch64.core");
--- a/gdb/aarch64-tdep.h
+++ b/gdb/aarch64-tdep.h
@@ -102,7 +102,8 @@ struct gdbarch_tdep
102102 }
103103 };
104104
105-const target_desc *aarch64_read_description (uint64_t vq, bool pauth_p);
105+const target_desc *aarch64_read_description (uint64_t vq, bool pauth_p,
106+ bool mte_p);
106107
107108 extern int aarch64_process_record (struct gdbarch *gdbarch,
108109 struct regcache *regcache, CORE_ADDR addr);
--- a/gdb/arch/aarch64.c
+++ b/gdb/arch/aarch64.c
@@ -23,11 +23,12 @@
2323 #include "../features/aarch64-fpu.c"
2424 #include "../features/aarch64-sve.c"
2525 #include "../features/aarch64-pauth.c"
26+#include "../features/aarch64-mte.c"
2627
2728 /* See arch/aarch64.h. */
2829
2930 target_desc *
30-aarch64_create_target_description (uint64_t vq, bool pauth_p)
31+aarch64_create_target_description (uint64_t vq, bool pauth_p, bool mte_p)
3132 {
3233 target_desc *tdesc = allocate_target_description ();
3334
@@ -47,5 +48,9 @@ aarch64_create_target_description (uint64_t vq, bool pauth_p)
4748 if (pauth_p)
4849 regnum = create_feature_aarch64_pauth (tdesc, regnum);
4950
51+ /* Memory tagging extension registers. */
52+ if (mte_p)
53+ regnum = create_feature_aarch64_mte (tdesc, regnum);
54+
5055 return tdesc;
5156 }
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -25,9 +25,12 @@
2525 /* Create the aarch64 target description. A non zero VQ value indicates both
2626 the presence of SVE and the Vector Quotient - the number of 128bit chunks in
2727 an SVE Z register. HAS_PAUTH_P indicates the presence of the PAUTH
28- feature. */
28+ feature.
2929
30-target_desc *aarch64_create_target_description (uint64_t vq, bool has_pauth_p);
30+ MTE_P indicates the presence of the Memory Tagging Extension feature. */
31+
32+target_desc *aarch64_create_target_description (uint64_t vq, bool has_pauth_p,
33+ bool mte_p);
3134
3235 /* Register numbers of various important registers.
3336 Note that on SVE, the Z registers reuse the V register numbers and the V
--- a/gdb/features/Makefile
+++ b/gdb/features/Makefile
@@ -204,6 +204,7 @@ $(outdir)/%.dat: %.xml number-regs.xsl sort-regs.xsl gdbserver-regs.xsl
204204 FEATURE_XMLFILES = aarch64-core.xml \
205205 aarch64-fpu.xml \
206206 aarch64-pauth.xml \
207+ aarch64-mte.xml \
207208 arc/core-v2.xml \
208209 arc/aux-v2.xml \
209210 arc/core-arcompact.xml \
--- /dev/null
+++ b/gdb/features/aarch64-mte.c
@@ -0,0 +1,15 @@
1+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
2+ Original: aarch64-mte.xml */
3+
4+#include "gdbsupport/tdesc.h"
5+
6+static int
7+create_feature_aarch64_mte (struct target_desc *result, long regnum)
8+{
9+ struct tdesc_feature *feature;
10+
11+ feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.mte");
12+ tdesc_create_reg (feature, "sctlr", regnum++, 1, "mte", 64, "uint64");
13+ tdesc_create_reg (feature, "gcr", regnum++, 1, "mte", 64, "uint64");
14+ return regnum;
15+}
--- /dev/null
+++ b/gdb/features/aarch64-mte.xml
@@ -0,0 +1,12 @@
1+<?xml version="1.0"?>
2+<!-- Copyright (C) 2020 Free Software Foundation, Inc.
3+
4+ Copying and distribution of this file, with or without modification,
5+ are permitted in any medium without royalty provided the copyright
6+ notice and this notice are preserved. -->
7+
8+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
9+<feature name="org.gnu.gdb.aarch64.mte">
10+ <reg name="sctlr" bitsize="64" type="uint64" group="mte"/>
11+ <reg name="gcr" bitsize="64" type="uint64" group="mte"/>
12+</feature>
--- a/gdbserver/linux-aarch64-ipa.cc
+++ b/gdbserver/linux-aarch64-ipa.cc
@@ -147,12 +147,12 @@ get_raw_reg (const unsigned char *raw_regs, int regnum)
147147
148148 /* Return target_desc to use for IPA, given the tdesc index passed by
149149 gdbserver. Index is ignored, since we have only one tdesc
150- at the moment. SVE and pauth not yet supported. */
150+ at the moment. SVE, pauth and MTE not yet supported. */
151151
152152 const struct target_desc *
153153 get_ipa_tdesc (int idx)
154154 {
155- return aarch64_linux_read_description (0, false);
155+ return aarch64_linux_read_description (0, false, false);
156156 }
157157
158158 /* Allocate buffer for the jump pads. The branch instruction has a reach
@@ -204,6 +204,6 @@ alloc_jump_pad_buffer (size_t size)
204204 void
205205 initialize_low_tracepoint (void)
206206 {
207- /* SVE and pauth not yet supported. */
208- aarch64_linux_read_description (0, false);
207+ /* SVE, pauth and MTE not yet supported. */
208+ aarch64_linux_read_description (0, false, false);
209209 }
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -642,9 +642,13 @@ aarch64_target::low_arch_setup ()
642642 {
643643 uint64_t vq = aarch64_sve_get_vq (tid);
644644 unsigned long hwcap = linux_get_hwcap (8);
645+ unsigned long hwcap2 = linux_get_hwcap2 (8);
645646 bool pauth_p = hwcap & AARCH64_HWCAP_PACA;
647+ /* MTE is AArch64-only. */
648+ bool mte_p = hwcap2 & HWCAP2_MTE;
646649
647- current_process ()->tdesc = aarch64_linux_read_description (vq, pauth_p);
650+ current_process ()->tdesc
651+ = aarch64_linux_read_description (vq, pauth_p, mte_p);
648652 }
649653 else
650654 current_process ()->tdesc = aarch32_linux_read_description ();
--- a/gdbserver/linux-aarch64-tdesc.cc
+++ b/gdbserver/linux-aarch64-tdesc.cc
@@ -27,22 +27,22 @@
2727 #include <inttypes.h>
2828
2929 /* All possible aarch64 target descriptors. */
30-struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/];
30+struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/][2 /* mte */];
3131
3232 /* Create the aarch64 target description. */
3333
3434 const target_desc *
35-aarch64_linux_read_description (uint64_t vq, bool pauth_p)
35+aarch64_linux_read_description (uint64_t vq, bool pauth_p, bool mte_p)
3636 {
3737 if (vq > AARCH64_MAX_SVE_VQ)
3838 error (_("VQ is %" PRIu64 ", maximum supported value is %d"), vq,
3939 AARCH64_MAX_SVE_VQ);
4040
41- struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p];
41+ struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p][mte_p];
4242
4343 if (tdesc == NULL)
4444 {
45- tdesc = aarch64_create_target_description (vq, pauth_p);
45+ tdesc = aarch64_create_target_description (vq, pauth_p, mte_p);
4646
4747 static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL };
4848 static const char *expedite_regs_aarch64_sve[] = { "x29", "sp", "pc",
@@ -53,7 +53,7 @@ aarch64_linux_read_description (uint64_t vq, bool pauth_p)
5353 else
5454 init_target_desc (tdesc, expedite_regs_aarch64_sve);
5555
56- tdesc_aarch64_list[vq][pauth_p] = tdesc;
56+ tdesc_aarch64_list[vq][pauth_p][mte_p] = tdesc;
5757 }
5858
5959 return tdesc;
--- a/gdbserver/linux-aarch64-tdesc.h
+++ b/gdbserver/linux-aarch64-tdesc.h
@@ -20,6 +20,7 @@
2020 #ifndef GDBSERVER_LINUX_AARCH64_TDESC_H
2121 #define GDBSERVER_LINUX_AARCH64_TDESC_H
2222
23-const target_desc * aarch64_linux_read_description (uint64_t vq, bool pauth_p);
23+const target_desc * aarch64_linux_read_description (uint64_t vq, bool pauth_p,
24+ bool mte_p);
2425
2526 #endif /* GDBSERVER_LINUX_AARCH64_TDESC_H */