diff options
author | Heiko Carstens <hca@linux.ibm.com> | 2024-02-03 11:45:15 +0100 |
---|---|---|
committer | Heiko Carstens <hca@linux.ibm.com> | 2024-02-16 14:30:16 +0100 |
commit | bdbd3acb33f5b09b99d75b0f0edeb7db98a05c89 (patch) | |
tree | b1589fdea4b9301980671fb803ea19d9695149be /arch/s390/kernel | |
parent | 9cbff7f2214d16af5c10f1f55ac72d4c1a8bd787 (diff) |
s390/fpu: remove anonymous union from struct fpu
The anonymous union within struct fpu contains a floating point register
array and a vector register array. Given that the vector register is always
present remove the floating point register array. For configurations
without vector registers save the floating point register contents within
their corresponding vector register location.
This allows to remove the union, and also to simplify ptrace and perf code.
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'arch/s390/kernel')
-rw-r--r-- | arch/s390/kernel/fpu.c | 8 | ||||
-rw-r--r-- | arch/s390/kernel/perf_regs.c | 5 | ||||
-rw-r--r-- | arch/s390/kernel/ptrace.c | 58 |
3 files changed, 15 insertions, 56 deletions
diff --git a/arch/s390/kernel/fpu.c b/arch/s390/kernel/fpu.c index a0ef3fc5d90f..733e188951b7 100644 --- a/arch/s390/kernel/fpu.c +++ b/arch/s390/kernel/fpu.c @@ -24,7 +24,7 @@ void __kernel_fpu_begin(struct kernel_fpu *state, int flags) fpu_stfpc(&state->fpc); if (!cpu_has_vx()) { if (flags & KERNEL_VXR_LOW) - save_fp_regs(state->fprs); + save_fp_regs_vx(state->vxrs); return; } mask = flags & KERNEL_VXR; @@ -73,7 +73,7 @@ void __kernel_fpu_end(struct kernel_fpu *state, int flags) fpu_lfpc(&state->fpc); if (!cpu_has_vx()) { if (flags & KERNEL_VXR_LOW) - load_fp_regs(state->fprs); + load_fp_regs_vx(state->vxrs); return; } mask = flags & KERNEL_VXR; @@ -115,7 +115,7 @@ void __load_user_fpu_regs(void) if (likely(cpu_has_vx())) load_vx_regs(state->vxrs); else - load_fp_regs(state->fprs); + load_fp_regs_vx(state->vxrs); clear_thread_flag(TIF_FPU); } @@ -143,7 +143,7 @@ void save_user_fpu_regs(void) if (likely(cpu_has_vx())) save_vx_regs(state->vxrs); else - save_fp_regs(state->fprs); + save_fp_regs_vx(state->vxrs); set_thread_flag(TIF_FPU); out: local_irq_restore(flags); diff --git a/arch/s390/kernel/perf_regs.c b/arch/s390/kernel/perf_regs.c index 511349b8bc5c..a6b058ee4a36 100644 --- a/arch/s390/kernel/perf_regs.c +++ b/arch/s390/kernel/perf_regs.c @@ -19,10 +19,7 @@ u64 perf_reg_value(struct pt_regs *regs, int idx) return 0; idx -= PERF_REG_S390_FP0; - if (cpu_has_vx()) - fp = *(freg_t *)(current->thread.ufpu.vxrs + idx); - else - fp = current->thread.ufpu.fprs[idx]; + fp = *(freg_t *)(current->thread.ufpu.vxrs + idx); return fp.ui; } diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c index f1ca79073173..1cfed8b710b8 100644 --- a/arch/s390/kernel/ptrace.c +++ b/arch/s390/kernel/ptrace.c @@ -252,17 +252,10 @@ static unsigned long __peek_user(struct task_struct *child, addr_t addr) } else if (addr < offsetof(struct user, regs.fp_regs) + sizeof(s390_fp_regs)) { /* - * floating point regs. are either in child->thread.ufpu - * or the child->thread.ufpu.vxrs array + * floating point regs. are in the child->thread.ufpu.vxrs array */ offset = addr - offsetof(struct user, regs.fp_regs.fprs); - if (cpu_has_vx()) - tmp = *(addr_t *) - ((addr_t)child->thread.ufpu.vxrs + 2 * offset); - else - tmp = *(addr_t *) - ((addr_t)child->thread.ufpu.fprs + offset); - + tmp = *(addr_t *)((addr_t)child->thread.ufpu.vxrs + 2 * offset); } else if (addr < offsetof(struct user, regs.per_info) + sizeof(per_struct)) { /* * Handle access to the per_info structure. @@ -400,17 +393,10 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data) } else if (addr < offsetof(struct user, regs.fp_regs) + sizeof(s390_fp_regs)) { /* - * floating point regs. are either in child->thread.ufpu - * or the child->thread.ufpu.vxrs array + * floating point regs. are in the child->thread.ufpu.vxrs array */ offset = addr - offsetof(struct user, regs.fp_regs.fprs); - if (cpu_has_vx()) - *(addr_t *)((addr_t) - child->thread.ufpu.vxrs + 2 * offset) = data; - else - *(addr_t *)((addr_t) - child->thread.ufpu.fprs + offset) = data; - + *(addr_t *)((addr_t)child->thread.ufpu.vxrs + 2 * offset) = data; } else if (addr < offsetof(struct user, regs.per_info) + sizeof(per_struct)) { /* * Handle access to the per_info structure. @@ -627,17 +613,10 @@ static u32 __peek_user_compat(struct task_struct *child, addr_t addr) } else if (addr < offsetof(struct compat_user, regs.fp_regs) + sizeof(s390_fp_regs)) { /* - * floating point regs. are either in child->thread.ufpu - * or the child->thread.ufpu.vxrs array + * floating point regs. are in the child->thread.ufpu.vxrs array */ offset = addr - offsetof(struct compat_user, regs.fp_regs.fprs); - if (cpu_has_vx()) - tmp = *(__u32 *) - ((addr_t)child->thread.ufpu.vxrs + 2 * offset); - else - tmp = *(__u32 *) - ((addr_t)child->thread.ufpu.fprs + offset); - + tmp = *(__u32 *)((addr_t)child->thread.ufpu.vxrs + 2 * offset); } else if (addr < offsetof(struct compat_user, regs.per_info) + sizeof(struct compat_per_struct_kernel)) { /* * Handle access to the per_info structure. @@ -753,17 +732,10 @@ static int __poke_user_compat(struct task_struct *child, } else if (addr < offsetof(struct compat_user, regs.fp_regs) + sizeof(s390_fp_regs)) { /* - * floating point regs. are either in child->thread.ufpu - * or the child->thread.ufpu.vxrs array + * floating point regs. are in the child->thread.ufpu.vxrs array */ offset = addr - offsetof(struct compat_user, regs.fp_regs.fprs); - if (cpu_has_vx()) - *(__u32 *)((addr_t) - child->thread.ufpu.vxrs + 2 * offset) = tmp; - else - *(__u32 *)((addr_t) - child->thread.ufpu.fprs + offset) = tmp; - + *(__u32 *)((addr_t)child->thread.ufpu.vxrs + 2 * offset) = tmp; } else if (addr < offsetof(struct compat_user, regs.per_info) + sizeof(struct compat_per_struct_kernel)) { /* * Handle access to the per_info structure. @@ -912,12 +884,7 @@ static int s390_fpregs_set(struct task_struct *target, if (target == current) save_user_fpu_regs(); - - if (cpu_has_vx()) - convert_vx_to_fp(fprs, target->thread.ufpu.vxrs); - else - memcpy(&fprs, target->thread.ufpu.fprs, sizeof(fprs)); - + convert_vx_to_fp(fprs, target->thread.ufpu.vxrs); if (count > 0 && pos < offsetof(s390_fp_regs, fprs)) { u32 ufpc[2] = { target->thread.ufpu.fpc, 0 }; rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ufpc, @@ -934,12 +901,7 @@ static int s390_fpregs_set(struct task_struct *target, fprs, offsetof(s390_fp_regs, fprs), -1); if (rc) return rc; - - if (cpu_has_vx()) - convert_fp_to_vx(target->thread.ufpu.vxrs, fprs); - else - memcpy(target->thread.ufpu.fprs, &fprs, sizeof(fprs)); - + convert_fp_to_vx(target->thread.ufpu.vxrs, fprs); return rc; } |