From 959c02787e3ad9cf174312c0843a0ec9425db5dd Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Wed, 18 Dec 1996 19:12:01 +0000 Subject: [PATCH] Only handle copyin/out/etc faults when not in an interrupt handler. This makes unexpected faults (in an interrupt handler) more likely to crash properly. It could be done even better (more robustly and more efficiently) using lazy fault handling. --- sys/amd64/amd64/trap.c | 17 +++++++++-------- sys/i386/i386/trap.c | 17 +++++++++-------- sys/kern/subr_trap.c | 17 +++++++++-------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index c86e7fd21855..e976df519457 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.82 1996/09/01 10:10:12 davidg Exp $ + * $Id: trap.c,v 1.83 1996/09/10 08:32:01 bde Exp $ */ /* @@ -350,10 +350,10 @@ trap(frame) doreti_popl_ds_fault); MAYBE_DORETI_FAULT(doreti_popl_es, doreti_popl_es_fault); - } - if (curpcb && curpcb->pcb_onfault) { - frame.tf_eip = (int)curpcb->pcb_onfault; - return; + if (curpcb && curpcb->pcb_onfault) { + frame.tf_eip = (int)curpcb->pcb_onfault; + return; + } } break; @@ -493,7 +493,8 @@ trap_pfault(frame, usermode) if (p == NULL || (!usermode && va < VM_MAXUSER_ADDRESS && - (curpcb == NULL || curpcb->pcb_onfault == NULL))) { + (intr_nesting_level != 0 || curpcb == NULL || + curpcb->pcb_onfault == NULL))) { trap_fatal(frame); return (-1); } @@ -550,7 +551,7 @@ trap_pfault(frame, usermode) return (0); nogo: if (!usermode) { - if (curpcb && curpcb->pcb_onfault) { + if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) { frame->tf_eip = (int)curpcb->pcb_onfault; return (0); } @@ -645,7 +646,7 @@ trap_pfault(frame, usermode) return (0); nogo: if (!usermode) { - if (curpcb && curpcb->pcb_onfault) { + if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) { frame->tf_eip = (int)curpcb->pcb_onfault; return (0); } diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index c86e7fd21855..e976df519457 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.82 1996/09/01 10:10:12 davidg Exp $ + * $Id: trap.c,v 1.83 1996/09/10 08:32:01 bde Exp $ */ /* @@ -350,10 +350,10 @@ trap(frame) doreti_popl_ds_fault); MAYBE_DORETI_FAULT(doreti_popl_es, doreti_popl_es_fault); - } - if (curpcb && curpcb->pcb_onfault) { - frame.tf_eip = (int)curpcb->pcb_onfault; - return; + if (curpcb && curpcb->pcb_onfault) { + frame.tf_eip = (int)curpcb->pcb_onfault; + return; + } } break; @@ -493,7 +493,8 @@ trap_pfault(frame, usermode) if (p == NULL || (!usermode && va < VM_MAXUSER_ADDRESS && - (curpcb == NULL || curpcb->pcb_onfault == NULL))) { + (intr_nesting_level != 0 || curpcb == NULL || + curpcb->pcb_onfault == NULL))) { trap_fatal(frame); return (-1); } @@ -550,7 +551,7 @@ trap_pfault(frame, usermode) return (0); nogo: if (!usermode) { - if (curpcb && curpcb->pcb_onfault) { + if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) { frame->tf_eip = (int)curpcb->pcb_onfault; return (0); } @@ -645,7 +646,7 @@ trap_pfault(frame, usermode) return (0); nogo: if (!usermode) { - if (curpcb && curpcb->pcb_onfault) { + if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) { frame->tf_eip = (int)curpcb->pcb_onfault; return (0); } diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index c86e7fd21855..e976df519457 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.82 1996/09/01 10:10:12 davidg Exp $ + * $Id: trap.c,v 1.83 1996/09/10 08:32:01 bde Exp $ */ /* @@ -350,10 +350,10 @@ trap(frame) doreti_popl_ds_fault); MAYBE_DORETI_FAULT(doreti_popl_es, doreti_popl_es_fault); - } - if (curpcb && curpcb->pcb_onfault) { - frame.tf_eip = (int)curpcb->pcb_onfault; - return; + if (curpcb && curpcb->pcb_onfault) { + frame.tf_eip = (int)curpcb->pcb_onfault; + return; + } } break; @@ -493,7 +493,8 @@ trap_pfault(frame, usermode) if (p == NULL || (!usermode && va < VM_MAXUSER_ADDRESS && - (curpcb == NULL || curpcb->pcb_onfault == NULL))) { + (intr_nesting_level != 0 || curpcb == NULL || + curpcb->pcb_onfault == NULL))) { trap_fatal(frame); return (-1); } @@ -550,7 +551,7 @@ trap_pfault(frame, usermode) return (0); nogo: if (!usermode) { - if (curpcb && curpcb->pcb_onfault) { + if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) { frame->tf_eip = (int)curpcb->pcb_onfault; return (0); } @@ -645,7 +646,7 @@ trap_pfault(frame, usermode) return (0); nogo: if (!usermode) { - if (curpcb && curpcb->pcb_onfault) { + if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) { frame->tf_eip = (int)curpcb->pcb_onfault; return (0); }