Skip to content

Commit ee4fbcf

Browse files
committed
AArch64: Use HWCAP to detect pauth feature
Add aarch64_get_hwcap functions for reading the HWCAP. From this extract the PACA value and use this to enable pauth. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_linux_nat_target::read_description): Read PACA hwcap. * aarch64-linux-tdep.c (aarch64_linux_core_read_description): Likewise. (aarch64_linux_get_hwcap): New function. * aarch64-linux-tdep.h (AARCH64_HWCAP_PACA): New define. (aarch64_linux_get_hwcap): New declaration. gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (AARCH64_HWCAP_PACA): New define. (aarch64_get_hwcap): New function. (aarch64_arch_setup): Read APIA hwcap.
1 parent 6dc0ebd commit ee4fbcf

File tree

6 files changed

+72
-8
lines changed

6 files changed

+72
-8
lines changed

gdb/ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2019-03-22 Alan Hayward <alan.hayward@arm.com>
2+
Jiong Wang <jiong.wang@arm.com>
3+
4+
* aarch64-linux-nat.c
5+
(aarch64_linux_nat_target::read_description): Read PACA hwcap.
6+
* aarch64-linux-tdep.c
7+
(aarch64_linux_core_read_description): Likewise.
8+
(aarch64_linux_get_hwcap): New function.
9+
* aarch64-linux-tdep.h (AARCH64_HWCAP_PACA): New define.
10+
(aarch64_linux_get_hwcap): New declaration.
11+
112
2019-03-22 Alan Hayward <alan.hayward@arm.com>
213
Jiong Wang <jiong.wang@arm.com>
314

gdb/aarch64-linux-nat.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,11 @@ aarch64_linux_nat_target::read_description ()
606606
if (ret == 0)
607607
return tdesc_arm_with_neon;
608608

609-
/* pauth not yet supported. */
610-
return aarch64_read_description (aarch64_sve_get_vq (tid), false);
609+
CORE_ADDR hwcap = 0;
610+
bool pauth_p = aarch64_linux_get_hwcap (this, &hwcap)
611+
&& (hwcap & AARCH64_HWCAP_PACA);
612+
613+
return aarch64_read_description (aarch64_sve_get_vq (tid), pauth_p);
611614
}
612615

613616
/* Convert a native/host siginfo object, into/from the siginfo in the

gdb/aarch64-linux-tdep.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,11 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
637637
{
638638
CORE_ADDR aarch64_hwcap = 0;
639639

640-
if (target_auxv_search (target, AT_HWCAP, &aarch64_hwcap) != 1)
641-
return NULL;
640+
if (!aarch64_linux_get_hwcap (target, &aarch64_hwcap))
641+
return nullptr;
642642

643-
/* pauth not yet supported. */
644643
return aarch64_read_description (aarch64_linux_core_read_vq (gdbarch, abfd),
645-
false);
644+
aarch64_hwcap & AARCH64_HWCAP_PACA);
646645
}
647646

648647
/* Implementation of `gdbarch_stap_is_single_operand', as defined in
@@ -1420,6 +1419,15 @@ aarch64_linux_gcc_target_options (struct gdbarch *gdbarch)
14201419
return NULL;
14211420
}
14221421

1422+
/* See aarch64-linux-tdep.h. */
1423+
1424+
bool
1425+
aarch64_linux_get_hwcap (struct target_ops *target, CORE_ADDR *hwcap)
1426+
{
1427+
*hwcap = 0;
1428+
return target_auxv_search (target, AT_HWCAP, hwcap) == 1;
1429+
}
1430+
14231431
static void
14241432
aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
14251433
{

gdb/aarch64-linux-tdep.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,10 @@
3636
extern const struct regset aarch64_linux_gregset;
3737
extern const struct regset aarch64_linux_fpregset;
3838

39+
/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */
40+
#define AARCH64_HWCAP_PACA (1 << 30)
41+
42+
/* Fetch the AT_HWCAP entry from the auxv vector for the given TARGET. */
43+
bool aarch64_linux_get_hwcap (struct target_ops *target, CORE_ADDR *hwcap);
44+
3945
#endif /* AARCH64_LINUX_TDEP_H */

gdb/gdbserver/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2019-03-22 Alan Hayward <alan.hayward@arm.com>
2+
Jiong Wang <jiong.wang@arm.com>
3+
4+
* linux-aarch64-low.c (AARCH64_HWCAP_PACA): New define.
5+
(aarch64_get_hwcap): New function.
6+
(aarch64_arch_setup): Read APIA hwcap.
7+
18
2019-03-22 Alan Hayward <alan.hayward@arm.com>
29
Jiong Wang <jiong.wang@arm.com>
310

gdb/gdbserver/linux-aarch64-low.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,33 @@ aarch64_linux_new_fork (struct process_info *parent,
485485
*child->priv->arch_private = *parent->priv->arch_private;
486486
}
487487

488+
/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */
489+
#define AARCH64_HWCAP_PACA (1 << 30)
490+
491+
/* Fetch the AT_HWCAP entry from the auxv vector. */
492+
493+
static bool
494+
aarch64_get_hwcap (unsigned long *valp)
495+
{
496+
unsigned char *data = (unsigned char *) alloca (16);
497+
int offset = 0;
498+
499+
while ((*the_target->read_auxv) (offset, data, 16) == 16)
500+
{
501+
unsigned long *data_p = (unsigned long *)data;
502+
if (data_p[0] == AT_HWCAP)
503+
{
504+
*valp = data_p[1];
505+
return true;
506+
}
507+
508+
offset += 16;
509+
}
510+
511+
*valp = 0;
512+
return false;
513+
}
514+
488515
/* Implementation of linux_target_ops method "arch_setup". */
489516

490517
static void
@@ -501,8 +528,10 @@ aarch64_arch_setup (void)
501528
if (is_elf64)
502529
{
503530
uint64_t vq = aarch64_sve_get_vq (tid);
504-
/* pauth not yet supported. */
505-
current_process ()->tdesc = aarch64_linux_read_description (vq, false);
531+
unsigned long hwcap = 0;
532+
bool pauth_p = aarch64_get_hwcap (&hwcap) && (hwcap & AARCH64_HWCAP_PACA);
533+
534+
current_process ()->tdesc = aarch64_linux_read_description (vq, pauth_p);
506535
}
507536
else
508537
current_process ()->tdesc = tdesc_arm_with_neon;

0 commit comments

Comments
 (0)