提交 ca6787ba 编写于 作者: I Ingo Molnar

x86/fpu: Remove 'struct task_struct' usage from drop_fpu()

Migrate this function to pure 'struct fpu' usage.
Reviewed-by: NBorislav 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: NIngo Molnar <mingo@kernel.org>
上级 c5bedc68
...@@ -358,14 +358,13 @@ static inline void __thread_fpu_begin(struct fpu *fpu) ...@@ -358,14 +358,13 @@ static inline void __thread_fpu_begin(struct fpu *fpu)
__thread_set_has_fpu(fpu); __thread_set_has_fpu(fpu);
} }
static inline void drop_fpu(struct task_struct *tsk) static inline void drop_fpu(struct fpu *fpu)
{ {
struct fpu *fpu = &tsk->thread.fpu;
/* /*
* Forget coprocessor state.. * Forget coprocessor state..
*/ */
preempt_disable(); preempt_disable();
tsk->thread.fpu.counter = 0; fpu->counter = 0;
if (fpu->has_fpu) { if (fpu->has_fpu) {
/* Ignore delayed exceptions from user space */ /* Ignore delayed exceptions from user space */
...@@ -394,8 +393,10 @@ static inline void restore_init_xstate(void) ...@@ -394,8 +393,10 @@ static inline void restore_init_xstate(void)
*/ */
static inline void fpu_reset_state(struct task_struct *tsk) static inline void fpu_reset_state(struct task_struct *tsk)
{ {
struct fpu *fpu = &tsk->thread.fpu;
if (!use_eager_fpu()) if (!use_eager_fpu())
drop_fpu(tsk); drop_fpu(fpu);
else else
restore_init_xstate(); restore_init_xstate();
} }
......
...@@ -389,7 +389,7 @@ void fpu__flush_thread(struct task_struct *tsk) ...@@ -389,7 +389,7 @@ void fpu__flush_thread(struct task_struct *tsk)
if (!use_eager_fpu()) { if (!use_eager_fpu()) {
/* FPU state will be reallocated lazily at the first use. */ /* FPU state will be reallocated lazily at the first use. */
drop_fpu(tsk); drop_fpu(fpu);
fpstate_free(&tsk->thread.fpu); fpstate_free(&tsk->thread.fpu);
} else { } else {
if (!fpu->fpstate_active) { if (!fpu->fpstate_active) {
......
...@@ -392,7 +392,7 @@ int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size) ...@@ -392,7 +392,7 @@ int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size)
* We will be ready to restore/save the state only after * We will be ready to restore/save the state only after
* fpu->fpstate_active is again set. * fpu->fpstate_active is again set.
*/ */
drop_fpu(tsk); drop_fpu(fpu);
if (__copy_from_user(&fpu->state->xsave, buf_fx, state_size) || if (__copy_from_user(&fpu->state->xsave, buf_fx, state_size) ||
__copy_from_user(&env, buf, sizeof(env))) { __copy_from_user(&env, buf, sizeof(env))) {
......
...@@ -104,6 +104,7 @@ void exit_thread(void) ...@@ -104,6 +104,7 @@ void exit_thread(void)
struct task_struct *me = current; struct task_struct *me = current;
struct thread_struct *t = &me->thread; struct thread_struct *t = &me->thread;
unsigned long *bp = t->io_bitmap_ptr; unsigned long *bp = t->io_bitmap_ptr;
struct fpu *fpu = &t->fpu;
if (bp) { if (bp) {
struct tss_struct *tss = &per_cpu(cpu_tss, get_cpu()); struct tss_struct *tss = &per_cpu(cpu_tss, get_cpu());
...@@ -119,7 +120,7 @@ void exit_thread(void) ...@@ -119,7 +120,7 @@ void exit_thread(void)
kfree(bp); kfree(bp);
} }
drop_fpu(me); drop_fpu(fpu);
} }
void flush_thread(void) void flush_thread(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册