From 14c6412e314fe1f46f3f3a63e92d439a9f19f70c Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Fri, 29 Mar 2024 21:19:31 +0000 Subject: Text faults should not invoke uvm_grow() since the fault address is not on stack. Remove duplicated "panic if uvm_fault() fails and we are in kernel mode" blocks. ok claudio@ kettenis@ --- sys/arch/sparc64/sparc64/trap.c | 54 ++++------------------------------------- 1 file changed, 5 insertions(+), 49 deletions(-) diff --git a/sys/arch/sparc64/sparc64/trap.c b/sys/arch/sparc64/sparc64/trap.c index e1648c80380..985490582e8 100644 --- a/sys/arch/sparc64/sparc64/trap.c +++ b/sys/arch/sparc64/sparc64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.124 2024/03/29 21:17:13 miod Exp $ */ +/* $OpenBSD: trap.c,v 1.125 2024/03/29 21:19:30 miod Exp $ */ /* $NetBSD: trap.c,v 1.73 2001/08/09 01:03:01 eeh Exp $ */ /* @@ -903,28 +903,8 @@ text_access_fault(struct trapframe *tf, unsigned type, vaddr_t pc, goto out; error = uvm_fault(&p->p_vmspace->vm_map, va, 0, access_type); - - /* - * If this was a stack access we keep track of the maximum - * accessed stack size. Also, if uvm_fault gets a protection - * failure it is due to accessing the stack region outside - * the current limit and we need to reflect that as an access - * error. - */ - if (error == 0) { - uvm_grow(p, va); + if (error == 0) goto out; - } - - /* - * Pagein failed. Any other page fault in kernel, die; if user - * fault, deliver SIGSEGV. - */ - if (tf->tf_tstate & TSTATE_PRIV) { - (void) splhigh(); - panic("kernel text fault: pc=%llx", (unsigned long long)pc); - /* NOTREACHED */ - } signal = SIGSEGV; sicode = SEGV_MAPERR; @@ -937,10 +917,8 @@ text_access_fault(struct trapframe *tf, unsigned type, vaddr_t pc, trapsignal(p, signal, access_type, sicode, sv); out: - if ((tf->tf_tstate & TSTATE_PRIV) == 0) { - userret(p); - share_fpu(p, tf); - } + userret(p); + share_fpu(p, tf); } @@ -997,30 +975,8 @@ text_access_error(struct trapframe *tf, unsigned type, vaddr_t pc, goto out; error = uvm_fault(&p->p_vmspace->vm_map, va, 0, access_type); - - /* - * If this was a stack access we keep track of the maximum - * accessed stack size. Also, if uvm_fault gets a protection - * failure it is due to accessing the stack region outside - * the current limit and we need to reflect that as an access - * error. - */ - if (error == 0) { - uvm_grow(p, va); + if (error == 0) goto out; - } - - /* - * Pagein failed. If doing copyin/out, return to onfault - * address. Any other page fault in kernel, die; if user - * fault, deliver SIGSEGV. - */ - if (tf->tf_tstate & TSTATE_PRIV) { - (void) splhigh(); - panic("kernel text error: pc=%lx sfsr=%lb", pc, - sfsr, SFSR_BITS); - /* NOTREACHED */ - } signal = SIGSEGV; sicode = SEGV_MAPERR; -- cgit v1.2.3