From: Chuck Ebbert <76306.1226@compuserve.com>
To: Andi Kleen <ak@suse.de>
Cc: pageexec <pageexec@freemail.hu>,
linux-kernel <linux-kernel@vger.kernel.org>,
Willy Tarreau <w@1wt.eu>
Subject: Re: [PATCH][RFC] exception processing in early boot
Date: Wed, 30 Aug 2006 22:05:46 -0400 [thread overview]
Message-ID: <200608302209_MC3-1-C9E0-28B7@compuserve.com> (raw)
In-Reply-To: <200608301830.40994.ak@suse.de>
On Wed, 30 Aug 2006 18:30:40 +0200, Andi Kleen wrote:
> It would be better to separate exceptions from interrupts here.
> A spurious interrupt is not necessarily fatal, just an exception is.
>
> But I went with the simpler patch with some changes now
> (added PANIC to the message etc.)
This is already in -mm:
================================================================================
From: Chuck Ebbert <76306.1226@compuserve.com>
Add early i386 fault handlers with debug information for common faults.
Handles:
divide error
invalid opcode
protection fault
page fault
Also adds code to detect early recursive/multiple faults and halt the
system when they happen (taken from x86_64.)
Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
Cc: Andi Kleen <ak@muc.de>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---
arch/i386/kernel/head.S | 67 ++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff -puN arch/i386/kernel/head.S~i386-early-fault-handler arch/i386/kernel/head.S
--- a/arch/i386/kernel/head.S~i386-early-fault-handler
+++ a/arch/i386/kernel/head.S
@@ -371,8 +371,65 @@ rp_sidt:
addl $8,%edi
dec %ecx
jne rp_sidt
+
+.macro set_early_handler handler,trapno
+ lea \handler,%edx
+ movl $(__KERNEL_CS << 16),%eax
+ movw %dx,%ax
+ movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
+ lea idt_table,%edi
+ movl %eax,8*\trapno(%edi)
+ movl %edx,8*\trapno+4(%edi)
+.endm
+
+ set_early_handler handler=early_divide_err,trapno=0
+ set_early_handler handler=early_illegal_opcode,trapno=6
+ set_early_handler handler=early_protection_fault,trapno=13
+ set_early_handler handler=early_page_fault,trapno=14
+
ret
+early_divide_err:
+ xor %edx,%edx
+ pushl $0 /* fake errcode */
+ jmp early_fault
+
+early_illegal_opcode:
+ movl $6,%edx
+ pushl $0 /* fake errcode */
+ jmp early_fault
+
+early_protection_fault:
+ movl $13,%edx
+ jmp early_fault
+
+early_page_fault:
+ movl $14,%edx
+ jmp early_fault
+
+early_fault:
+ cld
+#ifdef CONFIG_PRINTK
+ movl $(__KERNEL_DS),%eax
+ movl %eax,%ds
+ movl %eax,%es
+ cmpl $2,early_recursion_flag
+ je hlt_loop
+ incl early_recursion_flag
+ movl %cr2,%eax
+ pushl %eax
+ pushl %edx /* trapno */
+ pushl $fault_msg
+#ifdef CONFIG_EARLY_PRINTK
+ call early_printk
+#else
+ call printk
+#endif
+#endif
+hlt_loop:
+ hlt
+ jmp hlt_loop
+
/* This is the default interrupt "handler" :-) */
ALIGN
ignore_int:
@@ -386,6 +443,9 @@ ignore_int:
movl $(__KERNEL_DS),%eax
movl %eax,%ds
movl %eax,%es
+ cmpl $2,early_recursion_flag
+ je hlt_loop
+ incl early_recursion_flag
pushl 16(%esp)
pushl 24(%esp)
pushl 32(%esp)
@@ -431,9 +491,16 @@ ENTRY(stack_start)
ready: .byte 0
+early_recursion_flag:
+ .long 0
+
int_msg:
.asciz "Unknown interrupt or fault at EIP %p %p %p\n"
+fault_msg:
+ .ascii "Int %d: CR2 %p err %p EIP %p CS %p flags %p\n"
+ .asciz "Stack: %p %p %p %p %p %p %p %p\n"
+
/*
* The IDT and GDT 'descriptors' are a strange 48-bit object
* only used by the lidt and lgdt instructions. They are not
_
--
Chuck
next reply other threads:[~2006-08-31 2:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-31 2:05 Chuck Ebbert [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-08-30 6:39 Willy Tarreau
2006-08-30 9:51 ` Andi Kleen
2006-08-30 12:18 ` Willy Tarreau
2006-08-30 12:59 ` Andi Kleen
2006-08-30 13:16 ` Willy Tarreau
[not found] ` <20060830100015.6b967c32.seanlkml@sympatico.ca>
2006-08-30 13:46 ` Willy Tarreau
2006-08-30 14:00 ` Sean
[not found] ` <44F5D81A.9650.5BE48F99@pageexec.freemail.hu>
2006-08-30 16:30 ` Andi Kleen
2006-08-30 16:59 ` linux-os (Dick Johnson)
2006-08-30 17:02 ` Andi Kleen
2006-08-30 17:15 ` linux-os (Dick Johnson)
[not found] ` <44F5E818.20898.5C230A79@pageexec.freemail.hu>
2006-08-30 17:52 ` Andi Kleen
[not found] ` <44F5F348.1251.5C4EBCCB@pageexec.freemail.hu>
2006-08-30 18:26 ` Andi Kleen
2006-08-30 19:01 ` Willy Tarreau
2006-08-30 19:36 ` Andi Kleen
2006-08-30 20:03 ` Willy Tarreau
2006-08-30 20:06 ` Andi Kleen
2006-08-30 20:40 ` Willy Tarreau
2006-08-30 21:31 ` Alan Cox
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=200608302209_MC3-1-C9E0-28B7@compuserve.com \
--to=76306.1226@compuserve.com \
--cc=ak@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=pageexec@freemail.hu \
--cc=w@1wt.eu \
/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
all inboxes | Powered by JetHome®