From: Alan Hayward <Alan.Hayward@arm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: nd <nd@arm.com>, Alan Hayward <Alan.Hayward@arm.com>
Subject: [PATCH v2 4/8] AArch64: gdbserver: read pauth registers
Date: Wed, 06 Mar 2019 13:33:00 -0000 [thread overview]
Message-ID: <20190306133325.2531-5-alan.hayward@arm.com> (raw)
In-Reply-To: <20190306133325.2531-1-alan.hayward@arm.com>
Add the pauth registers to the regset lists.
Add a new regset type OPTIONAL_REGS which allows for the regset read to fail.
Once the read fails, it will not be checked again. This allows targets with
optional features to keep a single static regset_info structure.
gdb/ChangeLog:
2019-03-06 Alan Hayward <alan.hayward@arm.com>
Jiong Wang <jiong.wang@arm.com>
* arch/aarch64.h (AARCH64_PAUTH_REGS_SIZE): New define.
gdb/gdbserver/ChangeLog:
2019-03-06 Alan Hayward <alan.hayward@arm.com>
Jiong Wang <jiong.wang@arm.com>
* linux-aarch64-low.c (aarch64_store_pauthregset): New function.
* linux-low.c (regsets_store_inferior_registers): Allow optional reads
to fail.
* linux-low.h (enum regset_type): Add OPTIONAL_REGS.
---
gdb/arch/aarch64.h | 1 +
gdb/gdbserver/linux-aarch64-low.c | 23 +++++++++++++++++++++++
gdb/gdbserver/linux-low.c | 14 ++++++++------
gdb/gdbserver/linux-low.h | 1 +
4 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index 8c80b7be62..309fe75273 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -68,6 +68,7 @@ enum aarch64_regnum
#define AARCH64_PAUTH_DMASK_REGNUM(pauth_reg_base) (pauth_reg_base)
#define AARCH64_PAUTH_CMASK_REGNUM(pauth_reg_base) (pauth_reg_base + 1)
+#define AARCH64_PAUTH_REGS_SIZE (16)
#define AARCH64_X_REGS_NUM 31
#define AARCH64_V_REGS_NUM 32
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index e2e25f0e27..20c75493b0 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -135,6 +135,23 @@ aarch64_store_fpregset (struct regcache *regcache, const void *buf)
supply_register (regcache, AARCH64_FPCR_REGNUM, ®set->fpcr);
}
+/* Store the pauth registers to regcache. */
+
+static void
+aarch64_store_pauthregset (struct regcache *regcache, const void *buf)
+{
+ uint64_t *pauth_regset = (uint64_t *) buf;
+ int pauth_base = find_regno (regcache->tdesc, "pauth_dmask");
+
+ if (pauth_base == 0)
+ return;
+
+ supply_register (regcache, AARCH64_PAUTH_DMASK_REGNUM (pauth_base),
+ &pauth_regset[0]);
+ supply_register (regcache, AARCH64_PAUTH_CMASK_REGNUM (pauth_base),
+ &pauth_regset[1]);
+}
+
/* Enable miscellaneous debugging output. The name is historical - it
was originally used to debug LinuxThreads support. */
extern int debug_threads;
@@ -564,6 +581,9 @@ static struct regset_info aarch64_regsets[] =
sizeof (struct user_fpsimd_state), FP_REGS,
aarch64_fill_fpregset, aarch64_store_fpregset
},
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK,
+ AARCH64_PAUTH_REGS_SIZE, OPTIONAL_REGS,
+ NULL, aarch64_store_pauthregset },
NULL_REGSET
};
@@ -590,6 +610,9 @@ static struct regset_info aarch64_sve_regsets[] =
SVE_PT_SIZE (AARCH64_MAX_SVE_VQ, SVE_PT_REGS_SVE), EXTENDED_REGS,
aarch64_sve_regs_copy_from_regcache, aarch64_sve_regs_copy_to_regcache
},
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK,
+ AARCH64_PAUTH_REGS_SIZE, OPTIONAL_REGS,
+ NULL, aarch64_store_pauthregset },
NULL_REGSET
};
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 8c5a51f23c..e1cb7fcfbc 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -5359,10 +5359,11 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
#endif
if (res < 0)
{
- if (errno == EIO)
+ if (errno == EIO
+ || (errno == EINVAL && regset->type == OPTIONAL_REGS))
{
- /* If we get EIO on a regset, do not try it again for
- this process mode. */
+ /* If we get EIO on a regset, or an EINVAL and the regset is
+ optional, do not try it again for this process mode. */
disable_regset (regsets_info, regset);
}
else if (errno == ENODATA)
@@ -5457,10 +5458,11 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info,
if (res < 0)
{
- if (errno == EIO)
+ if (errno == EIO
+ || (errno == EINVAL && regset->type == OPTIONAL_REGS))
{
- /* If we get EIO on a regset, do not try it again for
- this process mode. */
+ /* If we get EIO on a regset, or an EINVAL and the regset is
+ optional, do not try it again for this process mode. */
disable_regset (regsets_info, regset);
}
else if (errno == ESRCH)
diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h
index d09390dd99..1ade35d648 100644
--- a/gdb/gdbserver/linux-low.h
+++ b/gdb/gdbserver/linux-low.h
@@ -40,6 +40,7 @@ enum regset_type {
GENERAL_REGS,
FP_REGS,
EXTENDED_REGS,
+ OPTIONAL_REGS, /* Do not error if the regset cannot be accessed. */
};
/* The arch's regsets array initializer must be terminated with a NULL
--
2.17.2 (Apple Git-113)
next prev parent reply other threads:[~2019-03-06 13:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-06 13:33 [PATCH v2 0/8] Support for AArch64 Pointer Authentication Alan Hayward
2019-03-06 13:33 ` [PATCH v2 7/8] AArch64: Prologue scan unwinder support for signed return addresses Alan Hayward
2019-03-06 13:33 ` [PATCH v2 5/8] AArch64: Add pauth DWARF registers Alan Hayward
2019-03-06 13:33 ` [PATCH v2 2/8] AArch64: Use HWCAP to detect pauth feature Alan Hayward
2019-03-21 20:51 ` Simon Marchi
2019-03-22 12:06 ` Alan Hayward
2019-03-06 13:33 ` [PATCH v2 8/8] AArch64: Read pauth section from core files Alan Hayward
2019-03-06 13:33 ` [PATCH v2 1/8] AArch64: Add pointer authentication feature Alan Hayward
2019-03-06 15:36 ` Eli Zaretskii
2019-03-06 13:33 ` Alan Hayward [this message]
2019-03-21 21:03 ` [PATCH v2 4/8] AArch64: gdbserver: read pauth registers Simon Marchi
2019-03-06 13:33 ` [PATCH v2 3/8] AArch64: Read " Alan Hayward
2019-03-21 20:56 ` Simon Marchi
2019-03-06 13:33 ` [PATCH v2 6/8] AArch64: DWARF unwinder support for signed return addresses Alan Hayward
2019-03-14 12:34 ` [PATCH v2 0/8] Support for AArch64 Pointer Authentication Alan Hayward
2019-03-21 21:29 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190306133325.2531-5-alan.hayward@arm.com \
--to=alan.hayward@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox