]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/x86/include/asm/i387.h
2 * Copyright (C) 1994 Linus Torvalds
4 * Pentium III FXSR, SSE support
5 * General FPU state handling cleanups
6 * Gareth Hughes <gareth@valinux.com>, May 2000
7 * x86-64 work by Andi Kleen 2002
10 #ifndef _ASM_X86_I387_H
11 #define _ASM_X86_I387_H
15 #include <linux/sched.h>
16 #include <linux/hardirq.h>
17 #include <asm/system.h>
20 struct user_i387_struct
;
22 extern int init_fpu(struct task_struct
*child
);
23 extern int dump_fpu(struct pt_regs
*, struct user_i387_struct
*);
24 extern void math_state_restore(void);
26 extern bool irq_fpu_usable(void);
27 extern void kernel_fpu_begin(void);
28 extern void kernel_fpu_end(void);
31 * Some instructions like VIA's padlock instructions generate a spurious
32 * DNA fault but don't modify SSE registers. And these instructions
33 * get used from interrupt context as well. To prevent these kernel instructions
34 * in interrupt context interacting wrongly with other user/kernel fpu usage, we
35 * should use them only in the context of irq_ts_save/restore()
37 static inline int irq_ts_save(void)
40 * If in process context and not atomic, we can take a spurious DNA fault.
41 * Otherwise, doing clts() in process context requires disabling preemption
42 * or some heavy lifting like kernel_fpu_begin()
47 if (read_cr0() & X86_CR0_TS
) {
55 static inline void irq_ts_restore(int TS_state
)
62 * The question "does this thread have fpu access?"
63 * is slightly racy, since preemption could come in
64 * and revoke it immediately after the test.
66 * However, even in that very unlikely scenario,
67 * we can just assume we have FPU access - typically
68 * to save the FP state - we'll just take a #NM
69 * fault and get the FPU access back.
71 static inline int user_has_fpu(void)
73 return current
->thread
.fpu
.has_fpu
;
76 extern void unlazy_fpu(struct task_struct
*tsk
);
78 #endif /* __ASSEMBLY__ */
80 #endif /* _ASM_X86_I387_H */