Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libkvm Change kvm_pa2off() and kvm_kvatop() prototypes (...
details: https://anonhg.NetBSD.org/src/rev/35ce78033b49
branches: trunk
changeset: 757755:35ce78033b49
user: jym <jym%NetBSD.org@localhost>
date: Mon Sep 20 23:23:16 2010 +0000
description:
Change kvm_pa2off() and kvm_kvatop() prototypes (private to kvm(3)):
-int _kvm_kvatop(kvm_t *, u_long, u_long *);
-off_t _kvm_pa2off(kvm_t *, u_long);
+int _kvm_kvatop(kvm_t *, vaddr_t, paddr_t *);
+off_t _kvm_pa2off(kvm_t *, paddr_t);
Basically, use vaddr_t for VA and paddr_t for PA. In addition, for variables
representing addresses, use paddr_t or vaddr_t, depending on the context.
For most arches, vaddr_t and paddr_t are equivalent to unsigned long. However,
the change was needed for exotic situations, like i386 PAE, were unsigned long
is not suitable for PA which are 64 bits long. As this required a complete
change of the function prototypes, all arches had to be adapted accordingly.
Core files from before this commit should still work with the new code; I did
not see any direct dependency between core's structure and kvatop/pa2off.
The change was compile tested for all arches, as it impacts all of them.
See also:
http://mail-index.netbsd.org/current-users/2010/09/07/msg014249.html
diffstat:
lib/libkvm/kvm.c | 13 +++++++------
lib/libkvm/kvm_alpha.c | 10 ++++++----
lib/libkvm/kvm_arm.c | 10 ++++++----
lib/libkvm/kvm_hppa.c | 12 +++++++-----
lib/libkvm/kvm_i386.c | 20 +++++++++++---------
lib/libkvm/kvm_m68k.c | 7 ++++---
lib/libkvm/kvm_m68k.h | 6 +++---
lib/libkvm/kvm_m68k_cmn.c | 24 ++++++++++++------------
lib/libkvm/kvm_mips.c | 13 ++++++++-----
lib/libkvm/kvm_powerpc.c | 25 +++++++++++++------------
lib/libkvm/kvm_powerpc64.c | 7 ++++---
lib/libkvm/kvm_private.h | 6 +++---
lib/libkvm/kvm_proc.c | 5 +++--
lib/libkvm/kvm_sh3.c | 10 ++++++----
lib/libkvm/kvm_sparc.c | 37 ++++++++++++++++++-------------------
lib/libkvm/kvm_sparc64.c | 20 +++++++++++---------
lib/libkvm/kvm_sun2.c | 14 +++++++-------
lib/libkvm/kvm_sun3.c | 16 ++++++++--------
lib/libkvm/kvm_sun3x.c | 12 ++++++------
lib/libkvm/kvm_vax.c | 14 +++++++++-----
lib/libkvm/kvm_x86_64.c | 12 +++++++-----
21 files changed, 159 insertions(+), 134 deletions(-)
diffs (truncated from 1176 to 300 lines):
diff -r b0baf7fec7f4 -r 35ce78033b49 lib/libkvm/kvm.c
--- a/lib/libkvm/kvm.c Mon Sep 20 23:11:38 2010 +0000
+++ b/lib/libkvm/kvm.c Mon Sep 20 23:23:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm.c,v 1.94 2009/09/14 19:29:20 apb Exp $ */
+/* $NetBSD: kvm.c,v 1.95 2010/09/20 23:23:16 jym Exp $ */
/*-
* Copyright (c) 1989, 1992, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94";
#else
-__RCSID("$NetBSD: kvm.c,v 1.94 2009/09/14 19:29:20 apb Exp $");
+__RCSID("$NetBSD: kvm.c,v 1.95 2010/09/20 23:23:16 jym Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -54,6 +54,7 @@
#include <sys/exec.h>
#include <sys/kcore.h>
#include <sys/ksyms.h>
+#include <sys/types.h>
#include <uvm/uvm_extern.h>
@@ -798,7 +799,7 @@
kvm_dump_inval(kvm_t *kd)
{
struct nlist nl[2];
- u_long pa;
+ paddr_t pa;
size_t dsize;
off_t doff;
void *newbuf;
@@ -814,7 +815,7 @@
_kvm_err(kd, 0, "bad namelist");
return (-1);
}
- if (_kvm_kvatop(kd, (u_long)nl[0].n_value, &pa) == 0)
+ if (_kvm_kvatop(kd, (vaddr_t)nl[0].n_value, &pa) == 0)
return (-1);
errno = 0;
@@ -868,10 +869,10 @@
}
cp = buf;
while (len > 0) {
- u_long pa;
+ paddr_t pa;
off_t foff;
- cc = _kvm_kvatop(kd, kva, &pa);
+ cc = _kvm_kvatop(kd, (vaddr_t)kva, &pa);
if (cc == 0)
return (-1);
if (cc > len)
diff -r b0baf7fec7f4 -r 35ce78033b49 lib/libkvm/kvm_alpha.c
--- a/lib/libkvm/kvm_alpha.c Mon Sep 20 23:11:38 2010 +0000
+++ b/lib/libkvm/kvm_alpha.c Mon Sep 20 23:23:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm_alpha.c,v 1.24 2010/09/19 02:07:00 jym Exp $ */
+/* $NetBSD: kvm_alpha.c,v 1.25 2010/09/20 23:23:16 jym Exp $ */
/*
* Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -34,12 +34,14 @@
#include <sys/proc.h>
#include <sys/stat.h>
#include <sys/kcore.h>
-#include <machine/kcore.h>
+#include <sys/types.h>
#include <unistd.h>
#include <nlist.h>
#include <kvm.h>
#include <uvm/uvm_extern.h>
+
+#include <machine/kcore.h>
#include <machine/pmap.h>
#include <machine/vmparam.h>
@@ -64,7 +66,7 @@
}
int
-_kvm_kvatop(kvm_t *kd, u_long va, u_long *pa)
+_kvm_kvatop(kvm_t *kd, vaddr_t va, paddr_t *pa)
{
cpu_kcore_hdr_t *cpu_kh;
alpha_pt_entry_t pte;
@@ -151,7 +153,7 @@
* Translate a physical address to a file-offset in the crash dump.
*/
off_t
-_kvm_pa2off(kvm_t *kd, u_long pa)
+_kvm_pa2off(kvm_t *kd, paddr_t pa)
{
cpu_kcore_hdr_t *cpu_kh;
phys_ram_seg_t *ramsegs;
diff -r b0baf7fec7f4 -r 35ce78033b49 lib/libkvm/kvm_arm.c
--- a/lib/libkvm/kvm_arm.c Mon Sep 20 23:11:38 2010 +0000
+++ b/lib/libkvm/kvm_arm.c Mon Sep 20 23:23:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm_arm.c,v 1.5 2010/09/19 02:07:00 jym Exp $ */
+/* $NetBSD: kvm_arm.c,v 1.6 2010/09/20 23:23:16 jym Exp $ */
/*-
* Copyright (C) 1996 Wolfgang Solfrank.
@@ -39,12 +39,14 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: kvm_arm.c,v 1.5 2010/09/19 02:07:00 jym Exp $");
+__RCSID("$NetBSD: kvm_arm.c,v 1.6 2010/09/20 23:23:16 jym Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <sys/exec.h>
#include <sys/kcore.h>
+#include <sys/types.h>
+
#include <arm/kcore.h>
#include <arm/arm32/pte.h>
@@ -71,12 +73,12 @@
}
int
-_kvm_kvatop(kvm_t * kd, u_long va, u_long *pa)
+_kvm_kvatop(kvm_t * kd, vaddr_t va, paddr_t *pa)
{
cpu_kcore_hdr_t *cpu_kh;
pd_entry_t pde;
pt_entry_t pte;
- uint32_t pde_pa, pte_pa;
+ paddr_t pde_pa, pte_pa;
if (ISALIVE(kd)) {
_kvm_err(kd, 0, "vatop called in live kernel!");
diff -r b0baf7fec7f4 -r 35ce78033b49 lib/libkvm/kvm_hppa.c
--- a/lib/libkvm/kvm_hppa.c Mon Sep 20 23:11:38 2010 +0000
+++ b/lib/libkvm/kvm_hppa.c Mon Sep 20 23:23:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm_hppa.c,v 1.5 2010/06/24 20:46:11 skrll Exp $ */
+/* $NetBSD: kvm_hppa.c,v 1.6 2010/09/20 23:23:16 jym Exp $ */
/*-
* Copyright (c) 1989, 1992, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: kvm_hppa.c,v 1.5 2010/06/24 20:46:11 skrll Exp $");
+__RCSID("$NetBSD: kvm_hppa.c,v 1.6 2010/09/20 23:23:16 jym Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -53,7 +53,8 @@
#include <sys/proc.h>
#include <sys/stat.h>
#include <sys/kcore.h>
-#include <machine/kcore.h>
+#include <sys/types.h>
+
#include <stdlib.h>
#include <unistd.h>
#include <nlist.h>
@@ -66,6 +67,7 @@
#include "kvm_private.h"
+#include <machine/kcore.h>
#include <machine/pmap.h>
#include <machine/pte.h>
#include <machine/vmparam.h>
@@ -96,7 +98,7 @@
* Translate a kernel virtual address to a physical address.
*/
int
-_kvm_kvatop(kvm_t *kd, u_long va, u_long *pa)
+_kvm_kvatop(kvm_t *kd, vaddr_t va, paddr_t *pa)
{
#if 0
cpu_kcore_hdr_t *cpu_kh;
@@ -161,7 +163,7 @@
* Translate a physical address to a file-offset in the crash dump.
*/
off_t
-_kvm_pa2off(kvm_t *kd, u_long pa)
+_kvm_pa2off(kvm_t *kd, paddr_t pa)
{
#if 0
cpu_kcore_hdr_t *cpu_kh;
diff -r b0baf7fec7f4 -r 35ce78033b49 lib/libkvm/kvm_i386.c
--- a/lib/libkvm/kvm_i386.c Mon Sep 20 23:11:38 2010 +0000
+++ b/lib/libkvm/kvm_i386.c Mon Sep 20 23:23:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm_i386.c,v 1.27 2010/09/19 02:07:00 jym Exp $ */
+/* $NetBSD: kvm_i386.c,v 1.28 2010/09/20 23:23:16 jym Exp $ */
/*-
* Copyright (c) 1989, 1992, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: kvm_i386.c,v 1.27 2010/09/19 02:07:00 jym Exp $");
+__RCSID("$NetBSD: kvm_i386.c,v 1.28 2010/09/20 23:23:16 jym Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -50,7 +50,8 @@
#include <sys/user.h>
#include <sys/stat.h>
#include <sys/kcore.h>
-#include <i386/kcore.h>
+#include <sys/types.h>
+
#include <stdlib.h>
#include <unistd.h>
#include <nlist.h>
@@ -63,6 +64,7 @@
#include "kvm_private.h"
+#include <i386/kcore.h>
#include <i386/pmap.h>
#include <i386/pte.h>
#include <i386/vmparam.h>
@@ -93,17 +95,17 @@
* Translate a kernel virtual address to a physical address.
*/
int
-_kvm_kvatop(kvm_t *kd, u_long va, u_long *pa)
+_kvm_kvatop(kvm_t *kd, vaddr_t va, paddr_t *pa)
{
cpu_kcore_hdr_t *cpu_kh;
u_long page_off;
pd_entry_t pde;
pt_entry_t pte;
- u_long pde_pa, pte_pa;
+ paddr_t pde_pa, pte_pa;
if (ISALIVE(kd)) {
_kvm_err(kd, 0, "vatop called in live kernel!");
- return (0);
+ return 0;
}
cpu_kh = kd->cpu_data;
@@ -152,15 +154,15 @@
return (int)(NBPG - page_off);
lose:
- *pa = (u_long)~0L;
- return (0);
+ *pa = (paddr_t)~0L;
+ return 0;
}
/*
* Translate a physical address to a file-offset in the crash dump.
*/
off_t
-_kvm_pa2off(kvm_t *kd, u_long pa)
+_kvm_pa2off(kvm_t *kd, paddr_t pa)
{
cpu_kcore_hdr_t *cpu_kh;
phys_ram_seg_t *ramsegs;
diff -r b0baf7fec7f4 -r 35ce78033b49 lib/libkvm/kvm_m68k.c
--- a/lib/libkvm/kvm_m68k.c Mon Sep 20 23:11:38 2010 +0000
+++ b/lib/libkvm/kvm_m68k.c Mon Sep 20 23:23:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm_m68k.c,v 1.17 2010/09/19 02:07:00 jym Exp $ */
+/* $NetBSD: kvm_m68k.c,v 1.18 2010/09/20 23:23:16 jym Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -42,6 +42,7 @@
#include <sys/exec.h>
#include <sys/kcore.h>
#include <sys/sysctl.h>
+#include <sys/types.h>
#include <stdio.h>
#include <string.h>
@@ -131,13 +132,13 @@
}
int
-_kvm_kvatop(kvm_t *kd, u_long va, u_long *pap)
+_kvm_kvatop(kvm_t *kd, vaddr_t va, paddr_t *pap)
{
return ((kd->vmst->ops->kvatop)(kd, va, pap));
}
off_t
-_kvm_pa2off(kvm_t *kd, u_long pa)
+_kvm_pa2off(kvm_t *kd, paddr_t pa)
Home |
Main Index |
Thread Index |
Old Index