libkvm code janitoring

- make WARNS=6 clean for archs w/o strict alignment requirments
- add const, ANSIfy, remove unused vars, cast types for comparison
- thanks to differing definitions of VM_MIN_ADDRESS across our archs, we
  need to trick the compiler to not complain about signedness. We could
  either fix VM_MIN_ADDRESS to always be a simple integer or make the
  check conditional on $ARCH.

Closes PRs:	kern/42386, kern/83364
Reviewed by:	bde
This commit is contained in:
Ulrich Spörlein 2011-01-23 11:08:28 +00:00
parent 9a6a64d3c4
commit c10970dd7d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=217744
20 changed files with 216 additions and 310 deletions

View File

@ -77,8 +77,7 @@ static char sccsid[] = "@(#)kvm.c 8.2 (Berkeley) 2/13/94";
int __fdnlist(int, struct nlist *);
char *
kvm_geterr(kd)
kvm_t *kd;
kvm_geterr(kvm_t *kd)
{
return (kd->errbuf);
}
@ -103,7 +102,7 @@ _kvm_err(kvm_t *kd, const char *program, const char *fmt, ...)
(void)fputc('\n', stderr);
} else
(void)vsnprintf(kd->errbuf,
sizeof(kd->errbuf), (char *)fmt, ap);
sizeof(kd->errbuf), fmt, ap);
va_end(ap);
}
@ -122,7 +121,7 @@ _kvm_syserr(kvm_t *kd, const char *program, const char *fmt, ...)
} else {
char *cp = kd->errbuf;
(void)vsnprintf(cp, sizeof(kd->errbuf), (char *)fmt, ap);
(void)vsnprintf(cp, sizeof(kd->errbuf), fmt, ap);
n = strlen(cp);
(void)snprintf(&cp[n], sizeof(kd->errbuf) - n, ": %s",
strerror(errno));
@ -131,25 +130,18 @@ _kvm_syserr(kvm_t *kd, const char *program, const char *fmt, ...)
}
void *
_kvm_malloc(kd, n)
kvm_t *kd;
size_t n;
_kvm_malloc(kvm_t *kd, size_t n)
{
void *p;
if ((p = calloc(n, sizeof(char))) == NULL)
_kvm_err(kd, kd->program, "can't allocate %u bytes: %s",
_kvm_err(kd, kd->program, "can't allocate %zu bytes: %s",
n, strerror(errno));
return (p);
}
static kvm_t *
_kvm_open(kd, uf, mf, flag, errout)
kvm_t *kd;
const char *uf;
const char *mf;
int flag;
char *errout;
_kvm_open(kvm_t *kd, const char *uf, const char *mf, int flag, char *errout)
{
struct stat st;
@ -242,12 +234,8 @@ _kvm_open(kd, uf, mf, flag, errout)
}
kvm_t *
kvm_openfiles(uf, mf, sf, flag, errout)
const char *uf;
const char *mf;
const char *sf __unused;
int flag;
char *errout;
kvm_openfiles(const char *uf, const char *mf, const char *sf __unused, int flag,
char *errout)
{
kvm_t *kd;
@ -260,12 +248,8 @@ kvm_openfiles(uf, mf, sf, flag, errout)
}
kvm_t *
kvm_open(uf, mf, sf, flag, errstr)
const char *uf;
const char *mf;
const char *sf __unused;
int flag;
const char *errstr;
kvm_open(const char *uf, const char *mf, const char *sf __unused, int flag,
const char *errstr)
{
kvm_t *kd;
@ -280,8 +264,7 @@ kvm_open(uf, mf, sf, flag, errstr)
}
int
kvm_close(kd)
kvm_t *kd;
kvm_close(kvm_t *kd)
{
int error = 0;
@ -316,8 +299,9 @@ kvm_fdnlist_prefix(kvm_t *kd, struct nlist *nl, int missing, const char *prefix,
{
struct nlist *n, *np, *p;
char *cp, *ce;
const char *ccp;
size_t len;
int unresolved;
int slen, unresolved;
/*
* Calculate the space we need to malloc for nlist and names.
@ -355,13 +339,13 @@ kvm_fdnlist_prefix(kvm_t *kd, struct nlist *nl, int missing, const char *prefix,
continue;
bcopy(p, np, sizeof(struct nlist));
/* Save the new\0orig. name so we can later match it again. */
len = snprintf(cp, ce - cp, "%s%s%c%s", prefix,
slen = snprintf(cp, ce - cp, "%s%s%c%s", prefix,
(prefix[0] != '\0' && p->n_name[0] == '_') ?
(p->n_name + 1) : p->n_name, '\0', p->n_name);
if (len >= ce - cp)
if (slen < 0 || slen >= ce - cp)
continue;
np->n_name = cp;
cp += len + 1;
cp += slen + 1;
np++;
unresolved++;
}
@ -385,8 +369,8 @@ kvm_fdnlist_prefix(kvm_t *kd, struct nlist *nl, int missing, const char *prefix,
if (p->n_type != N_UNDF)
continue;
/* Skip expanded name and compare to orig. one. */
cp = np->n_name + strlen(np->n_name) + 1;
if (strcmp(cp, p->n_name))
ccp = np->n_name + strlen(np->n_name) + 1;
if (strcmp(ccp, p->n_name) != 0)
continue;
/* Update nlist with new, translated results. */
p->n_type = np->n_type;
@ -416,7 +400,8 @@ _kvm_nlist(kvm_t *kd, struct nlist *nl, int initialize)
int nvalid;
struct kld_sym_lookup lookup;
int error;
char *prefix = "", symname[1024]; /* XXX-BZ symbol name length limit? */
const char *prefix = "";
char symname[1024]; /* XXX-BZ symbol name length limit? */
int tried_vnet, tried_dpcpu;
/*
@ -458,9 +443,8 @@ _kvm_nlist(kvm_t *kd, struct nlist *nl, int initialize)
error = snprintf(symname, sizeof(symname), "%s%s", prefix,
(prefix[0] != '\0' && p->n_name[0] == '_') ?
(p->n_name + 1) : p->n_name);
if (error >= sizeof(symname))
if (error < 0 || error >= (int)sizeof(symname))
continue;
lookup.symname = symname;
if (lookup.symname[0] == '_')
lookup.symname++;
@ -470,11 +454,11 @@ _kvm_nlist(kvm_t *kd, struct nlist *nl, int initialize)
p->n_other = 0;
p->n_desc = 0;
if (_kvm_vnet_initialized(kd, initialize) &&
!strcmp(prefix, VNET_SYMPREFIX))
!strcmp(prefix, VNET_SYMPREFIX) == 0)
p->n_value =
_kvm_vnet_validaddr(kd, lookup.symvalue);
else if (_kvm_dpcpu_initialized(kd, initialize) &&
!strcmp(prefix, DPCPU_SYMPREFIX))
!strcmp(prefix, DPCPU_SYMPREFIX) == 0)
p->n_value =
_kvm_dpcpu_validaddr(kd, lookup.symvalue);
else
@ -511,9 +495,7 @@ _kvm_nlist(kvm_t *kd, struct nlist *nl, int initialize)
}
int
kvm_nlist(kd, nl)
kvm_t *kd;
struct nlist *nl;
kvm_nlist(kvm_t *kd, struct nlist *nl)
{
/*
@ -524,13 +506,11 @@ kvm_nlist(kd, nl)
}
ssize_t
kvm_read(kd, kva, buf, len)
kvm_t *kd;
u_long kva;
void *buf;
size_t len;
kvm_read(kvm_t *kd, u_long kva, void *buf, size_t len)
{
int cc;
ssize_t cr;
off_t pa;
char *cp;
if (ISALIVE(kd)) {
@ -540,59 +520,52 @@ kvm_read(kd, kva, buf, len)
*/
errno = 0;
if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) {
_kvm_err(kd, 0, "invalid address (%x)", kva);
_kvm_err(kd, 0, "invalid address (%lx)", kva);
return (-1);
}
cc = read(kd->vmfd, buf, len);
if (cc < 0) {
cr = read(kd->vmfd, buf, len);
if (cr < 0) {
_kvm_syserr(kd, 0, "kvm_read");
return (-1);
} else if (cc < len)
} else if (cr < (ssize_t)len)
_kvm_err(kd, kd->program, "short read");
return (cc);
} else {
cp = buf;
while (len > 0) {
off_t pa;
cc = _kvm_kvatop(kd, kva, &pa);
if (cc == 0)
return (-1);
if (cc > len)
cc = len;
errno = 0;
if (lseek(kd->pmfd, pa, 0) == -1 && errno != 0) {
_kvm_syserr(kd, 0, _PATH_MEM);
break;
}
cc = read(kd->pmfd, cp, cc);
if (cc < 0) {
_kvm_syserr(kd, kd->program, "kvm_read");
break;
}
/*
* If kvm_kvatop returns a bogus value or our core
* file is truncated, we might wind up seeking beyond
* the end of the core file in which case the read will
* return 0 (EOF).
*/
if (cc == 0)
break;
cp += cc;
kva += cc;
len -= cc;
}
return (cp - (char *)buf);
return (cr);
}
/* NOTREACHED */
cp = buf;
while (len > 0) {
cc = _kvm_kvatop(kd, kva, &pa);
if (cc == 0)
return (-1);
if (cc > (ssize_t)len)
cc = len;
errno = 0;
if (lseek(kd->pmfd, pa, 0) == -1 && errno != 0) {
_kvm_syserr(kd, 0, _PATH_MEM);
break;
}
cr = read(kd->pmfd, cp, cc);
if (cr < 0) {
_kvm_syserr(kd, kd->program, "kvm_read");
break;
}
/*
* If kvm_kvatop returns a bogus value or our core file is
* truncated, we might wind up seeking beyond the end of the
* core file in which case the read will return 0 (EOF).
*/
if (cr == 0)
break;
cp += cr;
kva += cr;
len -= cr;
}
return (cp - (char *)buf);
}
ssize_t
kvm_write(kd, kva, buf, len)
kvm_t *kd;
u_long kva;
const void *buf;
size_t len;
kvm_write(kvm_t *kd, u_long kva, const void *buf, size_t len)
{
int cc;
@ -602,14 +575,14 @@ kvm_write(kd, kva, buf, len)
*/
errno = 0;
if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) {
_kvm_err(kd, 0, "invalid address (%x)", kva);
_kvm_err(kd, 0, "invalid address (%lx)", kva);
return (-1);
}
cc = write(kd->vmfd, buf, len);
if (cc < 0) {
_kvm_syserr(kd, 0, "kvm_write");
return (-1);
} else if (cc < len)
} else if ((size_t)cc < len)
_kvm_err(kd, kd->program, "short write");
return (cc);
} else {

View File

@ -88,7 +88,7 @@ kvm_t *kvm_openfiles
(const char *, const char *, const char *, int, char *);
ssize_t kvm_read(kvm_t *, unsigned long, void *, size_t);
ssize_t kvm_uread
(kvm_t *, struct kinfo_proc *, unsigned long, char *, size_t);
(kvm_t *, const struct kinfo_proc *, unsigned long, char *, size_t);
ssize_t kvm_write(kvm_t *, unsigned long, const void *, size_t);
__END_DECLS

View File

@ -147,7 +147,7 @@ _kvm_freevtop(kvm_t *kd)
int
_kvm_initvtop(kvm_t *kd)
{
struct nlist nlist[2];
struct nlist nl[2];
u_long pa;
u_long kernbase;
pml4_entry_t *PML4;
@ -176,23 +176,23 @@ _kvm_initvtop(kvm_t *kd)
return (-1);
}
nlist[0].n_name = "kernbase";
nlist[1].n_name = 0;
nl[0].n_name = "kernbase";
nl[1].n_name = 0;
if (kvm_nlist(kd, nlist) != 0) {
if (kvm_nlist(kd, nl) != 0) {
_kvm_err(kd, kd->program, "bad namelist - no kernbase");
return (-1);
}
kernbase = nlist[0].n_value;
kernbase = nl[0].n_value;
nlist[0].n_name = "KPML4phys";
nlist[1].n_name = 0;
nl[0].n_name = "KPML4phys";
nl[1].n_name = 0;
if (kvm_nlist(kd, nlist) != 0) {
if (kvm_nlist(kd, nl) != 0) {
_kvm_err(kd, kd->program, "bad namelist - no KPML4phys");
return (-1);
}
if (kvm_read(kd, (nlist[0].n_value - kernbase), &pa, sizeof(pa)) !=
if (kvm_read(kd, (nl[0].n_value - kernbase), &pa, sizeof(pa)) !=
sizeof(pa)) {
_kvm_err(kd, kd->program, "cannot read KPML4phys");
return (-1);
@ -222,7 +222,6 @@ _kvm_vatop(kvm_t *kd, u_long va, off_t *pa)
u_long pdpeindex;
u_long pdeindex;
u_long pteindex;
int i;
u_long a;
off_t ofs;
size_t s;

View File

@ -124,7 +124,7 @@ int
_kvm_initvtop(kvm_t *kd)
{
struct vmstate *vm;
struct nlist nlist[2];
struct nlist nl[2];
u_long kernbase, physaddr, pa;
pd_entry_t *l1pt;
Elf32_Ehdr *ehdr;
@ -154,25 +154,25 @@ _kvm_initvtop(kvm_t *kd)
hdrsz = ehdr->e_phoff + ehdr->e_phentsize * ehdr->e_phnum;
if (_kvm_maphdrs(kd, hdrsz) == -1)
return (-1);
nlist[0].n_name = "kernbase";
nlist[1].n_name = NULL;
if (kvm_nlist(kd, nlist) != 0)
nl[0].n_name = "kernbase";
nl[1].n_name = NULL;
if (kvm_nlist(kd, nl) != 0)
kernbase = KERNBASE;
else
kernbase = nlist[0].n_value;
kernbase = nl[0].n_value;
nlist[0].n_name = "physaddr";
if (kvm_nlist(kd, nlist) != 0) {
nl[0].n_name = "physaddr";
if (kvm_nlist(kd, nl) != 0) {
_kvm_err(kd, kd->program, "couldn't get phys addr");
return (-1);
}
physaddr = nlist[0].n_value;
nlist[0].n_name = "kernel_l1pa";
if (kvm_nlist(kd, nlist) != 0) {
physaddr = nl[0].n_value;
nl[0].n_name = "kernel_l1pa";
if (kvm_nlist(kd, nl) != 0) {
_kvm_err(kd, kd->program, "bad namelist");
return (-1);
}
if (kvm_read(kd, (nlist[0].n_value - kernbase + physaddr), &pa,
if (kvm_read(kd, (nl[0].n_value - kernbase + physaddr), &pa,
sizeof(pa)) != sizeof(pa)) {
_kvm_err(kd, kd->program, "cannot read kernel_l1pa");
return (-1);
@ -205,7 +205,6 @@ _kvm_initvtop(kvm_t *kd)
int
_kvm_kvatop(kvm_t *kd, u_long va, off_t *pa)
{
u_long offset = va & (PAGE_SIZE - 1);
struct vmstate *vm = kd->vmst;
pd_entry_t pd;
pt_entry_t pte;
@ -244,7 +243,7 @@ _kvm_kvatop(kvm_t *kd, u_long va, off_t *pa)
*pa = (pte & L2_S_FRAME) | (va & L2_S_OFFSET);
return (_kvm_pa2off(kd, *pa, pa, PAGE_SIZE));
invalid:
_kvm_err(kd, 0, "Invalid address (%x)", va);
_kvm_err(kd, 0, "Invalid address (%lx)", va);
return 0;
}
@ -253,16 +252,15 @@ _kvm_kvatop(kvm_t *kd, u_long va, off_t *pa)
* not just those for a kernel crash dump. Some architectures
* have to deal with these NOT being constants! (i.e. m68k)
*/
#ifdef FBSD_NOT_YET
int
_kvm_mdopen(kd)
kvm_t *kd;
_kvm_mdopen(kvm_t *kd)
{
#ifdef FBSD_NOT_YET
kd->usrstack = USRSTACK;
kd->min_uva = VM_MIN_ADDRESS;
kd->max_uva = VM_MAXUSER_ADDRESS;
#endif
return (0);
}
#endif

View File

@ -44,8 +44,8 @@ __FBSDID("$FreeBSD$");
#include "kvm_private.h"
static struct nlist kvm_cp_time_nl[] = {
{ "_cp_time" }, /* (deprecated) */
{ NULL },
{ .n_name = "_cp_time" }, /* (deprecated) */
{ .n_name = NULL },
};
#define NL_CP_TIME 0
@ -59,6 +59,7 @@ _kvm_cp_time_init(kvm_t *kd)
if (kvm_nlist(kd, kvm_cp_time_nl) < 0)
return (-1);
kvm_cp_time_cached = 1;
return (0);
}
static int

View File

@ -69,16 +69,14 @@ static char sccsid[] = "@(#)kvm_file.c 8.1 (Berkeley) 6/4/93";
(kvm_read(kd, addr, obj, sizeof(*obj)) != sizeof(*obj))
#define KREADN(kd, addr, obj, cnt) \
(kvm_read(kd, addr, obj, (cnt)) != (cnt))
(kvm_read(kd, addr, obj, (cnt)) != (ssize_t)(cnt))
/*
* Get file structures.
*/
static int
kvm_deadfiles(kd, op, arg, allproc_o, nprocs)
kvm_t *kd;
int op, arg, nprocs;
long allproc_o;
kvm_deadfiles(kvm_t *kd, int op __unused, int arg __unused, long allproc_o,
int nprocs __unused)
{
struct proc proc;
struct filedesc filed;
@ -88,7 +86,7 @@ kvm_deadfiles(kd, op, arg, allproc_o, nprocs)
struct proc *p;
char *where = kd->argspc;
if (buflen < sizeof (struct file *) + sizeof (struct file))
if (buflen < (int)(sizeof(struct file *) + sizeof(struct file)))
return (0);
if (KREAD(kd, allproc_o, &p)) {
_kvm_err(kd, kd->program, "cannot read allproc");
@ -96,7 +94,7 @@ kvm_deadfiles(kd, op, arg, allproc_o, nprocs)
}
for (; p != NULL; p = LIST_NEXT(&proc, p_list)) {
if (KREAD(kd, (u_long)p, &proc)) {
_kvm_err(kd, kd->program, "can't read proc at %x", p);
_kvm_err(kd, kd->program, "can't read proc at %p", p);
goto fail;
}
if (proc.p_state == PRS_NEW)
@ -104,7 +102,7 @@ kvm_deadfiles(kd, op, arg, allproc_o, nprocs)
if (proc.p_fd == NULL)
continue;
if (KREAD(kd, (u_long)p->p_fd, &filed)) {
_kvm_err(kd, kd->program, "can't read filedesc at %x",
_kvm_err(kd, kd->program, "can't read filedesc at %p",
p->p_fd);
goto fail;
}
@ -118,7 +116,7 @@ kvm_deadfiles(kd, op, arg, allproc_o, nprocs)
}
if (KREADN(kd, (u_long)filed.fd_ofiles, ofiles,
ocnt * sizeof(struct file *))) {
_kvm_err(kd, kd->program, "can't read ofiles at %x",
_kvm_err(kd, kd->program, "can't read ofiles at %p",
filed.fd_ofiles);
return (0);
}
@ -135,7 +133,7 @@ kvm_deadfiles(kd, op, arg, allproc_o, nprocs)
where += sizeof (fp);
once = 1;
}
if (buflen < sizeof (struct file))
if (buflen < (int)sizeof(struct file))
goto fail;
if (KREAD(kd, (long)fp, ((struct file *)where))) {
_kvm_err(kd, kd->program, "can't read kfp");
@ -156,10 +154,7 @@ kvm_deadfiles(kd, op, arg, allproc_o, nprocs)
}
char *
kvm_getfiles(kd, op, arg, cnt)
kvm_t *kd;
int op, arg;
int *cnt;
kvm_getfiles(kvm_t *kd, int op, int arg, int *cnt)
{
int mib[2], st, n, nfiles, nprocs;
size_t size;
@ -177,7 +172,7 @@ kvm_getfiles(kd, op, arg, cnt)
}
if (kd->argspc == 0)
kd->argspc = (char *)_kvm_malloc(kd, size);
else if (kd->arglen < size)
else if (kd->arglen < (int)size)
kd->argspc = (char *)_kvm_realloc(kd, kd->argspc, size);
if (kd->argspc == 0)
return (0);
@ -214,7 +209,7 @@ kvm_getfiles(kd, op, arg, cnt)
size = sizeof(void *) + (nfiles + 10) * sizeof(struct file);
if (kd->argspc == 0)
kd->argspc = (char *)_kvm_malloc(kd, size);
else if (kd->arglen < size)
else if (kd->arglen < (int)size)
kd->argspc = (char *)_kvm_realloc(kd, kd->argspc, size);
if (kd->argspc == 0)
return (0);

View File

@ -48,11 +48,11 @@ static char sccsid[] = "@(#)kvm_getloadavg.c 8.1 (Berkeley) 6/4/93";
#include "kvm_private.h"
static struct nlist nl[] = {
{ "_averunnable" },
{ .n_name = "_averunnable" },
#define X_AVERUNNABLE 0
{ "_fscale" },
{ .n_name = "_fscale" },
#define X_FSCALE 1
{ "" },
{ .n_name = "" },
};
/*
@ -62,10 +62,7 @@ static struct nlist nl[] = {
* Return number of samples retrieved, or -1 on error.
*/
int
kvm_getloadavg(kd, loadavg, nelem)
kvm_t *kd;
double loadavg[];
int nelem;
kvm_getloadavg(kvm_t *kd, double loadavg[], int nelem)
{
struct loadavg loadinfo;
struct nlist *p;
@ -95,7 +92,7 @@ kvm_getloadavg(kd, loadavg, nelem)
if (!KREAD(kd, nl[X_FSCALE].n_value, &fscale))
loadinfo.fscale = fscale;
nelem = MIN(nelem, sizeof(loadinfo.ldavg) / sizeof(fixpt_t));
nelem = MIN(nelem, (int)(sizeof(loadinfo.ldavg) / sizeof(fixpt_t)));
for (i = 0; i < nelem; i++)
loadavg[i] = (double) loadinfo.ldavg[i] / loadinfo.fscale;
return (nelem);

View File

@ -51,9 +51,9 @@ __FBSDID("$FreeBSD$");
#include "kvm_private.h"
static struct nlist kvm_swap_nl[] = {
{ "_swtailq" }, /* list of swap devices and sizes */
{ "_dmmax" }, /* maximum size of a swap block */
{ NULL }
{ .n_name = "_swtailq" }, /* list of swap devices and sizes */
{ .n_name = "_dmmax" }, /* maximum size of a swap block */
{ .n_name = NULL }
};
#define NL_SWTAILQ 0
@ -66,7 +66,7 @@ static int dmmax;
static int kvm_getswapinfo_kvm(kvm_t *, struct kvm_swap *, int, int);
static int kvm_getswapinfo_sysctl(kvm_t *, struct kvm_swap *, int, int);
static int nlist_init(kvm_t *);
static int getsysctl(kvm_t *, char *, void *, size_t);
static int getsysctl(kvm_t *, const char *, void *, size_t);
#define KREAD(kd, addr, obj) \
(kvm_read(kd, addr, (char *)(obj), sizeof(*obj)) != sizeof(*obj))
@ -90,12 +90,8 @@ static int getsysctl(kvm_t *, char *, void *, size_t);
}
int
kvm_getswapinfo(
kvm_t *kd,
struct kvm_swap *swap_ary,
int swap_max,
int flags
) {
kvm_getswapinfo(kvm_t *kd, struct kvm_swap *swap_ary, int swap_max, int flags)
{
/*
* clear cache
@ -113,12 +109,9 @@ kvm_getswapinfo(
}
int
kvm_getswapinfo_kvm(
kvm_t *kd,
struct kvm_swap *swap_ary,
int swap_max,
int flags
) {
kvm_getswapinfo_kvm(kvm_t *kd, struct kvm_swap *swap_ary, int swap_max,
int flags)
{
int i, ttl;
TAILQ_HEAD(, swdevt) swtailq;
struct swdevt *sp, swinfo;
@ -161,12 +154,9 @@ kvm_getswapinfo_kvm(
#define SWI_MAXMIB 3
int
kvm_getswapinfo_sysctl(
kvm_t *kd,
struct kvm_swap *swap_ary,
int swap_max,
int flags
) {
kvm_getswapinfo_sysctl(kvm_t *kd, struct kvm_swap *swap_ary, int swap_max,
int flags)
{
int ti, ttl;
size_t mibi, len;
int soid[SWI_MAXMIB];
@ -229,8 +219,6 @@ kvm_getswapinfo_sysctl(
static int
nlist_init(kvm_t *kd)
{
TAILQ_HEAD(, swdevt) swtailq;
struct swdevt *sp, swinfo;
if (kvm_swap_nl_cached)
return (1);
@ -257,12 +245,8 @@ nlist_init(kvm_t *kd)
}
static int
getsysctl (
kvm_t *kd,
char *name,
void *ptr,
size_t len
) {
getsysctl(kvm_t *kd, const char *name, void *ptr, size_t len)
{
size_t nlen = len;
if (sysctlbyname(name, ptr, &nlen, NULL, 0) == -1) {
_kvm_err(kd, kd->program, "cannot read sysctl %s:%s", name,

View File

@ -153,7 +153,7 @@ _kvm_freevtop(kvm_t *kd)
int
_kvm_initvtop(kvm_t *kd)
{
struct nlist nlist[2];
struct nlist nl[2];
u_long pa;
u_long kernbase;
char *PTD;
@ -183,21 +183,21 @@ _kvm_initvtop(kvm_t *kd)
return (-1);
}
nlist[0].n_name = "kernbase";
nlist[1].n_name = 0;
nl[0].n_name = "kernbase";
nl[1].n_name = 0;
if (kvm_nlist(kd, nlist) != 0)
if (kvm_nlist(kd, nl) != 0)
kernbase = KERNBASE; /* for old kernels */
else
kernbase = nlist[0].n_value;
kernbase = nl[0].n_value;
nlist[0].n_name = "IdlePDPT";
nlist[1].n_name = 0;
nl[0].n_name = "IdlePDPT";
nl[1].n_name = 0;
if (kvm_nlist(kd, nlist) == 0) {
if (kvm_nlist(kd, nl) == 0) {
uint64_t pa64;
if (kvm_read(kd, (nlist[0].n_value - kernbase), &pa,
if (kvm_read(kd, (nl[0].n_value - kernbase), &pa,
sizeof(pa)) != sizeof(pa)) {
_kvm_err(kd, kd->program, "cannot read IdlePDPT");
return (-1);
@ -220,14 +220,14 @@ _kvm_initvtop(kvm_t *kd)
kd->vmst->PTD = PTD;
kd->vmst->pae = 1;
} else {
nlist[0].n_name = "IdlePTD";
nlist[1].n_name = 0;
nl[0].n_name = "IdlePTD";
nl[1].n_name = 0;
if (kvm_nlist(kd, nlist) != 0) {
if (kvm_nlist(kd, nl) != 0) {
_kvm_err(kd, kd->program, "bad namelist");
return (-1);
}
if (kvm_read(kd, (nlist[0].n_value - kernbase), &pa,
if (kvm_read(kd, (nl[0].n_value - kernbase), &pa,
sizeof(pa)) != sizeof(pa)) {
_kvm_err(kd, kd->program, "cannot read IdlePTD");
return (-1);

View File

@ -32,6 +32,7 @@
#include <sys/elf64.h>
#include <sys/mman.h>
#include <machine/atomic.h>
#include <machine/pte.h>
#include <kvm.h>
@ -123,7 +124,7 @@ _kvm_freevtop(kvm_t *kd)
int
_kvm_initvtop(kvm_t *kd)
{
struct nlist nlist[2];
struct nlist nl[2];
uint64_t va;
Elf64_Ehdr *ehdr;
size_t hdrsz;
@ -150,15 +151,15 @@ _kvm_initvtop(kvm_t *kd)
* addresses/values.
*/
nlist[0].n_name = "ia64_kptdir";
nlist[1].n_name = 0;
nl[0].n_name = "ia64_kptdir";
nl[1].n_name = 0;
if (kvm_nlist(kd, nlist) != 0) {
if (kvm_nlist(kd, nl) != 0) {
_kvm_err(kd, kd->program, "bad namelist");
return (-1);
}
if (kvm_read(kd, (nlist[0].n_value), &va, sizeof(va)) != sizeof(va)) {
if (kvm_read(kd, (nl[0].n_value), &va, sizeof(va)) != sizeof(va)) {
_kvm_err(kd, kd->program, "cannot read kptdir");
return (-1);
}

View File

@ -136,7 +136,6 @@ _kvm_minidump_freevtop(kvm_t *kd)
int
_kvm_minidump_initvtop(kvm_t *kd)
{
u_long pa;
struct vmstate *vmst;
off_t off;
@ -207,7 +206,6 @@ _kvm_minidump_vatop_v1(kvm_t *kd, u_long va, off_t *pa)
u_long offset;
pt_entry_t pte;
u_long pteindex;
int i;
u_long a;
off_t ofs;
@ -258,7 +256,6 @@ _kvm_minidump_vatop(kvm_t *kd, u_long va, off_t *pa)
pd_entry_t pte;
u_long pteindex;
u_long pdeindex;
int i;
u_long a;
off_t ofs;

View File

@ -138,7 +138,6 @@ _kvm_minidump_freevtop(kvm_t *kd)
int
_kvm_minidump_initvtop(kvm_t *kd)
{
u_long pa;
struct vmstate *vmst;
off_t off;
@ -179,7 +178,7 @@ _kvm_minidump_initvtop(kvm_t *kd)
}
if (pread(kd->pmfd, vmst->bitmap, vmst->hdr.bitmapsize, off) !=
vmst->hdr.bitmapsize) {
(ssize_t)vmst->hdr.bitmapsize) {
_kvm_err(kd, kd->program, "cannot read %d bytes for page bitmap",
vmst->hdr.bitmapsize);
return (-1);
@ -194,7 +193,7 @@ _kvm_minidump_initvtop(kvm_t *kd)
}
if (pread(kd->pmfd, vmst->ptemap, vmst->hdr.ptesize, off) !=
vmst->hdr.ptesize) {
(ssize_t)vmst->hdr.ptesize) {
_kvm_err(kd, kd->program, "cannot read %d bytes for ptemap",
vmst->hdr.ptesize);
return (-1);
@ -216,7 +215,6 @@ _kvm_minidump_kvatop(kvm_t *kd, u_long va, off_t *pa)
u_long offset, pteindex, a;
off_t ofs;
uint32_t *ptemap;
int i;
if (ISALIVE(kd)) {
_kvm_err(kd, 0, "kvm_kvatop called in live kernel!");

View File

@ -138,7 +138,6 @@ _kvm_minidump_freevtop(kvm_t *kd)
int
_kvm_minidump_initvtop(kvm_t *kd)
{
u_long pa;
struct vmstate *vmst;
off_t off;
@ -173,7 +172,7 @@ _kvm_minidump_initvtop(kvm_t *kd)
return (-1);
}
if (pread(kd->pmfd, vmst->bitmap, vmst->hdr.bitmapsize, off) !=
vmst->hdr.bitmapsize) {
(ssize_t)vmst->hdr.bitmapsize) {
_kvm_err(kd, kd->program, "cannot read %d bytes for page bitmap", vmst->hdr.bitmapsize);
return (-1);
}
@ -185,7 +184,7 @@ _kvm_minidump_initvtop(kvm_t *kd)
return (-1);
}
if (pread(kd->pmfd, vmst->ptemap, vmst->hdr.ptesize, off) !=
vmst->hdr.ptesize) {
(ssize_t)vmst->hdr.ptesize) {
_kvm_err(kd, kd->program, "cannot read %d bytes for ptemap", vmst->hdr.ptesize);
return (-1);
}
@ -204,7 +203,6 @@ _kvm_minidump_vatop_pae(kvm_t *kd, u_long va, off_t *pa)
uint64_t offset;
uint64_t pte;
u_long pteindex;
int i;
uint64_t a;
off_t ofs;
uint64_t *ptemap;
@ -245,7 +243,6 @@ _kvm_minidump_vatop(kvm_t *kd, u_long va, off_t *pa)
u_long offset;
pt_entry_t pte;
u_long pteindex;
int i;
u_long a;
off_t ofs;
uint32_t *ptemap;

View File

@ -140,7 +140,6 @@ _kvm_minidump_freevtop(kvm_t *kd)
int
_kvm_minidump_initvtop(kvm_t *kd)
{
u_long pa;
struct vmstate *vmst;
off_t off;
@ -182,7 +181,7 @@ _kvm_minidump_initvtop(kvm_t *kd)
}
if (pread(kd->pmfd, vmst->bitmap, vmst->hdr.bitmapsize, off) !=
vmst->hdr.bitmapsize) {
(ssize_t)vmst->hdr.bitmapsize) {
_kvm_err(kd, kd->program, "cannot read %d bytes for page bitmap",
vmst->hdr.bitmapsize);
return (-1);
@ -197,7 +196,7 @@ _kvm_minidump_initvtop(kvm_t *kd)
}
if (pread(kd->pmfd, vmst->ptemap, vmst->hdr.ptesize, off) !=
vmst->hdr.ptesize) {
(ssize_t)vmst->hdr.ptesize) {
_kvm_err(kd, kd->program, "cannot read %d bytes for ptemap",
vmst->hdr.ptesize);
return (-1);
@ -219,7 +218,6 @@ _kvm_minidump_kvatop(kvm_t *kd, u_long va, off_t *pa)
u_long offset, pteindex, a;
off_t ofs;
pt_entry_t *ptemap;
int i;
if (ISALIVE(kd)) {
_kvm_err(kd, 0, "kvm_kvatop called in live kernel!");
@ -238,9 +236,9 @@ _kvm_minidump_kvatop(kvm_t *kd, u_long va, off_t *pa)
a = (MIPS_XKPHYS_TO_PHYS(va));
else
#endif
if (va >= MIPS_KSEG0_START && va < MIPS_KSEG0_END)
if (va >= (u_long)MIPS_KSEG0_START && va < (u_long)MIPS_KSEG0_END)
a = (MIPS_KSEG0_TO_PHYS(va));
else if (va >= MIPS_KSEG1_START && va < MIPS_KSEG1_END)
else if (va >= (u_long)MIPS_KSEG1_START && va < (u_long)MIPS_KSEG1_END)
a = (MIPS_KSEG1_TO_PHYS(va));
else if (va >= vm->hdr.kernbase) {
pteindex = (va - vm->hdr.kernbase) >> PAGE_SHIFT;

View File

@ -94,12 +94,9 @@ _kvm_initvtop(kvm_t *kd)
}
int
_kvm_kvatop(kvm_t *kd, u_long va , off_t *pa)
_kvm_kvatop(kvm_t *kd, u_long va, off_t *pa)
{
u_long offset = va & (PAGE_SIZE - 1);
struct vmstate *vm = kd->vmst;
if (kd->vmst->minidump)
return _kvm_minidump_kvatop(kd, va, pa);
@ -113,9 +110,11 @@ _kvm_kvatop(kvm_t *kd, u_long va , off_t *pa)
* not just those for a kernel crash dump. Some architectures
* have to deal with these NOT being constants! (i.e. m68k)
*/
#ifdef FBSD_NOT_YET
int
_kvm_mdopen(kvm_t *kd __unused)
{
return (0);
}
#endif

View File

@ -48,9 +48,9 @@ __FBSDID("$FreeBSD$");
#include "kvm_private.h"
static struct nlist kvm_pcpu_nl[] = {
{ "_cpuid_to_pcpu" },
{ "_mp_maxcpus" },
{ NULL },
{ .n_name = "_cpuid_to_pcpu" },
{ .n_name = "_mp_maxcpus" },
{ .n_name = NULL },
};
/*
@ -96,7 +96,7 @@ _kvm_pcpu_init(kvm_t *kd)
return (-1);
}
if (kvm_read(kd, kvm_pcpu_nl[NL_CPUID_TO_PCPU].n_value, data, len) !=
len) {
(ssize_t)len) {
_kvm_err(kd, kd->program, "cannot read cpuid_to_pcpu array");
free(data);
return (-1);
@ -119,7 +119,6 @@ void *
kvm_getpcpu(kvm_t *kd, int cpu)
{
char *buf;
int i;
if (kd == NULL) {
_kvm_pcpu_clear();
@ -197,14 +196,14 @@ _kvm_dpcpu_init(kvm_t *kd)
{
struct nlist nl[] = {
#define NLIST_START_SET_PCPU 0
{ "___start_" DPCPU_SETNAME },
{ .n_name = "___start_" DPCPU_SETNAME },
#define NLIST_STOP_SET_PCPU 1
{ "___stop_" DPCPU_SETNAME },
{ .n_name = "___stop_" DPCPU_SETNAME },
#define NLIST_DPCPU_OFF 2
{ "_dpcpu_off" },
{ .n_name = "_dpcpu_off" },
#define NLIST_MP_MAXCPUS 3
{ "_mp_maxcpus" },
{ NULL },
{ .n_name = "_mp_maxcpus" },
{ .n_name = NULL },
};
uintptr_t *dpcpu_off_buf;
size_t len;
@ -225,7 +224,7 @@ _kvm_dpcpu_init(kvm_t *kd)
if (dpcpu_off_buf == NULL)
return (-1);
if (kvm_read(kd, nl[NLIST_DPCPU_OFF].n_value, dpcpu_off_buf, len) !=
len) {
(ssize_t)len) {
free(dpcpu_off_buf);
return (-1);
}

View File

@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <limits.h>
#include <kvm.h>
#include <stdlib.h>
#include <string.h>
#include "kvm_private.h"

View File

@ -94,12 +94,8 @@ static int hz;
* at most maxcnt procs.
*/
static int
kvm_proclist(kd, what, arg, p, bp, maxcnt)
kvm_t *kd;
int what, arg;
struct proc *p;
struct kinfo_proc *bp;
int maxcnt;
kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
struct kinfo_proc *bp, int maxcnt)
{
int cnt = 0;
struct kinfo_proc kinfo_proc, *kp;
@ -109,7 +105,9 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
struct tty tty;
struct vmspace vmspace;
struct sigacts sigacts;
#if 0
struct pstats pstats;
#endif
struct ucred ucred;
struct prison pr;
struct thread mtd;
@ -128,14 +126,14 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
for (; cnt < maxcnt && p != NULL; p = LIST_NEXT(&proc, p_list)) {
memset(kp, 0, sizeof *kp);
if (KREAD(kd, (u_long)p, &proc)) {
_kvm_err(kd, kd->program, "can't read proc at %x", p);
_kvm_err(kd, kd->program, "can't read proc at %p", p);
return (-1);
}
if (proc.p_state != PRS_ZOMBIE) {
if (KREAD(kd, (u_long)TAILQ_FIRST(&proc.p_threads),
&mtd)) {
_kvm_err(kd, kd->program,
"can't read thread at %x",
"can't read thread at %p",
TAILQ_FIRST(&proc.p_threads));
return (-1);
}
@ -157,7 +155,7 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
if (ucred.cr_prison != NULL) {
if (KREAD(kd, (u_long)ucred.cr_prison, &pr)) {
_kvm_err(kd, kd->program,
"can't read prison at %x",
"can't read prison at %p",
ucred.cr_prison);
return (-1);
}
@ -215,7 +213,7 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
if (proc.p_sigacts != NULL) {
if (KREAD(kd, (u_long)proc.p_sigacts, &sigacts)) {
_kvm_err(kd, kd->program,
"can't read sigacts at %x", proc.p_sigacts);
"can't read sigacts at %p", proc.p_sigacts);
return (-1);
}
kp->ki_sigignore = sigacts.ps_sigignore;
@ -248,7 +246,7 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
else if (proc.p_pptr) {
if (KREAD(kd, (u_long)proc.p_pptr, &pproc)) {
_kvm_err(kd, kd->program,
"can't read pproc at %x", proc.p_pptr);
"can't read pproc at %p", proc.p_pptr);
return (-1);
}
kp->ki_ppid = pproc.p_pid;
@ -257,14 +255,14 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
if (proc.p_pgrp == NULL)
goto nopgrp;
if (KREAD(kd, (u_long)proc.p_pgrp, &pgrp)) {
_kvm_err(kd, kd->program, "can't read pgrp at %x",
_kvm_err(kd, kd->program, "can't read pgrp at %p",
proc.p_pgrp);
return (-1);
}
kp->ki_pgid = pgrp.pg_id;
kp->ki_jobc = pgrp.pg_jobc;
if (KREAD(kd, (u_long)pgrp.pg_session, &sess)) {
_kvm_err(kd, kd->program, "can't read session at %x",
_kvm_err(kd, kd->program, "can't read session at %p",
pgrp.pg_session);
return (-1);
}
@ -277,13 +275,13 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
if ((proc.p_flag & P_CONTROLT) && sess.s_ttyp != NULL) {
if (KREAD(kd, (u_long)sess.s_ttyp, &tty)) {
_kvm_err(kd, kd->program,
"can't read tty at %x", sess.s_ttyp);
"can't read tty at %p", sess.s_ttyp);
return (-1);
}
if (tty.t_dev != NULL) {
if (KREAD(kd, (u_long)tty.t_dev, &t_cdev)) {
_kvm_err(kd, kd->program,
"can't read cdev at %x",
"can't read cdev at %p",
tty.t_dev);
return (-1);
}
@ -296,7 +294,7 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
if (tty.t_pgrp != NULL) {
if (KREAD(kd, (u_long)tty.t_pgrp, &pgrp)) {
_kvm_err(kd, kd->program,
"can't read tpgrp at %x",
"can't read tpgrp at %p",
tty.t_pgrp);
return (-1);
}
@ -306,7 +304,7 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
if (tty.t_session != NULL) {
if (KREAD(kd, (u_long)tty.t_session, &sess)) {
_kvm_err(kd, kd->program,
"can't read session at %x",
"can't read session at %p",
tty.t_session);
return (-1);
}
@ -439,12 +437,8 @@ kvm_proclist(kd, what, arg, p, bp, maxcnt)
* Return number of procs read. maxcnt is the max we will read.
*/
static int
kvm_deadprocs(kd, what, arg, a_allproc, a_zombproc, maxcnt)
kvm_t *kd;
int what, arg;
u_long a_allproc;
u_long a_zombproc;
int maxcnt;
kvm_deadprocs(kvm_t *kd, int what, int arg, u_long a_allproc,
u_long a_zombproc, int maxcnt)
{
struct kinfo_proc *bp = kd->procbase;
int acnt, zcnt;
@ -470,10 +464,7 @@ kvm_deadprocs(kd, what, arg, a_allproc, a_zombproc, maxcnt)
}
struct kinfo_proc *
kvm_getprocs(kd, op, arg, cnt)
kvm_t *kd;
int op, arg;
int *cnt;
kvm_getprocs(kvm_t *kd, int op, int arg, int *cnt)
{
int mib[4], st, nprocs;
size_t size;
@ -543,7 +534,7 @@ kvm_getprocs(kd, op, arg, cnt)
if (size > 0 &&
kd->procbase->ki_structsize != sizeof(struct kinfo_proc)) {
_kvm_err(kd, kd->program,
"kinfo_proc size mismatch (expected %d, got %d)",
"kinfo_proc size mismatch (expected %zu, got %d)",
sizeof(struct kinfo_proc),
kd->procbase->ki_structsize);
return (0);
@ -596,8 +587,7 @@ kvm_getprocs(kd, op, arg, cnt)
}
void
_kvm_freeprocs(kd)
kvm_t *kd;
_kvm_freeprocs(kvm_t *kd)
{
if (kd->procbase) {
free(kd->procbase);
@ -606,10 +596,7 @@ _kvm_freeprocs(kd)
}
void *
_kvm_realloc(kd, p, n)
kvm_t *kd;
void *p;
size_t n;
_kvm_realloc(kvm_t *kd, void *p, size_t n)
{
void *np = (void *)realloc(p, n);
@ -631,12 +618,8 @@ _kvm_realloc(kd, p, n)
* environment strings. Read at most maxcnt characters of strings.
*/
static char **
kvm_argv(kd, kp, addr, narg, maxcnt)
kvm_t *kd;
struct kinfo_proc *kp;
u_long addr;
int narg;
int maxcnt;
kvm_argv(kvm_t *kd, const struct kinfo_proc *kp, u_long addr, int narg,
int maxcnt)
{
char *np, *cp, *ep, *ap;
u_long oaddr = -1;
@ -644,10 +627,13 @@ kvm_argv(kd, kp, addr, narg, maxcnt)
char **argv;
/*
* Check that there aren't an unreasonable number of agruments,
* and that the address is in user space.
* Check that there aren't an unreasonable number of arguments,
* and that the address is in user space. Special test for
* VM_MIN_ADDRESS as it evaluates to zero, but is not a simple zero
* constant for some archs. We cannot use the pre-processor here and
* for some archs the compiler would trigger a signedness warning.
*/
if (narg > 512 || addr < VM_MIN_ADDRESS || addr >= VM_MAXUSER_ADDRESS)
if (narg > 512 || addr + 1 < VM_MIN_ADDRESS + 1 || addr >= VM_MAXUSER_ADDRESS)
return (0);
/*
@ -807,20 +793,14 @@ kvm_argv(kd, kp, addr, narg, maxcnt)
}
static void
ps_str_a(p, addr, n)
struct ps_strings *p;
u_long *addr;
int *n;
ps_str_a(struct ps_strings *p, u_long *addr, int *n)
{
*addr = (u_long)p->ps_argvstr;
*n = p->ps_nargvstr;
}
static void
ps_str_e(p, addr, n)
struct ps_strings *p;
u_long *addr;
int *n;
ps_str_e (struct ps_strings *p, u_long *addr, int *n)
{
*addr = (u_long)p->ps_envstr;
*n = p->ps_nenvstr;
@ -832,8 +812,7 @@ ps_str_e(p, addr, n)
* being wrong are very low.
*/
static int
proc_verify(curkp)
struct kinfo_proc *curkp;
proc_verify(const struct kinfo_proc *curkp)
{
struct kinfo_proc newkp;
int mib[4];
@ -851,11 +830,8 @@ proc_verify(curkp)
}
static char **
kvm_doargv(kd, kp, nchr, info)
kvm_t *kd;
struct kinfo_proc *kp;
int nchr;
void (*info)(struct ps_strings *, u_long *, int *);
kvm_doargv(kvm_t *kd, const struct kinfo_proc *kp, int nchr,
void (*info)(struct ps_strings *, u_long *, int *))
{
char **ap;
u_long addr;
@ -895,10 +871,7 @@ kvm_doargv(kd, kp, nchr, info)
* Get the command args. This code is now machine independent.
*/
char **
kvm_getargv(kd, kp, nchr)
kvm_t *kd;
const struct kinfo_proc *kp;
int nchr;
kvm_getargv(kvm_t *kd, const struct kinfo_proc *kp, int nchr)
{
int oid[4];
int i;
@ -957,10 +930,7 @@ kvm_getargv(kd, kp, nchr)
}
char **
kvm_getenvv(kd, kp, nchr)
kvm_t *kd;
const struct kinfo_proc *kp;
int nchr;
kvm_getenvv(kvm_t *kd, const struct kinfo_proc *kp, int nchr)
{
return (kvm_doargv(kd, kp, nchr, ps_str_e));
}
@ -969,12 +939,8 @@ kvm_getenvv(kd, kp, nchr)
* Read from user space. The user context is given by p.
*/
ssize_t
kvm_uread(kd, kp, uva, buf, len)
kvm_t *kd;
struct kinfo_proc *kp;
u_long uva;
char *buf;
size_t len;
kvm_uread(kvm_t *kd, const struct kinfo_proc *kp, u_long uva, char *buf,
size_t len)
{
char *cp;
char procfile[MAXPATHLEN];
@ -998,7 +964,7 @@ kvm_uread(kd, kp, uva, buf, len)
while (len > 0) {
errno = 0;
if (lseek(fd, (off_t)uva, 0) == -1 && errno != 0) {
_kvm_err(kd, kd->program, "invalid address (%x) in %s",
_kvm_err(kd, kd->program, "invalid address (%lx) in %s",
uva, procfile);
break;
}

View File

@ -97,7 +97,7 @@ _kvm_read_phys(kvm_t *kd, off_t pos, void *buf, size_t size)
_kvm_syserr(kd, kd->program, "_kvm_read_phys: lseek");
return (0);
}
if (read(kd->pmfd, buf, size) != size) {
if (read(kd->pmfd, buf, size) != (ssize_t)size) {
_kvm_syserr(kd, kd->program, "_kvm_read_phys: read");
return (0);
}
@ -146,7 +146,6 @@ _kvm_initvtop(kvm_t *kd)
struct vmstate *vm;
size_t regsz;
vm_offset_t pa;
vm_size_t mask;
vm = (struct vmstate *)_kvm_malloc(kd, sizeof(*vm));
if (vm == NULL) {
@ -189,12 +188,13 @@ _kvm_initvtop(kvm_t *kd)
int
_kvm_kvatop(kvm_t *kd, u_long va, off_t *pa)
{
struct vmstate *vm;
#if !defined(SUN4V)
struct tte tte;
off_t tte_off;
u_long vpn;
#endif
off_t tte_off, pa_off;
u_long pg_off, vpn;
off_t pa_off;
u_long pg_off;
int rest;
pg_off = va & PAGE_MASK;
@ -220,6 +220,6 @@ _kvm_kvatop(kvm_t *kd, u_long va, off_t *pa)
return (rest);
invalid:
_kvm_err(kd, 0, "invalid address (%x)", va);
_kvm_err(kd, 0, "invalid address (%lx)", va);
return (0);
}

View File

@ -59,7 +59,6 @@ int
_kvm_vnet_selectpid(kvm_t *kd, pid_t pid)
{
struct proc proc;
struct thread td;
struct ucred cred;
struct prison prison;
struct vnet vnet;
@ -82,7 +81,12 @@ _kvm_vnet_selectpid(kvm_t *kd, pid_t pid)
{ .n_name = "proc0" },
{ .n_name = NULL },
};
uintptr_t procp, tdp, credp;
uintptr_t procp, credp;
#define VMCORE_VNET_OF_PROC0
#ifndef VMCORE_VNET_OF_PROC0
struct thread td;
uintptr_t tdp;
#endif
lwpid_t dumptid;
/*
@ -124,7 +128,6 @@ _kvm_vnet_selectpid(kvm_t *kd, pid_t pid)
credp = 0;
procp = nl[NLIST_ALLPROC].n_value;
#define VMCORE_VNET_OF_PROC0
#ifdef VMCORE_VNET_OF_PROC0
if (dumptid > 0) {
procp = nl[NLIST_PROC0].n_value;