GNU Binutils with patches for OS216
Révision | d7212f00a4fedc86e4edb72067735be6a8c08a68 (tree) |
---|---|
l'heure | 2020-06-16 21:58:32 |
Auteur | Luis Machado <luis.machado@lina...> |
Commiter | Luis Machado |
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.
@@ -653,9 +653,12 @@ aarch64_linux_nat_target::read_description () | ||
653 | 653 | return aarch32_read_description (); |
654 | 654 | |
655 | 655 | CORE_ADDR hwcap = linux_get_hwcap (this); |
656 | + CORE_ADDR hwcap2 = linux_get_hwcap2 (this); | |
657 | + | |
658 | + bool mte_p = hwcap2 & HWCAP2_MTE; | |
656 | 659 | |
657 | 660 | return aarch64_read_description (aarch64_sve_get_vq (tid), |
658 | - hwcap & AARCH64_HWCAP_PACA); | |
661 | + hwcap & AARCH64_HWCAP_PACA, mte_p); | |
659 | 662 | } |
660 | 663 | |
661 | 664 | /* Convert a native/host siginfo object, into/from the siginfo in the |
@@ -654,9 +654,11 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch, | ||
654 | 654 | struct target_ops *target, bfd *abfd) |
655 | 655 | { |
656 | 656 | CORE_ADDR hwcap = linux_get_hwcap (target); |
657 | + CORE_ADDR hwcap2 = linux_get_hwcap2 (target); | |
657 | 658 | |
659 | + bool mte_p = (hwcap2 & HWCAP2_MTE)? true : false; | |
658 | 660 | return aarch64_read_description (aarch64_linux_core_read_vq (gdbarch, abfd), |
659 | - hwcap & AARCH64_HWCAP_PACA); | |
661 | + hwcap & AARCH64_HWCAP_PACA, mte_p); | |
660 | 662 | } |
661 | 663 | |
662 | 664 | /* Implementation of `gdbarch_stap_is_single_operand', as defined in |
@@ -62,7 +62,7 @@ | ||
62 | 62 | #define HA_MAX_NUM_FLDS 4 |
63 | 63 | |
64 | 64 | /* 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 */]; | |
66 | 66 | |
67 | 67 | /* The standard register names, and all the valid aliases for them. */ |
68 | 68 | static const struct |
@@ -3139,21 +3139,23 @@ aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch, | ||
3139 | 3139 | |
3140 | 3140 | /* Get the correct target description for the given VQ value. |
3141 | 3141 | 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. */ | |
3143 | 3145 | |
3144 | 3146 | 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) | |
3146 | 3148 | { |
3147 | 3149 | if (vq > AARCH64_MAX_SVE_VQ) |
3148 | 3150 | error (_("VQ is %" PRIu64 ", maximum supported value is %d"), vq, |
3149 | 3151 | AARCH64_MAX_SVE_VQ); |
3150 | 3152 | |
3151 | - struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p]; | |
3153 | + struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p][mte_p]; | |
3152 | 3154 | |
3153 | 3155 | if (tdesc == NULL) |
3154 | 3156 | { |
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; | |
3157 | 3159 | } |
3158 | 3160 | |
3159 | 3161 | return tdesc; |
@@ -3253,7 +3255,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) | ||
3253 | 3255 | value. */ |
3254 | 3256 | const struct target_desc *tdesc = info.target_desc; |
3255 | 3257 | 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); | |
3257 | 3259 | gdb_assert (tdesc); |
3258 | 3260 | |
3259 | 3261 | feature_core = tdesc_find_feature (tdesc,"org.gnu.gdb.aarch64.core"); |
@@ -102,7 +102,8 @@ struct gdbarch_tdep | ||
102 | 102 | } |
103 | 103 | }; |
104 | 104 | |
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); | |
106 | 107 | |
107 | 108 | extern int aarch64_process_record (struct gdbarch *gdbarch, |
108 | 109 | struct regcache *regcache, CORE_ADDR addr); |
@@ -23,11 +23,12 @@ | ||
23 | 23 | #include "../features/aarch64-fpu.c" |
24 | 24 | #include "../features/aarch64-sve.c" |
25 | 25 | #include "../features/aarch64-pauth.c" |
26 | +#include "../features/aarch64-mte.c" | |
26 | 27 | |
27 | 28 | /* See arch/aarch64.h. */ |
28 | 29 | |
29 | 30 | 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) | |
31 | 32 | { |
32 | 33 | target_desc *tdesc = allocate_target_description (); |
33 | 34 |
@@ -47,5 +48,9 @@ aarch64_create_target_description (uint64_t vq, bool pauth_p) | ||
47 | 48 | if (pauth_p) |
48 | 49 | regnum = create_feature_aarch64_pauth (tdesc, regnum); |
49 | 50 | |
51 | + /* Memory tagging extension registers. */ | |
52 | + if (mte_p) | |
53 | + regnum = create_feature_aarch64_mte (tdesc, regnum); | |
54 | + | |
50 | 55 | return tdesc; |
51 | 56 | } |
@@ -25,9 +25,12 @@ | ||
25 | 25 | /* Create the aarch64 target description. A non zero VQ value indicates both |
26 | 26 | the presence of SVE and the Vector Quotient - the number of 128bit chunks in |
27 | 27 | an SVE Z register. HAS_PAUTH_P indicates the presence of the PAUTH |
28 | - feature. */ | |
28 | + feature. | |
29 | 29 | |
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); | |
31 | 34 | |
32 | 35 | /* Register numbers of various important registers. |
33 | 36 | Note that on SVE, the Z registers reuse the V register numbers and the V |
@@ -204,6 +204,7 @@ $(outdir)/%.dat: %.xml number-regs.xsl sort-regs.xsl gdbserver-regs.xsl | ||
204 | 204 | FEATURE_XMLFILES = aarch64-core.xml \ |
205 | 205 | aarch64-fpu.xml \ |
206 | 206 | aarch64-pauth.xml \ |
207 | + aarch64-mte.xml \ | |
207 | 208 | arc/core-v2.xml \ |
208 | 209 | arc/aux-v2.xml \ |
209 | 210 | arc/core-arcompact.xml \ |
@@ -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 | +} |
@@ -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> |
@@ -147,12 +147,12 @@ get_raw_reg (const unsigned char *raw_regs, int regnum) | ||
147 | 147 | |
148 | 148 | /* Return target_desc to use for IPA, given the tdesc index passed by |
149 | 149 | 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. */ | |
151 | 151 | |
152 | 152 | const struct target_desc * |
153 | 153 | get_ipa_tdesc (int idx) |
154 | 154 | { |
155 | - return aarch64_linux_read_description (0, false); | |
155 | + return aarch64_linux_read_description (0, false, false); | |
156 | 156 | } |
157 | 157 | |
158 | 158 | /* Allocate buffer for the jump pads. The branch instruction has a reach |
@@ -204,6 +204,6 @@ alloc_jump_pad_buffer (size_t size) | ||
204 | 204 | void |
205 | 205 | initialize_low_tracepoint (void) |
206 | 206 | { |
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); | |
209 | 209 | } |
@@ -642,9 +642,13 @@ aarch64_target::low_arch_setup () | ||
642 | 642 | { |
643 | 643 | uint64_t vq = aarch64_sve_get_vq (tid); |
644 | 644 | unsigned long hwcap = linux_get_hwcap (8); |
645 | + unsigned long hwcap2 = linux_get_hwcap2 (8); | |
645 | 646 | bool pauth_p = hwcap & AARCH64_HWCAP_PACA; |
647 | + /* MTE is AArch64-only. */ | |
648 | + bool mte_p = hwcap2 & HWCAP2_MTE; | |
646 | 649 | |
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); | |
648 | 652 | } |
649 | 653 | else |
650 | 654 | current_process ()->tdesc = aarch32_linux_read_description (); |
@@ -27,22 +27,22 @@ | ||
27 | 27 | #include <inttypes.h> |
28 | 28 | |
29 | 29 | /* 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 */]; | |
31 | 31 | |
32 | 32 | /* Create the aarch64 target description. */ |
33 | 33 | |
34 | 34 | 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) | |
36 | 36 | { |
37 | 37 | if (vq > AARCH64_MAX_SVE_VQ) |
38 | 38 | error (_("VQ is %" PRIu64 ", maximum supported value is %d"), vq, |
39 | 39 | AARCH64_MAX_SVE_VQ); |
40 | 40 | |
41 | - struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p]; | |
41 | + struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p][mte_p]; | |
42 | 42 | |
43 | 43 | if (tdesc == NULL) |
44 | 44 | { |
45 | - tdesc = aarch64_create_target_description (vq, pauth_p); | |
45 | + tdesc = aarch64_create_target_description (vq, pauth_p, mte_p); | |
46 | 46 | |
47 | 47 | static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL }; |
48 | 48 | static const char *expedite_regs_aarch64_sve[] = { "x29", "sp", "pc", |
@@ -53,7 +53,7 @@ aarch64_linux_read_description (uint64_t vq, bool pauth_p) | ||
53 | 53 | else |
54 | 54 | init_target_desc (tdesc, expedite_regs_aarch64_sve); |
55 | 55 | |
56 | - tdesc_aarch64_list[vq][pauth_p] = tdesc; | |
56 | + tdesc_aarch64_list[vq][pauth_p][mte_p] = tdesc; | |
57 | 57 | } |
58 | 58 | |
59 | 59 | return tdesc; |
@@ -20,6 +20,7 @@ | ||
20 | 20 | #ifndef GDBSERVER_LINUX_AARCH64_TDESC_H |
21 | 21 | #define GDBSERVER_LINUX_AARCH64_TDESC_H |
22 | 22 | |
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); | |
24 | 25 | |
25 | 26 | #endif /* GDBSERVER_LINUX_AARCH64_TDESC_H */ |