Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 287656
b: refs/heads/master
c: f94edac
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Feb 18, 2012
1 parent bdab093 commit 007b60e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4903062b5485f0e2c286a23b44c9b59d9b017d53
refs/heads/master: f94edacf998516ac9d849f7bc6949a703977a7f3
44 changes: 22 additions & 22 deletions trunk/arch/x86/include/asm/i387.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,21 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
* be preemption protection *and* they need to be
* properly paired with the CR0.TS changes!
*/
static inline int __thread_has_fpu(struct thread_info *ti)
static inline int __thread_has_fpu(struct task_struct *tsk)
{
return ti->status & TS_USEDFPU;
return tsk->thread.has_fpu;
}

/* Must be paired with an 'stts' after! */
static inline void __thread_clear_has_fpu(struct thread_info *ti)
static inline void __thread_clear_has_fpu(struct task_struct *tsk)
{
ti->status &= ~TS_USEDFPU;
tsk->thread.has_fpu = 0;
}

/* Must be paired with a 'clts' before! */
static inline void __thread_set_has_fpu(struct thread_info *ti)
static inline void __thread_set_has_fpu(struct task_struct *tsk)
{
ti->status |= TS_USEDFPU;
tsk->thread.has_fpu = 1;
}

/*
Expand All @@ -288,16 +288,16 @@ static inline void __thread_set_has_fpu(struct thread_info *ti)
* These generally need preemption protection to work,
* do try to avoid using these on their own.
*/
static inline void __thread_fpu_end(struct thread_info *ti)
static inline void __thread_fpu_end(struct task_struct *tsk)
{
__thread_clear_has_fpu(ti);
__thread_clear_has_fpu(tsk);
stts();
}

static inline void __thread_fpu_begin(struct thread_info *ti)
static inline void __thread_fpu_begin(struct task_struct *tsk)
{
clts();
__thread_set_has_fpu(ti);
__thread_set_has_fpu(tsk);
}

/*
Expand All @@ -308,21 +308,21 @@ extern int restore_i387_xstate(void __user *buf);

static inline void __unlazy_fpu(struct task_struct *tsk)
{
if (__thread_has_fpu(task_thread_info(tsk))) {
if (__thread_has_fpu(tsk)) {
__save_init_fpu(tsk);
__thread_fpu_end(task_thread_info(tsk));
__thread_fpu_end(tsk);
} else
tsk->fpu_counter = 0;
}

static inline void __clear_fpu(struct task_struct *tsk)
{
if (__thread_has_fpu(task_thread_info(tsk))) {
if (__thread_has_fpu(tsk)) {
/* Ignore delayed exceptions from user space */
asm volatile("1: fwait\n"
"2:\n"
_ASM_EXTABLE(1b, 2b));
__thread_fpu_end(task_thread_info(tsk));
__thread_fpu_end(tsk);
}
}

Expand All @@ -337,7 +337,7 @@ static inline void __clear_fpu(struct task_struct *tsk)
*/
static inline bool interrupted_kernel_fpu_idle(void)
{
return !__thread_has_fpu(current_thread_info()) &&
return !__thread_has_fpu(current) &&
(read_cr0() & X86_CR0_TS);
}

Expand Down Expand Up @@ -371,12 +371,12 @@ static inline bool irq_fpu_usable(void)

static inline void kernel_fpu_begin(void)
{
struct thread_info *me = current_thread_info();
struct task_struct *me = current;

WARN_ON_ONCE(!irq_fpu_usable());
preempt_disable();
if (__thread_has_fpu(me)) {
__save_init_fpu(me->task);
__save_init_fpu(me);
__thread_clear_has_fpu(me);
/* We do 'stts()' in kernel_fpu_end() */
} else
Expand Down Expand Up @@ -441,21 +441,21 @@ static inline void irq_ts_restore(int TS_state)
*/
static inline int user_has_fpu(void)
{
return __thread_has_fpu(current_thread_info());
return __thread_has_fpu(current);
}

static inline void user_fpu_end(void)
{
preempt_disable();
__thread_fpu_end(current_thread_info());
__thread_fpu_end(current);
preempt_enable();
}

static inline void user_fpu_begin(void)
{
preempt_disable();
if (!user_has_fpu())
__thread_fpu_begin(current_thread_info());
__thread_fpu_begin(current);
preempt_enable();
}

Expand All @@ -464,10 +464,10 @@ static inline void user_fpu_begin(void)
*/
static inline void save_init_fpu(struct task_struct *tsk)
{
WARN_ON_ONCE(!__thread_has_fpu(task_thread_info(tsk)));
WARN_ON_ONCE(!__thread_has_fpu(tsk));
preempt_disable();
__save_init_fpu(tsk);
__thread_fpu_end(task_thread_info(tsk));
__thread_fpu_end(tsk);
preempt_enable();
}

Expand Down
1 change: 1 addition & 0 deletions trunk/arch/x86/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ struct thread_struct {
unsigned long trap_no;
unsigned long error_code;
/* floating point and extended processor state */
unsigned long has_fpu;
struct fpu fpu;
#ifdef CONFIG_X86_32
/* Virtual 86 mode info */
Expand Down
2 changes: 0 additions & 2 deletions trunk/arch/x86/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,6 @@ static inline struct thread_info *current_thread_info(void)
* ever touches our thread-synchronous status, so we don't
* have to worry about atomic accesses.
*/
#define TS_USEDFPU 0x0001 /* FPU was used by this task
this quantum (SMP) */
#define TS_COMPAT 0x0002 /* 32bit syscall active (64BIT)*/
#define TS_POLLING 0x0004 /* idle task polling need_resched,
skip sending interrupt */
Expand Down
11 changes: 5 additions & 6 deletions trunk/arch/x86/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,11 @@ asmlinkage void __attribute__((weak)) smp_threshold_interrupt(void)
*/
void math_state_restore(void)
{
struct thread_info *thread = current_thread_info();
struct task_struct *tsk = thread->task;
struct task_struct *tsk = current;

/* We need a safe address that is cheap to find and that is already
in L1. We just brought in "thread->task", so use that */
#define safe_address (thread->task)
in L1. We're just bringing in "tsk->thread.has_fpu", so use that */
#define safe_address (tsk->thread.has_fpu)

if (!tsk_used_math(tsk)) {
local_irq_enable();
Expand All @@ -604,7 +603,7 @@ void math_state_restore(void)
local_irq_disable();
}

__thread_fpu_begin(thread);
__thread_fpu_begin(tsk);

/* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception
is pending. Clear the x87 state here by setting it to fixed
Expand All @@ -620,7 +619,7 @@ void math_state_restore(void)
* Paranoid restore. send a SIGSEGV if we fail to restore the state.
*/
if (unlikely(restore_fpu_checking(tsk))) {
__thread_fpu_end(thread);
__thread_fpu_end(tsk);
force_sig(SIGSEGV, tsk);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/xsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void __sanitize_i387_state(struct task_struct *tsk)
if (!fx)
return;

BUG_ON(__thread_has_fpu(task_thread_info(tsk)));
BUG_ON(__thread_has_fpu(tsk));

xstate_bv = tsk->thread.fpu.state->xsave.xsave_hdr.xstate_bv;

Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ static void __vmx_load_host_state(struct vcpu_vmx *vmx)
#ifdef CONFIG_X86_64
wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_host_kernel_gs_base);
#endif
if (__thread_has_fpu(current_thread_info()))
if (__thread_has_fpu(current))
clts();
load_gdt(&__get_cpu_var(host_gdt));
}
Expand Down

0 comments on commit 007b60e

Please sign in to comment.