summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libkvm/kvm_amd64.c8
-rw-r--r--lib/libkvm/kvm_arm.c4
-rw-r--r--lib/libkvm/kvm_hppa.c4
-rw-r--r--lib/libkvm/kvm_hppa64.c4
-rw-r--r--lib/libkvm/kvm_i386.c14
-rw-r--r--lib/libkvm/kvm_m68k.c12
-rw-r--r--lib/libkvm/kvm_sh.c10
-rw-r--r--lib/libkvm/kvm_sparc64.c4
-rw-r--r--lib/libkvm/kvm_vax.c6
9 files changed, 32 insertions, 34 deletions
diff --git a/lib/libkvm/kvm_amd64.c b/lib/libkvm/kvm_amd64.c
index 934d85e1d54..30cf67331b1 100644
--- a/lib/libkvm/kvm_amd64.c
+++ b/lib/libkvm/kvm_amd64.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_amd64.c,v 1.9 2012/12/05 23:20:02 deraadt Exp $ */
+/* $OpenBSD: kvm_amd64.c,v 1.10 2013/03/28 16:27:31 deraadt Exp $ */
/* $NetBSD: kvm_x86_64.c,v 1.3 2002/06/05 22:01:55 fvdl Exp $ */
/*-
@@ -96,11 +96,11 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
return (0);
}
- page_off = va & PAGE_MASK;
+ page_off = va & (kd->nbpg - 1);
if (va >= PMAP_DIRECT_BASE && va <= PMAP_DIRECT_END) {
*pa = va - PMAP_DIRECT_BASE;
- return (int)(PAGE_SIZE - page_off);
+ return (int)(kd->nbpg - page_off);
}
cpu_kh = kd->cpu_data;
@@ -177,7 +177,7 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
goto lose;
}
*pa = (pte & PG_FRAME) + page_off;
- return (int)(PAGE_SIZE - page_off);
+ return (int)(kd->nbpg - page_off);
lose:
*pa = (u_long)~0L;
diff --git a/lib/libkvm/kvm_arm.c b/lib/libkvm/kvm_arm.c
index 368249bf5ff..6e4cfb600f9 100644
--- a/lib/libkvm/kvm_arm.c
+++ b/lib/libkvm/kvm_arm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_arm.c,v 1.7 2013/03/20 14:46:45 deraadt Exp $ */
+/* $OpenBSD: kvm_arm.c,v 1.8 2013/03/28 16:27:31 deraadt Exp $ */
/*
* Copyright (c) 2006 Miodrag Vallat.
*
@@ -106,7 +106,7 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
va < cpup->kernelbase + cpup->kerneloffs + cpup->staticsize) {
*pa = (va - cpup->kernelbase) +
(paddr_t)cpup->ram_segs[0].start;
- return (int)(PAGE_SIZE - (va & PAGE_MASK));
+ return (int)(kd->nbpg - (va & (kd->nbpg - 1)));
}
_kvm_err(kd, 0, "kvm_vatop: va %x unreachable", va);
diff --git a/lib/libkvm/kvm_hppa.c b/lib/libkvm/kvm_hppa.c
index 9aadc9602d6..837a6aaa099 100644
--- a/lib/libkvm/kvm_hppa.c
+++ b/lib/libkvm/kvm_hppa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_hppa.c,v 1.7 2009/07/28 12:56:25 deraadt Exp $ */
+/* $OpenBSD: kvm_hppa.c,v 1.8 2013/03/28 16:27:31 deraadt Exp $ */
/*
* Copyright (c) 2002, Miodrag Vallat.
@@ -63,7 +63,7 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
/* XXX this only really works for the kernel image only */
*pa = va;
- return (PAGE_SIZE - (va & PAGE_MASK));
+ return (kd->nbpg - (va & (kd->nbpg - 1)));
}
/*
diff --git a/lib/libkvm/kvm_hppa64.c b/lib/libkvm/kvm_hppa64.c
index 7b54f168ff4..51ea2bf84c9 100644
--- a/lib/libkvm/kvm_hppa64.c
+++ b/lib/libkvm/kvm_hppa64.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_hppa64.c,v 1.1 2011/07/09 00:29:59 kettenis Exp $ */
+/* $OpenBSD: kvm_hppa64.c,v 1.2 2013/03/28 16:27:31 deraadt Exp $ */
/*
* Copyright (c) 2002, Miodrag Vallat.
@@ -63,7 +63,7 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
/* XXX this only really works for the kernel image only */
*pa = va;
- return (PAGE_SIZE - (va & PAGE_MASK));
+ return (kd->nbpg - (va & (kd->nbpg - 1)));
}
/*
diff --git a/lib/libkvm/kvm_i386.c b/lib/libkvm/kvm_i386.c
index a270d67eac5..54109723296 100644
--- a/lib/libkvm/kvm_i386.c
+++ b/lib/libkvm/kvm_i386.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_i386.c,v 1.22 2012/07/09 08:43:10 deraadt Exp $ */
+/* $OpenBSD: kvm_i386.c,v 1.23 2013/03/28 16:27:31 deraadt Exp $ */
/* $NetBSD: kvm_i386.c,v 1.9 1996/03/18 22:33:38 thorpej Exp $ */
/*-
@@ -101,10 +101,10 @@ _kvm_initvtop(kvm_t *kd)
(off_t)_kvm_pa2off(kd, nl[0].n_value - KERNBASE)) != sizeof pa)
goto invalid;
- vm->PTD = (pd_entry_t *)_kvm_malloc(kd, PAGE_SIZE);
+ vm->PTD = (pd_entry_t *)_kvm_malloc(kd, kd->nbpg);
- if (_kvm_pread(kd, kd->pmfd, vm->PTD, PAGE_SIZE,
- (off_t)_kvm_pa2off(kd, pa)) != PAGE_SIZE)
+ if (_kvm_pread(kd, kd->pmfd, vm->PTD, kd->nbpg,
+ (off_t)_kvm_pa2off(kd, pa)) != kd->nbpg)
goto invalid;
return (0);
@@ -138,7 +138,7 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
}
vm = kd->vmst;
- offset = va & PAGE_MASK;
+ offset = va & (kd->nbpg - 1);
/*
* If we are initializing (kernel page table descriptor pointer
@@ -146,7 +146,7 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
*/
if (vm->PTD == NULL) {
*pa = va;
- return (PAGE_SIZE - (int)offset);
+ return (kd->nbpg - (int)offset);
}
if ((vm->PTD[pdei(va)] & PG_V) == 0)
goto invalid;
@@ -160,7 +160,7 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
goto invalid;
*pa = (pte & PG_FRAME) + offset;
- return (PAGE_SIZE - (int)offset);
+ return (kd->nbpg - (int)offset);
invalid:
_kvm_err(kd, 0, "invalid address (%lx)", va);
diff --git a/lib/libkvm/kvm_m68k.c b/lib/libkvm/kvm_m68k.c
index b66552b392f..8f98263f95a 100644
--- a/lib/libkvm/kvm_m68k.c
+++ b/lib/libkvm/kvm_m68k.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_m68k.c,v 1.20 2012/07/09 08:43:10 deraadt Exp $ */
+/* $OpenBSD: kvm_m68k.c,v 1.21 2013/03/28 16:27:31 deraadt Exp $ */
/* $NetBSD: kvm_m68k.c,v 1.9 1996/05/07 06:09:11 leo Exp $ */
/*-
@@ -67,8 +67,8 @@
#include <machine/kcore.h>
#ifndef btop
-#define btop(x) (((unsigned)(x)) >> PAGE_SHIFT) /* XXX */
-#define ptob(x) ((caddr_t)((x) << PAGE_SHIFT)) /* XXX */
+#define btop(x) (((unsigned)(x)) / kd->nbpg) /* XXX */
+#define ptob(x) ((caddr_t)((x) * kd->nbpg)) /* XXX */
#endif
void
@@ -97,7 +97,7 @@ _kvm_vatop(kvm_t *kd, st_entry_t *sta, u_long va, u_long *pa)
_kvm_err(kd, 0, "vatop called in live kernel!");
return (0);
}
- offset = va & PAGE_MASK;
+ offset = va & (kd->nbpg - 1);
cpu_kh = kd->cpu_data;
/*
* If we are initializing (kernel segment table pointer not yet set)
@@ -105,7 +105,7 @@ _kvm_vatop(kvm_t *kd, st_entry_t *sta, u_long va, u_long *pa)
*/
if (cpu_kh->sysseg_pa == 0) {
*pa = va + cpu_kh->kernel_pa;
- return (PAGE_SIZE - offset);
+ return (kd->nbpg - offset);
}
if (cpu_kh->mmutype == MMU_68040 || cpu_kh->mmutype == MMU_68060) {
st_entry_t *sta2;
@@ -174,7 +174,7 @@ _kvm_vatop(kvm_t *kd, st_entry_t *sta, u_long va, u_long *pa)
}
*pa = addr + offset;
- return (PAGE_SIZE - offset);
+ return (kd->nbpg - offset);
invalid:
_kvm_err(kd, 0, "invalid address (%lx)", va);
return (0);
diff --git a/lib/libkvm/kvm_sh.c b/lib/libkvm/kvm_sh.c
index 94db3628b48..e24fe0752d0 100644
--- a/lib/libkvm/kvm_sh.c
+++ b/lib/libkvm/kvm_sh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_sh.c,v 1.5 2013/03/20 14:46:45 deraadt Exp $ */
+/* $OpenBSD: kvm_sh.c,v 1.6 2013/03/28 16:27:31 deraadt Exp $ */
/*
* Copyright (c) 2007 Miodrag Vallat.
@@ -56,9 +56,9 @@ _kvm_initvtop(kvm_t *kd)
#define __PMAP_PTP_N 512 /* # of page table page maps 2GB. */
/* Stolen from sys/arch/sh/sh/pmap.c */
#define __PMAP_PTP_SHIFT 22
-#define __PMAP_PTP_PG_N (PAGE_SIZE / sizeof(pt_entry_t))
+#define __PMAP_PTP_PG_N (kd->nbpg / sizeof(pt_entry_t))
#define __PMAP_PTP_INDEX(va) (((va) >> __PMAP_PTP_SHIFT) & (__PMAP_PTP_N - 1))
-#define __PMAP_PTP_OFSET(va) ((va >> PAGE_SHIFT) & (__PMAP_PTP_PG_N - 1))
+#define __PMAP_PTP_OFSET(va) ((va / kd->nbpg) & (__PMAP_PTP_PG_N - 1))
int
_kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
@@ -128,8 +128,8 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
goto bad;
}
- *pa = (l2pte & PG_PPN) | (va & PAGE_MASK);
- return (PAGE_SIZE - (va & PAGE_MASK));
+ *pa = (l2pte & PG_PPN) | (va & (kd->nbpg - 1));
+ return (kd->nbpg - (va & (kd->nbpg - 1)));
}
/*
diff --git a/lib/libkvm/kvm_sparc64.c b/lib/libkvm/kvm_sparc64.c
index 86a556a875c..56efe07b873 100644
--- a/lib/libkvm/kvm_sparc64.c
+++ b/lib/libkvm/kvm_sparc64.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_sparc64.c,v 1.8 2012/12/05 23:20:02 deraadt Exp $ */
+/* $OpenBSD: kvm_sparc64.c,v 1.9 2013/03/28 16:27:31 deraadt Exp $ */
/* $NetBSD: kvm_sparc64.c,v 1.7 2001/08/05 03:33:15 matt Exp $ */
/*-
@@ -88,8 +88,6 @@ _kvm_freevtop(kvm_t *kd)
int
_kvm_initvtop(kvm_t *kd)
{
- kd->nbpg = 0x2000;
-
return (0);
}
diff --git a/lib/libkvm/kvm_vax.c b/lib/libkvm/kvm_vax.c
index 5a5fb249aca..643aca422dd 100644
--- a/lib/libkvm/kvm_vax.c
+++ b/lib/libkvm/kvm_vax.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_vax.c,v 1.13 2006/06/19 20:25:49 miod Exp $ */
+/* $OpenBSD: kvm_vax.c,v 1.14 2013/03/28 16:27:31 deraadt Exp $ */
/* $NetBSD: kvm_vax.c,v 1.3 1996/03/18 22:34:06 thorpej Exp $ */
/*-
@@ -109,9 +109,9 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
return (0);
}
- ofs = va & PAGE_MASK;
+ ofs = va & (kd->nbpg - 1);
*pa = ((pte & PG_FRAME) << VAX_PGSHIFT) | ofs;
- return (int)(PAGE_SIZE - ofs);
+ return (int)(kd->nbpg - ofs);
}
/*