diff options
author | Ingo Molnar <mingo@kernel.org> | 2015-04-26 10:56:05 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-05-19 09:47:48 -0400 |
commit | 952f07ecbd4d9bac77c003ba136f8ee8ce631591 (patch) | |
tree | 83d3abaa36140b5f9765796b9a6bc1b34066bbac | |
parent | d63e79b114c0208bc2b7712c879568e180909d60 (diff) |
x86/fpu: Move various internal function prototypes to fpu/internal.h
There are a number of FPU internal function prototypes and an inline function
in fpu/api.h, mostly placed so historically as the code grew over the years.
Move them over into fpu/internal.h where they belong. (Add sched.h include
to stackprotector.h which incorrectly relied on getting it from fpu/api.h.)
fpu/api.h is now a pure file that only contains FPU APIs intended for driver
use.
Reviewed-by: Borislav Petkov <bp@alien8.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/fpu/api.h | 31 | ||||
-rw-r--r-- | arch/x86/include/asm/fpu/internal.h | 25 | ||||
-rw-r--r-- | arch/x86/include/asm/stackprotector.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/bugs.c | 2 | ||||
-rw-r--r-- | arch/x86/kvm/vmx.c | 2 | ||||
-rw-r--r-- | arch/x86/math-emu/fpu_entry.c | 2 | ||||
-rw-r--r-- | arch/x86/power/cpu.c | 1 | ||||
-rw-r--r-- | drivers/lguest/x86/core.c | 2 |
8 files changed, 33 insertions, 34 deletions
diff --git a/arch/x86/include/asm/fpu/api.h b/arch/x86/include/asm/fpu/api.h index d4ab9e3af234..0c713455fc63 100644 --- a/arch/x86/include/asm/fpu/api.h +++ b/arch/x86/include/asm/fpu/api.h | |||
@@ -10,23 +10,8 @@ | |||
10 | #ifndef _ASM_X86_FPU_API_H | 10 | #ifndef _ASM_X86_FPU_API_H |
11 | #define _ASM_X86_FPU_API_H | 11 | #define _ASM_X86_FPU_API_H |
12 | 12 | ||
13 | #include <linux/sched.h> | ||
14 | #include <linux/hardirq.h> | 13 | #include <linux/hardirq.h> |
15 | 14 | ||
16 | struct pt_regs; | ||
17 | struct user_i387_struct; | ||
18 | |||
19 | extern int fpstate_alloc_init(struct fpu *fpu); | ||
20 | extern void fpstate_init(struct fpu *fpu); | ||
21 | extern void fpu__clear(struct task_struct *tsk); | ||
22 | |||
23 | extern int dump_fpu(struct pt_regs *, struct user_i387_struct *); | ||
24 | extern void fpu__restore(void); | ||
25 | extern void fpu__init_check_bugs(void); | ||
26 | extern void fpu__resume_cpu(void); | ||
27 | |||
28 | extern bool irq_fpu_usable(void); | ||
29 | |||
30 | /* | 15 | /* |
31 | * Careful: __kernel_fpu_begin/end() must be called with preempt disabled | 16 | * Careful: __kernel_fpu_begin/end() must be called with preempt disabled |
32 | * and they don't touch the preempt state on their own. | 17 | * and they don't touch the preempt state on their own. |
@@ -41,6 +26,7 @@ extern void __kernel_fpu_begin(void); | |||
41 | extern void __kernel_fpu_end(void); | 26 | extern void __kernel_fpu_end(void); |
42 | extern void kernel_fpu_begin(void); | 27 | extern void kernel_fpu_begin(void); |
43 | extern void kernel_fpu_end(void); | 28 | extern void kernel_fpu_end(void); |
29 | extern bool irq_fpu_usable(void); | ||
44 | 30 | ||
45 | /* | 31 | /* |
46 | * Some instructions like VIA's padlock instructions generate a spurious | 32 | * Some instructions like VIA's padlock instructions generate a spurious |
@@ -73,19 +59,4 @@ static inline void irq_ts_restore(int TS_state) | |||
73 | stts(); | 59 | stts(); |
74 | } | 60 | } |
75 | 61 | ||
76 | /* | ||
77 | * The question "does this thread have fpu access?" | ||
78 | * is slightly racy, since preemption could come in | ||
79 | * and revoke it immediately after the test. | ||
80 | * | ||
81 | * However, even in that very unlikely scenario, | ||
82 | * we can just assume we have FPU access - typically | ||
83 | * to save the FP state - we'll just take a #NM | ||
84 | * fault and get the FPU access back. | ||
85 | */ | ||
86 | static inline int user_has_fpu(void) | ||
87 | { | ||
88 | return current->thread.fpu.fpregs_active; | ||
89 | } | ||
90 | |||
91 | #endif /* _ASM_X86_FPU_API_H */ | 62 | #endif /* _ASM_X86_FPU_API_H */ |
diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h index 0c8c812d23b4..89c6ec80c1ac 100644 --- a/arch/x86/include/asm/fpu/internal.h +++ b/arch/x86/include/asm/fpu/internal.h | |||
@@ -12,6 +12,7 @@ | |||
12 | 12 | ||
13 | #include <linux/regset.h> | 13 | #include <linux/regset.h> |
14 | #include <linux/compat.h> | 14 | #include <linux/compat.h> |
15 | #include <linux/sched.h> | ||
15 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
16 | 17 | ||
17 | #include <asm/user.h> | 18 | #include <asm/user.h> |
@@ -43,6 +44,15 @@ extern void fpu__init_system_xstate(void); | |||
43 | extern void fpu__init_cpu_xstate(void); | 44 | extern void fpu__init_cpu_xstate(void); |
44 | extern void fpu__init_system(struct cpuinfo_x86 *c); | 45 | extern void fpu__init_system(struct cpuinfo_x86 *c); |
45 | 46 | ||
47 | extern int fpstate_alloc_init(struct fpu *fpu); | ||
48 | extern void fpstate_init(struct fpu *fpu); | ||
49 | extern void fpu__clear(struct task_struct *tsk); | ||
50 | |||
51 | extern int dump_fpu(struct pt_regs *, struct user_i387_struct *); | ||
52 | extern void fpu__restore(void); | ||
53 | extern void fpu__init_check_bugs(void); | ||
54 | extern void fpu__resume_cpu(void); | ||
55 | |||
46 | DECLARE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx); | 56 | DECLARE_PER_CPU(struct fpu *, fpu_fpregs_owner_ctx); |
47 | 57 | ||
48 | extern void convert_from_fxsr(struct user_i387_ia32_struct *env, | 58 | extern void convert_from_fxsr(struct user_i387_ia32_struct *env, |
@@ -335,6 +345,21 @@ static inline void __fpregs_activate(struct fpu *fpu) | |||
335 | } | 345 | } |
336 | 346 | ||
337 | /* | 347 | /* |
348 | * The question "does this thread have fpu access?" | ||
349 | * is slightly racy, since preemption could come in | ||
350 | * and revoke it immediately after the test. | ||
351 | * | ||
352 | * However, even in that very unlikely scenario, | ||
353 | * we can just assume we have FPU access - typically | ||
354 | * to save the FP state - we'll just take a #NM | ||
355 | * fault and get the FPU access back. | ||
356 | */ | ||
357 | static inline int user_has_fpu(void) | ||
358 | { | ||
359 | return current->thread.fpu.fpregs_active; | ||
360 | } | ||
361 | |||
362 | /* | ||
338 | * Encapsulate the CR0.TS handling together with the | 363 | * Encapsulate the CR0.TS handling together with the |
339 | * software flag. | 364 | * software flag. |
340 | * | 365 | * |
diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h index 6a998598f172..c2e00bb2a136 100644 --- a/arch/x86/include/asm/stackprotector.h +++ b/arch/x86/include/asm/stackprotector.h | |||
@@ -39,7 +39,9 @@ | |||
39 | #include <asm/processor.h> | 39 | #include <asm/processor.h> |
40 | #include <asm/percpu.h> | 40 | #include <asm/percpu.h> |
41 | #include <asm/desc.h> | 41 | #include <asm/desc.h> |
42 | |||
42 | #include <linux/random.h> | 43 | #include <linux/random.h> |
44 | #include <linux/sched.h> | ||
43 | 45 | ||
44 | /* | 46 | /* |
45 | * 24 byte read-only segment initializer for stack canary. Linker | 47 | * 24 byte read-only segment initializer for stack canary. Linker |
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c index 29dd74318ec6..bd17db15a2c1 100644 --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include <asm/bugs.h> | 12 | #include <asm/bugs.h> |
13 | #include <asm/processor.h> | 13 | #include <asm/processor.h> |
14 | #include <asm/processor-flags.h> | 14 | #include <asm/processor-flags.h> |
15 | #include <asm/fpu/api.h> | 15 | #include <asm/fpu/internal.h> |
16 | #include <asm/msr.h> | 16 | #include <asm/msr.h> |
17 | #include <asm/paravirt.h> | 17 | #include <asm/paravirt.h> |
18 | #include <asm/alternative.h> | 18 | #include <asm/alternative.h> |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 5cb738a18ca3..f93ae71416e4 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #include <asm/vmx.h> | 40 | #include <asm/vmx.h> |
41 | #include <asm/virtext.h> | 41 | #include <asm/virtext.h> |
42 | #include <asm/mce.h> | 42 | #include <asm/mce.h> |
43 | #include <asm/fpu/api.h> | 43 | #include <asm/fpu/internal.h> |
44 | #include <asm/xcr.h> | 44 | #include <asm/xcr.h> |
45 | #include <asm/perf_event.h> | 45 | #include <asm/perf_event.h> |
46 | #include <asm/debugreg.h> | 46 | #include <asm/debugreg.h> |
diff --git a/arch/x86/math-emu/fpu_entry.c b/arch/x86/math-emu/fpu_entry.c index 3bb4c6a24ea5..cf843855e4f6 100644 --- a/arch/x86/math-emu/fpu_entry.c +++ b/arch/x86/math-emu/fpu_entry.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include <asm/traps.h> | 31 | #include <asm/traps.h> |
32 | #include <asm/desc.h> | 32 | #include <asm/desc.h> |
33 | #include <asm/user.h> | 33 | #include <asm/user.h> |
34 | #include <asm/fpu/api.h> | 34 | #include <asm/fpu/internal.h> |
35 | 35 | ||
36 | #include "fpu_system.h" | 36 | #include "fpu_system.h" |
37 | #include "fpu_emu.h" | 37 | #include "fpu_emu.h" |
diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c index ad0ce6b70fac..0d7dd1f5ac36 100644 --- a/arch/x86/power/cpu.c +++ b/arch/x86/power/cpu.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <asm/page.h> | 19 | #include <asm/page.h> |
20 | #include <asm/mce.h> | 20 | #include <asm/mce.h> |
21 | #include <asm/suspend.h> | 21 | #include <asm/suspend.h> |
22 | #include <asm/fpu/internal.h> | ||
22 | #include <asm/debugreg.h> | 23 | #include <asm/debugreg.h> |
23 | #include <asm/cpu.h> | 24 | #include <asm/cpu.h> |
24 | 25 | ||
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c index fce5989e66d9..b80e4b8c9b6e 100644 --- a/drivers/lguest/x86/core.c +++ b/drivers/lguest/x86/core.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <asm/setup.h> | 46 | #include <asm/setup.h> |
47 | #include <asm/lguest.h> | 47 | #include <asm/lguest.h> |
48 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
49 | #include <asm/fpu/api.h> | 49 | #include <asm/fpu/internal.h> |
50 | #include <asm/tlbflush.h> | 50 | #include <asm/tlbflush.h> |
51 | #include "../lg.h" | 51 | #include "../lg.h" |
52 | 52 | ||