Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/i386 Disable interrupts for T_NMI (inline call...



details:   https://anonhg.NetBSD.org/src/rev/54528c47f70c
branches:  trunk
changeset: 824689:54528c47f70c
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Jun 14 17:21:04 2017 +0000

description:
Disable interrupts for T_NMI (inline calltrap). Note that there's still a
way to evade the NMI mode here, if a segment register faults in
INTRFASTEXIT; but we don't care. I didn't test this change, but it seems
fine enough.

diffstat:

 sys/arch/i386/i386/i386_trap.S |  21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diffs (46 lines):

diff -r 782a676696d6 -r 54528c47f70c sys/arch/i386/i386/i386_trap.S
--- a/sys/arch/i386/i386/i386_trap.S    Wed Jun 14 17:11:39 2017 +0000
+++ b/sys/arch/i386/i386/i386_trap.S    Wed Jun 14 17:21:04 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i386_trap.S,v 1.7 2017/06/14 17:02:16 maxv Exp $       */
+/*     $NetBSD: i386_trap.S,v 1.8 2017/06/14 17:21:04 maxv Exp $       */
 
 /*
  * Copyright 2002 (c) Wasabi Systems, Inc.
@@ -66,7 +66,7 @@
 
 #if 0
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.7 2017/06/14 17:02:16 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.8 2017/06/14 17:21:04 maxv Exp $");
 #endif
 
 /*
@@ -98,11 +98,26 @@
        BPTTRAP(T_TRCTRAP)
 IDTVEC_END(trap01)
 
+/*
+ * Non Maskable Interrupts are a special case: they can be triggered even
+ * with interrupts disabled, and once triggered they block further NMIs
+ * until an 'iret' instruction is executed.
+ *
+ * Therefore we don't enable interrupts, because the CPU could switch to
+ * another LWP, call 'iret' and unintentionally leave the NMI mode.
+ */
 IDTVEC(trap02)
        pushl   $0
        pushl   $(T_NMI)
        INTRENTRY
-       jmp     _C_LABEL(calltrap)
+
+       addl    $1,CPUVAR(NTRAP)        /* statistical info */
+       adcl    $0,CPUVAR(NTRAP)+4
+       pushl   %esp
+       call    _C_LABEL(trap)
+       addl    $4,%esp
+
+       INTRFASTEXIT
 IDTVEC_END(trap02)
 
 IDTVEC(trap03)



Home | Main Index | Thread Index | Old Index