mirror of
https://github.com/opnsense/src.git
synced 2026-06-06 23:32:52 -04:00
vmm: Make vmmops declarations more consistent
- On amd64, make vmmops_* functions globally visible, as some will be called from machine-independent code in the future. - On arm64 and riscv, move declarations to vmm.h, since they're supposed to be generic across different VMM backends (only amd64 has more than one backend). - Make the declaration macros consistent with each other. - On amd64, make the function typedef names consistent with the corresponding ifunc names. No functional change intended. Reviewed by: corvink MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D53011 (cherry picked from commit e9182981f7feeb97ee440bb9c1db9a1bc5309b92)
This commit is contained in:
parent
a0b365dad4
commit
1e307c5c1a
6 changed files with 107 additions and 99 deletions
|
|
@ -170,55 +170,63 @@ struct vm_eventinfo {
|
|||
int *iptr; /* reqidle cookie */
|
||||
};
|
||||
|
||||
typedef int (*vmm_init_func_t)(int ipinum);
|
||||
typedef int (*vmm_cleanup_func_t)(void);
|
||||
typedef void (*vmm_suspend_func_t)(void);
|
||||
typedef void (*vmm_resume_func_t)(void);
|
||||
typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap);
|
||||
typedef int (*vmi_run_func_t)(void *vcpui, register_t rip,
|
||||
struct pmap *pmap, struct vm_eventinfo *info);
|
||||
typedef void (*vmi_cleanup_func_t)(void *vmi);
|
||||
typedef void * (*vmi_vcpu_init_func_t)(void *vmi, struct vcpu *vcpu,
|
||||
int vcpu_id);
|
||||
typedef void (*vmi_vcpu_cleanup_func_t)(void *vcpui);
|
||||
typedef int (*vmi_get_register_t)(void *vcpui, int num, uint64_t *retval);
|
||||
typedef int (*vmi_set_register_t)(void *vcpui, int num, uint64_t val);
|
||||
typedef int (*vmi_get_desc_t)(void *vcpui, int num, struct seg_desc *desc);
|
||||
typedef int (*vmi_set_desc_t)(void *vcpui, int num, struct seg_desc *desc);
|
||||
typedef int (*vmi_get_cap_t)(void *vcpui, int num, int *retval);
|
||||
typedef int (*vmi_set_cap_t)(void *vcpui, int num, int val);
|
||||
typedef struct vmspace * (*vmi_vmspace_alloc)(vm_offset_t min, vm_offset_t max);
|
||||
typedef void (*vmi_vmspace_free)(struct vmspace *vmspace);
|
||||
typedef struct vlapic * (*vmi_vlapic_init)(void *vcpui);
|
||||
typedef void (*vmi_vlapic_cleanup)(struct vlapic *vlapic);
|
||||
typedef int (*vmi_snapshot_vcpu_t)(void *vcpui, struct vm_snapshot_meta *meta);
|
||||
typedef int (*vmi_restore_tsc_t)(void *vcpui, uint64_t now);
|
||||
#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \
|
||||
typedef ret_type (*vmmops_##opname##_t) args; \
|
||||
ret_type vmmops_##opname args
|
||||
|
||||
DECLARE_VMMOPS_FUNC(int, modinit, (int ipinum));
|
||||
DECLARE_VMMOPS_FUNC(int, modcleanup, (void));
|
||||
DECLARE_VMMOPS_FUNC(void, modresume, (void));
|
||||
DECLARE_VMMOPS_FUNC(void, modsuspend, (void));
|
||||
DECLARE_VMMOPS_FUNC(void *, init, (struct vm *vm, struct pmap *pmap));
|
||||
DECLARE_VMMOPS_FUNC(int, run, (void *vcpui, register_t pc,
|
||||
struct pmap *pmap, struct vm_eventinfo *info));
|
||||
DECLARE_VMMOPS_FUNC(void, cleanup, (void *vmi));
|
||||
DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu,
|
||||
int vcpu_id));
|
||||
DECLARE_VMMOPS_FUNC(void, vcpu_cleanup, (void *vcpui));
|
||||
DECLARE_VMMOPS_FUNC(int, getreg, (void *vcpui, int num, uint64_t *retval));
|
||||
DECLARE_VMMOPS_FUNC(int, setreg, (void *vcpui, int num, uint64_t val));
|
||||
DECLARE_VMMOPS_FUNC(int, getdesc, (void *vcpui, int num,
|
||||
struct seg_desc *desc));
|
||||
DECLARE_VMMOPS_FUNC(int, setdesc, (void *vcpui, int num,
|
||||
struct seg_desc *desc));
|
||||
DECLARE_VMMOPS_FUNC(int, getcap, (void *vcpui, int num, int *retval));
|
||||
DECLARE_VMMOPS_FUNC(int, setcap, (void *vcpui, int num, int val));
|
||||
DECLARE_VMMOPS_FUNC(struct vmspace *, vmspace_alloc,
|
||||
(vm_offset_t min, vm_offset_t max));
|
||||
DECLARE_VMMOPS_FUNC(void, vmspace_free, (struct vmspace *vmspace));
|
||||
DECLARE_VMMOPS_FUNC(struct vlapic *, vlapic_init, (void *vcpui));
|
||||
DECLARE_VMMOPS_FUNC(void, vlapic_cleanup, (struct vlapic *vlapic));
|
||||
DECLARE_VMMOPS_FUNC(int, vcpu_snapshot, (void *vcpui,
|
||||
struct vm_snapshot_meta *meta));
|
||||
DECLARE_VMMOPS_FUNC(int, restore_tsc, (void *vcpui, uint64_t now));
|
||||
|
||||
struct vmm_ops {
|
||||
vmm_init_func_t modinit; /* module wide initialization */
|
||||
vmm_cleanup_func_t modcleanup;
|
||||
vmm_resume_func_t modsuspend;
|
||||
vmm_resume_func_t modresume;
|
||||
vmmops_modinit_t modinit; /* module wide initialization */
|
||||
vmmops_modcleanup_t modcleanup;
|
||||
vmmops_modresume_t modsuspend;
|
||||
vmmops_modresume_t modresume;
|
||||
|
||||
vmi_init_func_t init; /* vm-specific initialization */
|
||||
vmi_run_func_t run;
|
||||
vmi_cleanup_func_t cleanup;
|
||||
vmi_vcpu_init_func_t vcpu_init;
|
||||
vmi_vcpu_cleanup_func_t vcpu_cleanup;
|
||||
vmi_get_register_t getreg;
|
||||
vmi_set_register_t setreg;
|
||||
vmi_get_desc_t getdesc;
|
||||
vmi_set_desc_t setdesc;
|
||||
vmi_get_cap_t getcap;
|
||||
vmi_set_cap_t setcap;
|
||||
vmi_vmspace_alloc vmspace_alloc;
|
||||
vmi_vmspace_free vmspace_free;
|
||||
vmi_vlapic_init vlapic_init;
|
||||
vmi_vlapic_cleanup vlapic_cleanup;
|
||||
vmmops_init_t init; /* vm-specific initialization */
|
||||
vmmops_run_t run;
|
||||
vmmops_cleanup_t cleanup;
|
||||
vmmops_vcpu_init_t vcpu_init;
|
||||
vmmops_vcpu_cleanup_t vcpu_cleanup;
|
||||
vmmops_getreg_t getreg;
|
||||
vmmops_setreg_t setreg;
|
||||
vmmops_getdesc_t getdesc;
|
||||
vmmops_setdesc_t setdesc;
|
||||
vmmops_getcap_t getcap;
|
||||
vmmops_setcap_t setcap;
|
||||
vmmops_vmspace_alloc_t vmspace_alloc;
|
||||
vmmops_vmspace_free_t vmspace_free;
|
||||
vmmops_vlapic_init_t vlapic_init;
|
||||
vmmops_vlapic_cleanup_t vlapic_cleanup;
|
||||
|
||||
/* checkpoint operations */
|
||||
vmi_snapshot_vcpu_t vcpu_snapshot;
|
||||
vmi_restore_tsc_t restore_tsc;
|
||||
vmmops_vcpu_snapshot_t vcpu_snapshot;
|
||||
vmmops_restore_tsc_t restore_tsc;
|
||||
};
|
||||
|
||||
extern const struct vmm_ops vmm_ops_intel;
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ vmmops_panic(void)
|
|||
}
|
||||
|
||||
#define DEFINE_VMMOPS_IFUNC(ret_type, opname, args) \
|
||||
DEFINE_IFUNC(static, ret_type, vmmops_##opname, args) \
|
||||
DEFINE_IFUNC(, ret_type, vmmops_##opname, args) \
|
||||
{ \
|
||||
if (vmm_is_intel()) \
|
||||
return (vmm_ops_intel.opname); \
|
||||
|
|
|
|||
|
|
@ -143,6 +143,37 @@ struct vm_eventinfo {
|
|||
int *iptr; /* reqidle cookie */
|
||||
};
|
||||
|
||||
#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \
|
||||
ret_type vmmops_##opname args
|
||||
|
||||
DECLARE_VMMOPS_FUNC(int, modinit, (int ipinum));
|
||||
DECLARE_VMMOPS_FUNC(int, modcleanup, (void));
|
||||
DECLARE_VMMOPS_FUNC(void *, init, (struct vm *vm, struct pmap *pmap));
|
||||
DECLARE_VMMOPS_FUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging,
|
||||
uint64_t gla, int prot, uint64_t *gpa, int *is_fault));
|
||||
DECLARE_VMMOPS_FUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap,
|
||||
struct vm_eventinfo *info));
|
||||
DECLARE_VMMOPS_FUNC(void, cleanup, (void *vmi));
|
||||
DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu,
|
||||
int vcpu_id));
|
||||
DECLARE_VMMOPS_FUNC(void, vcpu_cleanup, (void *vcpui));
|
||||
DECLARE_VMMOPS_FUNC(int, exception, (void *vcpui, uint64_t esr, uint64_t far));
|
||||
DECLARE_VMMOPS_FUNC(int, getreg, (void *vcpui, int num, uint64_t *retval));
|
||||
DECLARE_VMMOPS_FUNC(int, setreg, (void *vcpui, int num, uint64_t val));
|
||||
DECLARE_VMMOPS_FUNC(int, getcap, (void *vcpui, int num, int *retval));
|
||||
DECLARE_VMMOPS_FUNC(int, setcap, (void *vcpui, int num, int val));
|
||||
DECLARE_VMMOPS_FUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min,
|
||||
vm_offset_t max));
|
||||
DECLARE_VMMOPS_FUNC(void, vmspace_free, (struct vmspace *vmspace));
|
||||
#ifdef notyet
|
||||
#ifdef BHYVE_SNAPSHOT
|
||||
DECLARE_VMMOPS_FUNC(int, snapshot, (void *vmi, struct vm_snapshot_meta *meta));
|
||||
DECLARE_VMMOPS_FUNC(int, vcpu_snapshot, (void *vcpui,
|
||||
struct vm_snapshot_meta *meta));
|
||||
DECLARE_VMMOPS_FUNC(int, restore_tsc, (void *vcpui, uint64_t now));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int vm_create(const char *name, struct vm **retvm);
|
||||
struct vcpu *vm_alloc_vcpu(struct vm *vm, int vcpuid);
|
||||
void vm_disable_vcpu_creation(struct vm *vm);
|
||||
|
|
|
|||
|
|
@ -133,37 +133,6 @@ struct hyp {
|
|||
struct hypctx *ctx[];
|
||||
};
|
||||
|
||||
#define DEFINE_VMMOPS_IFUNC(ret_type, opname, args) \
|
||||
ret_type vmmops_##opname args;
|
||||
|
||||
DEFINE_VMMOPS_IFUNC(int, modinit, (int ipinum))
|
||||
DEFINE_VMMOPS_IFUNC(int, modcleanup, (void))
|
||||
DEFINE_VMMOPS_IFUNC(void *, init, (struct vm *vm, struct pmap *pmap))
|
||||
DEFINE_VMMOPS_IFUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging,
|
||||
uint64_t gla, int prot, uint64_t *gpa, int *is_fault))
|
||||
DEFINE_VMMOPS_IFUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap,
|
||||
struct vm_eventinfo *info))
|
||||
DEFINE_VMMOPS_IFUNC(void, cleanup, (void *vmi))
|
||||
DEFINE_VMMOPS_IFUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu,
|
||||
int vcpu_id))
|
||||
DEFINE_VMMOPS_IFUNC(void, vcpu_cleanup, (void *vcpui))
|
||||
DEFINE_VMMOPS_IFUNC(int, exception, (void *vcpui, uint64_t esr, uint64_t far))
|
||||
DEFINE_VMMOPS_IFUNC(int, getreg, (void *vcpui, int num, uint64_t *retval))
|
||||
DEFINE_VMMOPS_IFUNC(int, setreg, (void *vcpui, int num, uint64_t val))
|
||||
DEFINE_VMMOPS_IFUNC(int, getcap, (void *vcpui, int num, int *retval))
|
||||
DEFINE_VMMOPS_IFUNC(int, setcap, (void *vcpui, int num, int val))
|
||||
DEFINE_VMMOPS_IFUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min,
|
||||
vm_offset_t max))
|
||||
DEFINE_VMMOPS_IFUNC(void, vmspace_free, (struct vmspace *vmspace))
|
||||
#ifdef notyet
|
||||
#ifdef BHYVE_SNAPSHOT
|
||||
DEFINE_VMMOPS_IFUNC(int, snapshot, (void *vmi, struct vm_snapshot_meta *meta))
|
||||
DEFINE_VMMOPS_IFUNC(int, vcpu_snapshot, (void *vcpui,
|
||||
struct vm_snapshot_meta *meta))
|
||||
DEFINE_VMMOPS_IFUNC(int, restore_tsc, (void *vcpui, uint64_t now))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uint64_t vmm_call_hyp(uint64_t, ...);
|
||||
|
||||
#if 0
|
||||
|
|
|
|||
|
|
@ -123,6 +123,29 @@ struct vm_eventinfo {
|
|||
int *iptr; /* reqidle cookie */
|
||||
};
|
||||
|
||||
#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \
|
||||
ret_type vmmops_##opname args
|
||||
|
||||
DECLARE_VMMOPS_FUNC(int, modinit, (void));
|
||||
DECLARE_VMMOPS_FUNC(int, modcleanup, (void));
|
||||
DECLARE_VMMOPS_FUNC(void *, init, (struct vm *vm, struct pmap *pmap));
|
||||
DECLARE_VMMOPS_FUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging,
|
||||
uint64_t gla, int prot, uint64_t *gpa, int *is_fault));
|
||||
DECLARE_VMMOPS_FUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap,
|
||||
struct vm_eventinfo *info));
|
||||
DECLARE_VMMOPS_FUNC(void, cleanup, (void *vmi));
|
||||
DECLARE_VMMOPS_FUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu,
|
||||
int vcpu_id));
|
||||
DECLARE_VMMOPS_FUNC(void, vcpu_cleanup, (void *vcpui));
|
||||
DECLARE_VMMOPS_FUNC(int, exception, (void *vcpui, uint64_t scause));
|
||||
DECLARE_VMMOPS_FUNC(int, getreg, (void *vcpui, int num, uint64_t *retval));
|
||||
DECLARE_VMMOPS_FUNC(int, setreg, (void *vcpui, int num, uint64_t val));
|
||||
DECLARE_VMMOPS_FUNC(int, getcap, (void *vcpui, int num, int *retval));
|
||||
DECLARE_VMMOPS_FUNC(int, setcap, (void *vcpui, int num, int val));
|
||||
DECLARE_VMMOPS_FUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min,
|
||||
vm_offset_t max));
|
||||
DECLARE_VMMOPS_FUNC(void, vmspace_free, (struct vmspace *vmspace));
|
||||
|
||||
int vm_create(const char *name, struct vm **retvm);
|
||||
struct vcpu *vm_alloc_vcpu(struct vm *vm, int vcpuid);
|
||||
void vm_disable_vcpu_creation(struct vm *vm);
|
||||
|
|
|
|||
|
|
@ -122,29 +122,6 @@ struct hyptrap {
|
|||
uint64_t htinst;
|
||||
};
|
||||
|
||||
#define DEFINE_VMMOPS_IFUNC(ret_type, opname, args) \
|
||||
ret_type vmmops_##opname args;
|
||||
|
||||
DEFINE_VMMOPS_IFUNC(int, modinit, (void))
|
||||
DEFINE_VMMOPS_IFUNC(int, modcleanup, (void))
|
||||
DEFINE_VMMOPS_IFUNC(void *, init, (struct vm *vm, struct pmap *pmap))
|
||||
DEFINE_VMMOPS_IFUNC(int, gla2gpa, (void *vcpui, struct vm_guest_paging *paging,
|
||||
uint64_t gla, int prot, uint64_t *gpa, int *is_fault))
|
||||
DEFINE_VMMOPS_IFUNC(int, run, (void *vcpui, register_t pc, struct pmap *pmap,
|
||||
struct vm_eventinfo *info))
|
||||
DEFINE_VMMOPS_IFUNC(void, cleanup, (void *vmi))
|
||||
DEFINE_VMMOPS_IFUNC(void *, vcpu_init, (void *vmi, struct vcpu *vcpu,
|
||||
int vcpu_id))
|
||||
DEFINE_VMMOPS_IFUNC(void, vcpu_cleanup, (void *vcpui))
|
||||
DEFINE_VMMOPS_IFUNC(int, exception, (void *vcpui, uint64_t scause))
|
||||
DEFINE_VMMOPS_IFUNC(int, getreg, (void *vcpui, int num, uint64_t *retval))
|
||||
DEFINE_VMMOPS_IFUNC(int, setreg, (void *vcpui, int num, uint64_t val))
|
||||
DEFINE_VMMOPS_IFUNC(int, getcap, (void *vcpui, int num, int *retval))
|
||||
DEFINE_VMMOPS_IFUNC(int, setcap, (void *vcpui, int num, int val))
|
||||
DEFINE_VMMOPS_IFUNC(struct vmspace *, vmspace_alloc, (vm_offset_t min,
|
||||
vm_offset_t max))
|
||||
DEFINE_VMMOPS_IFUNC(void, vmspace_free, (struct vmspace *vmspace))
|
||||
|
||||
#define dprintf(fmt, ...)
|
||||
|
||||
struct hypctx *riscv_get_active_vcpu(void);
|
||||
|
|
|
|||
Loading…
Reference in a new issue