diff options
author | Ian Moffett <ian@osmora.org> | 2025-06-09 14:03:53 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-06-09 14:03:53 -0400 |
commit | 4fbb2a1db3959cd11291d960532ffeec28c33ab2 (patch) | |
tree | 02aeb96f376c4b85adb329921985381ca090e69c | |
parent | 06a2ef92bd8e35dccad318f264c396623a1b6536 (diff) |
kernel/amd64: Add `alloc` to pmap_update_tbl()
Add an `alloc' paramater to pmap_update_tbl() to ensure that functions
like pmap_map() and pmap_unmap() have control over, whether or not to
allocate new page table entries. This is useful as unmapping memory does
not require new page table entries to be allocated and doing so anyways
may result in undefined behaviour such as hangs.
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/arch/amd64/amd64/pmap.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/arch/amd64/amd64/pmap.c b/sys/arch/amd64/amd64/pmap.c index 0bdf3b7..5b0d046 100644 --- a/sys/arch/amd64/amd64/pmap.c +++ b/sys/arch/amd64/amd64/pmap.c @@ -178,14 +178,15 @@ done: * @vas: Virtual address space. * @va: Target virtual address. * @val: Value to write. + * @alloc: True to alloc new paging entries. */ static int -pmap_update_tbl(struct vas vas, vaddr_t va, uint64_t val) +pmap_update_tbl(struct vas vas, vaddr_t va, uint64_t val, bool alloc) { uintptr_t *tbl; int status; - if ((status = pmap_get_tbl(vas, va, true, &tbl)) != 0) { + if ((status = pmap_get_tbl(vas, va, alloc, &tbl)) != 0) { return status; } @@ -268,13 +269,13 @@ pmap_map(struct vas vas, vaddr_t va, paddr_t pa, vm_prot_t prot) { uint32_t flags = pmap_prot_to_pte(prot); - return pmap_update_tbl(vas, va, (pa | flags)); + return pmap_update_tbl(vas, va, (pa | flags), true); } int pmap_unmap(struct vas vas, vaddr_t va) { - return pmap_update_tbl(vas, va, 0); + return pmap_update_tbl(vas, va, 0, false); } int |