Module Name: src Committed By: matt Date: Sat May 30 23:59:33 UTC 2015
Modified Files: src/sys/arch/arm/arm32: arm32_kvminit.c pmap.c src/sys/arch/arm/include/arm32: pmap.h Log Message: Support directmapped systems with >1GB that start memory at 0x80000000. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/arm32/arm32_kvminit.c cvs rdiff -u -r1.322 -r1.323 src/sys/arch/arm/arm32/pmap.c cvs rdiff -u -r1.139 -r1.140 src/sys/arch/arm/include/arm32/pmap.h 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/arm/arm32/arm32_kvminit.c diff -u src/sys/arch/arm/arm32/arm32_kvminit.c:1.33 src/sys/arch/arm/arm32/arm32_kvminit.c:1.34 --- src/sys/arch/arm/arm32/arm32_kvminit.c:1.33 Mon May 4 00:44:12 2015 +++ src/sys/arch/arm/arm32/arm32_kvminit.c Sat May 30 23:59:33 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: arm32_kvminit.c,v 1.33 2015/05/04 00:44:12 matt Exp $ */ +/* $NetBSD: arm32_kvminit.c,v 1.34 2015/05/30 23:59:33 matt Exp $ */ /* * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. @@ -124,7 +124,7 @@ #include "opt_multiprocessor.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.33 2015/05/04 00:44:12 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arm32_kvminit.c,v 1.34 2015/05/30 23:59:33 matt Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -195,6 +195,7 @@ arm32_bootmem_init(paddr_t memstart, psi if (physical_end == 0) { physical_end = -PAGE_SIZE; memsize -= PAGE_SIZE; + bmi->bmi_end -= PAGE_SIZE; #ifdef VERBOSE_INIT_ARM printf("%s: memsize shrunk by a page to avoid ending at 4GB\n", __func__); @@ -441,8 +442,10 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b * from TTBR0 to map some of the physical memory. But try to use as * much high memory space as possible. */ - if (kernel_vm_base - KERNEL_BASE < physical_size) { - pmap_directbase = kernel_vm_base - physical_size; + pmap_directlimit = kernel_vm_base; + if (kernel_vm_base - KERNEL_BASE < physical_size + && kernel_vm_base - physical_size >= physical_start) { + pmap_directbase -= KERNEL_BASE_VOFFSET; printf("%s: changing pmap_directbase to %#lx\n", __func__, pmap_directbase); } @@ -838,6 +841,9 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b && cur_pv.pv_cache == PTE_CACHE) { cur_pv.pv_size = bmi->bmi_end - cur_pv.pv_pa; } else { + KASSERTMSG(cur_pv.pv_va + cur_pv.pv_size <= kernel_vm_base, + "%#lx >= %#lx", cur_pv.pv_va + cur_pv.pv_size, + kernel_vm_base); #ifdef VERBOSE_INIT_ARM printf("%s: mapping chunk VA %#lx..%#lx " "(PA %#lx, prot %d, cache %d)\n", @@ -854,6 +860,13 @@ arm32_kernel_vm_init(vaddr_t kernel_vm_b } } + // The amount we can direct is limited by the start of the + // virtual part of the kernel address space. Don't overrun + // into it. + if (mapallmem_p && cur_pv.pv_va + cur_pv.pv_size > kernel_vm_base) { + cur_pv.pv_size = kernel_vm_base - cur_pv.pv_va; + } + /* * Now we map the final chunk. */ Index: src/sys/arch/arm/arm32/pmap.c diff -u src/sys/arch/arm/arm32/pmap.c:1.322 src/sys/arch/arm/arm32/pmap.c:1.323 --- src/sys/arch/arm/arm32/pmap.c:1.322 Wed May 13 15:33:47 2015 +++ src/sys/arch/arm/arm32/pmap.c Sat May 30 23:59:33 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.322 2015/05/13 15:33:47 skrll Exp $ */ +/* $NetBSD: pmap.c,v 1.323 2015/05/30 23:59:33 matt Exp $ */ /* * Copyright 2003 Wasabi Systems, Inc. @@ -216,7 +216,7 @@ #include <arm/locore.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.322 2015/05/13 15:33:47 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.323 2015/05/30 23:59:33 matt Exp $"); //#define PMAP_DEBUG #ifdef PMAP_DEBUG @@ -517,6 +517,7 @@ bool pmap_initialized; * Start of direct-mapped memory */ vaddr_t pmap_directbase = KERNEL_BASE; +vaddr_t pmap_directlimit; #endif /* @@ -7859,7 +7860,7 @@ pmap_direct_mapped_phys(paddr_t pa, bool if (physical_start <= pa && pa < physical_end) { #ifdef ARM_MMU_EXTENDED const vaddr_t newva = pmap_directbase + pa - physical_start; - if (newva >= KERNEL_BASE) { + if (newva >= KERNEL_BASE && newva < pmap_directlimit) { va = newva; ok = true; } Index: src/sys/arch/arm/include/arm32/pmap.h diff -u src/sys/arch/arm/include/arm32/pmap.h:1.139 src/sys/arch/arm/include/arm32/pmap.h:1.140 --- src/sys/arch/arm/include/arm32/pmap.h:1.139 Tue May 12 07:07:16 2015 +++ src/sys/arch/arm/include/arm32/pmap.h Sat May 30 23:59:33 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.h,v 1.139 2015/05/12 07:07:16 skrll Exp $ */ +/* $NetBSD: pmap.h,v 1.140 2015/05/30 23:59:33 matt Exp $ */ /* * Copyright (c) 2002, 2003 Wasabi Systems, Inc. @@ -431,6 +431,7 @@ extern vaddr_t pmap_curmaxkvaddr; * Starting VA of direct mapped memory (usually KERNEL_BASE). */ extern vaddr_t pmap_directbase; +extern vaddr_t pmap_directlimit; #endif /*