ptrace-spe.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. #include <linux/regset.h>
  3. #include <asm/switch_to.h>
  4. #include "ptrace-decl.h"
  5. /*
  6. * For get_evrregs/set_evrregs functions 'data' has the following layout:
  7. *
  8. * struct {
  9. * u32 evr[32];
  10. * u64 acc;
  11. * u32 spefscr;
  12. * }
  13. */
  14. int evr_active(struct task_struct *target, const struct user_regset *regset)
  15. {
  16. flush_spe_to_thread(target);
  17. return target->thread.used_spe ? regset->n : 0;
  18. }
  19. int evr_get(struct task_struct *target, const struct user_regset *regset,
  20. struct membuf to)
  21. {
  22. flush_spe_to_thread(target);
  23. membuf_write(&to, &target->thread.evr, sizeof(target->thread.evr));
  24. BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
  25. offsetof(struct thread_struct, spefscr));
  26. return membuf_write(&to, &target->thread.acc,
  27. sizeof(u64) + sizeof(u32));
  28. }
  29. int evr_set(struct task_struct *target, const struct user_regset *regset,
  30. unsigned int pos, unsigned int count,
  31. const void *kbuf, const void __user *ubuf)
  32. {
  33. int ret;
  34. flush_spe_to_thread(target);
  35. ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
  36. &target->thread.evr,
  37. 0, sizeof(target->thread.evr));
  38. BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
  39. offsetof(struct thread_struct, spefscr));
  40. if (!ret)
  41. ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
  42. &target->thread.acc,
  43. sizeof(target->thread.evr), -1);
  44. return ret;
  45. }