diff options
author | jhb <jhb@FreeBSD.org> | 2001-05-11 23:50:08 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-05-11 23:50:08 +0000 |
commit | c20ad9aee20025e5e02cc318f355e6866e04bef1 (patch) | |
tree | bc6fd1892ca4ffcf8937beab0e366b979b5c8a37 | |
parent | bba3cec519b0df520da69e77e569c12fad190810 (diff) | |
download | FreeBSD-src-c20ad9aee20025e5e02cc318f355e6866e04bef1.zip FreeBSD-src-c20ad9aee20025e5e02cc318f355e6866e04bef1.tar.gz |
Simplify the vm fault trap handling code a bit by using if-else instead of
duplicating code in the then case and then using a goto to jump around
the else case.
-rw-r--r-- | sys/amd64/amd64/trap.c | 44 | ||||
-rw-r--r-- | sys/i386/i386/trap.c | 44 | ||||
-rw-r--r-- | sys/ia64/ia64/trap.c | 15 | ||||
-rw-r--r-- | sys/kern/subr_trap.c | 44 |
4 files changed, 49 insertions, 98 deletions
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index d9597df..5ff51fd 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -743,16 +743,11 @@ trap_pfault(frame, usermode, eva) * a growable stack region, or if the stack * growth succeeded. */ - if (!grow_stack (p, va)) { + if (!grow_stack (p, va)) rv = KERN_FAILURE; - PROC_LOCK(p); - --p->p_lock; - PROC_UNLOCK(p); - goto nogo; - } - - /* Fault in the user page: */ - rv = vm_fault(map, va, ftype, + else + /* Fault in the user page: */ + rv = vm_fault(map, va, ftype, (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY : VM_FAULT_NORMAL); @@ -864,16 +859,11 @@ trap_pfault(frame, usermode, eva) * a growable stack region, or if the stack * growth succeeded. */ - if (!grow_stack (p, va)) { + if (!grow_stack (p, va)) rv = KERN_FAILURE; - PROC_LOCK(p); - --p->p_lock; - PROC_UNLOCK(p); - goto nogo; - } - - /* Fault in the user page: */ - rv = vm_fault(map, va, ftype, + else + /* Fault in the user page: */ + rv = vm_fault(map, va, ftype, (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY : VM_FAULT_NORMAL); @@ -1044,17 +1034,13 @@ int trapwrite(addr) ++p->p_lock; PROC_UNLOCK(p); - if (!grow_stack (p, va)) { - PROC_LOCK(p); - --p->p_lock; - PROC_UNLOCK(p); - return (1); - } - - /* - * fault the data page - */ - rv = vm_fault(&vm->vm_map, va, VM_PROT_WRITE, VM_FAULT_DIRTY); + if (!grow_stack (p, va)) + rv = KERN_FAILURE; + else + /* + * fault the data page + */ + rv = vm_fault(&vm->vm_map, va, VM_PROT_WRITE, VM_FAULT_DIRTY); PROC_LOCK(p); --p->p_lock; diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index d9597df..5ff51fd 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -743,16 +743,11 @@ trap_pfault(frame, usermode, eva) * a growable stack region, or if the stack * growth succeeded. */ - if (!grow_stack (p, va)) { + if (!grow_stack (p, va)) rv = KERN_FAILURE; - PROC_LOCK(p); - --p->p_lock; - PROC_UNLOCK(p); - goto nogo; - } - - /* Fault in the user page: */ - rv = vm_fault(map, va, ftype, + else + /* Fault in the user page: */ + rv = vm_fault(map, va, ftype, (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY : VM_FAULT_NORMAL); @@ -864,16 +859,11 @@ trap_pfault(frame, usermode, eva) * a growable stack region, or if the stack * growth succeeded. */ - if (!grow_stack (p, va)) { + if (!grow_stack (p, va)) rv = KERN_FAILURE; - PROC_LOCK(p); - --p->p_lock; - PROC_UNLOCK(p); - goto nogo; - } - - /* Fault in the user page: */ - rv = vm_fault(map, va, ftype, + else + /* Fault in the user page: */ + rv = vm_fault(map, va, ftype, (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY : VM_FAULT_NORMAL); @@ -1044,17 +1034,13 @@ int trapwrite(addr) ++p->p_lock; PROC_UNLOCK(p); - if (!grow_stack (p, va)) { - PROC_LOCK(p); - --p->p_lock; - PROC_UNLOCK(p); - return (1); - } - - /* - * fault the data page - */ - rv = vm_fault(&vm->vm_map, va, VM_PROT_WRITE, VM_FAULT_DIRTY); + if (!grow_stack (p, va)) + rv = KERN_FAILURE; + else + /* + * fault the data page + */ + rv = vm_fault(&vm->vm_map, va, VM_PROT_WRITE, VM_FAULT_DIRTY); PROC_LOCK(p); --p->p_lock; diff --git a/sys/ia64/ia64/trap.c b/sys/ia64/ia64/trap.c index 8f9b258..3582dd2 100644 --- a/sys/ia64/ia64/trap.c +++ b/sys/ia64/ia64/trap.c @@ -396,17 +396,11 @@ trap(int vector, int imm, struct trapframe *framep) * a growable stack region, or if the stack * growth succeeded. */ - if (!grow_stack (p, va)) { + if (!grow_stack (p, va)) rv = KERN_FAILURE; - PROC_LOCK(p); - --p->p_lock; - PROC_UNLOCK(p); - goto nogo; - } - - - /* Fault in the user page: */ - rv = vm_fault(map, va, ftype, + else + /* Fault in the user page: */ + rv = vm_fault(map, va, ftype, (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY : VM_FAULT_NORMAL); @@ -422,7 +416,6 @@ trap(int vector, int imm, struct trapframe *framep) rv = vm_fault(map, va, ftype, VM_FAULT_NORMAL); } - nogo:; /* * If this was a stack access we keep track of the * maximum accessed stack size. Also, if vm_fault diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index d9597df..5ff51fd 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -743,16 +743,11 @@ trap_pfault(frame, usermode, eva) * a growable stack region, or if the stack * growth succeeded. */ - if (!grow_stack (p, va)) { + if (!grow_stack (p, va)) rv = KERN_FAILURE; - PROC_LOCK(p); - --p->p_lock; - PROC_UNLOCK(p); - goto nogo; - } - - /* Fault in the user page: */ - rv = vm_fault(map, va, ftype, + else + /* Fault in the user page: */ + rv = vm_fault(map, va, ftype, (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY : VM_FAULT_NORMAL); @@ -864,16 +859,11 @@ trap_pfault(frame, usermode, eva) * a growable stack region, or if the stack * growth succeeded. */ - if (!grow_stack (p, va)) { + if (!grow_stack (p, va)) rv = KERN_FAILURE; - PROC_LOCK(p); - --p->p_lock; - PROC_UNLOCK(p); - goto nogo; - } - - /* Fault in the user page: */ - rv = vm_fault(map, va, ftype, + else + /* Fault in the user page: */ + rv = vm_fault(map, va, ftype, (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY : VM_FAULT_NORMAL); @@ -1044,17 +1034,13 @@ int trapwrite(addr) ++p->p_lock; PROC_UNLOCK(p); - if (!grow_stack (p, va)) { - PROC_LOCK(p); - --p->p_lock; - PROC_UNLOCK(p); - return (1); - } - - /* - * fault the data page - */ - rv = vm_fault(&vm->vm_map, va, VM_PROT_WRITE, VM_FAULT_DIRTY); + if (!grow_stack (p, va)) + rv = KERN_FAILURE; + else + /* + * fault the data page + */ + rv = vm_fault(&vm->vm_map, va, VM_PROT_WRITE, VM_FAULT_DIRTY); PROC_LOCK(p); --p->p_lock; |