]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
When pmap_enter_{l2,pde}() are called to create a kernel mapping, they are
authoralc <alc@FreeBSD.org>
Wed, 18 Dec 2019 18:21:39 +0000 (18:21 +0000)
committeralc <alc@FreeBSD.org>
Wed, 18 Dec 2019 18:21:39 +0000 (18:21 +0000)
commite5b1f5ca560adbe27aacea5f4fa409e480fb0bd2
tree3619f73f2bd843508f93fb8d6ecee0a1e34aabdd
parentb401f8a4a8725dc063fa5a0e9c0d66a90415cb68
When pmap_enter_{l2,pde}() are called to create a kernel mapping, they are
incrementing (and decrementing) the ref_count on kernel page table pages.
They should not do this.  Kernel page table pages are expected to have a
fixed ref_count.  Address this problem by refactoring pmap_alloc{_l2,pde}()
and their callers.  This also eliminates some duplicated code from the
callers.

Correctly implement PMAP_ENTER_NOREPLACE in pmap_enter_{l2,pde}() on kernel
mappings.

Reduce code duplication by defining a function, pmap_abort_ptp(), for
handling a common error case.

Handle a possible page table page leak in pmap_copy().  Suppose that we are
determining whether to copy a superpage mapping.  If we abort because there
is already a mapping in the destination pmap at the current address, then
simply decrementing the page table page's ref_count is correct, because the
page table page must have a ref_count > 1.  However, if we abort because we
failed to allocate a PV entry, this might be a just allocated page table
page that has a ref_count = 1, so we should call pmap_abort_ptp().

Simplify error handling in pmap_enter_quick_locked().

Reviewed by: kib, markj (an earlier)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22763
sys/amd64/amd64/pmap.c
sys/arm64/arm64/pmap.c