From 7fdb044e9a63b0b91a00acfc39f98b83715bf803 Mon Sep 17 00:00:00 2001 From: Jacek Galowicz Date: Mon, 30 May 2011 11:22:54 +0200 Subject: [PATCH] Encapsulated FPU restore instructions. There is a new procedure restore_fpu_state() in arch/x86/include/asm/tasks_types. Will need this code in lguest, too. --- arch/x86/include/asm/tasks_types.h | 7 +++++++ arch/x86/kernel/isrs.c | 6 +----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/tasks_types.h b/arch/x86/include/asm/tasks_types.h index ffaee4fd..34c01228 100644 --- a/arch/x86/include/asm/tasks_types.h +++ b/arch/x86/include/asm/tasks_types.h @@ -68,6 +68,13 @@ static inline void save_fpu_state(union fpu_state* state) { asm volatile ("fsave %0; fwait" : "=m"((*state).fsave)); } +static inline void restore_fpu_state(union fpu_state* state) { + if (has_fxsr()) + asm volatile ("fxrstor %0" :: "m"(state->fxsave)); + else + asm volatile ("frstor %0" :: "m"(state->fsave)); +} + #ifdef __cplusplus } #endif diff --git a/arch/x86/kernel/isrs.c b/arch/x86/kernel/isrs.c index 4c461894..ed0d6792 100644 --- a/arch/x86/kernel/isrs.c +++ b/arch/x86/kernel/isrs.c @@ -196,11 +196,7 @@ static void fpu_handler(struct state *s) task->flags |= TASK_FPU_INIT; } - // restore the FPU context - if (has_fxsr()) - asm volatile ("fxrstor %0" :: "m"(task->fpu.fxsave)); - else - asm volatile ("frstor %0" :: "m"(task->fpu.fsave)); + restore_fpu_state(&task->fpu); task->flags |= TASK_FPU_USED; }