From c0d31b20abf9a3c1d3fcff499e49c36fa71c3a3b Mon Sep 17 00:00:00 2001 From: beveloper Date: Sat, 30 Nov 2002 02:01:29 +0000 Subject: [PATCH] Fixed the detection of page faults that happen while interrupts were disabled. If a page fault happend while a interrupt handler is executed, or while a section of code is running with interrupts disabled (with the exception of the initial kernel startup), the page fault handler will now panic, to give you the chance to fix the bug. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2124 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/arch/x86/arch_int.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/kernel/core/arch/x86/arch_int.c b/src/kernel/core/arch/x86/arch_int.c index e5cecf7bfc..ff7cd37e06 100755 --- a/src/kernel/core/arch/x86/arch_int.c +++ b/src/kernel/core/arch/x86/arch_int.c @@ -185,13 +185,13 @@ i386_handle_trap(struct iframe frame) asm("movl %%cr2, %0" : "=r" (cr2)); - // get the old interrupt enable/disable state and restore to that - if (frame.flags & 0x200) { - dprintf("page_fault: enabling interrupts\n"); - if (!kernel_startup) - dprintf("page_fault, but interrupts are disabled. touching address %p from eip %p\n", (void *)cr2, (void *)frame.eip); - enable_interrupts(); + // if the interrupts were disabled, and we are not running the kernel startup + // the page fault was not allowed to happen and we must panic + if (0 == (frame.flags & 0x200) && !kernel_startup) { + panic("page_fault, but interrupts were disabled. Touching address %p from eip %p\n", (void *)cr2, (void *)frame.eip); } + enable_interrupts(); + ret = vm_page_fault(cr2, frame.eip, (frame.error_code & 0x2) != 0, (frame.error_code & 0x4) != 0,