* [patch] i386: early pagefault handler
@ 2006-07-05 11:44 Chuck Ebbert
2006-07-05 11:47 ` Ingo Molnar
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Chuck Ebbert @ 2006-07-05 11:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Andrew Morton, Ingo Molnar, Linus Torvalds
Page faults during kernel initialization can be hard to diagnose.
Add a handler that prints the fault address, EIP and top of stack
when an early page fault happens.
Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
arch/i386/kernel/head.S | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+)
--- 2.6.17-nb.orig/arch/i386/kernel/head.S
+++ 2.6.17-nb/arch/i386/kernel/head.S
@@ -378,8 +378,41 @@ rp_sidt:
addl $8,%edi
dec %ecx
jne rp_sidt
+
+ lea page_fault,%edi /* early page fault handler */
+ movw %di,%ax
+ andl $0x0000ffff,%edx
+ andl $0xffff0000,%edi
+ orl %edi,%edx
+ lea idt_table,%edi
+ movl %eax,8*14(%edi)
+ movl %edx,8*14+4(%edi)
+
ret
+/* This is the early page fault handler */
+ ALIGN
+page_fault:
+ cld
+#ifdef CONFIG_PRINTK
+ movl $(__KERNEL_DS),%eax
+ movl %eax,%ds
+ movl %eax,%es
+ movl %cr2,%eax
+ pushl %eax
+ pushl $pf_msg
+#ifdef CONFIG_EARLY_PRINTK
+ call early_printk
+#else
+ call printk
+#endif
+#endif
+hlt_loop:
+ hlt
+1:
+ rep ; nop
+ jmp 1b
+
/* This is the default interrupt "handler" :-) */
ALIGN
ignore_int:
@@ -441,6 +474,10 @@ ready: .byte 0
int_msg:
.asciz "Unknown interrupt or fault at EIP %p %p %p\n"
+pf_msg:
+ .ascii "Pg flt: CR2 %p err %p EIP %p CS %p flags %p\n"
+ .asciz " Stk: %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
"You can't read a newspaper if you can't read." --George W. Bush
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] i386: early pagefault handler
2006-07-05 11:44 [patch] i386: early pagefault handler Chuck Ebbert
@ 2006-07-05 11:47 ` Ingo Molnar
2006-07-05 13:10 ` Andi Kleen
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Ingo Molnar @ 2006-07-05 11:47 UTC (permalink / raw)
To: Chuck Ebbert; +Cc: linux-kernel, Andrew Morton, Linus Torvalds
* Chuck Ebbert <76306.1226@compuserve.com> wrote:
> Page faults during kernel initialization can be hard to diagnose.
>
> Add a handler that prints the fault address, EIP and top of stack when
> an early page fault happens.
>
> Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
nice!
Acked-by: Ingo Molnar <mingo@elte.hu>
Ingo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] i386: early pagefault handler
2006-07-05 11:44 [patch] i386: early pagefault handler Chuck Ebbert
2006-07-05 11:47 ` Ingo Molnar
@ 2006-07-05 13:10 ` Andi Kleen
2006-07-05 16:38 ` H. Peter Anvin
2006-07-05 20:24 ` Linus Torvalds
2006-07-07 2:06 ` Daniel Phillips
3 siblings, 1 reply; 11+ messages in thread
From: Andi Kleen @ 2006-07-05 13:10 UTC (permalink / raw)
To: Chuck Ebbert; +Cc: Andrew Morton, Ingo Molnar, Linus Torvalds, linux-kernel
Chuck Ebbert <76306.1226@compuserve.com> writes:
> Page faults during kernel initialization can be hard to diagnose.
>
> Add a handler that prints the fault address, EIP and top of stack
> when an early page fault happens.
You should do it for all the exceptions then
(except perhaps NMI). Isn't much more work - see the x86-64 code.
> +hlt_loop:
> + hlt
There are still supported i386 CPUs that don't support HLT and
would recursively fault here.
> + rep ; nop
> + jmp 1b
Looks a bit weird to not jump to hlt back again but ok.
The HLT is unlikely to come back anyways because interrupts
are off.
-Andi
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] i386: early pagefault handler
2006-07-05 13:10 ` Andi Kleen
@ 2006-07-05 16:38 ` H. Peter Anvin
2006-07-05 16:54 ` Linus Torvalds
0 siblings, 1 reply; 11+ messages in thread
From: H. Peter Anvin @ 2006-07-05 16:38 UTC (permalink / raw)
To: Andi Kleen
Cc: Chuck Ebbert, Andrew Morton, Ingo Molnar, Linus Torvalds,
linux-kernel
Andi Kleen wrote:
>
>> +hlt_loop:
>> + hlt
>
> There are still supported i386 CPUs that don't support HLT and
> would recursively fault here.
>
The HLT has been supported since 8086. However, it was broken in some
early 486s (not 386s); that's what the test in the kernel is for.
I don't remember what the failure mode was, though; didn't think it was
recursive faulting.
-hpa
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] i386: early pagefault handler
2006-07-05 16:38 ` H. Peter Anvin
@ 2006-07-05 16:54 ` Linus Torvalds
2006-07-05 18:28 ` Alan Cox
0 siblings, 1 reply; 11+ messages in thread
From: Linus Torvalds @ 2006-07-05 16:54 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Andi Kleen, Chuck Ebbert, Andrew Morton, Ingo Molnar,
linux-kernel
On Wed, 5 Jul 2006, H. Peter Anvin wrote:
>
> I don't remember what the failure mode was, though; didn't think it was
> recursive faulting.
I think we should probably remove the test. The failure mode was simply
that a machine with the "halt" idle loop simply didn't work, and would
lock up. The most likely reason for that is probably just a bad CPU power
VRM, and the potential high current fluctuations, not so much any CPU bug
itself.
Anybody with that old a CPU will have learnt to to say "no-hlt" or
whatever the kernel command line is, and we could probably retire the
silly old hlt check (which I'm not even sure really ever worked).
Linus
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] i386: early pagefault handler
2006-07-05 18:28 ` Alan Cox
@ 2006-07-05 18:26 ` H. Peter Anvin
2006-07-05 18:41 ` Linus Torvalds
1 sibling, 0 replies; 11+ messages in thread
From: H. Peter Anvin @ 2006-07-05 18:26 UTC (permalink / raw)
To: Alan Cox
Cc: Linus Torvalds, Andi Kleen, Chuck Ebbert, Andrew Morton,
Ingo Molnar, linux-kernel
Alan Cox wrote:
> Ar Mer, 2006-07-05 am 09:54 -0700, ysgrifennodd Linus Torvalds:
>> Anybody with that old a CPU will have learnt to to say "no-hlt" or
>> whatever the kernel command line is, and we could probably retire the
>> silly old hlt check (which I'm not even sure really ever worked).
>
> The one specific case I know precisely details of was the Cyrix 5510. A
> hlt by the CPU on that chipset during an IDE DMA transfer hangs the
> system forever.
>
> Its some years since I've even seen a 5510 and that check could be
> automated anyway
I think HLT for a die loop should be safe :)
-hpa
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] i386: early pagefault handler
2006-07-05 16:54 ` Linus Torvalds
@ 2006-07-05 18:28 ` Alan Cox
2006-07-05 18:26 ` H. Peter Anvin
2006-07-05 18:41 ` Linus Torvalds
0 siblings, 2 replies; 11+ messages in thread
From: Alan Cox @ 2006-07-05 18:28 UTC (permalink / raw)
To: Linus Torvalds
Cc: H. Peter Anvin, Andi Kleen, Chuck Ebbert, Andrew Morton,
Ingo Molnar, linux-kernel
Ar Mer, 2006-07-05 am 09:54 -0700, ysgrifennodd Linus Torvalds:
> Anybody with that old a CPU will have learnt to to say "no-hlt" or
> whatever the kernel command line is, and we could probably retire the
> silly old hlt check (which I'm not even sure really ever worked).
The one specific case I know precisely details of was the Cyrix 5510. A
hlt by the CPU on that chipset during an IDE DMA transfer hangs the
system forever.
Its some years since I've even seen a 5510 and that check could be
automated anyway
Alan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] i386: early pagefault handler
2006-07-05 18:28 ` Alan Cox
2006-07-05 18:26 ` H. Peter Anvin
@ 2006-07-05 18:41 ` Linus Torvalds
1 sibling, 0 replies; 11+ messages in thread
From: Linus Torvalds @ 2006-07-05 18:41 UTC (permalink / raw)
To: Alan Cox
Cc: H. Peter Anvin, Andi Kleen, Chuck Ebbert, Andrew Morton,
Ingo Molnar, linux-kernel
On Wed, 5 Jul 2006, Alan Cox wrote:
>
> Ar Mer, 2006-07-05 am 09:54 -0700, ysgrifennodd Linus Torvalds:
> > Anybody with that old a CPU will have learnt to to say "no-hlt" or
> > whatever the kernel command line is, and we could probably retire the
> > silly old hlt check (which I'm not even sure really ever worked).
>
> The one specific case I know precisely details of was the Cyrix 5510. A
> hlt by the CPU on that chipset during an IDE DMA transfer hangs the
> system forever.
Yeah, now that you say it, another "halt" problem was some floppy DMA
apparently being broken by halt on some machines.
The indirect point of that being that the boot-time hlt test wouldn't
actually have triggered that anyway (no DMA taking place at that time).
Although I suspect back when this mattered (a long long time ago ;), the
boot-time hlt test made a lot of people more _aware_ of the fact that halt
could cause problems.
Sometimes the solutions are purely psychological ;)
Linus
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] i386: early pagefault handler
2006-07-05 11:44 [patch] i386: early pagefault handler Chuck Ebbert
2006-07-05 11:47 ` Ingo Molnar
2006-07-05 13:10 ` Andi Kleen
@ 2006-07-05 20:24 ` Linus Torvalds
2006-07-07 2:06 ` Daniel Phillips
3 siblings, 0 replies; 11+ messages in thread
From: Linus Torvalds @ 2006-07-05 20:24 UTC (permalink / raw)
To: Chuck Ebbert; +Cc: linux-kernel, Andrew Morton, Ingo Molnar
On Wed, 5 Jul 2006, Chuck Ebbert wrote:
>
> Page faults during kernel initialization can be hard to diagnose.
>
> Add a handler that prints the fault address, EIP and top of stack
> when an early page fault happens.
Is there really any reason to do this in assembler? The "start_kernel"
call into C happens not that much later, and none of what the routine does
seems to really be especially assembler-friendly.
Linus
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] i386: early pagefault handler
2006-07-05 11:44 [patch] i386: early pagefault handler Chuck Ebbert
` (2 preceding siblings ...)
2006-07-05 20:24 ` Linus Torvalds
@ 2006-07-07 2:06 ` Daniel Phillips
2006-07-07 2:51 ` H. Peter Anvin
3 siblings, 1 reply; 11+ messages in thread
From: Daniel Phillips @ 2006-07-07 2:06 UTC (permalink / raw)
To: Chuck Ebbert; +Cc: linux-kernel, Andrew Morton, Ingo Molnar, Linus Torvalds
Chuck Ebbert wrote:
> +page_fault:
> + cld
My i386 lore is getting a little rusty, can the direction flag actually be
random here?
Regards,
Daniel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch] i386: early pagefault handler
2006-07-07 2:06 ` Daniel Phillips
@ 2006-07-07 2:51 ` H. Peter Anvin
0 siblings, 0 replies; 11+ messages in thread
From: H. Peter Anvin @ 2006-07-07 2:51 UTC (permalink / raw)
To: Daniel Phillips
Cc: Chuck Ebbert, linux-kernel, Andrew Morton, Ingo Molnar,
Linus Torvalds
Daniel Phillips wrote:
> Chuck Ebbert wrote:
>> +page_fault:
>> + cld
>
> My i386 lore is getting a little rusty, can the direction flag actually be
> random here?
Yes.
-hpa
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2006-07-07 2:53 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-05 11:44 [patch] i386: early pagefault handler Chuck Ebbert
2006-07-05 11:47 ` Ingo Molnar
2006-07-05 13:10 ` Andi Kleen
2006-07-05 16:38 ` H. Peter Anvin
2006-07-05 16:54 ` Linus Torvalds
2006-07-05 18:28 ` Alan Cox
2006-07-05 18:26 ` H. Peter Anvin
2006-07-05 18:41 ` Linus Torvalds
2006-07-05 20:24 ` Linus Torvalds
2006-07-07 2:06 ` Daniel Phillips
2006-07-07 2:51 ` H. Peter Anvin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox