mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86: Call fixup_exception() before notify_die() in math_error()
@ 2018-06-14 19:36 Siarhei Liakh
  2018-06-18 21:47 ` Andy Lutomirski
  2018-06-20  9:48 ` [tip:x86/urgent] " tip-bot for Siarhei Liakh
  0 siblings, 2 replies; 6+ messages in thread
From: Siarhei Liakh @ 2018-06-14 19:36 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andy Lutomirski,
	Borislav Petkov

fpu__drop() has an explicit fwait which under some conditions can trigger
a fixable FPU exception while in kernel. Thus, we should attempt to fixup
the exception first, and only call notify_die() if the fixup failed just
like in do_general_protection(). The original call sequence incorrectly
triggers KDB entry on debug kernels under particular FPU-intensive
workloads. This issue had been privately observed, fixed, and tested 
on 4.9.98, while this patch brings the fix to the upstream.

Signed-off-by: Siarhei Liakh <siarhei.liakh@concurrent-rt.com>
---

diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index a535dd6..68d77a3 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -835,16 +835,18 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)
 	char *str = (trapnr == X86_TRAP_MF) ? "fpu exception" :
 						"simd exception";
 
-	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, SIGFPE) == NOTIFY_STOP)
-		return;
 	cond_local_irq_enable(regs);
 
 	if (!user_mode(regs)) {
-		if (!fixup_exception(regs, trapnr)) {
-			task->thread.error_code = error_code;
-			task->thread.trap_nr = trapnr;
+		if (fixup_exception(regs, trapnr))
+			return;
+
+		task->thread.error_code = error_code;
+		task->thread.trap_nr = trapnr;
+
+		if (notify_die(DIE_TRAP, str, regs, error_code,
+					trapnr, SIGFPE) != NOTIFY_STOP)
 			die(str, regs, error_code);
-		}
 		return;
 	}
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-20  9:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-14 19:36 [PATCH] x86: Call fixup_exception() before notify_die() in math_error() Siarhei Liakh
2018-06-18 21:47 ` Andy Lutomirski
2018-06-19  6:23   ` Thomas Gleixner
2018-06-19 15:23     ` Andy Lutomirski
     [not found]     ` <DM5PR11MB2011397361BB5C0FB3D4FDFFB1700@DM5PR11MB2011.namprd11.prod.outlook.com>
     [not found]       ` <B739D98B-BA3F-40F6-82DF-6444546B6B4C@amacapital.net>
2018-06-19 19:56         ` Siarhei Liakh
2018-06-20  9:48 ` [tip:x86/urgent] " tip-bot for Siarhei Liakh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome