Changeset View
Changeset View
Standalone View
Standalone View
lib/libvmmapi/vmmapi.h
Show All 27 Lines | |||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#ifndef _VMMAPI_H_ | #ifndef _VMMAPI_H_ | ||||
#define _VMMAPI_H_ | #define _VMMAPI_H_ | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/cpuset.h> | #include <sys/cpuset.h> | ||||
#include <machine/vmm_dev.h> | |||||
/* | /* | ||||
* API version for out-of-tree consumers like grub-bhyve for making compile | * API version for out-of-tree consumers like grub-bhyve for making compile | ||||
* time decisions. | * time decisions. | ||||
*/ | */ | ||||
#define VMMAPI_VERSION 0103 /* 2 digit major followed by 2 digit minor */ | #define VMMAPI_VERSION 0103 /* 2 digit major followed by 2 digit minor */ | ||||
struct iovec; | struct iovec; | ||||
struct vmctx; | struct vmctx; | ||||
struct vm_snapshot_meta; | |||||
enum x2apic_state; | enum x2apic_state; | ||||
/* | /* | ||||
* Different styles of mapping the memory assigned to a VM into the address | * Different styles of mapping the memory assigned to a VM into the address | ||||
* space of the controlling process. | * space of the controlling process. | ||||
*/ | */ | ||||
enum vm_mmap_style { | enum vm_mmap_style { | ||||
VM_MMAP_NONE, /* no mapping */ | VM_MMAP_NONE, /* no mapping */ | ||||
Show All 30 Lines | |||||
/* | /* | ||||
* Iterate over the guest address space. This function finds an address range | * Iterate over the guest address space. This function finds an address range | ||||
* that starts at an address >= *gpa. | * that starts at an address >= *gpa. | ||||
* | * | ||||
* Returns 0 if the next address range was found and non-zero otherwise. | * Returns 0 if the next address range was found and non-zero otherwise. | ||||
*/ | */ | ||||
int vm_mmap_getnext(struct vmctx *ctx, vm_paddr_t *gpa, int *segid, | int vm_mmap_getnext(struct vmctx *ctx, vm_paddr_t *gpa, int *segid, | ||||
vm_ooffset_t *segoff, size_t *len, int *prot, int *flags); | vm_ooffset_t *segoff, size_t *len, int *prot, int *flags); | ||||
int vm_get_guestmem_from_ctx(struct vmctx *ctx, char **guest_baseaddr, | |||||
size_t *lowmem_size, size_t *highmem_size); | |||||
/* | /* | ||||
* Create a device memory segment identified by 'segid'. | * Create a device memory segment identified by 'segid'. | ||||
* | * | ||||
* Returns a pointer to the memory segment on success and MAP_FAILED otherwise. | * Returns a pointer to the memory segment on success and MAP_FAILED otherwise. | ||||
*/ | */ | ||||
void *vm_create_devmem(struct vmctx *ctx, int segid, const char *name, | void *vm_create_devmem(struct vmctx *ctx, int segid, const char *name, | ||||
size_t len); | size_t len); | ||||
/* | /* | ||||
* Map the memory segment identified by 'segid' into the guest address space | * Map the memory segment identified by 'segid' into the guest address space | ||||
* at [gpa,gpa+len) with protection 'prot'. | * at [gpa,gpa+len) with protection 'prot'. | ||||
*/ | */ | ||||
int vm_mmap_memseg(struct vmctx *ctx, vm_paddr_t gpa, int segid, | int vm_mmap_memseg(struct vmctx *ctx, vm_paddr_t gpa, int segid, | ||||
vm_ooffset_t segoff, size_t len, int prot); | vm_ooffset_t segoff, size_t len, int prot); | ||||
int vm_create(const char *name); | int vm_create(const char *name); | ||||
int vm_get_device_fd(struct vmctx *ctx); | int vm_get_device_fd(struct vmctx *ctx); | ||||
struct vmctx *vm_open(const char *name); | struct vmctx *vm_open(const char *name); | ||||
void vm_destroy(struct vmctx *ctx); | void vm_destroy(struct vmctx *ctx); | ||||
int vm_parse_memsize(const char *optarg, size_t *memsize); | int vm_parse_memsize(const char *optarg, size_t *memsize); | ||||
int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s); | 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); | 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); | |||||
int vm_get_gpa_pmap(struct vmctx *, uint64_t gpa, uint64_t *pte, int *num); | int vm_get_gpa_pmap(struct vmctx *, uint64_t gpa, uint64_t *pte, int *num); | ||||
int vm_gla2gpa(struct vmctx *, int vcpuid, struct vm_guest_paging *paging, | int vm_gla2gpa(struct vmctx *, int vcpuid, struct vm_guest_paging *paging, | ||||
uint64_t gla, int prot, uint64_t *gpa, int *fault); | uint64_t gla, int prot, uint64_t *gpa, int *fault); | ||||
int vm_gla2gpa_nofault(struct vmctx *, int vcpuid, | int vm_gla2gpa_nofault(struct vmctx *, int vcpuid, | ||||
struct vm_guest_paging *paging, uint64_t gla, int prot, | struct vm_guest_paging *paging, uint64_t gla, int prot, | ||||
uint64_t *gpa, int *fault); | uint64_t *gpa, int *fault); | ||||
uint32_t vm_get_lowmem_limit(struct vmctx *ctx); | uint32_t vm_get_lowmem_limit(struct vmctx *ctx); | ||||
void vm_set_lowmem_limit(struct vmctx *ctx, uint32_t limit); | void vm_set_lowmem_limit(struct vmctx *ctx, uint32_t limit); | ||||
void vm_set_memflags(struct vmctx *ctx, int flags); | void vm_set_memflags(struct vmctx *ctx, int flags); | ||||
int vm_get_memflags(struct vmctx *ctx); | int vm_get_memflags(struct vmctx *ctx); | ||||
int vm_get_name(struct vmctx *ctx, char *buffer, size_t max_len); | |||||
dab: Why not declare `max_len` as `size_t`? | |||||
Done Inline ActionsWe should prefer size_t (and bool) where appropriate in new code - of course this is relatively rare in FreeBSD today because much of the code predates these types. emaste: We should prefer `size_t` (and `bool`) where appropriate in new code - of course this is… | |||||
size_t vm_get_lowmem_size(struct vmctx *ctx); | size_t vm_get_lowmem_size(struct vmctx *ctx); | ||||
size_t vm_get_highmem_size(struct vmctx *ctx); | size_t vm_get_highmem_size(struct vmctx *ctx); | ||||
int vm_set_desc(struct vmctx *ctx, int vcpu, int reg, | int vm_set_desc(struct vmctx *ctx, int vcpu, int reg, | ||||
uint64_t base, uint32_t limit, uint32_t access); | uint64_t base, uint32_t limit, uint32_t access); | ||||
int vm_get_desc(struct vmctx *ctx, int vcpu, int reg, | int vm_get_desc(struct vmctx *ctx, int vcpu, int reg, | ||||
uint64_t *base, uint32_t *limit, uint32_t *access); | uint64_t *base, uint32_t *limit, uint32_t *access); | ||||
int vm_get_seg_desc(struct vmctx *ctx, int vcpu, int reg, | int vm_get_seg_desc(struct vmctx *ctx, int vcpu, int reg, | ||||
struct seg_desc *seg_desc); | struct seg_desc *seg_desc); | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
int vm_setup_freebsd_registers(struct vmctx *ctx, int vcpu, | int vm_setup_freebsd_registers(struct vmctx *ctx, int vcpu, | ||||
uint64_t rip, uint64_t cr3, uint64_t gdtbase, | uint64_t rip, uint64_t cr3, uint64_t gdtbase, | ||||
uint64_t rsp); | uint64_t rsp); | ||||
int vm_setup_freebsd_registers_i386(struct vmctx *vmctx, int vcpu, | int vm_setup_freebsd_registers_i386(struct vmctx *vmctx, int vcpu, | ||||
uint32_t eip, uint32_t gdtbase, | uint32_t eip, uint32_t gdtbase, | ||||
uint32_t esp); | uint32_t esp); | ||||
void vm_setup_freebsd_gdt(uint64_t *gdtr); | void vm_setup_freebsd_gdt(uint64_t *gdtr); | ||||
/* | |||||
* Save and restore | |||||
*/ | |||||
#define MAX_SNAPSHOT_VMNAME 100 | |||||
enum checkpoint_opcodes { | |||||
START_CHECKPOINT = 0, | |||||
START_SUSPEND = 1, | |||||
}; | |||||
struct checkpoint_op { | |||||
Done Inline ActionsThis is normally spelled 'packed' in FreeBSD and would be added to the end of the struct normally. However, I don't think you need packed here since a char array is not going to have padding on any architectures FreeBSD supports. jhb: This is normally spelled '__packed' in FreeBSD and would be added to the end of the struct… | |||||
unsigned int op; | |||||
char snapshot_filename[MAX_SNAPSHOT_VMNAME]; | |||||
}; | |||||
int vm_snapshot_req(struct vm_snapshot_meta *meta); | |||||
int vm_restore_time(struct vmctx *ctx); | |||||
#endif /* _VMMAPI_H_ */ | #endif /* _VMMAPI_H_ */ |
Why not declare max_len as size_t?