Module Name:    src
Committed By:   riastradh
Date:           Tue Oct  8 21:09:08 UTC 2024

Modified Files:
        src/sys/arch/x86/x86: pmap.c

Log Message:
x86/pmap: Use UVM_KMF_WAITVA to ensure pmap_pdp_alloc never fails.

This is used as the backing page allocator for pmap_pdp_pool, and
pmap_ctor assumes that PR_WAITOK allocations from it don't fail and
unconditionally writes to the resulting kva, which if null leads
nowhere good.

It is unclear to me why uvm_km_alloc can accept any combination of
the options UVM_KMF_NOWAIT and UVM_KMF_WAITVA.  It seems to me that
at least one should be required (and they should be exclusive), and
any other use should trip an assertion.

PR kern/58666: panic: lock error: Reader / writer lock:
rw_vector_enter,357: locking against myself


To generate a diff of this commit:
cvs rdiff -u -r1.426 -r1.427 src/sys/arch/x86/x86/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.426 src/sys/arch/x86/x86/pmap.c:1.427
--- src/sys/arch/x86/x86/pmap.c:1.426	Wed Oct  4 20:28:06 2023
+++ src/sys/arch/x86/x86/pmap.c	Tue Oct  8 21:09:08 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.426 2023/10/04 20:28:06 ad Exp $	*/
+/*	$NetBSD: pmap.c,v 1.427 2024/10/08 21:09:08 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017, 2019, 2020 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.426 2023/10/04 20:28:06 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.427 2024/10/08 21:09:08 riastradh Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -2844,7 +2844,8 @@ pmap_pdp_alloc(struct pool *pp, int flag
 {
 	return (void *)uvm_km_alloc(kernel_map,
 	    PAGE_SIZE * PDP_SIZE, PAGE_SIZE * PDP_SIZE,
-	    ((flags & PR_WAITOK) ? 0 : UVM_KMF_NOWAIT | UVM_KMF_TRYLOCK) |
+	    ((flags & PR_WAITOK) ? UVM_KMF_WAITVA
+		: UVM_KMF_NOWAIT | UVM_KMF_TRYLOCK) |
 	    UVM_KMF_WIRED);
 }
 

Reply via email to