summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-01-02 05:16:57 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-01-02 05:16:57 +0000
commit5b37de33cc86ef68c740c43e807bb02de820f715 (patch)
treeb2c49185634f74be04fb4cce6b34c9e0d0d7cc99 /lib
parent5c3b6a6b6cc881601be856f52724050d6a56d83d (diff)
Sync _kvm_kvatop with existing pmap code: handle direct mappings and
level 2 large pages.
Diffstat (limited to 'lib')
-rw-r--r--lib/libkvm/kvm_amd64.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/libkvm/kvm_amd64.c b/lib/libkvm/kvm_amd64.c
index 63897a45ec7..8c8fe0bfee4 100644
--- a/lib/libkvm/kvm_amd64.c
+++ b/lib/libkvm/kvm_amd64.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_amd64.c,v 1.5 2007/01/08 18:54:12 deraadt Exp $ */
+/* $OpenBSD: kvm_amd64.c,v 1.6 2009/01/02 05:16:56 miod Exp $ */
/* $NetBSD: kvm_x86_64.c,v 1.3 2002/06/05 22:01:55 fvdl Exp $ */
/*-
@@ -98,9 +98,20 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
return (0);
}
- cpu_kh = kd->cpu_data;
page_off = va & PGOFSET;
+ if (va >= PMAP_DIRECT_BASE && va <= PMAP_DIRECT_END) {
+ *pa = va - PMAP_DIRECT_BASE;
+ return (int)(NBPG - page_off);
+ }
+
+ if (va >= PMAP_DIRECT_BASE_NC && va <= PMAP_DIRECT_END_NC) {
+ *pa = va - PMAP_DIRECT_BASE_NC;
+ return (int)(NBPG - page_off);
+ }
+
+ cpu_kh = kd->cpu_data;
+
/*
* Find and read all entries to get to the pa.
*/
@@ -147,6 +158,14 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
goto lose;
}
+ /*
+ * Might be a large page.
+ */
+ if ((pde & PG_PS) != 0) {
+ page_off = va & (NBPD_L2 - 1);
+ *pa = (pde & PG_LGFRAME) | page_off;
+ return (int)(NBPD_L2 - page_off);
+ }
/*
* Level 1.
@@ -196,5 +215,8 @@ _kvm_pa2off(kvm_t *kd, paddr_t pa)
off += ramsegs[i].size;
}
+ if (i == cpu_kh->nmemsegs)
+ _kvm_err(kd, 0, "pa %lx not in dump", pa);
+
return (kd->dump_off + off);
}