diff options
author | Mark Johnston <markj@FreeBSD.org> | 2020-12-03 17:12:31 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2020-12-03 17:12:31 +0000 |
commit | b957b185946ed5ad96436b50bb118db8c1a24ded (patch) | |
tree | 125498308c1e41aa43e9666cf39b931ab6f3c5a9 /lib/libkvm/kvm_private.c | |
parent | 7be2770a426dc7399b63115b1c2c7d8bebdea06a (diff) | |
download | src-b957b185946ed5ad96436b50bb118db8c1a24ded.tar.gz src-b957b185946ed5ad96436b50bb118db8c1a24ded.zip |
Always use 64-bit physical addresses for dump_avail[] in minidumps
As of r365978, minidumps include a copy of dump_avail[]. This is an
array of vm_paddr_t ranges. libkvm walks the array assuming that
sizeof(vm_paddr_t) is equal to the platform "word size", but that's not
correct on some platforms. For instance, i386 uses a 64-bit vm_paddr_t.
Fix the problem by always dumping 64-bit addresses. On platforms where
vm_paddr_t is 32 bits wide, namely arm and mips (sometimes), translate
dump_avail[] to an array of uint64_t ranges. With this change, libkvm
no longer needs to maintain a notion of the target word size, so get rid
of it.
This is a no-op on platforms where sizeof(vm_paddr_t) == 8.
Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27082
Notes
Notes:
svn path=/head/; revision=368307
Diffstat (limited to 'lib/libkvm/kvm_private.c')
-rw-r--r-- | lib/libkvm/kvm_private.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/lib/libkvm/kvm_private.c b/lib/libkvm/kvm_private.c index 9424502adfad..d853d1643101 100644 --- a/lib/libkvm/kvm_private.c +++ b/lib/libkvm/kvm_private.c @@ -291,8 +291,7 @@ _kvm_map_get(kvm_t *kd, u_long pa, unsigned int page_size) int _kvm_pt_init(kvm_t *kd, size_t dump_avail_size, off_t dump_avail_off, - size_t map_len, off_t map_off, off_t sparse_off, int page_size, - int word_size) + size_t map_len, off_t map_off, off_t sparse_off, int page_size) { uint64_t *addr; uint32_t *popcount_bin; @@ -311,14 +310,8 @@ _kvm_pt_init(kvm_t *kd, size_t dump_avail_size, off_t dump_avail_off, * last_pa. Create an implied dump_avail that * expresses this. */ - kd->dump_avail = calloc(4, word_size); - if (word_size == sizeof(uint32_t)) { - ((uint32_t *)kd->dump_avail)[1] = _kvm32toh(kd, - map_len * 8 * page_size); - } else { - kd->dump_avail[1] = _kvm64toh(kd, - map_len * 8 * page_size); - } + kd->dump_avail = calloc(4, sizeof(uint64_t)); + kd->dump_avail[1] = _kvm64toh(kd, map_len * 8 * page_size); } /* @@ -375,7 +368,6 @@ _kvm_pt_init(kvm_t *kd, size_t dump_avail_size, off_t dump_avail_off, kd->pt_sparse_off = sparse_off; kd->pt_sparse_size = (uint64_t)*popcount_bin * page_size; kd->pt_page_size = page_size; - kd->pt_word_size = word_size; /* * Map the sparse page array. This is useful for performing point @@ -419,13 +411,7 @@ _kvm_pmap_init(kvm_t *kd, uint32_t pmap_size, off_t pmap_off) static inline uint64_t dump_avail_n(kvm_t *kd, long i) { - uint32_t *d32; - - if (kd->pt_word_size == sizeof(uint32_t)) { - d32 = (uint32_t *)kd->dump_avail; - return (_kvm32toh(kd, d32[i])); - } else - return (_kvm64toh(kd, kd->dump_avail[i])); + return (_kvm64toh(kd, kd->dump_avail[i])); } uint64_t |