diff options
author | andrew <andrew@FreeBSD.org> | 2014-10-19 20:23:31 +0000 |
---|---|---|
committer | andrew <andrew@FreeBSD.org> | 2014-10-19 20:23:31 +0000 |
commit | 63825ea04332876e69745b559d94ee550dffb9b9 (patch) | |
tree | 0dc53de4acffc3c0e10494e9f09f0436479b1731 /lib/libkvm | |
parent | 6cd79c01dc29411b1c7171f41fd0c3b2e3074009 (diff) | |
download | FreeBSD-src-63825ea04332876e69745b559d94ee550dffb9b9.zip FreeBSD-src-63825ea04332876e69745b559d94ee550dffb9b9.tar.gz |
Allow libkvm to get the kernel va to pa delta without the need for
physaddr. This should allow for a kernel where PHYSADDR and KERNPHYSADDR
are both undefined.
For now libkvm will use the old method of reading physaddr and kernaddr
to allow it to work with old kernels. This could be removed in the future
when enough time has passed.
Differential Revision: https://reviews.freebsd.org/D939
MFC after: 1 week
Diffstat (limited to 'lib/libkvm')
-rw-r--r-- | lib/libkvm/kvm_arm.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/lib/libkvm/kvm_arm.c b/lib/libkvm/kvm_arm.c index ceff383..cc808e3 100644 --- a/lib/libkvm/kvm_arm.c +++ b/lib/libkvm/kvm_arm.c @@ -132,8 +132,10 @@ _kvm_initvtop(kvm_t *kd) u_long kernbase, physaddr, pa; pd_entry_t *l1pt; Elf32_Ehdr *ehdr; + Elf32_Phdr *phdr; size_t hdrsz; char minihdr[8]; + int found, i; if (!kd->rawdump) { if (pread(kd->pmfd, &minihdr, 8, 0) == 8) { @@ -158,19 +160,33 @@ _kvm_initvtop(kvm_t *kd) hdrsz = ehdr->e_phoff + ehdr->e_phentsize * ehdr->e_phnum; if (_kvm_maphdrs(kd, hdrsz) == -1) return (-1); - nl[0].n_name = "kernbase"; + + phdr = (Elf32_Phdr *)((uint8_t *)ehdr + ehdr->e_phoff); + found = 0; + for (i = 0; i < ehdr->e_phnum; i++) { + if (phdr[i].p_type == PT_DUMP_DELTA) { + kernbase = phdr[i].p_vaddr; + physaddr = phdr[i].p_paddr; + found = 1; + break; + } + } + nl[1].n_name = NULL; - if (kvm_nlist(kd, nl) != 0) - kernbase = KERNBASE; - else - kernbase = nl[0].n_value; + if (!found) { + nl[0].n_name = "kernbase"; + if (kvm_nlist(kd, nl) != 0) + kernbase = KERNBASE; + else + kernbase = nl[0].n_value; - nl[0].n_name = "physaddr"; - if (kvm_nlist(kd, nl) != 0) { - _kvm_err(kd, kd->program, "couldn't get phys addr"); - return (-1); + nl[0].n_name = "physaddr"; + if (kvm_nlist(kd, nl) != 0) { + _kvm_err(kd, kd->program, "couldn't get phys addr"); + return (-1); + } + physaddr = nl[0].n_value; } - physaddr = nl[0].n_value; nl[0].n_name = "kernel_l1pa"; if (kvm_nlist(kd, nl) != 0) { _kvm_err(kd, kd->program, "bad namelist"); |