git: 2601c0521063 - stable/13 - Only change DMAP props on DMAP covered memory
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 29 Dec 2021 10:16:48 UTC
The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=2601c05210631bf7880b1c3aa22d3269d433259b commit 2601c05210631bf7880b1c3aa22d3269d433259b Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2021-12-14 10:05:15 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2021-12-29 10:05:09 +0000 Only change DMAP props on DMAP covered memory When changing memory properties in the arm64 pmap we need to keep both the kernel address and DMAP mappings in sync. To keep the kernel and DMAP memory in sync we recurse when updating the former to also update the latter. There was insuffucuent checking around this recursion. It would check if the virtual address is not within the DMAP region, but not if the physical address is covered. Add the missing check as without it the recursion may return an error. Sponsored by: The FreeBSD Foundation (cherry picked from commit 6238905c5b253c5b8c6a4b66796819c3a0bed637) --- sys/arm64/arm64/pmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index f30a180612ef..793126fcf58d 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -6148,6 +6148,7 @@ pmap_change_props_locked(vm_offset_t va, vm_size_t size, vm_prot_t prot, { vm_offset_t base, offset, tmpva; vm_size_t pte_size; + vm_paddr_t pa; pt_entry_t pte, *ptep, *newpte; pt_entry_t bits, mask; int lvl, rv; @@ -6261,12 +6262,13 @@ pmap_change_props_locked(vm_offset_t va, vm_size_t size, vm_prot_t prot, pmap_update_entry(kernel_pmap, ptep, pte, tmpva, pte_size); - if (!VIRT_IN_DMAP(tmpva)) { + pa = pte & ~ATTR_MASK; + if (!VIRT_IN_DMAP(tmpva) && PHYS_IN_DMAP(pa)) { /* * Keep the DMAP memory in sync. */ rv = pmap_change_props_locked( - PHYS_TO_DMAP(pte & ~ATTR_MASK), pte_size, + PHYS_TO_DMAP(pa), pte_size, prot, mode); if (rv != 0) return (rv);