From: Alan Hayward Date: Fri, 22 Mar 2019 09:58:42 +0000 (+0000) Subject: AArch64: Add pointer authentication feature X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6dc0ebde59dfb73eae507ced718bafa54023bf33;p=binutils-gdb.git AArch64: Add pointer authentication feature Pointer Authentication is a new feature in AArch64 v8.3-a. When enabled in the compiler, function return addresses will be mangled by the kernel. Add register description xml and wire up to aarch64_linux_read_description. This description includes the two pauth user registers. Nothing yet uses the feature - that is added in later patches. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_linux_nat_target::read_description): Add pauth param. * aarch64-linux-tdep.c (aarch64_linux_core_read_description): Likewise. * aarch64-tdep.c (struct target_desc): Add in pauth. (aarch64_read_description): Add pauth param. (aarch64_gdbarch_init): Likewise. * aarch64-tdep.h (aarch64_read_description): Likewise. * arch/aarch64.c (aarch64_create_target_description): Likewise. * arch/aarch64.h (aarch64_create_target_description): Likewise. * features/Makefile: Add new files. * features/aarch64-pauth.c: New file. * features/aarch64-pauth.xml: New file. gdb/doc/ChangeLog: * gdb.texinfo: Describe pauth feature. gdb/gdbserver/ChangeLog: * linux-aarch64-ipa.c (get_ipa_tdesc): Add pauth param. (initialize_low_tracepoint): Likewise. * linux-aarch64-low.c (aarch64_arch_setup): Likewise. * linux-aarch64-tdesc-selftest.c (aarch64_tdesc_test): Likewise. * linux-aarch64-tdesc.c (struct target_desc): Likewise. (aarch64_linux_read_description): Likewise. * linux-aarch64-tdesc.h (aarch64_linux_read_description): Likewise. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4345e014695..743f510b295 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,20 @@ +2019-03-22 Alan Hayward + Jiong Wang + + * aarch64-linux-nat.c + (aarch64_linux_nat_target::read_description): Add pauth param. + * aarch64-linux-tdep.c + (aarch64_linux_core_read_description): Likewise. + * aarch64-tdep.c (struct target_desc): Add in pauth. + (aarch64_read_description): Add pauth param. + (aarch64_gdbarch_init): Likewise. + * aarch64-tdep.h (aarch64_read_description): Likewise. + * arch/aarch64.c (aarch64_create_target_description): Likewise. + * arch/aarch64.h (aarch64_create_target_description): Likewise. + * features/Makefile: Add new files. + * features/aarch64-pauth.c: New file. + * features/aarch64-pauth.xml: New file. + 2019-03-20 Tom Tromey * infrun.c (handle_inferior_event): Rename from diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 6f91e9568e5..f58a41e1955 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -605,8 +605,9 @@ aarch64_linux_nat_target::read_description () ret = ptrace (PTRACE_GETREGSET, tid, NT_ARM_VFP, &iovec); if (ret == 0) return tdesc_arm_with_neon; - else - return aarch64_read_description (aarch64_sve_get_vq (tid)); + + /* pauth not yet supported. */ + return aarch64_read_description (aarch64_sve_get_vq (tid), false); } /* Convert a native/host siginfo object, into/from the siginfo in the diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 39e607658f4..445019accc7 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -640,7 +640,9 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch, if (target_auxv_search (target, AT_HWCAP, &aarch64_hwcap) != 1) return NULL; - return aarch64_read_description (aarch64_linux_core_read_vq (gdbarch, abfd)); + /* pauth not yet supported. */ + return aarch64_read_description (aarch64_linux_core_read_vq (gdbarch, abfd), + false); } /* Implementation of `gdbarch_stap_is_single_operand', as defined in diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index dd57ef98739..0518837a1f9 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -69,7 +69,7 @@ #define HA_MAX_NUM_FLDS 4 /* All possible aarch64 target descriptors. */ -struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1]; +struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/]; /* The standard register names, and all the valid aliases for them. */ static const struct @@ -2885,18 +2885,18 @@ aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch, (It is not possible to set VQ to zero on an SVE system). */ const target_desc * -aarch64_read_description (uint64_t vq) +aarch64_read_description (uint64_t vq, bool pauth_p) { 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]; + struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p]; if (tdesc == NULL) { - tdesc = aarch64_create_target_description (vq); - tdesc_aarch64_list[vq] = tdesc; + tdesc = aarch64_create_target_description (vq, pauth_p); + tdesc_aarch64_list[vq][pauth_p] = tdesc; } return tdesc; @@ -2961,7 +2961,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Ensure we always have a target description. */ if (!tdesc_has_registers (tdesc)) - tdesc = aarch64_read_description (0); + tdesc = aarch64_read_description (0, false); gdb_assert (tdesc); feature_core = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.core"); @@ -3190,7 +3190,7 @@ When on, AArch64 specific debugging is enabled."), selftests::register_test ("aarch64-process-record", selftests::aarch64_process_record_test); selftests::record_xml_tdesc ("aarch64.xml", - aarch64_create_target_description (0)); + aarch64_create_target_description (0, false)); #endif } diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h index 704eacb50c8..3db6bee9f3f 100644 --- a/gdb/aarch64-tdep.h +++ b/gdb/aarch64-tdep.h @@ -89,7 +89,7 @@ struct gdbarch_tdep } }; -const target_desc *aarch64_read_description (uint64_t vq); +const target_desc *aarch64_read_description (uint64_t vq, bool pauth_p); extern int aarch64_process_record (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR addr); diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c index d36ed9d19e8..11a15dd94cb 100644 --- a/gdb/arch/aarch64.c +++ b/gdb/arch/aarch64.c @@ -22,11 +22,12 @@ #include "../features/aarch64-core.c" #include "../features/aarch64-fpu.c" #include "../features/aarch64-sve.c" +#include "../features/aarch64-pauth.c" /* See arch/aarch64.h. */ target_desc * -aarch64_create_target_description (uint64_t vq) +aarch64_create_target_description (uint64_t vq, bool pauth_p) { target_desc *tdesc = allocate_target_description (); @@ -43,5 +44,8 @@ aarch64_create_target_description (uint64_t vq) else regnum = create_feature_aarch64_sve (tdesc, regnum, vq); + if (pauth_p) + regnum = create_feature_aarch64_pauth (tdesc, regnum); + return tdesc; } diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h index 807a4a6558b..4fe6d02f6e2 100644 --- a/gdb/arch/aarch64.h +++ b/gdb/arch/aarch64.h @@ -24,9 +24,10 @@ /* Create the aarch64 target description. A non zero VQ value indicates both the presence of SVE and the Vector Quotient - the number of 128bit chunks in - an SVE Z register. */ + an SVE Z register. HAS_PAUTH_P indicates the presence of the PAUTH + feature. */ -target_desc *aarch64_create_target_description (uint64_t vq); +target_desc *aarch64_create_target_description (uint64_t vq, bool has_pauth_p); /* Register numbers of various important registers. Note that on SVE, the Z registers reuse the V register numbers and the V diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 447d74e2fa4..1f41498dc83 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +2019-03-22 Alan Hayward + Jiong Wang + + * gdb.texinfo (AArch64 Features): Describe pauth feature. + 2019-03-20 Tom Tromey * python.texi (Selecting Pretty-Printers): Use @defvar for diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 271739b6cdc..4c1d5e8294f 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -43162,6 +43162,9 @@ The @samp{org.gnu.gdb.aarch64.sve} feature is optional. If present, it should contain registers @samp{z0} through @samp{z31}, @samp{p0} through @samp{p15}, @samp{ffr} and @samp{vg}. +The @samp{org.gnu.gdb.aarch64.pauth} feature is optional. If present, +it should contain registers @samp{pauth_dmask} and @samp{pauth_cmask}. + @node ARC Features @subsection ARC Features @cindex target descriptions, ARC Features diff --git a/gdb/features/Makefile b/gdb/features/Makefile index 3d84ca09a15..d0cd4f851fc 100644 --- a/gdb/features/Makefile +++ b/gdb/features/Makefile @@ -227,6 +227,7 @@ $(outdir)/%.dat: %.xml number-regs.xsl sort-regs.xsl gdbserver-regs.xsl FEATURE_XMLFILES = aarch64-core.xml \ aarch64-fpu.xml \ + aarch64-pauth.xml \ i386/32bit-core.xml \ i386/32bit-sse.xml \ i386/32bit-linux.xml \ diff --git a/gdb/features/aarch64-pauth.c b/gdb/features/aarch64-pauth.c new file mode 100644 index 00000000000..e4b84ffb552 --- /dev/null +++ b/gdb/features/aarch64-pauth.c @@ -0,0 +1,16 @@ +/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro: + Original: aarch64-pauth.xml */ + +#include "common/tdesc.h" + +static int +create_feature_aarch64_pauth (struct target_desc *result, long regnum) +{ + struct tdesc_feature *feature; + + feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.pauth"); + tdesc_create_reg (feature, "pauth_dmask", regnum++, 1, NULL, 64, "int"); + tdesc_create_reg (feature, "pauth_cmask", regnum++, 1, NULL, 64, "int"); + + return regnum; +} diff --git a/gdb/features/aarch64-pauth.xml b/gdb/features/aarch64-pauth.xml new file mode 100644 index 00000000000..9c8987fca7c --- /dev/null +++ b/gdb/features/aarch64-pauth.xml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 9879481b17e..9fdbe1d866e 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,14 @@ +2019-03-22 Alan Hayward + Jiong Wang + + * linux-aarch64-ipa.c (get_ipa_tdesc): Add pauth param. + (initialize_low_tracepoint): Likewise. + * linux-aarch64-low.c (aarch64_arch_setup): Likewise. + * linux-aarch64-tdesc-selftest.c (aarch64_tdesc_test): Likewise. + * linux-aarch64-tdesc.c (struct target_desc): Likewise. + (aarch64_linux_read_description): Likewise. + * linux-aarch64-tdesc.h (aarch64_linux_read_description): Likewise. + 2019-03-12 John Baldwin * linux-x86-tdesc.c (i386_linux_read_description): Update call to diff --git a/gdb/gdbserver/linux-aarch64-ipa.c b/gdb/gdbserver/linux-aarch64-ipa.c index 94db53f59ad..3804b1e2394 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. SVE not yet supported. */ + at the moment. SVE and pauth not yet supported. */ const struct target_desc * get_ipa_tdesc (int idx) { - return aarch64_linux_read_description (0); + return aarch64_linux_read_description (0, false); } /* Allocate buffer for the jump pads. The branch instruction has a reach @@ -204,6 +204,6 @@ alloc_jump_pad_buffer (size_t size) void initialize_low_tracepoint (void) { - /* SVE not yet supported. */ - aarch64_linux_read_description (0); + /* SVE and pauth not yet supported. */ + aarch64_linux_read_description (0, false); } diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c index 0b2946ea228..db329da4dc9 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -501,7 +501,8 @@ aarch64_arch_setup (void) if (is_elf64) { uint64_t vq = aarch64_sve_get_vq (tid); - current_process ()->tdesc = aarch64_linux_read_description (vq); + /* pauth not yet supported. */ + current_process ()->tdesc = aarch64_linux_read_description (vq, false); } 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 1b2453aa30d..bf24a27c598 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 (0); + const target_desc *tdesc = aarch64_linux_read_description (0, false); SELF_CHECK (*tdesc == *tdesc_aarch64); } } diff --git a/gdb/gdbserver/linux-aarch64-tdesc.c b/gdb/gdbserver/linux-aarch64-tdesc.c index 6ab473ea51c..6f9b4f1efc6 100644 --- a/gdb/gdbserver/linux-aarch64-tdesc.c +++ b/gdb/gdbserver/linux-aarch64-tdesc.c @@ -24,22 +24,22 @@ #include /* All possible aarch64 target descriptors. */ -struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1]; +struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/]; /* Create the aarch64 target description. */ const target_desc * -aarch64_linux_read_description (uint64_t vq) +aarch64_linux_read_description (uint64_t vq, bool pauth_p) { 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]; + struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p]; if (tdesc == NULL) { - tdesc = aarch64_create_target_description (vq); + tdesc = aarch64_create_target_description (vq, pauth_p); static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL }; static const char *expedite_regs_aarch64_sve[] = { "x29", "sp", "pc", @@ -50,7 +50,7 @@ aarch64_linux_read_description (uint64_t vq) else init_target_desc (tdesc, expedite_regs_aarch64_sve); - tdesc_aarch64_list[vq] = tdesc; + tdesc_aarch64_list[vq][pauth_p] = tdesc; } return tdesc; diff --git a/gdb/gdbserver/linux-aarch64-tdesc.h b/gdb/gdbserver/linux-aarch64-tdesc.h index 7ce81506636..06b3ec9b1e6 100644 --- a/gdb/gdbserver/linux-aarch64-tdesc.h +++ b/gdb/gdbserver/linux-aarch64-tdesc.h @@ -20,7 +20,7 @@ #ifndef GDBSERVER_LINUX_AARCH64_TDESC_H #define GDBSERVER_LINUX_AARCH64_TDESC_H -const target_desc * aarch64_linux_read_description (uint64_t vq); +const target_desc * aarch64_linux_read_description (uint64_t vq, bool pauth_p); #if GDB_SELF_TEST void initialize_low_tdesc ();