Module Name:    src
Committed By:   chs
Date:           Sat Aug  6 05:55:37 UTC 2022

Modified Files:
        src/sys/uvm: uvm_km.c

Log Message:
allow KMSAN to work again by restoring the limiting of kva even with
NKMEMPAGES_MAX_UNLIMITED.  we used to limit kva to 1/8 of physmem
but limiting to 1/4 should be enough, and 1/4 still gives the kernel
enough kva to map all of the RAM that KMSAN has not stolen.

Reported-by: syzbot+ca3710b4c40cdd61a...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/sys/uvm/uvm_km.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/uvm/uvm_km.c
diff -u src/sys/uvm/uvm_km.c:1.161 src/sys/uvm/uvm_km.c:1.162
--- src/sys/uvm/uvm_km.c:1.161	Wed Aug  3 01:52:11 2022
+++ src/sys/uvm/uvm_km.c	Sat Aug  6 05:55:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_km.c,v 1.161 2022/08/03 01:52:11 chs Exp $	*/
+/*	$NetBSD: uvm_km.c,v 1.162 2022/08/06 05:55:37 chs Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -152,7 +152,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.161 2022/08/03 01:52:11 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.162 2022/08/06 05:55:37 chs Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -226,22 +226,25 @@ kmeminit_nkmempages(void)
 		return;
 	}
 
-#ifdef NKMEMPAGES_MAX_UNLIMITED
+#if defined(NKMEMPAGES_MAX_UNLIMITED) && !defined(KMSAN)
 	npages = physmem;
 #else
 
 #if defined(KMSAN)
-	npages = (physmem / 8);
+	npages = (physmem / 4);
 #elif defined(PMAP_MAP_POOLPAGE)
 	npages = (physmem / 4);
 #else
 	npages = (physmem / 3) * 2;
 #endif /* defined(PMAP_MAP_POOLPAGE) */
 
+#if !defined(NKMEMPAGES_MAX_UNLIMITED)
 	if (npages > NKMEMPAGES_MAX)
 		npages = NKMEMPAGES_MAX;
 #endif
 
+#endif
+
 	if (npages < NKMEMPAGES_MIN)
 		npages = NKMEMPAGES_MIN;
 

Reply via email to