PERFORCE change 79103 for review
Peter Wemm
peter at FreeBSD.org
Tue Jun 28 19:52:19 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=79103
Change 79103 by peter at peter_daintree on 2005/06/28 19:51:45
Tidy up error messages
Use the cvs layout of the functions a bit more to reduce some diffs.
Converge i386/amd64 a bit more.
Affected files ...
.. //depot/projects/hammer/lib/libkvm/kvm_amd64.c#14 edit
.. //depot/projects/hammer/lib/libkvm/kvm_i386.c#5 edit
Differences ...
==== //depot/projects/hammer/lib/libkvm/kvm_amd64.c#14 (text+ko) ====
@@ -193,8 +193,8 @@
return (0);
}
-int
-_kvm_kvatop(kvm_t *kd, u_long va, uint64_t *pa)
+static int
+_kvm_vatop(kvm_t *kd, u_long va, uint64_t *pa)
{
struct vmstate *vm;
u_long offset;
@@ -213,11 +213,6 @@
u_long a, ofs;
size_t s;
- if (ISALIVE(kd)) {
- _kvm_err(kd, 0, "kvm_kvatop called in live kernel!");
- return((off_t)0);
- }
-
vm = kd->vmst;
offset = va & (PAGE_SIZE - 1);
@@ -331,3 +326,14 @@
_kvm_err(kd, 0, "invalid address (0x%lx)", (unsigned long)va);
return (0);
}
+
+int
+kvm_vvatop(kvm_t *kd, u_long va, uint64_t *pa)
+{
+ if (ISALIVE(kd)) {
+ _kvm_err(kd, 0, "kvm_kvatop called in live kernel!");
+ return (0);
+ }
+
+ return (_kvm_vatop(kd, va, pa));
+}
==== //depot/projects/hammer/lib/libkvm/kvm_i386.c#5 (text+ko) ====
@@ -228,8 +228,8 @@
return (0);
}
-int
-kvm_kvatop(kvm_t *kd, u_long va, uint64_t *pa)
+static int
+_kvm_vatop(kvm_t *kd, u_long va, uint64_t *pa)
{
struct vmstate *vm;
u_long offset;
@@ -244,12 +244,6 @@
uint64_t ofs;
uint32_t *PTD;
-
- if (ISALIVE(kd)) {
- _kvm_err(kd, 0, "vatop called in live kernel!");
- return((off_t)0);
- }
-
vm = kd->vmst;
PTD = (uint32_t *)vm->PTD;
offset = va & (PAGE_SIZE - 1);
@@ -262,7 +256,7 @@
s = _kvm_pa2off(kd, va, pa);
if (s == 0) {
_kvm_err(kd, kd->program,
- "_kvm_kvatop: bootstrap data not in dump");
+ "_kvm_vatop: bootstrap data not in dump");
goto invalid;
} else
return (PAGE_SIZE - offset);
@@ -285,7 +279,7 @@
pde_pa = ((u_long)pde & PG_FRAME4M) + (va & PAGE4M_MASK);
s = _kvm_pa2off(kd, pde_pa, &ofs);
if (s <= sizeof pde) {
- _kvm_syserr(kd, kd->program, "_kvm_kvatop: pde_pa not found");
+ _kvm_syserr(kd, kd->program, "_kvm_vatop: pde_pa not found");
goto invalid;
}
*pa = ofs;
@@ -297,7 +291,7 @@
s = _kvm_pa2off(kd, pte_pa, &ofs);
if (s <= sizeof pte) {
- _kvm_err(kd, kd->program, "_kvm_kvatop: pdpe_pa not found");
+ _kvm_err(kd, kd->program, "_kvm_vatop: pdpe_pa not found");
goto invalid;
}
@@ -316,7 +310,7 @@
a = ((u_long)pte & PG_FRAME) + offset;
s =_kvm_pa2off(kd, a, pa);
if (s == 0) {
- _kvm_err(kd, kd->program, "_kvm_kvatop: address not in dump");
+ _kvm_err(kd, kd->program, "_kvm_vatop: address not in dump");
goto invalid;
} else
return (PAGE_SIZE - offset);
@@ -326,8 +320,8 @@
return (0);
}
-int
-kvm_kvatop_pae(kvm_t *kd, u_long va, uint64_t *pa)
+static int
+_kvm_vatop_pae(kvm_t *kd, u_long va, uint64_t *pa)
{
struct vmstate *vm;
uint64_t offset;
@@ -341,12 +335,6 @@
uint64_t a, ofs;
uint64_t *PTD;
-
- if (ISALIVE(kd)) {
- _kvm_err(kd, 0, "vatop called in live kernel!");
- return((off_t)0);
- }
-
vm = kd->vmst;
PTD = (uint64_t *)vm->PTD;
offset = va & (PAGE_SIZE - 1);
@@ -359,7 +347,7 @@
s = _kvm_pa2off(kd, va, pa);
if (s == 0) {
_kvm_err(kd, kd->program,
- "_kvm_kvatop: bootstrap data not in dump");
+ "_kvm_vatop_pae: bootstrap data not in dump");
goto invalid;
} else
return (PAGE_SIZE - offset);
@@ -382,7 +370,7 @@
pde_pa = ((u_long)pde & PG_FRAME4M) + (va & PAGE4M_MASK);
s = _kvm_pa2off(kd, pde_pa, &ofs);
if (s <= sizeof pde) {
- _kvm_syserr(kd, kd->program, "_kvm_kvatop: pde_pa not found");
+ _kvm_syserr(kd, kd->program, "_kvm_vatop_pae: pde_pa not found");
goto invalid;
}
*pa = ofs;
@@ -394,17 +382,17 @@
s = _kvm_pa2off(kd, pte_pa, &ofs);
if (s <= sizeof pte) {
- _kvm_err(kd, kd->program, "_kvm_kvatop: pdpe_pa not found");
+ _kvm_err(kd, kd->program, "_kvm_vatop_pae: pdpe_pa not found");
goto invalid;
}
/* XXX This has to be a physical address read, kvm_read is virtual */
if (lseek(kd->pmfd, ofs, 0) == -1) {
- _kvm_syserr(kd, kd->program, "_kvm_vatop: lseek");
+ _kvm_syserr(kd, kd->program, "_kvm_vatop_pae: lseek");
goto invalid;
}
if (read(kd->pmfd, &pte, sizeof pte) != sizeof pte) {
- _kvm_syserr(kd, kd->program, "_kvm_vatop: read");
+ _kvm_syserr(kd, kd->program, "_kvm_vatop_pae: read");
goto invalid;
}
if (((uint64_t)pte & PG_V) == 0)
@@ -413,7 +401,7 @@
a = ((uint64_t)pte & PG_FRAME_PAE) + offset;
s =_kvm_pa2off(kd, a, pa);
if (s == 0) {
- _kvm_err(kd, kd->program, "_kvm_kvatop: address not in dump");
+ _kvm_err(kd, kd->program, "_kvm_vatop_pae: address not in dump");
goto invalid;
} else
return (PAGE_SIZE - offset);
@@ -426,8 +414,13 @@
int
_kvm_kvatop(kvm_t *kd, u_long va, uint64_t *pa)
{
+ if (ISALIVE(kd)) {
+ _kvm_err(kd, 0, "vatop called in live kernel!");
+ return (0);
+ }
+
if (kd->vmst->pae)
- kvm_kvatop_pae(kd, va, pa);
+ _kvm_vatop_pae(kd, va, pa);
else
- kvm_kvatop(kd, va, pa);
+ _kvm_vatop(kd, va, pa);
}
More information about the p4-projects
mailing list