diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2006-06-09 09:46:05 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2006-06-09 09:46:05 +0000 |
commit | a4bbb13e55f2c68e6c4706c68bb227224ef17db7 (patch) | |
tree | 71d66a3ee1a93c30fbfe5b294997cc04da6f61f1 /lib/libkvm/kvm_i386.c | |
parent | ea0e480bf4b4efc866472f2ee21c3c70fe43b84c (diff) |
proper type and ptdsize checks; had it for three weeks now... sigh
Diffstat (limited to 'lib/libkvm/kvm_i386.c')
-rw-r--r-- | lib/libkvm/kvm_i386.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/libkvm/kvm_i386.c b/lib/libkvm/kvm_i386.c index 3d56435f98a..e88444fcb71 100644 --- a/lib/libkvm/kvm_i386.c +++ b/lib/libkvm/kvm_i386.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_i386.c,v 1.18 2006/05/07 12:57:21 kettenis Exp $ */ +/* $OpenBSD: kvm_i386.c,v 1.19 2006/06/09 09:46:04 mickey Exp $ */ /* $NetBSD: kvm_i386.c,v 1.9 1996/03/18 22:33:38 thorpej Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93"; #else -static char *rcsid = "$OpenBSD: kvm_i386.c,v 1.18 2006/05/07 12:57:21 kettenis Exp $"; +static char *rcsid = "$OpenBSD: kvm_i386.c,v 1.19 2006/06/09 09:46:04 mickey Exp $"; #endif #endif /* LIBC_SCCS and not lint */ @@ -128,10 +128,13 @@ _kvm_initvtop(kvm_t *kd) vm->pg_frame = 0xfffff000; vm->pt_mask = 0x003ff000; vm->pte_size = 4; - } else { + } else if (ps == NBPG * 4) { vm->pg_frame = 0xffffff000ULL; vm->pt_mask = 0x001ff000; vm->pte_size = 8; + } else { + _kvm_err(kd, 0, "PTDsize is invalid"); + return (-1); } if (_kvm_pread(kd, kd->pmfd, &pa, vm->pte_size, @@ -158,9 +161,9 @@ _kvm_initvtop(kvm_t *kd) int _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa) { - u_long offset, pte_pa; + u_long offset; struct vmstate *vm; - paddr_t pte; + paddr_t pte, pte_pa; if (!kd->vmst) { _kvm_err(kd, 0, "vatop called before initvtop"); @@ -192,7 +195,7 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa) /* XXX READ PHYSICAL XXX */ pte = 0; if (_kvm_pread(kd, kd->pmfd, &pte, pte_size(vm), - (off_t)_kvm_pa2off(kd, pte_pa)) != pte_size(vm)) + _kvm_pa2off(kd, pte_pa)) != pte_size(vm)) goto invalid; *pa = (pte & PG_FRAME(vm)) + offset; |