Selaa lähdekoodia

x86: fix taking DNA during 64bit sigreturn

restore sigcontext is taking a DNA exception while restoring FP context
from the user stack, during the sigreturn.  Appended patch fixes it by
doing clts() if the app doesn't touch FP during the signal handler
execution.  This will stop generating a DNA, during the fxrstor in the
sigreturn.

This improves 64-bit lat_sig numbers by ~30% on my core2 platform.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Siddha, Suresh B 17 vuotta sitten
vanhempi
commit
92d140e21f
2 muutettua tiedostoa jossa 10 lisäystä ja 4 poistoa
  1. 5 4
      arch/x86/kernel/i387_64.c
  2. 5 0
      include/asm-x86/i387_64.h

+ 5 - 4
arch/x86/kernel/i387_64.c

@@ -92,13 +92,14 @@ int save_i387(struct _fpstate __user *buf)
 	if (task_thread_info(tsk)->status & TS_USEDFPU) {
 	if (task_thread_info(tsk)->status & TS_USEDFPU) {
 		err = save_i387_checking((struct i387_fxsave_struct __user *)buf);
 		err = save_i387_checking((struct i387_fxsave_struct __user *)buf);
 		if (err) return err;
 		if (err) return err;
+		task_thread_info(tsk)->status &= ~TS_USEDFPU;
 		stts();
 		stts();
-		} else {
-		if (__copy_to_user(buf, &tsk->thread.i387.fxsave, 
+	} else {
+		if (__copy_to_user(buf, &tsk->thread.i387.fxsave,
 				   sizeof(struct i387_fxsave_struct)))
 				   sizeof(struct i387_fxsave_struct)))
 			return -1;
 			return -1;
-	} 
-		return 1;
+	}
+	return 1;
 }
 }
 
 
 /*
 /*

+ 5 - 0
include/asm-x86/i387_64.h

@@ -203,6 +203,11 @@ static inline void save_init_fpu(struct task_struct *tsk)
  */
  */
 static inline int restore_i387(struct _fpstate __user *buf)
 static inline int restore_i387(struct _fpstate __user *buf)
 {
 {
+	set_used_math();
+	if (!(task_thread_info(current)->status & TS_USEDFPU)) {
+		clts();
+		task_thread_info(current)->status |= TS_USEDFPU;
+	}
 	return restore_fpu_checking((__force struct i387_fxsave_struct *)buf);
 	return restore_fpu_checking((__force struct i387_fxsave_struct *)buf);
 }
 }