HomeFreeBSD

amd64: Make it possible to grow the KERNBASE region of KVA

Description

amd64: Make it possible to grow the KERNBASE region of KVA

pmap_growkernel() may be called when mapping a region above KERNBASE,
typically for a kernel module. If we have enough PTPs left over from
bootstrap, pmap_growkernel() does nothing. However, it's possible to
run out, and in this case pmap_growkernel() will try to grow the kernel
map all the way from kernel_vm_end to somewhere past KERNBASE, which can
easily run the system out of memory. This happens with large kernel
modules such as the nvidia GPU driver. There is also a WIP dtrace
provider which needs to map KVA in the region above KERNBASE (to provide
trampolines which allow a copy of traced kernel instruction to be
executed), and its allocations could potentially trigger this scenario.

This change modifies pmap_growkernel() to manage the two regions
separately, allowing them to grow independently. The end of the
KERNBASE region is tracked by modifying "nkpt".

PR: 265019
Reviewed by: alc, imp, kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D36673

Details

Provenance
markjAuthored on Sep 24 2022, 1:19 PM
Reviewer
alc
Differential Revision
D36673: amd64: Make it possible to grow the KERNBASE region of KVA
Parents
rG8694fd333556: smr: Fix synchronization in smr_enter()
Branches
Unknown
Tags
Unknown