Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Mar 2019 23:56:41 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344827 - head/sys/riscv/riscv
Message-ID:  <201903052356.x25Nuf9H019510@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Mar  5 23:56:40 2019
New Revision: 344827
URL: https://svnweb.freebsd.org/changeset/base/344827

Log:
  Add pmap_get_tables() for riscv.
  
  This mirrors the arm64 implementation and is for use in the minidump
  code.
  
  Submitted by:	Mitchell Horne <mhorne063@gmail.com>
  Differential Revision:	https://reviews.freebsd.org/D18321

Modified:
  head/sys/riscv/riscv/pmap.c

Modified: head/sys/riscv/riscv/pmap.c
==============================================================================
--- head/sys/riscv/riscv/pmap.c	Tue Mar  5 22:55:33 2019	(r344826)
+++ head/sys/riscv/riscv/pmap.c	Tue Mar  5 23:56:40 2019	(r344827)
@@ -4438,3 +4438,40 @@ pmap_is_valid_memattr(pmap_t pmap __unused, vm_memattr
 
 	return (mode >= VM_MEMATTR_DEVICE && mode <= VM_MEMATTR_WRITE_BACK);
 }
+
+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;
+
+	/* Get l1 directory entry. */
+	l1p = pmap_l1(pmap, va);
+	*l1 = l1p;
+
+	if (l1p == NULL || (pmap_load(l1p) & PTE_V) == 0)
+		return (false);
+
+	if ((pmap_load(l1p) & PTE_RX) != 0) {
+		*l2 = NULL;
+		*l3 = NULL;
+		return (true);
+	}
+
+	/* Get l2 directory entry. */
+	l2p = pmap_l1_to_l2(l1p, va);
+	*l2 = l2p;
+
+	if (l2p == NULL || (pmap_load(l2p) & PTE_V) == 0)
+		return (false);
+
+	if ((pmap_load(l2p) & PTE_RX) != 0) {
+		*l3 = NULL;
+		return (true);
+	}
+
+	/* Get l3 page table entry. */
+	*l3 = pmap_l2_to_l3(l2p, va);
+
+	return (true);
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903052356.x25Nuf9H019510>