libvmmapi: Conditionalize compilation of some functions

Hide definitions of several functions that currently don't have
implementatations in the arm64 vmm port.  In particular, add a
WITH_VMMAPI_SNAPSHOT preprocessor variable that can be used to enable
compilation of save/restore functions, and conditionalize compilation of
some functions only used by amd64 bhyve.  If in the long term they
remain amd64-only, they can move to vmmapi_machdep.c, but for now it's
not clear to me that that's the right thing to do.

MFC after:	2 weeks
Sponsored by:	Innovate UK
This commit is contained in:
Mark Johnston 2024-04-03 13:45:06 -04:00
parent 981f9f7495
commit 56a26fc1af
6 changed files with 24 additions and 11 deletions

View file

@ -1,4 +1,3 @@
PACKAGE=lib${LIB}
LIB= vmmapi
SHLIB_MAJOR= 6

View file

@ -1,3 +1,5 @@
SRCS+= ppt.c \
vmmapi_machdep.c \
vmmapi_freebsd_machdep.c
CFLAGS+= -DWITH_VMMAPI_SNAPSHOT

View file

@ -77,7 +77,14 @@ const char *vm_capstrmap[] = {
VM_RTC_WRITE, \
VM_RTC_READ, \
VM_RTC_SETTIME, \
VM_RTC_GETTIME
VM_RTC_GETTIME, \
VM_GET_GPA_PMAP, \
VM_GLA2GPA, \
VM_SET_INTINFO, \
VM_GET_INTINFO, \
VM_RESTART_INSTRUCTION, \
VM_SNAPSHOT_REQ, \
VM_RESTORE_TIME
const cap_ioctl_t vm_ioctl_cmds[] = {
VM_COMMON_IOCTLS,

View file

@ -54,20 +54,13 @@ extern const char *vm_capstrmap[];
VM_GET_CAPABILITY, \
VM_STATS, \
VM_STAT_DESC, \
VM_GET_GPA_PMAP, \
VM_GLA2GPA, \
VM_GLA2GPA_NOFAULT, \
VM_ACTIVATE_CPU, \
VM_GET_CPUS, \
VM_SUSPEND_CPU, \
VM_RESUME_CPU, \
VM_SET_INTINFO, \
VM_GET_INTINFO, \
VM_RESTART_INSTRUCTION, \
VM_SET_TOPOLOGY, \
VM_GET_TOPOLOGY, \
VM_SNAPSHOT_REQ, \
VM_RESTORE_TIME
VM_GET_TOPOLOGY
#define VM_PPT_IOCTLS \
VM_BIND_PPTDEV, \

View file

@ -51,7 +51,9 @@
#include <vm/vm.h>
#include <machine/vmm.h>
#include <machine/vmm_dev.h>
#ifdef WITH_VMMAPI_SNAPSHOT
#include <machine/vmm_snapshot.h>
#endif
#include "vmmapi.h"
#include "internal.h"
@ -796,6 +798,7 @@ vm_get_stat_desc(struct vmctx *ctx, int index)
return (NULL);
}
#ifdef __amd64__
int
vm_get_gpa_pmap(struct vmctx *ctx, uint64_t gpa, uint64_t *pte, int *num)
{
@ -835,6 +838,7 @@ vm_gla2gpa(struct vcpu *vcpu, struct vm_guest_paging *paging,
}
return (error);
}
#endif
int
vm_gla2gpa_nofault(struct vcpu *vcpu, struct vm_guest_paging *paging,
@ -860,6 +864,7 @@ vm_gla2gpa_nofault(struct vcpu *vcpu, struct vm_guest_paging *paging,
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifdef __amd64__
int
vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *paging,
uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt,
@ -897,6 +902,7 @@ vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *paging,
}
return (0);
}
#endif
void
vm_copy_teardown(struct iovec *iov __unused, int iovcnt __unused)
@ -1041,6 +1047,7 @@ vm_resume_all_cpus(struct vmctx *ctx)
return (error);
}
#ifdef __amd64__
int
vm_get_intinfo(struct vcpu *vcpu, uint64_t *info1, uint64_t *info2)
{
@ -1067,7 +1074,9 @@ vm_set_intinfo(struct vcpu *vcpu, uint64_t info1)
error = vcpu_ioctl(vcpu, VM_SET_INTINFO, &vmii);
return (error);
}
#endif
#ifdef WITH_VMMAPI_SNAPSHOT
int
vm_restart_instruction(struct vcpu *vcpu)
{
@ -1098,6 +1107,7 @@ vm_restore_time(struct vmctx *ctx)
dummy = 0;
return (ioctl(ctx->fd, VM_RESTORE_TIME, &dummy));
}
#endif
int
vm_set_topology(struct vmctx *ctx,

View file

@ -128,9 +128,11 @@ int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s);
void *vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len);
/* inverse operation to vm_map_gpa - extract guest address from host pointer */
vm_paddr_t vm_rev_map_gpa(struct vmctx *ctx, void *addr);
#ifdef __amd64__
int vm_get_gpa_pmap(struct vmctx *, uint64_t gpa, uint64_t *pte, int *num);
int vm_gla2gpa(struct vcpu *vcpu, struct vm_guest_paging *paging,
uint64_t gla, int prot, uint64_t *gpa, int *fault);
#endif
int vm_gla2gpa_nofault(struct vcpu *vcpu,
struct vm_guest_paging *paging, uint64_t gla, int prot,
uint64_t *gpa, int *fault);
@ -220,7 +222,6 @@ int vm_get_x2apic_state(struct vcpu *vcpu, enum x2apic_state *s);
int vm_set_x2apic_state(struct vcpu *vcpu, enum x2apic_state s);
int vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities);
#endif
/*
* Translate the GLA range [gla,gla+len) into GPA segments in 'iov'.
@ -234,6 +235,7 @@ int vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities);
int vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *pg,
uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt,
int *fault);
#endif
void vm_copyin(struct iovec *guest_iov, void *host_dst, size_t len);
void vm_copyout(const void *host_src, struct iovec *guest_iov, size_t len);
void vm_copy_teardown(struct iovec *iov, int iovcnt);