Skip to content

Commit b0f3bdc

Browse files
specialpointcentralchenhuacai
authored andcommitted
LoongArch: Fix missing fcsr in ptrace's fpr_set
In file ptrace.c, function fpr_set does not copy fcsr data from ubuf to kbuf. That's the reason why fcsr cannot be modified by ptrace. This patch fixs this problem and allows users using ptrace to modify the fcsr. Co-developed-by: Xu Li <[email protected]> Signed-off-by: Qi Hu <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 1aea29d commit b0f3bdc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

arch/loongarch/kernel/ptrace.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static int fpr_set(struct task_struct *target,
193193
const void *kbuf, const void __user *ubuf)
194194
{
195195
const int fcc_start = NUM_FPU_REGS * sizeof(elf_fpreg_t);
196-
const int fcc_end = fcc_start + sizeof(u64);
196+
const int fcsr_start = fcc_start + sizeof(u64);
197197
int err;
198198

199199
BUG_ON(count % sizeof(elf_fpreg_t));
@@ -209,10 +209,12 @@ static int fpr_set(struct task_struct *target,
209209
if (err)
210210
return err;
211211

212-
if (count > 0)
213-
err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf,
214-
&target->thread.fpu.fcc,
215-
fcc_start, fcc_end);
212+
err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf,
213+
&target->thread.fpu.fcc, fcc_start,
214+
fcc_start + sizeof(u64));
215+
err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf,
216+
&target->thread.fpu.fcsr, fcsr_start,
217+
fcsr_start + sizeof(u32));
216218

217219
return err;
218220
}

0 commit comments

Comments
 (0)