From fefa175e8f518f17121a1870270a415c851cbacc Mon Sep 17 00:00:00 2001 From: Alan Hayward Date: Mon, 11 Jun 2018 10:32:52 +0100 Subject: [PATCH] Enable Aarch64 SVE for gdbserver gdbserver/ * linux-aarch64-ipa.c (get_ipa_tdesc): Add null VQ param. (initialize_low_tracepoint): Likewise * linux-aarch64-low.c (aarch64_arch_setup): Get VQ. * linux-aarch64-tdesc-selftest.c (aarch64_tdesc_test): Add null VQ param. * linux-aarch64-tdesc.c (aarch64_linux_read_description): Add VQ checks. * linux-aarch64-tdesc.h (aarch64_linux_read_description): Add VQ. --- gdb/gdbserver/ChangeLog | 11 +++++++ gdb/gdbserver/linux-aarch64-ipa.c | 7 +++-- gdb/gdbserver/linux-aarch64-low.c | 6 +++- gdb/gdbserver/linux-aarch64-tdesc-selftest.c | 2 +- gdb/gdbserver/linux-aarch64-tdesc.c | 30 ++++++++++++++------ gdb/gdbserver/linux-aarch64-tdesc.h | 2 +- 6 files changed, 44 insertions(+), 14 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index fac340e2f02..ac1eb1c9099 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,14 @@ +2018-06-11 Alan Hayward + + * linux-aarch64-ipa.c (get_ipa_tdesc): Add null VQ param. + (initialize_low_tracepoint): Likewise + * linux-aarch64-low.c (aarch64_arch_setup): Get VQ. + * linux-aarch64-tdesc-selftest.c (aarch64_tdesc_test): Add null VQ + param. + * linux-aarch64-tdesc.c (aarch64_linux_read_description): Add VQ + checks. + * linux-aarch64-tdesc.h (aarch64_linux_read_description): Add VQ. + 2018-06-11 Alan Hayward * server.h (PBUFSIZ): Increase size diff --git a/gdb/gdbserver/linux-aarch64-ipa.c b/gdb/gdbserver/linux-aarch64-ipa.c index 3095408cf85..efdc0510675 100644 --- a/gdb/gdbserver/linux-aarch64-ipa.c +++ b/gdb/gdbserver/linux-aarch64-ipa.c @@ -147,12 +147,12 @@ get_raw_reg (const unsigned char *raw_regs, int regnum) /* Return target_desc to use for IPA, given the tdesc index passed by gdbserver. Index is ignored, since we have only one tdesc - at the moment. */ + at the moment. SVE not yet supported. */ const struct target_desc * get_ipa_tdesc (int idx) { - return aarch64_linux_read_description (); + return aarch64_linux_read_description (0); } /* Allocate buffer for the jump pads. The branch instruction has a reach @@ -204,5 +204,6 @@ alloc_jump_pad_buffer (size_t size) void initialize_low_tracepoint (void) { - aarch64_linux_read_description (); + /* SVE not yet supported. */ + aarch64_linux_read_description (0); } diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index 7ea24c23634..9db9a7c1c34 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -40,6 +40,7 @@ #include "gdb_proc_service.h" #include "arch/aarch64.h" #include "linux-aarch64-tdesc.h" +#include "nat/aarch64-sve-linux-ptrace.h" #ifdef HAVE_SYS_REG_H #include @@ -503,7 +504,10 @@ aarch64_arch_setup (void) is_elf64 = linux_pid_exe_is_elf_64_file (tid, &machine); if (is_elf64) - current_process ()->tdesc = aarch64_linux_read_description (); + { + uint64_t vq = aarch64_sve_get_vq (tid); + current_process ()->tdesc = aarch64_linux_read_description (vq); + } else current_process ()->tdesc = tdesc_arm_with_neon; diff --git a/gdb/gdbserver/linux-aarch64-tdesc-selftest.c b/gdb/gdbserver/linux-aarch64-tdesc-selftest.c index 379951ac86e..eef0b9c9a66 100644 --- a/gdb/gdbserver/linux-aarch64-tdesc-selftest.c +++ b/gdb/gdbserver/linux-aarch64-tdesc-selftest.c @@ -29,7 +29,7 @@ namespace tdesc { static void aarch64_tdesc_test () { - const target_desc *tdesc = aarch64_linux_read_description (); + const target_desc *tdesc = aarch64_linux_read_description (0); SELF_CHECK (*tdesc == *tdesc_aarch64); } } diff --git a/gdb/gdbserver/linux-aarch64-tdesc.c b/gdb/gdbserver/linux-aarch64-tdesc.c index f0761797e9c..f538543175b 100644 --- a/gdb/gdbserver/linux-aarch64-tdesc.c +++ b/gdb/gdbserver/linux-aarch64-tdesc.c @@ -21,23 +21,37 @@ #include "tdesc.h" #include "arch/aarch64.h" #include "linux-aarch32-low.h" +#include + +/* All possible aarch64 target descriptors. */ +struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1]; /* Create the aarch64 target description. */ const target_desc * -aarch64_linux_read_description () +aarch64_linux_read_description (uint64_t vq) { - static target_desc *aarch64_tdesc = NULL; - target_desc **tdesc = &aarch64_tdesc; + if (vq > AARCH64_MAX_SVE_VQ) + error (_("VQ is %" PRIu64 ", maximum supported value is %d"), vq, + AARCH64_MAX_SVE_VQ); + + struct target_desc *tdesc = tdesc_aarch64_list[vq]; - if (*tdesc == NULL) + if (tdesc == NULL) { - /* SVE not yet supported. */ - *tdesc = aarch64_create_target_description (0); + tdesc = aarch64_create_target_description (vq); static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL }; - init_target_desc (*tdesc, expedite_regs_aarch64); + static const char *expedite_regs_aarch64_sve[] = { "x29", "sp", "pc", + "vg", NULL }; + + if (vq == 0) + init_target_desc (tdesc, expedite_regs_aarch64); + else + init_target_desc (tdesc, expedite_regs_aarch64_sve); + + tdesc_aarch64_list[vq] = tdesc; } - return *tdesc; + return tdesc; } diff --git a/gdb/gdbserver/linux-aarch64-tdesc.h b/gdb/gdbserver/linux-aarch64-tdesc.h index dc362998c24..4d2b883b555 100644 --- a/gdb/gdbserver/linux-aarch64-tdesc.h +++ b/gdb/gdbserver/linux-aarch64-tdesc.h @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -const target_desc * aarch64_linux_read_description (); +const target_desc * aarch64_linux_read_description (uint64_t vq); #if GDB_SELF_TEST void initialize_low_tdesc (); -- 2.30.2