From: sthen Date: Sun, 20 Jun 2021 10:58:36 +0000 (+0000) Subject: Reinstate locks around uvm_fault calls from upageflttrap and kpageflttrap X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b26de507dd722693b172902f717b5d4950ee6717;p=openbsd Reinstate locks around uvm_fault calls from upageflttrap and kpageflttrap on i386. This is a backout of revision 1.152. Kernel crash with messages printed concurrently from multiple CPUs occasionally seen during ports build: "WARNING: SPL NOT LOWERED ON TRAP EXIT" and these panics ddb{1}> sh panic cpu1: uvm_fault(0xd470a0a0, 0xcf9b7000, 0, 1) -> e cpu3: kernel diagnostic assertion "!_kernel_lock_held()" failed: file "/usr/src/sys/uvm/uvm_map.c", line 2707 --- diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index 35bd6735ac8..e97d0928b47 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.153 2021/05/16 15:10:19 deraadt Exp $ */ +/* $OpenBSD: trap.c,v 1.154 2021/06/20 10:58:36 sthen Exp $ */ /* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */ /*- @@ -126,7 +126,10 @@ upageflttrap(struct trapframe *frame, uint32_t cr2) union sigval sv; int signal, sicode, error; + KERNEL_LOCK(); error = uvm_fault(&p->p_vmspace->vm_map, va, 0, access_type); + KERNEL_UNLOCK(); + if (error == 0) { uvm_grow(p, va); return 1; @@ -200,7 +203,9 @@ kpageflttrap(struct trapframe *frame, uint32_t cr2) if (curcpu()->ci_inatomic == 0 || map == kernel_map) { onfault = pcb->pcb_onfault; pcb->pcb_onfault = NULL; + KERNEL_LOCK(); error = uvm_fault(map, va, 0, access_type); + KERNEL_UNLOCK(); pcb->pcb_onfault = onfault; if (error == 0 && map != kernel_map)