kvm: fix types for cross-debugging

As with other libkvm interfaces use maximum-sized types to support
cross-debugging (e.g. a 64-bit vmcore on a 32-bit host).  See
https://lists.freebsd.org/pipermail/svn-src-all/2019-February/176051.html
for further discussion.

This is an API-breaking change, but there are few consumers of this
interface today.

Reviewed by:	will
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21945
This commit is contained in:
Ed Maste 2019-11-08 14:51:09 +00:00
parent c1131de6f1
commit 9dc7ed6253
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=354543
3 changed files with 21 additions and 20 deletions

View File

@ -82,18 +82,18 @@ struct kvm_swap {
}; };
struct kvm_page { struct kvm_page {
unsigned int version; u_int kp_version;
u_long paddr; kpaddr_t kp_paddr;
u_long kmap_vaddr; kvaddr_t kp_kmap_vaddr;
u_long dmap_vaddr; kvaddr_t kp_dmap_vaddr;
vm_prot_t prot; vm_prot_t kp_prot;
u_long offset; off_t kp_offset;
size_t len; size_t kp_len;
/* end of version 1 */ /* end of version 2 */
}; };
#define SWIF_DEV_PREFIX 0x0002 #define SWIF_DEV_PREFIX 0x0002
#define LIBKVM_WALK_PAGES_VERSION 1 #define LIBKVM_WALK_PAGES_VERSION 2
__BEGIN_DECLS __BEGIN_DECLS
int kvm_close(kvm_t *); int kvm_close(kvm_t *);

View File

@ -755,13 +755,13 @@ _kvm_visit_cb(kvm_t *kd, kvm_walk_pages_cb_t *cb, void *arg, u_long pa,
{ {
unsigned int pgsz = page_size ? page_size : len; unsigned int pgsz = page_size ? page_size : len;
struct kvm_page p = { struct kvm_page p = {
.version = LIBKVM_WALK_PAGES_VERSION, .kp_version = LIBKVM_WALK_PAGES_VERSION,
.paddr = pa, .kp_paddr = pa,
.kmap_vaddr = kmap_vaddr, .kp_kmap_vaddr = kmap_vaddr,
.dmap_vaddr = dmap_vaddr, .kp_dmap_vaddr = dmap_vaddr,
.prot = prot, .kp_prot = prot,
.offset = _kvm_pt_find(kd, pa, pgsz), .kp_offset = _kvm_pt_find(kd, pa, pgsz),
.len = len, .kp_len = len,
}; };
return cb(&p, arg); return cb(&p, arg);

View File

@ -252,11 +252,12 @@ typedef struct cap_rights cap_rights_t;
#endif #endif
/* /*
* Types suitable for exporting size and pointers (as virtual addresses) * Types suitable for exporting physical addresses, virtual addresses
* from the kernel independent of native word size. These should be * (pointers), and memory object sizes from the kernel independent of native
* used in place of size_t and (u)intptr_t in structs which contain such * word size. These should be used in place of vm_paddr_t, (u)intptr_t, and
* types that are shared with userspace. * size_t in structs which contain such types that are shared with userspace.
*/ */
typedef __uint64_t kpaddr_t;
typedef __uint64_t kvaddr_t; typedef __uint64_t kvaddr_t;
typedef __uint64_t ksize_t; typedef __uint64_t ksize_t;