On Sat, Aug 17, 2024 at 01:36:33AM +0200, Mark Wielaard wrote:
> Hi,
>
> On Wed, Aug 14, 2024 at 04:51:19PM +0800, Kuan-Ying Lee wrote:
> > Add the NT_ARM_PAC_MASK and NT_ARM_PAC_ENABLED_KEYS for aarch64.
> > Recognize and print the new core item.
>
> For NT_ARM_PAC_MASK it looks like the user_pac_mask struct, so two 8
> byte words. But for NT_ARM_PAC_ENABLED_KEYS I cannot find the
> definition. This assumes it is just one 8 byte word. Is that correct?
> Can it be more than one?
>
Hi Mark,
Thanks for your review.
I believe it should be exactly one 8-byte word in size.
I based this on the following code[1]:
| [REGSET_PAC_ENABLED_KEYS] = {
| .core_note_type = NT_ARM_PAC_ENABLED_KEYS,
| .n = 1,
| .size = sizeof(long),
| .align = sizeof(long),
| .regset_get = pac_enabled_keys_get,
| .set = pac_enabled_keys_set,
The size is sizeof(long), and n is 1.
It seems that there is only 1 8-byte word for arm64.
[1]
https://elixir.bootlin.com/linux/v6.10.5/source/arch/arm64/kernel/ptrace.c#L1595
Thanks,
Kuan-Ying Lee
> Thanks,
>
> Mark
>
> > Signed-off-by: Kuan-Ying Lee <[email protected]>
> > ---
> > backends/aarch64_corenote.c | 24 +++++++++++++++++++++++-
> > libebl/eblcorenotetypename.c | 2 ++
> > 2 files changed, 25 insertions(+), 1 deletion(-)
> >
> > diff --git a/backends/aarch64_corenote.c b/backends/aarch64_corenote.c
> > index bd0a4a725411..35c8e8012c7b 100644
> > --- a/backends/aarch64_corenote.c
> > +++ b/backends/aarch64_corenote.c
> > @@ -115,6 +115,26 @@ static const Ebl_Core_Item aarch64_mte_items [] =
> > }
> > };
> >
> > +static const Ebl_Core_Item aarch64_pac_enabled_items [] =
> > + {
> > + {
> > + .name = "enabled_keys", .type = ELF_T_XWORD, .format = 'x',
> > + .offset = 0, .group = "register"
> > + }
> > + };
> > +
> > +static const Ebl_Core_Item aarch64_pac_mask_items [] =
> > + {
> > + {
> > + .name = "pauth_dmask", .type = ELF_T_XWORD, .format = 'x',
> > + .offset = 0, .group = "register"
> > + },
> > + {
> > + .name = "pauth_cmask", .type = ELF_T_XWORD, .format = 'x',
> > + .offset = 8, .group = "register"
> > + }
> > + };
> > +
> > #define AARCH64_HWBP_REG(KIND, N) \
> > {
> > \
> > .name = "DBG" KIND "VR" #N "_EL1", .type = ELF_T_XWORD, .format =
> > 'x', \
> > @@ -176,6 +196,8 @@ AARCH64_BP_WP_GROUP ("W", aarch64_hw_wp_items);
> > EXTRA_ITEMS (NT_ARM_HW_BREAK, 264, aarch64_hw_bp_items) \
> > EXTRA_ITEMS (NT_ARM_HW_WATCH, 264, aarch64_hw_wp_items) \
> > EXTRA_ITEMS (NT_ARM_SYSTEM_CALL, 4, aarch64_syscall_items) \
> > - EXTRA_ITEMS (NT_ARM_TAGGED_ADDR_CTRL, 8, aarch64_mte_items)
> > + EXTRA_ITEMS (NT_ARM_TAGGED_ADDR_CTRL, 8, aarch64_mte_items) \
> > + EXTRA_ITEMS (NT_ARM_PAC_ENABLED_KEYS, 8, aarch64_pac_enabled_items) \
> > + EXTRA_ITEMS (NT_ARM_PAC_MASK, 16, aarch64_pac_mask_items)
> >
> > #include "linux-core-note.c"
> > diff --git a/libebl/eblcorenotetypename.c b/libebl/eblcorenotetypename.c
> > index 49331bdf76e8..3e2f8daa0fd5 100644
> > --- a/libebl/eblcorenotetypename.c
> > +++ b/libebl/eblcorenotetypename.c
> > @@ -93,6 +93,8 @@ ebl_core_note_type_name (Ebl *ebl, uint32_t type, char
> > *buf, size_t len)
> > KNOWNSTYPE (ARM_HW_WATCH);
> > KNOWNSTYPE (ARM_SYSTEM_CALL);
> > KNOWNSTYPE (ARM_TAGGED_ADDR_CTRL);
> > + KNOWNSTYPE (ARM_PAC_ENABLED_KEYS);
> > + KNOWNSTYPE (ARM_PAC_MASK);
> > KNOWNSTYPE (SIGINFO);
> > KNOWNSTYPE (FILE);
> > #undef KNOWNSTYPE
> > --
> > 2.43.0
> >