Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 
0003 #include <linux/regset.h>
0004 
0005 #include <asm/switch_to.h>
0006 
0007 #include "ptrace-decl.h"
0008 
0009 /*
0010  * For get_evrregs/set_evrregs functions 'data' has the following layout:
0011  *
0012  * struct {
0013  *   u32 evr[32];
0014  *   u64 acc;
0015  *   u32 spefscr;
0016  * }
0017  */
0018 
0019 int evr_active(struct task_struct *target, const struct user_regset *regset)
0020 {
0021     flush_spe_to_thread(target);
0022     return target->thread.used_spe ? regset->n : 0;
0023 }
0024 
0025 int evr_get(struct task_struct *target, const struct user_regset *regset,
0026         struct membuf to)
0027 {
0028     flush_spe_to_thread(target);
0029 
0030     membuf_write(&to, &target->thread.evr, sizeof(target->thread.evr));
0031 
0032     BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
0033              offsetof(struct thread_struct, spefscr));
0034 
0035     return membuf_write(&to, &target->thread.acc,
0036                 sizeof(u64) + sizeof(u32));
0037 }
0038 
0039 int evr_set(struct task_struct *target, const struct user_regset *regset,
0040         unsigned int pos, unsigned int count,
0041         const void *kbuf, const void __user *ubuf)
0042 {
0043     int ret;
0044 
0045     flush_spe_to_thread(target);
0046 
0047     ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
0048                  &target->thread.evr,
0049                  0, sizeof(target->thread.evr));
0050 
0051     BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
0052              offsetof(struct thread_struct, spefscr));
0053 
0054     if (!ret)
0055         ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
0056                      &target->thread.acc,
0057                      sizeof(target->thread.evr), -1);
0058 
0059     return ret;
0060 }