浏览代码

x86: unify the implementation of FPU traps

On 32 bits, we may suffer IRQ 13, or supposedly we might have a buggy
implementation which gives spurious trap 16.  We did not check for
this on 64 bits, but there is no reason we can't make the code the
same in both cases.  Furthermore, this is presumably rare, so do the
spurious check last, instead of first.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
H. Peter Anvin 16 年之前
父节点
当前提交
a73ad3331f
共有 1 个文件被更改,包括 4 次插入7 次删除
  1. 4 7
      arch/x86/kernel/traps.c

+ 4 - 7
arch/x86/kernel/traps.c

@@ -689,12 +689,7 @@ void math_error(void __user *ip)
 	cwd = get_fpu_cwd(task);
 	cwd = get_fpu_cwd(task);
 	swd = get_fpu_swd(task);
 	swd = get_fpu_swd(task);
 
 
-	err = swd & ~cwd & 0x3f;
-
-#ifdef CONFIG_X86_32
-	if (!err)
-		return;
-#endif
+	err = swd & ~cwd;
 
 
 	if (err & 0x001) {	/* Invalid op */
 	if (err & 0x001) {	/* Invalid op */
 		/*
 		/*
@@ -712,7 +707,9 @@ void math_error(void __user *ip)
 	} else if (err & 0x020) { /* Precision */
 	} else if (err & 0x020) { /* Precision */
 		info.si_code = FPE_FLTRES;
 		info.si_code = FPE_FLTRES;
 	} else {
 	} else {
-		info.si_code = __SI_FAULT|SI_KERNEL; /* WTF? */
+		/* If we're using IRQ 13, or supposedly even some trap 16
+		   implementations, it's possible we get a spurious trap... */
+		return;		/* Spurious trap, no error */
 	}
 	}
 	force_sig_info(SIGFPE, &info, task);
 	force_sig_info(SIGFPE, &info, task);
 }
 }