Module Name: src Committed By: rin Date: Tue Oct 19 03:47:33 UTC 2021
Modified Files: src/sys/arch/mips/mips: vm_machdep.c Log Message: Revert previous: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/mips/mips/vm_machdep.c#rev1.163 > cpu_uarea_alloc: For ILP32, do not try to allocate physical memory above > pmap_limits.avail_end. > > Fix NULL dereference in uvm_pglistalloc_contig_aggressive(). "high" argument larger than pmap_limits.avail_end is just legal for uvm_pglistalloc(); uvm_pglistalloc_contig_aggressive() and friends allocate memory between uvm_physseg_get_avail_start() and uvm_physseg_get_avail_end(). It turned out that the NULL dereference took place as PHYS_TO_VM_PAGE() aka uvm_phys_to_vm_page() returns NULL for a valid pa. I've not figured out why... Thanks chs@ for correcting my misunderstanding. To generate a diff of this commit: cvs rdiff -u -r1.163 -r1.164 src/sys/arch/mips/mips/vm_machdep.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/mips/mips/vm_machdep.c diff -u src/sys/arch/mips/mips/vm_machdep.c:1.163 src/sys/arch/mips/mips/vm_machdep.c:1.164 --- src/sys/arch/mips/mips/vm_machdep.c:1.163 Thu Oct 14 02:22:25 2021 +++ src/sys/arch/mips/mips/vm_machdep.c Tue Oct 19 03:47:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.163 2021/10/14 02:22:25 rin Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.164 2021/10/19 03:47:33 rin Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.163 2021/10/14 02:22:25 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.164 2021/10/19 03:47:33 rin Exp $"); #include "opt_ddb.h" #include "opt_cputype.h" @@ -176,13 +176,15 @@ cpu_uarea_alloc(bool system) #ifdef PMAP_MAP_POOLPAGE struct pglist pglist; +#ifdef _LP64 const paddr_t high = pmap_limits.avail_end; -#ifndef _LP64 +#else + const paddr_t high = MIPS_KSEG1_START - MIPS_KSEG0_START; /* * Don't allocate a direct mapped uarea if we aren't allocating for a * system lwp and we have memory that can't be mapped via KSEG0. */ - if (!system && high > MIPS_KSEG1_START - MIPS_KSEG0_START) + if (!system && high < pmap_limits.avail_end) return NULL; #endif int error;