ptrace-novsx.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. * Regardless of transactions, 'fp_state' holds the current running
  7. * value of all FPR registers and 'ckfp_state' holds the last checkpointed
  8. * value of all FPR registers for the current transaction.
  9. *
  10. * Userspace interface buffer layout:
  11. *
  12. * struct data {
  13. * u64 fpr[32];
  14. * u64 fpscr;
  15. * };
  16. */
  17. int fpr_get(struct task_struct *target, const struct user_regset *regset,
  18. struct membuf to)
  19. {
  20. #ifdef CONFIG_PPC_FPU_REGS
  21. BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
  22. offsetof(struct thread_fp_state, fpr[32]));
  23. flush_fp_to_thread(target);
  24. return membuf_write(&to, &target->thread.fp_state, 33 * sizeof(u64));
  25. #else
  26. return membuf_write(&to, &empty_zero_page, 33 * sizeof(u64));
  27. #endif
  28. }
  29. /*
  30. * Regardless of transactions, 'fp_state' holds the current running
  31. * value of all FPR registers and 'ckfp_state' holds the last checkpointed
  32. * value of all FPR registers for the current transaction.
  33. *
  34. * Userspace interface buffer layout:
  35. *
  36. * struct data {
  37. * u64 fpr[32];
  38. * u64 fpscr;
  39. * };
  40. *
  41. */
  42. int fpr_set(struct task_struct *target, const struct user_regset *regset,
  43. unsigned int pos, unsigned int count,
  44. const void *kbuf, const void __user *ubuf)
  45. {
  46. #ifdef CONFIG_PPC_FPU_REGS
  47. BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
  48. offsetof(struct thread_fp_state, fpr[32]));
  49. flush_fp_to_thread(target);
  50. return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
  51. &target->thread.fp_state, 0, -1);
  52. #else
  53. return 0;
  54. #endif
  55. }