HomeFreeBSD

riscv: handle superpage in pmap_enter_quick_locked()

Description

riscv: handle superpage in pmap_enter_quick_locked()

Previously, if pmap_enter_l2() was asked to re-map an existing superpage
(the result of madvise(MADV_WILLNEED) on a mapped range), it could
'fail' to do so, falling back to trying pmap_enter_quick_locked() for
each 4K virtual page. Because this function does not check if the l2
entry it finds is a superpage, it would proceed, sometimes resulting in
the creation of false PV entries.

If the relevant range was later munmap'ed, the system would panic during
the process' exit in pmap_remove_pages(), while attempting to clean up
the PV entries for mappings which no longer exist.

Instead, we should return early in the presence of an existing
superpage, as is done in other pmaps.

PR: 266108
Reviewed by: markj, alc
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36563

(cherry picked from commit 9d1aef84021f4e99d37f4e9149a8799c3d9e5e03)

Details

Provenance
mhorneAuthored on Oct 5 2022, 5:11 PM
Reviewer
markj
Differential Revision
D36563: riscv: handle existing mapping in pmap_enter_l2()
Parents
rG3562dcf3290a: riscv: optimize MADV_WILLNEED on existing superpages
Branches
Unknown
Tags
Unknown