Patchwork [v2,08/10] Enable Aarch64 SVE for gdbserver

login
register
mail settings
Submitter Alan Hayward
Date June 6, 2018, 3:16 p.m.
Message ID <20180606151629.36602-9-alan.hayward@arm.com>
Download mbox | patch
Permalink /patch/27665/
State New
Headers show

Comments

Alan Hayward - June 6, 2018, 3:16 p.m.
Simply add the check for SVE, similar to gdb.

2018-06-06  Alan Hayward  <alan.hayward@arm.com>

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/linux-aarch64-ipa.c            |  9 +++++----
 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 +-
 5 files changed, 34 insertions(+), 15 deletions(-)
Simon Marchi - June 11, 2018, 12:48 a.m.
On 2018-06-06 11:16 AM, Alan Hayward wrote:
> Simply add the check for SVE, similar to gdb.
> 
> 2018-06-06  Alan Hayward  <alan.hayward@arm.com>
> 
> 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.

LGTM.

Simon

Patch

diff --git a/gdb/gdbserver/linux-aarch64-ipa.c b/gdb/gdbserver/linux-aarch64-ipa.c
index 3095408cf8..98a758f770 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);
+}
\ No newline at end of file
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 7ea24c2363..9db9a7c1c3 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 <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;
 
diff --git a/gdb/gdbserver/linux-aarch64-tdesc-selftest.c b/gdb/gdbserver/linux-aarch64-tdesc-selftest.c
index 379951ac86..eef0b9c9a6 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 f0761797e9..f538543175 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 <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;
 }
diff --git a/gdb/gdbserver/linux-aarch64-tdesc.h b/gdb/gdbserver/linux-aarch64-tdesc.h
index dc362998c2..4d2b883b55 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 <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 ();