diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2016-05-22 22:52:02 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2016-05-22 22:52:02 +0000 |
commit | 7621f2c5f9b06ba244413f5a394b539ae6f26e01 (patch) | |
tree | 7f4a7c6abc90a0092c9aeeb496d8f471634e5d45 /lib/libkvm/kvm_proc.c | |
parent | 8c3be85775dbefcde947b1bb50d0cb074fa36872 (diff) |
Revert previous: breaks i386 and powerpc, probably all non-PMAP_DIRECT archs
Diffstat (limited to 'lib/libkvm/kvm_proc.c')
-rw-r--r-- | lib/libkvm/kvm_proc.c | 64 |
1 files changed, 11 insertions, 53 deletions
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c index bec8b775d77..bf9230c6116 100644 --- a/lib/libkvm/kvm_proc.c +++ b/lib/libkvm/kvm_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_proc.c,v 1.54 2016/05/22 16:18:26 stefan Exp $ */ +/* $OpenBSD: kvm_proc.c,v 1.55 2016/05/22 22:52:01 guenther Exp $ */ /* $NetBSD: kvm_proc.c,v 1.30 1999/03/24 05:50:50 mrg Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -108,56 +108,6 @@ static int proc_verify(kvm_t *, const struct kinfo_proc *); static void ps_str_a(struct ps_strings *, u_long *, int *); static void ps_str_e(struct ps_strings *, u_long *, int *); -static struct vm_anon * -_kvm_findanon(kvm_t *kd, struct vm_amap *amapp, int slot) -{ - u_long addr; - int bucket; - struct vm_amap amap; - struct vm_amap_chunk chunk, *chunkp; - struct vm_anon *anonp; - - addr = (u_long)amapp; - if (KREAD(kd, addr, &amap)) - return (NULL); - - /* sanity-check slot number */ - if (slot > amap.am_nslot) - return (NULL); - - if (UVM_AMAP_SMALL(&amap)) - chunkp = &amapp->am_small; - else { - bucket = UVM_AMAP_BUCKET(&amap, slot); - addr = (u_long)(amap.am_buckets + bucket); - if (KREAD(kd, addr, &chunkp)) - return (NULL); - - while (chunkp != NULL) { - addr = (u_long)chunkp; - if (KREAD(kd, addr, &chunk)) - return (NULL); - - if (UVM_AMAP_BUCKET(&amap, chunk.ac_baseslot) != - bucket) - return (NULL); - if (slot >= chunk.ac_baseslot && - slot < chunk.ac_baseslot + chunk.ac_nslot) - break; - - chunkp = TAILQ_NEXT(&chunk, ac_list); - } - if (chunkp == NULL) - return (NULL); - } - - addr = (u_long)&chunkp->ac_anon[UVM_AMAP_SLOTIDX(slot)]; - if (KREAD(kd, addr, &anonp)) - return (NULL); - - return (anonp); -} - static char * _kvm_ureadm(kvm_t *kd, const struct kinfo_proc *p, u_long va, u_long *cnt) { @@ -165,6 +115,7 @@ _kvm_ureadm(kvm_t *kd, const struct kinfo_proc *p, u_long va, u_long *cnt) struct vmspace vm; struct vm_anon *anonp, anon; struct vm_map_entry vme; + struct vm_amap amap; struct vm_page pg; if (kd->swapspc == 0) { @@ -202,11 +153,18 @@ _kvm_ureadm(kvm_t *kd, const struct kinfo_proc *p, u_long va, u_long *cnt) if (vme.aref.ar_amap == NULL) return (NULL); + addr = (u_long)vme.aref.ar_amap; + if (KREAD(kd, addr, &amap)) + return (NULL); + offset = va - vme.start; slot = offset / kd->nbpg + vme.aref.ar_pageoff; + /* sanity-check slot number */ + if (slot > amap.am_nslot) + return (NULL); - anonp = _kvm_findanon(kd, vme.aref.ar_amap, slot); - if (anonp == NULL) + addr = (u_long)amap.am_anon + (offset / kd->nbpg) * sizeof(anonp); + if (KREAD(kd, addr, &anonp)) return (NULL); addr = (u_long)anonp; |