Enable Aarch64 SVE for gdbserver
authorAlan Hayward <alan.hayward@arm.com>
Mon, 11 Jun 2018 09:32:52 +0000 (10:32 +0100)
committerAlan Hayward <alan.hayward@arm.com>
Mon, 11 Jun 2018 12:25:15 +0000 (13:25 +0100)
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
gdb/gdbserver/linux-aarch64-ipa.c
gdb/gdbserver/linux-aarch64-low.c
gdb/gdbserver/linux-aarch64-tdesc-selftest.c
gdb/gdbserver/linux-aarch64-tdesc.c
gdb/gdbserver/linux-aarch64-tdesc.h

index fac340e2f0295fe20af58ee7175cb40bce67c63b..ac1eb1c909978f582c9a5a6419a906da53bc922d 100644 (file)
@@ -1,3 +1,14 @@
+2018-06-11  Alan Hayward  <alan.hayward@arm.com>
+
+       * 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  <alan.hayward@arm.com>
 
        * server.h (PBUFSIZ): Increase size
index 3095408cf8540d1626f5cf8d75aafb3d9afe9bdd..efdc0510675d6a50f239eaea8a0725780567bca6 100644 (file)
@@ -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);
 }
index 7ea24c23634bcb996816f82babb44f2e87acdb48..9db9a7c1c3409a05c46f35a2b0f57798228b3e3c 100644 (file)
@@ -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 <sys/reg.h>
@@ -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;
 
index 379951ac86e0b5a944cf040fe04f1039eac98fa0..eef0b9c9a66568ce8b663c974af899998d3d5637 100644 (file)
@@ -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);
 }
 }
index f0761797e9c332971fe00c871d2371da4b0e119a..f538543175be47f3da4dc7a7656df770b7ba6d8b 100644 (file)
 #include "tdesc.h"
 #include "arch/aarch64.h"
 #include "linux-aarch32-low.h"
+#include <inttypes.h>
+
+/* 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;
 }
index dc362998c245eda7eb5dd96b54f0956a3fb89c72..4d2b883b555d4fb04a0c87b96efa3f4ddc1cae43 100644 (file)
@@ -17,7 +17,7 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-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 ();