git: 383fd3ea0012 - main - arm64: Handle an unaligned start in pmap_mask_set_locked()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 05 Jul 2024 05:45:10 UTC
The branch main has been updated by alc: URL: https://cgit.FreeBSD.org/src/commit/?id=383fd3ea00128cf65fbea0e4cbdb9849945c854b commit 383fd3ea00128cf65fbea0e4cbdb9849945c854b Author: Alan Cox <alc@FreeBSD.org> AuthorDate: 2024-07-03 05:15:35 +0000 Commit: Alan Cox <alc@FreeBSD.org> CommitDate: 2024-07-05 05:42:52 +0000 arm64: Handle an unaligned start in pmap_mask_set_locked() In pmap_mask_set_locked(), correctly handle a starting address that is in the middle of an L3C page. The symptoms arising from this error included assertion failures in pmap_demote_l3c(). Reported by: andrew Reviewed by: markj Fixes: fd6cb031f577 "arm64 pmap: Add ATTR_CONTIGUOUS support [Part 1]" Differential Revision: https://reviews.freebsd.org/D45851 --- sys/arm64/arm64/pmap.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index f4a46823428a..a9cb8c7fe468 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -4403,8 +4403,22 @@ pmap_mask_set_locked(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, pt_entry_t m va = va_next; } if ((l3 & ATTR_CONTIGUOUS) != 0) { - l3p += L3C_ENTRIES - 1; - sva += L3C_SIZE - L3_SIZE; + /* + * Does this L3C page extend beyond + * the requested range? Handle the + * possibility that "va_next" is zero. + */ + if ((sva | L3C_OFFSET) > va_next - 1) + break; + + /* + * Skip ahead to the last L3_PAGE + * within this L3C page. + */ + l3p = (pt_entry_t *)((uintptr_t)l3p | + ((L3C_ENTRIES - 1) * + sizeof(pt_entry_t))); + sva |= L3C_SIZE - L3_SIZE; } continue; }