From 9a0de24b5ed847cb411e81272ac464c971a6afb2 Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Thu, 20 Aug 2015 12:05:42 +0000 Subject: [PATCH] Add pmap_get_tables to get the page tables for a given virtual address. This will be used for minidump support. Obtained from: ABT Systems Ltd Sponsored by: The FreeBSD Foundation --- sys/arm64/arm64/pmap.c | 34 ++++++++++++++++++++++++++++++++++ sys/arm64/include/pmap.h | 3 +++ 2 files changed, 37 insertions(+) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index c2bccb84173e..bd8be0c03b62 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -314,6 +314,40 @@ pmap_l3(pmap_t pmap, vm_offset_t va) return (pmap_l2_to_l3(l2, va)); } +bool +pmap_get_tables(pmap_t pmap, vm_offset_t va, pd_entry_t **l1, pd_entry_t **l2, + pt_entry_t **l3) +{ + pd_entry_t *l1p, *l2p; + + if (pmap->pm_l1 == NULL) + return (false); + + l1p = pmap_l1(pmap, va); + *l1 = l1p; + + if ((*l1p & ATTR_DESCR_MASK) == L1_BLOCK) { + *l2 = NULL; + *l3 = NULL; + return (true); + } + + if ((*l1p & ATTR_DESCR_MASK) != L1_TABLE) + return (false); + + l2p = pmap_l1_to_l2(l1p, va); + *l2 = l2p; + + if ((*l2p & ATTR_DESCR_MASK) == L2_BLOCK) { + *l3 = NULL; + return (true); + } + + *l3 = pmap_l2_to_l3(l2p, va); + + return (true); +} + /* * These load the old table data and store the new value. * They need to be atomic as the System MMU may write to the table at diff --git a/sys/arm64/include/pmap.h b/sys/arm64/include/pmap.h index 63ae34c81c13..274f23278191 100644 --- a/sys/arm64/include/pmap.h +++ b/sys/arm64/include/pmap.h @@ -149,6 +149,9 @@ void pmap_unmapbios(vm_offset_t, vm_size_t); boolean_t pmap_map_io_transient(vm_page_t *, vm_offset_t *, int, boolean_t); void pmap_unmap_io_transient(vm_page_t *, vm_offset_t *, int, boolean_t); +bool pmap_get_tables(pmap_t, vm_offset_t, pd_entry_t **, pd_entry_t **, + pt_entry_t **); + #define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list)) #endif /* _KERNEL */