git: 663de81f852f - main - uma: Avoid unmapping direct-mapped slabs

Mark Johnston markj at FreeBSD.org
Sun Jan 3 16:51:15 UTC 2021


The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=663de81f852fccc38006b0172f9337147b65890f

commit 663de81f852fccc38006b0172f9337147b65890f
Author:     Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-01-03 16:31:00 +0000
Commit:     Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-01-03 16:50:31 +0000

    uma: Avoid unmapping direct-mapped slabs
    
    startup_alloc() uses pmap_map() to map slabs used for bootstrapping the
    VM.  pmap_map() may ignore the hint address and simply return a range
    from the direct map.  In this case we must not unmap the range in
    startup_free().
    
    UMA uses bootstart and bootmem to track the range of KVA into which
    slabs are mapped if the direct map is not used.  Unmap a startup slab
    only if it was mapped into that range.
    
    Reported by:    alc
    Reviewed by:    alc, kib
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D27885
---
 sys/vm/uma_core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index 39c846effac8..0b6e02861785 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -1691,7 +1691,13 @@ startup_free(void *mem, vm_size_t bytes)
 
 	va = (vm_offset_t)mem;
 	m = PHYS_TO_VM_PAGE(pmap_kextract(va));
-	pmap_remove(kernel_pmap, va, va + bytes);
+
+	/*
+	 * startup_alloc() returns direct-mapped slabs on some platforms.  Avoid
+	 * unmapping ranges of the direct map.
+	 */
+	if (va >= bootstart && va + bytes <= bootmem)
+		pmap_remove(kernel_pmap, va, va + bytes);
 	for (; bytes != 0; bytes -= PAGE_SIZE, m++) {
 #if defined(__aarch64__) || defined(__amd64__) || defined(__mips__) || \
     defined(__riscv) || defined(__powerpc64__)


More information about the dev-commits-src-all mailing list