Skip to content

Commit 4035c22

Browse files
brooniectmarinas
authored andcommitted
arm64/ptrace: Expose FPMR via ptrace
Add a new regset to expose FPMR via ptrace. It is not added to the FPSIMD registers since that structure is exposed elsewhere without any allowance for extension we don't add there. Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 8c46def commit 4035c22

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

arch/arm64/kernel/ptrace.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,39 @@ static int tls_set(struct task_struct *target, const struct user_regset *regset,
698698
return ret;
699699
}
700700

701+
static int fpmr_get(struct task_struct *target, const struct user_regset *regset,
702+
struct membuf to)
703+
{
704+
if (!system_supports_fpmr())
705+
return -EINVAL;
706+
707+
if (target == current)
708+
fpsimd_preserve_current_state();
709+
710+
return membuf_store(&to, target->thread.uw.fpmr);
711+
}
712+
713+
static int fpmr_set(struct task_struct *target, const struct user_regset *regset,
714+
unsigned int pos, unsigned int count,
715+
const void *kbuf, const void __user *ubuf)
716+
{
717+
int ret;
718+
unsigned long fpmr;
719+
720+
if (!system_supports_fpmr())
721+
return -EINVAL;
722+
723+
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &fpmr, 0, count);
724+
if (ret)
725+
return ret;
726+
727+
target->thread.uw.fpmr = fpmr;
728+
729+
fpsimd_flush_task_state(target);
730+
731+
return 0;
732+
}
733+
701734
static int system_call_get(struct task_struct *target,
702735
const struct user_regset *regset,
703736
struct membuf to)
@@ -1419,6 +1452,7 @@ enum aarch64_regset {
14191452
REGSET_HW_BREAK,
14201453
REGSET_HW_WATCH,
14211454
#endif
1455+
REGSET_FPMR,
14221456
REGSET_SYSTEM_CALL,
14231457
#ifdef CONFIG_ARM64_SVE
14241458
REGSET_SVE,
@@ -1497,6 +1531,14 @@ static const struct user_regset aarch64_regsets[] = {
14971531
.regset_get = system_call_get,
14981532
.set = system_call_set,
14991533
},
1534+
[REGSET_FPMR] = {
1535+
.core_note_type = NT_ARM_FPMR,
1536+
.n = 1,
1537+
.size = sizeof(u64),
1538+
.align = sizeof(u64),
1539+
.regset_get = fpmr_get,
1540+
.set = fpmr_set,
1541+
},
15001542
#ifdef CONFIG_ARM64_SVE
15011543
[REGSET_SVE] = { /* Scalable Vector Extension */
15021544
.core_note_type = NT_ARM_SVE,

include/uapi/linux/elf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ typedef struct elf64_shdr {
440440
#define NT_ARM_SSVE 0x40b /* ARM Streaming SVE registers */
441441
#define NT_ARM_ZA 0x40c /* ARM SME ZA registers */
442442
#define NT_ARM_ZT 0x40d /* ARM SME ZT registers */
443+
#define NT_ARM_FPMR 0x40e /* ARM floating point mode register */
443444
#define NT_ARC_V2 0x600 /* ARCv2 accumulator/extra registers */
444445
#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note */
445446
#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers */

0 commit comments

Comments
 (0)