blob: 1429a7c736db813e84dc50ab9ee3644f33030f6d [file] [log] [blame]
Roland McGrath1eeaed72008-01-30 13:31:51 +01001/*
2 * Copyright (C) 1994 Linus Torvalds
3 *
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
8 */
9
Ingo Molnardf6b35f2015-04-24 02:46:00 +020010#ifndef _ASM_X86_FPU_API_H
11#define _ASM_X86_FPU_API_H
Roland McGrath1eeaed72008-01-30 13:31:51 +010012
Suresh Siddhab1a74bf2012-09-20 11:01:49 -070013/*
14 * Careful: __kernel_fpu_begin/end() must be called with preempt disabled
15 * and they don't touch the preempt state on their own.
16 * If you enable preemption after __kernel_fpu_begin(), preempt notifier
17 * should call the __kernel_fpu_end() to prevent the kernel/user FPU
18 * state from getting corrupted. KVM for example uses this model.
19 *
20 * All other cases use kernel_fpu_begin/end() which disable preemption
21 * during kernel FPU usage.
22 */
23extern void __kernel_fpu_begin(void);
24extern void __kernel_fpu_end(void);
Ingo Molnard63e79b2015-04-26 12:07:18 +020025extern void kernel_fpu_begin(void);
26extern void kernel_fpu_end(void);
Ingo Molnar952f07e2015-04-26 16:56:05 +020027extern bool irq_fpu_usable(void);
Roland McGrath1eeaed72008-01-30 13:31:51 +010028
Suresh Siddhae4914012008-08-13 22:02:26 +100029/*
30 * Some instructions like VIA's padlock instructions generate a spurious
31 * DNA fault but don't modify SSE registers. And these instructions
Chuck Ebbert0b8c3d52009-06-09 10:40:50 -040032 * get used from interrupt context as well. To prevent these kernel instructions
33 * in interrupt context interacting wrongly with other user/kernel fpu usage, we
Suresh Siddhae4914012008-08-13 22:02:26 +100034 * should use them only in the context of irq_ts_save/restore()
35 */
Ingo Molnar91066582015-04-26 16:57:55 +020036extern int irq_ts_save(void);
37extern void irq_ts_restore(int TS_state);
Suresh Siddhae4914012008-08-13 22:02:26 +100038
Ingo Molnar5b073432015-04-28 08:51:17 +020039/*
40 * Query the presence of one or more xfeatures. Works on any legacy CPU as well.
41 *
42 * If 'feature_name' is set then put a human-readable description of
43 * the feature there as well - this can be used to print error (or success)
44 * messages.
45 */
46extern int cpu_has_xfeatures(u64 xfeatures_mask, const char **feature_name);
47
Ingo Molnardf6b35f2015-04-24 02:46:00 +020048#endif /* _ASM_X86_FPU_API_H */