Skip to content

Commit 1ef53e6

Browse files
committed
AArch64: gdbserver: read pauth registers
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: * arch/aarch64.h (AARCH64_PAUTH_REGS_SIZE): New define. gdb/gdbserver/ChangeLog: * 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.
1 parent 76bed0f commit 1ef53e6

File tree

6 files changed

+46
-6
lines changed

6 files changed

+46
-6
lines changed

gdb/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2019-03-22 Alan Hayward <alan.hayward@arm.com>
2+
Jiong Wang <jiong.wang@arm.com>
3+
4+
* arch/aarch64.h (AARCH64_PAUTH_REGS_SIZE): New define.
5+
16
2019-03-22 Alan Hayward <alan.hayward@arm.com>
27
Jiong Wang <jiong.wang@arm.com>
38

gdb/arch/aarch64.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ enum aarch64_regnum
6868

6969
#define AARCH64_PAUTH_DMASK_REGNUM(pauth_reg_base) (pauth_reg_base)
7070
#define AARCH64_PAUTH_CMASK_REGNUM(pauth_reg_base) (pauth_reg_base + 1)
71+
#define AARCH64_PAUTH_REGS_SIZE (16)
7172

7273
#define AARCH64_X_REGS_NUM 31
7374
#define AARCH64_V_REGS_NUM 32

gdb/gdbserver/ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2019-03-22 Alan Hayward <alan.hayward@arm.com>
2+
Jiong Wang <jiong.wang@arm.com>
3+
4+
* linux-aarch64-low.c (aarch64_store_pauthregset): New function.
5+
* linux-low.c (regsets_store_inferior_registers): Allow optional reads
6+
to fail.
7+
* linux-low.h (enum regset_type): Add OPTIONAL_REGS.
8+
19
2019-03-22 Alan Hayward <alan.hayward@arm.com>
210
Jiong Wang <jiong.wang@arm.com>
311

gdb/gdbserver/linux-aarch64-low.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@ aarch64_store_fpregset (struct regcache *regcache, const void *buf)
135135
supply_register (regcache, AARCH64_FPCR_REGNUM, &regset->fpcr);
136136
}
137137

138+
/* Store the pauth registers to regcache. */
139+
140+
static void
141+
aarch64_store_pauthregset (struct regcache *regcache, const void *buf)
142+
{
143+
uint64_t *pauth_regset = (uint64_t *) buf;
144+
int pauth_base = find_regno (regcache->tdesc, "pauth_dmask");
145+
146+
if (pauth_base == 0)
147+
return;
148+
149+
supply_register (regcache, AARCH64_PAUTH_DMASK_REGNUM (pauth_base),
150+
&pauth_regset[0]);
151+
supply_register (regcache, AARCH64_PAUTH_CMASK_REGNUM (pauth_base),
152+
&pauth_regset[1]);
153+
}
154+
138155
/* Enable miscellaneous debugging output. The name is historical - it
139156
was originally used to debug LinuxThreads support. */
140157
extern int debug_threads;
@@ -564,6 +581,9 @@ static struct regset_info aarch64_regsets[] =
564581
sizeof (struct user_fpsimd_state), FP_REGS,
565582
aarch64_fill_fpregset, aarch64_store_fpregset
566583
},
584+
{ PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK,
585+
AARCH64_PAUTH_REGS_SIZE, OPTIONAL_REGS,
586+
NULL, aarch64_store_pauthregset },
567587
NULL_REGSET
568588
};
569589

@@ -590,6 +610,9 @@ static struct regset_info aarch64_sve_regsets[] =
590610
SVE_PT_SIZE (AARCH64_MAX_SVE_VQ, SVE_PT_REGS_SVE), EXTENDED_REGS,
591611
aarch64_sve_regs_copy_from_regcache, aarch64_sve_regs_copy_to_regcache
592612
},
613+
{ PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_PAC_MASK,
614+
AARCH64_PAUTH_REGS_SIZE, OPTIONAL_REGS,
615+
NULL, aarch64_store_pauthregset },
593616
NULL_REGSET
594617
};
595618

gdb/gdbserver/linux-low.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5358,10 +5358,11 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
53585358
#endif
53595359
if (res < 0)
53605360
{
5361-
if (errno == EIO)
5361+
if (errno == EIO
5362+
|| (errno == EINVAL && regset->type == OPTIONAL_REGS))
53625363
{
5363-
/* If we get EIO on a regset, do not try it again for
5364-
this process mode. */
5364+
/* If we get EIO on a regset, or an EINVAL and the regset is
5365+
optional, do not try it again for this process mode. */
53655366
disable_regset (regsets_info, regset);
53665367
}
53675368
else if (errno == ENODATA)
@@ -5456,10 +5457,11 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info,
54565457

54575458
if (res < 0)
54585459
{
5459-
if (errno == EIO)
5460+
if (errno == EIO
5461+
|| (errno == EINVAL && regset->type == OPTIONAL_REGS))
54605462
{
5461-
/* If we get EIO on a regset, do not try it again for
5462-
this process mode. */
5463+
/* If we get EIO on a regset, or an EINVAL and the regset is
5464+
optional, do not try it again for this process mode. */
54635465
disable_regset (regsets_info, regset);
54645466
}
54655467
else if (errno == ESRCH)

gdb/gdbserver/linux-low.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ enum regset_type {
4040
GENERAL_REGS,
4141
FP_REGS,
4242
EXTENDED_REGS,
43+
OPTIONAL_REGS, /* Do not error if the regset cannot be accessed. */
4344
};
4445

4546
/* The arch's regsets array initializer must be terminated with a NULL

0 commit comments

Comments
 (0)