git: e8816b4b66ad - main - riscv pmap: Introduce 'pmap_abort_ptp'
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 16 Jun 2024 16:20:09 UTC
The branch main has been updated by bnovkov:
URL: https://cgit.FreeBSD.org/src/commit/?id=e8816b4b66adf2e6052803cd0eb609ee63fbb3ed
commit e8816b4b66adf2e6052803cd0eb609ee63fbb3ed
Author: Bojan Novković <bnovkov@FreeBSD.org>
AuthorDate: 2024-06-13 16:13:53 +0000
Commit: Bojan Novković <bnovkov@FreeBSD.org>
CommitDate: 2024-06-16 16:19:27 +0000
riscv pmap: Introduce 'pmap_abort_ptp'
This commit moves code for releasing pagetable page references
into a separate function. No functional change intended.
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D45579
---
sys/riscv/riscv/pmap.c | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index 1902f1f4009b..4f6305ed651d 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -3137,6 +3137,28 @@ out:
return (rv);
}
+/*
+ * Release a page table page reference after a failed attempt to create a
+ * mapping.
+ */
+static void
+pmap_abort_ptp(pmap_t pmap, vm_offset_t va, vm_page_t l2pg)
+{
+ struct spglist free;
+
+ SLIST_INIT(&free);
+ if (pmap_unwire_ptp(pmap, va, l2pg, &free)) {
+ /*
+ * Although "va" is not mapped, paging-structure
+ * caches could nonetheless have entries that
+ * refer to the freed page table pages.
+ * Invalidate those entries.
+ */
+ pmap_invalidate_page(pmap, va);
+ vm_page_free_pages_toq(&free, true);
+ }
+}
+
/*
* Tries to create a read- and/or execute-only 2MB page mapping. Returns
* KERN_SUCCESS if the mapping was created. Otherwise, returns an error
@@ -3285,17 +3307,7 @@ pmap_enter_l2(pmap_t pmap, vm_offset_t va, pd_entry_t new_l2, u_int flags,
* Abort this mapping if its PV entry could not be created.
*/
if (!pmap_pv_insert_l2(pmap, va, new_l2, flags, lockp)) {
- SLIST_INIT(&free);
- if (pmap_unwire_ptp(pmap, va, l2pg, &free)) {
- /*
- * Although "va" is not mapped, paging-structure
- * caches could nonetheless have entries that
- * refer to the freed page table pages.
- * Invalidate those entries.
- */
- pmap_invalidate_page(pmap, va);
- vm_page_free_pages_toq(&free, true);
- }
+ pmap_abort_ptp(pmap, va, l2pg);
if (uwptpg != NULL) {
mt = pmap_remove_pt_page(pmap, va);
KASSERT(mt == uwptpg,