Index: lib/libkvm/kvm.h =================================================================== --- lib/libkvm/kvm.h +++ lib/libkvm/kvm.h @@ -124,6 +124,7 @@ ssize_t kvm_read_zpcpu(kvm_t *, unsigned long, void *, size_t, int); ssize_t kvm_read2(kvm_t *, kvaddr_t, void *, size_t); ssize_t kvm_write(kvm_t *, unsigned long, const void *, size_t); +off_t kvm_kerndisp(kvm_t *); typedef int kvm_walk_pages_cb_t(struct kvm_page *, void *); int kvm_walk_pages(kvm_t *, kvm_walk_pages_cb_t *, void *); Index: lib/libkvm/kvm.c =================================================================== --- lib/libkvm/kvm.c +++ lib/libkvm/kvm.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -499,3 +500,32 @@ return (kd->arch->ka_walk_pages(kd, cb, closure)); } + +off_t +kvm_kerndisp(kvm_t *kd) +{ + unsigned long kernbase, rel_kernbase; + size_t kernbase_len = sizeof(kernbase); + size_t rel_kernbase_len = sizeof(rel_kernbase); + + if (ISALIVE(kd)) { + if (sysctlbyname("kern.base_address", &kernbase, + &kernbase_len, NULL, 0) == -1) { + _kvm_syserr(kd, kd->program, + "failed to get kernel base address"); + return (0); + } + if (sysctlbyname("kern.relbase_address", &rel_kernbase, + &rel_kernbase_len, NULL, 0) == -1) { + _kvm_syserr(kd, kd->program, + "failed to get relocated kernel base address"); + return (0); + } + return (rel_kernbase - kernbase); + } + + if (kd->arch->ka_kerndisp == NULL) + return (0); + + return (kd->arch->ka_kerndisp(kd)); +} Index: lib/libkvm/kvm_minidump_powerpc64.c =================================================================== --- lib/libkvm/kvm_minidump_powerpc64.c +++ lib/libkvm/kvm_minidump_powerpc64.c @@ -184,6 +184,12 @@ #endif } +static off_t +_powerpc64_kerndisp(kvm_t *kd) +{ + return (kd->vmst->hdr.startkernel - PPC64_KERNBASE); +} + static int _powerpc64_minidump_walk_pages(kvm_t *kd, kvm_walk_pages_cb_t *cb, void *arg) { @@ -197,6 +203,7 @@ .ka_kvatop = _powerpc64_minidump_kvatop, .ka_walk_pages = _powerpc64_minidump_walk_pages, .ka_native = _powerpc64_native, + .ka_kerndisp = _powerpc64_kerndisp, }; KVM_ARCH(kvm_powerpc64_minidump); Index: lib/libkvm/kvm_private.h =================================================================== --- lib/libkvm/kvm_private.h +++ lib/libkvm/kvm_private.h @@ -47,6 +47,7 @@ int (*ka_kvatop)(kvm_t *, kvaddr_t, off_t *); int (*ka_native)(kvm_t *); int (*ka_walk_pages)(kvm_t *, kvm_walk_pages_cb_t *, void *); + off_t (*ka_kerndisp)(kvm_t *); }; #define KVM_ARCH(ka) DATA_SET(kvm_arch, ka)