Skip to content

Commit

Permalink
s390/fpu: rename save_fpu_regs() to save_user_fpu_regs(), etc
Browse files Browse the repository at this point in the history
Rename save_fpu_regs(), load_fpu_regs(), and struct thread_struct's fpu
member to save_user_fpu_regs(), load_user_fpu_regs(), and ufpu. This way
the function and variable names reflect for which context they are supposed
to be used.

This large and trivial conversion is a prerequisite for making the kernel
fpu usage preemptible.

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
  • Loading branch information
Heiko Carstens committed Feb 16, 2024
1 parent 419abc4 commit 87c5c70
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 102 deletions.
2 changes: 1 addition & 1 deletion arch/s390/include/asm/entry-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static __always_inline void arch_exit_to_user_mode_work(struct pt_regs *regs,
static __always_inline void arch_exit_to_user_mode(void)
{
if (test_thread_flag(TIF_FPU))
__load_fpu_regs();
__load_user_fpu_regs();

if (IS_ENABLED(CONFIG_DEBUG_ENTRY))
debug_user_asce(1);
Expand Down
8 changes: 4 additions & 4 deletions arch/s390/include/asm/fpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ static inline bool cpu_has_vx(void)
return likely(test_facility(129));
}

void save_fpu_regs(void);
void load_fpu_regs(void);
void __load_fpu_regs(void);
void save_user_fpu_regs(void);
void load_user_fpu_regs(void);
void __load_user_fpu_regs(void);

enum {
KERNEL_FPC_BIT = 0,
Expand Down Expand Up @@ -150,7 +150,7 @@ static inline void kernel_fpu_begin(struct kernel_fpu *state, u32 flags)
state->mask = S390_lowcore.fpu_flags;
if (!test_thread_flag(TIF_FPU)) {
/* Save user space FPU state and register contents */
save_fpu_regs();
save_user_fpu_regs();
} else if (state->mask & flags) {
/* Save FPU/vector register in-use by the kernel */
__kernel_fpu_begin(state, flags);
Expand Down
4 changes: 2 additions & 2 deletions arch/s390/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ struct thread_struct {
struct gs_cb *gs_cb; /* Current guarded storage cb */
struct gs_cb *gs_bc_cb; /* Broadcast guarded storage cb */
struct pgm_tdb trap_tdb; /* Transaction abort diagnose block */
struct fpu fpu; /* FP and VX register save area */
struct fpu ufpu; /* User FP and VX register save area */
};

/* Flag to disable transactions. */
Expand All @@ -200,7 +200,7 @@ typedef struct thread_struct thread_struct;

#define INIT_THREAD { \
.ksp = sizeof(init_stack) + (unsigned long) &init_stack, \
.fpu.regs = (void *) init_task.thread.fpu.fprs, \
.ufpu.regs = (void *)init_task.thread.ufpu.fprs, \
.last_break = 1, \
}

Expand Down
18 changes: 9 additions & 9 deletions arch/s390/kernel/compat_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ typedef struct
static void store_sigregs(void)
{
save_access_regs(current->thread.acrs);
save_fpu_regs();
save_user_fpu_regs();
}

/* Load registers after signal return */
Expand All @@ -79,7 +79,7 @@ static int save_sigregs32(struct pt_regs *regs, _sigregs32 __user *sregs)
user_sregs.regs.gprs[i] = (__u32) regs->gprs[i];
memcpy(&user_sregs.regs.acrs, current->thread.acrs,
sizeof(user_sregs.regs.acrs));
fpregs_store((_s390_fp_regs *) &user_sregs.fpregs, &current->thread.fpu);
fpregs_store((_s390_fp_regs *) &user_sregs.fpregs, &current->thread.ufpu);
if (__copy_to_user(sregs, &user_sregs, sizeof(_sigregs32)))
return -EFAULT;
return 0;
Expand Down Expand Up @@ -113,7 +113,7 @@ static int restore_sigregs32(struct pt_regs *regs,_sigregs32 __user *sregs)
regs->gprs[i] = (__u64) user_sregs.regs.gprs[i];
memcpy(&current->thread.acrs, &user_sregs.regs.acrs,
sizeof(current->thread.acrs));
fpregs_load((_s390_fp_regs *) &user_sregs.fpregs, &current->thread.fpu);
fpregs_load((_s390_fp_regs *)&user_sregs.fpregs, &current->thread.ufpu);

clear_pt_regs_flag(regs, PIF_SYSCALL); /* No longer in a system call */
return 0;
Expand All @@ -136,11 +136,11 @@ static int save_sigregs_ext32(struct pt_regs *regs,
/* Save vector registers to signal stack */
if (cpu_has_vx()) {
for (i = 0; i < __NUM_VXRS_LOW; i++)
vxrs[i] = current->thread.fpu.vxrs[i].low;
vxrs[i] = current->thread.ufpu.vxrs[i].low;
if (__copy_to_user(&sregs_ext->vxrs_low, vxrs,
sizeof(sregs_ext->vxrs_low)) ||
__copy_to_user(&sregs_ext->vxrs_high,
current->thread.fpu.vxrs + __NUM_VXRS_LOW,
current->thread.ufpu.vxrs + __NUM_VXRS_LOW,
sizeof(sregs_ext->vxrs_high)))
return -EFAULT;
}
Expand All @@ -165,12 +165,12 @@ static int restore_sigregs_ext32(struct pt_regs *regs,
if (cpu_has_vx()) {
if (__copy_from_user(vxrs, &sregs_ext->vxrs_low,
sizeof(sregs_ext->vxrs_low)) ||
__copy_from_user(current->thread.fpu.vxrs + __NUM_VXRS_LOW,
__copy_from_user(current->thread.ufpu.vxrs + __NUM_VXRS_LOW,
&sregs_ext->vxrs_high,
sizeof(sregs_ext->vxrs_high)))
return -EFAULT;
for (i = 0; i < __NUM_VXRS_LOW; i++)
current->thread.fpu.vxrs[i].low = vxrs[i];
current->thread.ufpu.vxrs[i].low = vxrs[i];
}
return 0;
}
Expand All @@ -184,7 +184,7 @@ COMPAT_SYSCALL_DEFINE0(sigreturn)
if (get_compat_sigset(&set, (compat_sigset_t __user *)frame->sc.oldmask))
goto badframe;
set_current_blocked(&set);
save_fpu_regs();
save_user_fpu_regs();
if (restore_sigregs32(regs, &frame->sregs))
goto badframe;
if (restore_sigregs_ext32(regs, &frame->sregs_ext))
Expand All @@ -207,7 +207,7 @@ COMPAT_SYSCALL_DEFINE0(rt_sigreturn)
set_current_blocked(&set);
if (compat_restore_altstack(&frame->uc.uc_stack))
goto badframe;
save_fpu_regs();
save_user_fpu_regs();
if (restore_sigregs32(regs, &frame->uc.uc_mcontext))
goto badframe;
if (restore_sigregs_ext32(regs, &frame->uc.uc_mcontext_ext))
Expand Down
20 changes: 10 additions & 10 deletions arch/s390/kernel/fpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ void __kernel_fpu_end(struct kernel_fpu *state, u32 flags)
}
EXPORT_SYMBOL(__kernel_fpu_end);

void __load_fpu_regs(void)
void __load_user_fpu_regs(void)
{
struct fpu *state = &current->thread.fpu;
void *regs = current->thread.fpu.regs;
struct fpu *state = &current->thread.ufpu;
void *regs = current->thread.ufpu.regs;

fpu_lfpc_safe(&state->fpc);
if (likely(cpu_has_vx()))
Expand All @@ -120,15 +120,15 @@ void __load_fpu_regs(void)
clear_thread_flag(TIF_FPU);
}

void load_fpu_regs(void)
void load_user_fpu_regs(void)
{
raw_local_irq_disable();
__load_fpu_regs();
__load_user_fpu_regs();
raw_local_irq_enable();
}
EXPORT_SYMBOL(load_fpu_regs);
EXPORT_SYMBOL(load_user_fpu_regs);

void save_fpu_regs(void)
void save_user_fpu_regs(void)
{
unsigned long flags;
struct fpu *state;
Expand All @@ -139,8 +139,8 @@ void save_fpu_regs(void)
if (test_thread_flag(TIF_FPU))
goto out;

state = &current->thread.fpu;
regs = current->thread.fpu.regs;
state = &current->thread.ufpu;
regs = current->thread.ufpu.regs;

fpu_stfpc(&state->fpc);
if (likely(cpu_has_vx()))
Expand All @@ -151,4 +151,4 @@ void save_fpu_regs(void)
out:
local_irq_restore(flags);
}
EXPORT_SYMBOL(save_fpu_regs);
EXPORT_SYMBOL(save_user_fpu_regs);
6 changes: 3 additions & 3 deletions arch/s390/kernel/perf_regs.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)

idx -= PERF_REG_S390_FP0;
if (cpu_has_vx())
fp = *(freg_t *)(current->thread.fpu.vxrs + idx);
fp = *(freg_t *)(current->thread.ufpu.vxrs + idx);
else
fp = current->thread.fpu.fprs[idx];
fp = current->thread.ufpu.fprs[idx];
return fp.ui;
}

Expand Down Expand Up @@ -64,6 +64,6 @@ void perf_get_regs_user(struct perf_regs *regs_user,
*/
regs_user->regs = task_pt_regs(current);
if (user_mode(regs_user->regs))
save_fpu_regs();
save_user_fpu_regs();
regs_user->abi = perf_reg_abi(current);
}
8 changes: 4 additions & 4 deletions arch/s390/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
* task and set the TIF_FPU flag to lazy restore the FPU register
* state when returning to user space.
*/
save_fpu_regs();
save_user_fpu_regs();

*dst = *src;
dst->thread.fpu.regs = dst->thread.fpu.fprs;
dst->thread.ufpu.regs = dst->thread.ufpu.fprs;

/*
* Don't transfer over the runtime instrumentation or the guarded
Expand Down Expand Up @@ -190,13 +190,13 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)

void execve_tail(void)
{
current->thread.fpu.fpc = 0;
current->thread.ufpu.fpc = 0;
fpu_sfpc(0);
}

struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *next)
{
save_fpu_regs();
save_user_fpu_regs();
save_access_regs(&prev->thread.acrs[0]);
save_ri_cb(prev->thread.ri_cb);
save_gs_cb(prev->thread.gs_cb);
Expand Down
Loading

0 comments on commit 87c5c70

Please sign in to comment.