Skip to content

Commit c9d6699

Browse files
Suzuki K Poulosewilldeacon
authored andcommitted
arm64: ptrace: nofpsimd: Fail FP/SIMD regset operations
When fp/simd is not supported on the system, fail the operations of FP/SIMD regsets. Fixes: 82e0191 ("arm64: Support systems without FP/ASIMD") Cc: Will Deacon <[email protected]> Cc: Mark Rutland <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 7559950 commit c9d6699

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

arch/arm64/kernel/ptrace.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,13 @@ static int gpr_set(struct task_struct *target, const struct user_regset *regset,
615615
return 0;
616616
}
617617

618+
static int fpr_active(struct task_struct *target, const struct user_regset *regset)
619+
{
620+
if (!system_supports_fpsimd())
621+
return -ENODEV;
622+
return regset->n;
623+
}
624+
618625
/*
619626
* TODO: update fp accessors for lazy context switching (sync/flush hwstate)
620627
*/
@@ -637,6 +644,9 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset,
637644
unsigned int pos, unsigned int count,
638645
void *kbuf, void __user *ubuf)
639646
{
647+
if (!system_supports_fpsimd())
648+
return -EINVAL;
649+
640650
if (target == current)
641651
fpsimd_preserve_current_state();
642652

@@ -676,6 +686,9 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,
676686
{
677687
int ret;
678688

689+
if (!system_supports_fpsimd())
690+
return -EINVAL;
691+
679692
ret = __fpr_set(target, regset, pos, count, kbuf, ubuf, 0);
680693
if (ret)
681694
return ret;
@@ -1134,6 +1147,7 @@ static const struct user_regset aarch64_regsets[] = {
11341147
*/
11351148
.size = sizeof(u32),
11361149
.align = sizeof(u32),
1150+
.active = fpr_active,
11371151
.get = fpr_get,
11381152
.set = fpr_set
11391153
},
@@ -1348,6 +1362,9 @@ static int compat_vfp_get(struct task_struct *target,
13481362
compat_ulong_t fpscr;
13491363
int ret, vregs_end_pos;
13501364

1365+
if (!system_supports_fpsimd())
1366+
return -EINVAL;
1367+
13511368
uregs = &target->thread.uw.fpsimd_state;
13521369

13531370
if (target == current)
@@ -1381,6 +1398,9 @@ static int compat_vfp_set(struct task_struct *target,
13811398
compat_ulong_t fpscr;
13821399
int ret, vregs_end_pos;
13831400

1401+
if (!system_supports_fpsimd())
1402+
return -EINVAL;
1403+
13841404
uregs = &target->thread.uw.fpsimd_state;
13851405

13861406
vregs_end_pos = VFP_STATE_SIZE - sizeof(compat_ulong_t);
@@ -1438,6 +1458,7 @@ static const struct user_regset aarch32_regsets[] = {
14381458
.n = VFP_STATE_SIZE / sizeof(compat_ulong_t),
14391459
.size = sizeof(compat_ulong_t),
14401460
.align = sizeof(compat_ulong_t),
1461+
.active = fpr_active,
14411462
.get = compat_vfp_get,
14421463
.set = compat_vfp_set
14431464
},

0 commit comments

Comments
 (0)