x86/entry, mce: Disallow #DB during #MC
authorPeter Zijlstra <peterz@infradead.org>
Fri, 29 May 2020 21:27:35 +0000 (23:27 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 11 Jun 2020 13:15:22 +0000 (15:15 +0200)
#MC is fragile as heck, don't tempt fate.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200529213321.131187767@infradead.org
arch/x86/kernel/cpu/mce/core.c

index 068e6cab1286c068c8237546498627356dc041f8..be499267bbb47a934406b89c418f12d6f1378314 100644 (file)
@@ -1943,22 +1943,34 @@ static __always_inline void exc_machine_check_user(struct pt_regs *regs)
 /* MCE hit kernel mode */
 DEFINE_IDTENTRY_MCE(exc_machine_check)
 {
+       unsigned long dr7;
+
+       dr7 = local_db_save();
        exc_machine_check_kernel(regs);
+       local_db_restore(dr7);
 }
 
 /* The user mode variant. */
 DEFINE_IDTENTRY_MCE_USER(exc_machine_check)
 {
+       unsigned long dr7;
+
+       dr7 = local_db_save();
        exc_machine_check_user(regs);
+       local_db_restore(dr7);
 }
 #else
 /* 32bit unified entry point */
 DEFINE_IDTENTRY_MCE(exc_machine_check)
 {
+       unsigned long dr7;
+
+       dr7 = local_db_save();
        if (user_mode(regs))
                exc_machine_check_user(regs);
        else
                exc_machine_check_kernel(regs);
+       local_db_restore(dr7);
 }
 #endif