Commit 4035c22e authored by Mark Brown's avatar Mark Brown Committed by Catalin Marinas
Browse files

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: default avatarMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20240306-arm64-2023-dpisa-v5-5-c568edc8ed7f@kernel.org


Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 8c46def4
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -698,6 +698,39 @@ static int tls_set(struct task_struct *target, const struct user_regset *regset,
	return ret;
}

static int fpmr_get(struct task_struct *target, const struct user_regset *regset,
		   struct membuf to)
{
	if (!system_supports_fpmr())
		return -EINVAL;

	if (target == current)
		fpsimd_preserve_current_state();

	return membuf_store(&to, target->thread.uw.fpmr);
}

static int fpmr_set(struct task_struct *target, const struct user_regset *regset,
		   unsigned int pos, unsigned int count,
		   const void *kbuf, const void __user *ubuf)
{
	int ret;
	unsigned long fpmr;

	if (!system_supports_fpmr())
		return -EINVAL;

	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &fpmr, 0, count);
	if (ret)
		return ret;

	target->thread.uw.fpmr = fpmr;

	fpsimd_flush_task_state(target);

	return 0;
}

static int system_call_get(struct task_struct *target,
			   const struct user_regset *regset,
			   struct membuf to)
@@ -1419,6 +1452,7 @@ enum aarch64_regset {
	REGSET_HW_BREAK,
	REGSET_HW_WATCH,
#endif
	REGSET_FPMR,
	REGSET_SYSTEM_CALL,
#ifdef CONFIG_ARM64_SVE
	REGSET_SVE,
@@ -1497,6 +1531,14 @@ static const struct user_regset aarch64_regsets[] = {
		.regset_get = system_call_get,
		.set = system_call_set,
	},
	[REGSET_FPMR] = {
		.core_note_type = NT_ARM_FPMR,
		.n = 1,
		.size = sizeof(u64),
		.align = sizeof(u64),
		.regset_get = fpmr_get,
		.set = fpmr_set,
	},
#ifdef CONFIG_ARM64_SVE
	[REGSET_SVE] = { /* Scalable Vector Extension */
		.core_note_type = NT_ARM_SVE,
+1 −0
Original line number Diff line number Diff line
@@ -440,6 +440,7 @@ typedef struct elf64_shdr {
#define NT_ARM_SSVE	0x40b		/* ARM Streaming SVE registers */
#define NT_ARM_ZA	0x40c		/* ARM SME ZA registers */
#define NT_ARM_ZT	0x40d		/* ARM SME ZT registers */
#define NT_ARM_FPMR	0x40e		/* ARM floating point mode register */
#define NT_ARC_V2	0x600		/* ARCv2 accumulator/extra registers */
#define NT_VMCOREDD	0x700		/* Vmcore Device Dump Note */
#define NT_MIPS_DSP	0x800		/* MIPS DSP ASE registers */