From: "Jan Beulich" <JBeulich@novell.com>
To: <linux-kernel@vger.kernel.org>
Subject: [PATCH] i386: NMI <-> debugging handler adjustments
Date: Tue, 08 Nov 2005 17:54:15 +0100 [thread overview]
Message-ID: <4370E647.76F0.0078.0@novell.com> (raw)
In-Reply-To: <4370AEE1.76F0.0078.0@novell.com>
[-- Attachment #1: Type: text/plain, Size: 394 bytes --]
Also account for an INT3 breakpoint potentially placed (from a kernel
debugger) on sysenter_entry, which requires the NMI handler to add one
more check. Further, don't discard debug or breakpoint traps/faults
happening on this one instruction and their handler getting
interrupted by an NMI before being able to fix the stack.
From: Jan Beulich <jbeulich@novell.com>
(actual patch attached)
[-- Attachment #2: linux-2.6.14-i386-nmi-int3.patch --]
[-- Type: application/octet-stream, Size: 2573 bytes --]
Also account for an INT3 breakpoint potentially placed (from a kernel
debugger) on sysenter_entry, which requires the NMI handler to add one
more check. Further, don't discard debug or breakpoint traps/faults
happening on this one instruction and their handler getting
interrupted by an NMI before being able to fix the stack.
From: Jan Beulich <jbeulich@novell.com>
--- 2.6.14/arch/i386/kernel/entry.S 2005-10-28 02:02:08.000000000 +0200
+++ 2.6.14-i386-nmi-int3/arch/i386/kernel/entry.S 2005-11-08 17:06:59.000000000 +0100
@@ -178,6 +178,7 @@ need_resched:
# sysenter call handler stub
ENTRY(sysenter_entry)
movl TSS_sysenter_esp0(%esp),%esp
+.globl sysenter_past_esp
sysenter_past_esp:
sti
pushl $(__USER_DS)
@@ -520,12 +521,12 @@ debug_stack_correct:
jmp ret_from_exception
.previous .text
/*
- * NMI is doubly nasty. It can happen _while_ we're handling
- * a debug fault, and the debug fault hasn't yet been able to
- * clear up the stack. So we first check whether we got an
+ * NMI is doubly nasty. It can happen _while_ we're handling a debug
+ * fault or breakpoint trap, and the fault/trap hasn't yet been able
+ * to clear up the stack. So we first check whether we got an
* NMI on the sysenter entry path, but after that we need to
- * check whether we got an NMI on the debug path where the debug
- * fault happened on the sysenter path.
+ * check whether we got an NMI on the debug/breakpoint path where the
+ * fault/trap happened on the sysenter path.
*/
ENTRY(nmi)
pushl %eax
@@ -546,6 +547,8 @@ ENTRY(nmi)
jae nmi_stack_correct
cmpl $sysenter_entry,12(%esp)
je nmi_debug_stack_check
+ cmpl $sysenter_entry+1,12(%esp)
+ je .Lnmi_int3_stack_check
nmi_stack_correct:
pushl %eax
SAVE_ALL
@@ -566,6 +569,21 @@ nmi_debug_stack_check:
jle nmi_debug_stack_fixup
nmi_debug_stack_fixup:
FIX_STACK(24,nmi_stack_correct, 1)
+ pushfl
+ pushl $__KERNEL_CS
+ pushl $debug_stack_correct
+ jmp nmi_stack_correct
+.Lnmi_int3_stack_check:
+ cmpw $__KERNEL_CS,16(%esp)
+ jne nmi_stack_correct
+ cmpl $int3, (%esp)
+ jb nmi_stack_correct
+ cmpl $.Lint3_esp_fix_insn, (%esp)
+ ja nmi_stack_correct
+ FIX_STACK(24,nmi_stack_correct, 1)
+ pushfl
+ pushl $__KERNEL_CS
+ pushl $.Lint3_stack_correct
jmp nmi_stack_correct
nmi_16bit_stack:
@@ -592,6 +610,10 @@ nmi_16bit_stack:
.previous
KPROBE_ENTRY(int3)
+ cmpl $sysenter_entry+1, (%esp)
+ jne .Lint3_stack_correct
+ FIX_STACK(12, .Lint3_stack_correct, .Lint3_esp_fix_insn)
+.Lint3_stack_correct:
pushl $-1 # mark this as an int
SAVE_ALL
xorl %edx,%edx # zero error code
next prev parent reply other threads:[~2005-11-08 16:53 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-08 12:57 [PATCH] i386: export genapic again Jan Beulich
2005-11-08 13:08 ` Arjan van de Ven
2005-11-08 13:22 ` Jan Beulich
2005-11-08 13:29 ` Adrian Bunk
2005-11-08 14:17 ` Jan Beulich
2005-11-08 16:52 ` [PATCH] i386: make trap information available to die handlers Jan Beulich
2005-11-08 16:59 ` Randy.Dunlap
2005-11-08 17:08 ` Jan Beulich
2005-11-08 17:13 ` Randy.Dunlap
2005-11-09 8:20 ` Jan Beulich
2005-11-10 12:21 ` Pavel Machek
2005-11-08 20:58 ` Richard Knutsson
2005-11-08 16:52 ` [PATCH] i386: int3 adjustment Jan Beulich
2005-11-09 8:37 ` [PATCH 1/2] i386: double fault adjustment - introduce THREAD_ORDER Jan Beulich
2005-11-09 8:38 ` [PATCH 2/2] i386: double fault adjustment Jan Beulich
2005-11-08 16:54 ` Jan Beulich [this message]
2005-11-08 16:55 ` [PATCH] i386: handle NMI case in IPI sending Jan Beulich
2005-11-08 16:55 ` [PATCH] i386: stand-alone CONFIG_PAE Jan Beulich
2005-11-08 17:02 ` Adrian Bunk
2005-11-08 17:10 ` Jan Beulich
2005-11-08 16:57 ` [PATCH] i386: adjust page fault handling Jan Beulich
2005-11-08 21:22 ` [PATCH] i386: export genapic again Randy.Dunlap
2005-11-09 8:18 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4370E647.76F0.0078.0@novell.com \
--to=jbeulich@novell.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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