Messages in this thread Patch in this message |  | | Date | Mon, 7 May 2001 13:58:40 -0700 (PDT) | From | Nigel Gamble <> | Subject | Re: [PATCH] x86 page fault handler not interrupt safe |
| |
On Mon, 7 May 2001, Linus Torvalds wrote: > On Mon, 7 May 2001, Brian Gerst wrote: > > This patch will still cause the user process to seg fault: The error > > code on the stack will not match the address in %cr2. > > You've convinced me. Good thinking. Let's do the irq thing.
I've actually seen user processes seg faulting because of this with the fully preemptible kernel patch applied. The fix we used in that patch was to use an interrupt gate for the fault handler, then to simply restore the interrupt state:
diff -Nur 2.4.2/arch/i386/kernel/traps.c linux/arch/i386/kernel/traps.c --- 2.4.2/arch/i386/kernel/traps.c Mon Mar 26 18:41:05 2001 +++ linux/arch/i386/kernel/traps.c Tue Mar 27 15:13:33 2001 @@ -973,7 +973,7 @@ set_trap_gate(11,&segment_not_present); set_trap_gate(12,&stack_segment); set_trap_gate(13,&general_protection); - set_trap_gate(14,&page_fault); + set_intr_gate(14,&page_fault); set_trap_gate(15,&spurious_interrupt_bug); set_trap_gate(16,&coprocessor_error); set_trap_gate(17,&alignment_check); diff -Nur 2.4.2/arch/i386/mm/fault.c linux/arch/i386/mm/fault.c --- 2.4.2/arch/i386/mm/fault.c Mon Mar 26 18:41:06 2001 +++ linux/arch/i386/mm/fault.c Tue Mar 27 15:13:33 2001 @@ -117,6 +117,9 @@ /* get the address */ __asm__("movl %%cr2,%0":"=r" (address)); + /* It's safe to allow preemption after cr2 has been saved */ + local_irq_restore(regs->eflags); + tsk = current; /* Nigel Gamble nigel@nrg.org Mountain View, CA, USA. http://www.nrg.org/
MontaVista Software nigel@mvista.com
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |