]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/sh/kernel/cpu/fpu.c
1 #include <linux/sched/signal.h>
2 #include <linux/sched/task.h>
3 #include <linux/slab.h>
4 #include <asm/processor.h>
7 #include <asm/ptrace.h>
9 int init_fpu(struct task_struct
*tsk
)
11 if (tsk_used_math(tsk
)) {
12 if ((boot_cpu_data
.flags
& CPU_HAS_FPU
) && tsk
== current
)
13 unlazy_fpu(tsk
, task_pt_regs(tsk
));
18 * Memory allocation at the first usage of the FPU and other state.
20 if (!tsk
->thread
.xstate
) {
21 tsk
->thread
.xstate
= kmem_cache_alloc(task_xstate_cachep
,
23 if (!tsk
->thread
.xstate
)
27 if (boot_cpu_data
.flags
& CPU_HAS_FPU
) {
28 struct sh_fpu_hard_struct
*fp
= &tsk
->thread
.xstate
->hardfpu
;
29 memset(fp
, 0, xstate_size
);
30 fp
->fpscr
= FPSCR_INIT
;
32 struct sh_fpu_soft_struct
*fp
= &tsk
->thread
.xstate
->softfpu
;
33 memset(fp
, 0, xstate_size
);
34 fp
->fpscr
= FPSCR_INIT
;
37 set_stopped_child_used_math(tsk
);
42 void __fpu_state_restore(void)
44 struct task_struct
*tsk
= current
;
48 task_thread_info(tsk
)->status
|= TS_USEDFPU
;
49 tsk
->thread
.fpu_counter
++;
52 void fpu_state_restore(struct pt_regs
*regs
)
54 struct task_struct
*tsk
= current
;
56 if (unlikely(!user_mode(regs
))) {
57 printk(KERN_ERR
"BUG: FPU is used in kernel mode.\n");
62 if (!tsk_used_math(tsk
)) {
65 * does a slab alloc which can sleep
71 do_group_exit(SIGKILL
);
79 __fpu_state_restore();
82 BUILD_TRAP_HANDLER(fpu_state_restore
)
86 fpu_state_restore(regs
);
88 #endif /* CONFIG_SH_FPU */