Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/include/vmm.h
Show All 28 Lines | |||||
*/ | */ | ||||
#ifndef _VMM_H_ | #ifndef _VMM_H_ | ||||
#define _VMM_H_ | #define _VMM_H_ | ||||
#include <sys/sdt.h> | #include <sys/sdt.h> | ||||
#include <x86/segments.h> | #include <x86/segments.h> | ||||
struct vm_snapshot_meta; | |||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
SDT_PROVIDER_DECLARE(vmm); | SDT_PROVIDER_DECLARE(vmm); | ||||
#endif | #endif | ||||
enum vm_suspend_how { | enum vm_suspend_how { | ||||
VM_SUSPEND_NONE, | VM_SUSPEND_NONE, | ||||
VM_SUSPEND_RESET, | VM_SUSPEND_RESET, | ||||
VM_SUSPEND_POWEROFF, | VM_SUSPEND_POWEROFF, | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | |||||
struct vm_run; | struct vm_run; | ||||
struct vhpet; | struct vhpet; | ||||
struct vioapic; | struct vioapic; | ||||
struct vlapic; | struct vlapic; | ||||
struct vmspace; | struct vmspace; | ||||
struct vm_object; | struct vm_object; | ||||
struct vm_guest_paging; | struct vm_guest_paging; | ||||
struct pmap; | struct pmap; | ||||
enum snapshot_req; | |||||
jhb: Ideally this isn't really part of the API. We'd just want some kind of opaque "CPU context"… | |||||
Done Inline ActionsRemoved it; no longer used. darius.mihaim_gmail.com: Removed it; no longer used. | |||||
struct vm_eventinfo { | struct vm_eventinfo { | ||||
void *rptr; /* rendezvous cookie */ | void *rptr; /* rendezvous cookie */ | ||||
int *sptr; /* suspend cookie */ | int *sptr; /* suspend cookie */ | ||||
int *iptr; /* reqidle cookie */ | int *iptr; /* reqidle cookie */ | ||||
}; | }; | ||||
typedef int (*vmm_init_func_t)(int ipinum); | typedef int (*vmm_init_func_t)(int ipinum); | ||||
Show All 12 Lines | |||||
typedef int (*vmi_set_desc_t)(void *vmi, int vcpu, int num, | typedef int (*vmi_set_desc_t)(void *vmi, int vcpu, int num, | ||||
struct seg_desc *desc); | struct seg_desc *desc); | ||||
typedef int (*vmi_get_cap_t)(void *vmi, int vcpu, int num, int *retval); | typedef int (*vmi_get_cap_t)(void *vmi, int vcpu, int num, int *retval); | ||||
typedef int (*vmi_set_cap_t)(void *vmi, int vcpu, int num, int val); | typedef int (*vmi_set_cap_t)(void *vmi, int vcpu, int num, int val); | ||||
typedef struct vmspace * (*vmi_vmspace_alloc)(vm_offset_t min, vm_offset_t max); | typedef struct vmspace * (*vmi_vmspace_alloc)(vm_offset_t min, vm_offset_t max); | ||||
typedef void (*vmi_vmspace_free)(struct vmspace *vmspace); | typedef void (*vmi_vmspace_free)(struct vmspace *vmspace); | ||||
typedef struct vlapic * (*vmi_vlapic_init)(void *vmi, int vcpu); | typedef struct vlapic * (*vmi_vlapic_init)(void *vmi, int vcpu); | ||||
typedef void (*vmi_vlapic_cleanup)(void *vmi, struct vlapic *vlapic); | typedef void (*vmi_vlapic_cleanup)(void *vmi, struct vlapic *vlapic); | ||||
typedef int (*vmi_snapshot_t)(void *vmi, struct vm_snapshot_meta *meta); | |||||
typedef int (*vmi_snapshot_vmcx_t)(void *vmi, struct vm_snapshot_meta *meta, | |||||
int vcpu); | |||||
typedef int (*vmi_restore_tsc_t)(void *vmi, int vcpuid, uint64_t now); | |||||
struct vmm_ops { | struct vmm_ops { | ||||
vmm_init_func_t init; /* module wide initialization */ | vmm_init_func_t init; /* module wide initialization */ | ||||
vmm_cleanup_func_t cleanup; | vmm_cleanup_func_t cleanup; | ||||
vmm_resume_func_t resume; | vmm_resume_func_t resume; | ||||
vmi_init_func_t vminit; /* vm-specific initialization */ | vmi_init_func_t vminit; /* vm-specific initialization */ | ||||
vmi_run_func_t vmrun; | vmi_run_func_t vmrun; | ||||
vmi_cleanup_func_t vmcleanup; | vmi_cleanup_func_t vmcleanup; | ||||
vmi_get_register_t vmgetreg; | vmi_get_register_t vmgetreg; | ||||
vmi_set_register_t vmsetreg; | vmi_set_register_t vmsetreg; | ||||
vmi_get_desc_t vmgetdesc; | vmi_get_desc_t vmgetdesc; | ||||
vmi_set_desc_t vmsetdesc; | vmi_set_desc_t vmsetdesc; | ||||
vmi_get_cap_t vmgetcap; | vmi_get_cap_t vmgetcap; | ||||
vmi_set_cap_t vmsetcap; | vmi_set_cap_t vmsetcap; | ||||
vmi_vmspace_alloc vmspace_alloc; | vmi_vmspace_alloc vmspace_alloc; | ||||
vmi_vmspace_free vmspace_free; | vmi_vmspace_free vmspace_free; | ||||
vmi_vlapic_init vlapic_init; | vmi_vlapic_init vlapic_init; | ||||
vmi_vlapic_cleanup vlapic_cleanup; | vmi_vlapic_cleanup vlapic_cleanup; | ||||
/* checkpoint operations */ | |||||
vmi_snapshot_t vmsnapshot; | |||||
vmi_snapshot_vmcx_t vmcx_snapshot; | |||||
vmi_restore_tsc_t vm_restore_tsc; | |||||
}; | }; | ||||
extern struct vmm_ops vmm_ops_intel; | extern struct vmm_ops vmm_ops_intel; | ||||
extern struct vmm_ops vmm_ops_amd; | extern struct vmm_ops vmm_ops_amd; | ||||
int vm_create(const char *name, struct vm **retvm); | int vm_create(const char *name, struct vm **retvm); | ||||
void vm_destroy(struct vm *vm); | void vm_destroy(struct vm *vm); | ||||
int vm_reinit(struct vm *vm); | int vm_reinit(struct vm *vm); | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
int vm_suspend_cpu(struct vm *vm, int vcpu); | int vm_suspend_cpu(struct vm *vm, int vcpu); | ||||
int vm_resume_cpu(struct vm *vm, int vcpu); | int vm_resume_cpu(struct vm *vm, int vcpu); | ||||
struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid); | struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid); | ||||
void vm_exit_suspended(struct vm *vm, int vcpuid, uint64_t rip); | void vm_exit_suspended(struct vm *vm, int vcpuid, uint64_t rip); | ||||
void vm_exit_debug(struct vm *vm, int vcpuid, uint64_t rip); | void vm_exit_debug(struct vm *vm, int vcpuid, uint64_t rip); | ||||
void vm_exit_rendezvous(struct vm *vm, int vcpuid, uint64_t rip); | void vm_exit_rendezvous(struct vm *vm, int vcpuid, uint64_t rip); | ||||
void vm_exit_astpending(struct vm *vm, int vcpuid, uint64_t rip); | void vm_exit_astpending(struct vm *vm, int vcpuid, uint64_t rip); | ||||
void vm_exit_reqidle(struct vm *vm, int vcpuid, uint64_t rip); | void vm_exit_reqidle(struct vm *vm, int vcpuid, uint64_t rip); | ||||
int vm_snapshot_req(struct vm *vm, struct vm_snapshot_meta *meta); | |||||
int vm_restore_time(struct vm *vm); | |||||
#ifdef _SYS__CPUSET_H_ | #ifdef _SYS__CPUSET_H_ | ||||
/* | /* | ||||
* Rendezvous all vcpus specified in 'dest' and execute 'func(arg)'. | * Rendezvous all vcpus specified in 'dest' and execute 'func(arg)'. | ||||
* The rendezvous 'func(arg)' is not allowed to do anything that will | * The rendezvous 'func(arg)' is not allowed to do anything that will | ||||
* cause the thread to be put to sleep. | * cause the thread to be put to sleep. | ||||
* | * | ||||
* If the rendezvous is being initiated from a vcpu context then the | * If the rendezvous is being initiated from a vcpu context then the | ||||
* 'vcpuid' must refer to that vcpu, otherwise it should be set to -1. | * 'vcpuid' must refer to that vcpu, otherwise it should be set to -1. | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | |||||
* call this function with 'intinfo=0' to indicate that the external event | * call this function with 'intinfo=0' to indicate that the external event | ||||
* is not pending anymore. | * is not pending anymore. | ||||
* | * | ||||
* Return value is 0 on success and non-zero on failure. | * Return value is 0 on success and non-zero on failure. | ||||
*/ | */ | ||||
int vm_exit_intinfo(struct vm *vm, int vcpuid, uint64_t intinfo); | int vm_exit_intinfo(struct vm *vm, int vcpuid, uint64_t intinfo); | ||||
/* | /* | ||||
* This function is called before every VM-entry to retrieve a pending | * This function is called before every VM-entry to retrieve a pending | ||||
Done Inline ActionsThis change seems to have been erroneously made. xistence_0x58.com: This change seems to have been erroneously made. | |||||
* event that should be injected into the guest. This function combines | * event that should be injected into the guest. This function combines | ||||
* nested events into a double or triple fault. | * nested events into a double or triple fault. | ||||
* | * | ||||
* Returns 0 if there are no events that need to be injected into the guest | * Returns 0 if there are no events that need to be injected into the guest | ||||
* and non-zero otherwise. | * and non-zero otherwise. | ||||
*/ | */ | ||||
int vm_entry_intinfo(struct vm *vm, int vcpuid, uint64_t *info); | int vm_entry_intinfo(struct vm *vm, int vcpuid, uint64_t *info); | ||||
int vm_get_intinfo(struct vm *vm, int vcpuid, uint64_t *info1, uint64_t *info2); | int vm_get_intinfo(struct vm *vm, int vcpuid, uint64_t *info1, uint64_t *info2); | ||||
/* | |||||
Done Inline ActionsFirst line of a comment should be /*. See style(9) xistence_0x58.com: First line of a comment should be `/*`. See style(9) | |||||
* Function used to keep track of the guest's TSC offset. The | |||||
* offset is used by the virutalization extensions to provide a consistent | |||||
* value for the Time Stamp Counter to the guest. | |||||
* | |||||
* Return value is 0 on success and non-zero on failure. | |||||
*/ | |||||
int vm_set_tsc_offset(struct vm *vm, int vcpu_id, uint64_t offset); | |||||
enum vm_reg_name vm_segment_name(int seg_encoding); | enum vm_reg_name vm_segment_name(int seg_encoding); | ||||
struct vm_copyinfo { | struct vm_copyinfo { | ||||
uint64_t gpa; | uint64_t gpa; | ||||
size_t len; | size_t len; | ||||
void *hva; | void *hva; | ||||
void *cookie; | void *cookie; | ||||
▲ Show 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | union { | ||||
} ioapic_eoi; | } ioapic_eoi; | ||||
struct { | struct { | ||||
enum vm_suspend_how how; | enum vm_suspend_how how; | ||||
} suspended; | } suspended; | ||||
struct vm_task_switch task_switch; | struct vm_task_switch task_switch; | ||||
} u; | } u; | ||||
}; | }; | ||||
/* APIs to inject faults into the guest */ | /* APIs to inject faults into the guest */ | ||||
Not Done Inline ActionsSome comments in this change /* Start with a capital letter and end with a period. */ and /* some are all lowercase without a period */. Style(9) wants the former. emaste: Some comments in this change `/* Start with a capital letter and end with a period. */ and /*… | |||||
void vm_inject_fault(void *vm, int vcpuid, int vector, int errcode_valid, | void vm_inject_fault(void *vm, int vcpuid, int vector, int errcode_valid, | ||||
int errcode); | int errcode); | ||||
static __inline void | static __inline void | ||||
vm_inject_ud(void *vm, int vcpuid) | vm_inject_ud(void *vm, int vcpuid) | ||||
{ | { | ||||
vm_inject_fault(vm, vcpuid, IDT_UD, 0, 0); | vm_inject_fault(vm, vcpuid, IDT_UD, 0, 0); | ||||
} | } | ||||
Show All 24 Lines |
Ideally this isn't really part of the API. We'd just want some kind of opaque "CPU context" perhaps that is VMCS on Intel, VMCB on AMD. This can be on the list for things to refine in tree.