^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/regset.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <asm/switch_to.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include "ptrace-decl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Regardless of transactions, 'fp_state' holds the current running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * value of all FPR registers and 'ckfp_state' holds the last checkpointed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * value of all FPR registers for the current transaction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Userspace interface buffer layout:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * struct data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * u64 fpr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * u64 fpscr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) int fpr_get(struct task_struct *target, const struct user_regset *regset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct membuf to)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) offsetof(struct thread_fp_state, fpr[32]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) flush_fp_to_thread(target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) return membuf_write(&to, &target->thread.fp_state, 33 * sizeof(u64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * Regardless of transactions, 'fp_state' holds the current running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * value of all FPR registers and 'ckfp_state' holds the last checkpointed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * value of all FPR registers for the current transaction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * Userspace interface buffer layout:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * struct data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * u64 fpr[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * u64 fpscr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) int fpr_set(struct task_struct *target, const struct user_regset *regset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) unsigned int pos, unsigned int count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) const void *kbuf, const void __user *ubuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) offsetof(struct thread_fp_state, fpr[32]));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) flush_fp_to_thread(target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) &target->thread.fp_state, 0, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }