Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/include/vmm.h
Show First 20 Lines • Show All 252 Lines • ▼ Show 20 Lines | |||||
vm_paddr_t vmm_sysmem_maxaddr(struct vm *vm); | vm_paddr_t vmm_sysmem_maxaddr(struct vm *vm); | ||||
void *vm_gpa_hold(struct vcpu *vcpu, vm_paddr_t gpa, size_t len, | void *vm_gpa_hold(struct vcpu *vcpu, vm_paddr_t gpa, size_t len, | ||||
int prot, void **cookie); | int prot, void **cookie); | ||||
void *vm_gpa_hold_global(struct vm *vm, vm_paddr_t gpa, size_t len, | void *vm_gpa_hold_global(struct vm *vm, vm_paddr_t gpa, size_t len, | ||||
int prot, void **cookie); | int prot, void **cookie); | ||||
void *vm_gpa_hold_global(struct vm *vm, vm_paddr_t gpa, size_t len, | void *vm_gpa_hold_global(struct vm *vm, vm_paddr_t gpa, size_t len, | ||||
int prot, void **cookie); | int prot, void **cookie); | ||||
void vm_gpa_release(void *cookie); | void vm_gpa_release(void *cookie); | ||||
bool vm_mem_allocated(struct vm *vm, int vcpuid, vm_paddr_t gpa); | bool vm_mem_allocated(struct vcpu *vcpu, vm_paddr_t gpa); | ||||
int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval); | int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval); | ||||
int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val); | int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val); | ||||
int vm_get_seg_desc(struct vcpu *vcpu, int reg, | int vm_get_seg_desc(struct vcpu *vcpu, int reg, | ||||
struct seg_desc *ret_desc); | struct seg_desc *ret_desc); | ||||
int vm_set_seg_desc(struct vm *vm, int vcpu, int reg, | int vm_set_seg_desc(struct vm *vm, int vcpu, int reg, | ||||
struct seg_desc *desc); | struct seg_desc *desc); | ||||
int vm_run(struct vm *vm, struct vm_run *vmrun); | int vm_run(struct vm *vm, struct vm_run *vmrun); | ||||
int vm_suspend(struct vm *vm, enum vm_suspend_how how); | int vm_suspend(struct vm *vm, enum vm_suspend_how how); | ||||
int vm_inject_nmi(struct vm *vm, int vcpu); | int vm_inject_nmi(struct vm *vm, int vcpu); | ||||
int vm_nmi_pending(struct vm *vm, int vcpuid); | int vm_nmi_pending(struct vcpu *vcpu); | ||||
void vm_nmi_clear(struct vm *vm, int vcpuid); | void vm_nmi_clear(struct vcpu *vcpu); | ||||
int vm_inject_extint(struct vm *vm, int vcpu); | int vm_inject_extint(struct vm *vm, int vcpu); | ||||
int vm_extint_pending(struct vm *vm, int vcpuid); | int vm_extint_pending(struct vcpu *vcpu); | ||||
void vm_extint_clear(struct vm *vm, int vcpuid); | void vm_extint_clear(struct vcpu *vcpu); | ||||
int vcpu_vcpuid(struct vcpu *vcpu); | int vcpu_vcpuid(struct vcpu *vcpu); | ||||
struct vm *vcpu_vm(struct vcpu *vcpu); | struct vm *vcpu_vm(struct vcpu *vcpu); | ||||
struct vcpu *vm_vcpu(struct vm *vm, int cpu); | struct vcpu *vm_vcpu(struct vm *vm, int cpu); | ||||
struct vlapic *vm_lapic(struct vcpu *vcpu); | struct vlapic *vm_lapic(struct vcpu *vcpu); | ||||
struct vioapic *vm_ioapic(struct vm *vm); | struct vioapic *vm_ioapic(struct vm *vm); | ||||
struct vhpet *vm_hpet(struct vm *vm); | struct vhpet *vm_hpet(struct vm *vm); | ||||
int vm_get_capability(struct vm *vm, int vcpu, int type, int *val); | int vm_get_capability(struct vm *vm, int vcpu, int type, int *val); | ||||
int vm_set_capability(struct vm *vm, int vcpu, int type, int val); | int vm_set_capability(struct vm *vm, int vcpu, int type, int val); | ||||
int vm_get_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state *state); | int vm_get_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state *state); | ||||
int vm_set_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state state); | int vm_set_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state state); | ||||
int vm_apicid2vcpuid(struct vm *vm, int apicid); | int vm_apicid2vcpuid(struct vm *vm, int apicid); | ||||
int vm_activate_cpu(struct vm *vm, int vcpu); | int vm_activate_cpu(struct vm *vm, int vcpu); | ||||
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); | ||||
int vm_restart_instruction(struct vcpu *vcpu); | int vm_restart_instruction(struct vcpu *vcpu); | ||||
struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid); | struct vm_exit *vm_exitinfo(struct vcpu *vcpu); | ||||
void vm_exit_suspended(struct vm *vm, int vcpuid, uint64_t rip); | void vm_exit_suspended(struct vcpu *vcpu, uint64_t rip); | ||||
void vm_exit_debug(struct vm *vm, int vcpuid, uint64_t rip); | void vm_exit_debug(struct vcpu *vcpu, uint64_t rip); | ||||
void vm_exit_rendezvous(struct vm *vm, int vcpuid, uint64_t rip); | void vm_exit_rendezvous(struct vcpu *vcpu, uint64_t rip); | ||||
void vm_exit_astpending(struct vm *vm, int vcpuid, uint64_t rip); | void vm_exit_astpending(struct vcpu *vcpu, uint64_t rip); | ||||
void vm_exit_reqidle(struct vm *vm, int vcpuid, uint64_t rip); | void vm_exit_reqidle(struct vcpu *vcpu, uint64_t rip); | ||||
int vm_snapshot_req(struct vm *vm, struct vm_snapshot_meta *meta); | int vm_snapshot_req(struct vm *vm, struct vm_snapshot_meta *meta); | ||||
int vm_restore_time(struct vm *vm); | 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. | ||||
Show All 31 Lines | |||||
static __inline int | static __inline int | ||||
vcpu_reqidle(struct vm_eventinfo *info) | vcpu_reqidle(struct vm_eventinfo *info) | ||||
{ | { | ||||
return (*info->iptr); | return (*info->iptr); | ||||
} | } | ||||
int vcpu_debugged(struct vm *vm, int vcpuid); | int vcpu_debugged(struct vcpu *vcpu); | ||||
/* | /* | ||||
* Return true if device indicated by bus/slot/func is supposed to be a | * Return true if device indicated by bus/slot/func is supposed to be a | ||||
* pci passthrough device. | * pci passthrough device. | ||||
* | * | ||||
* Return false otherwise. | * Return false otherwise. | ||||
*/ | */ | ||||
bool vmm_is_pptdev(int bus, int slot, int func); | bool vmm_is_pptdev(int bus, int slot, int func); | ||||
void *vm_iommu_domain(struct vm *vm); | void *vm_iommu_domain(struct vm *vm); | ||||
enum vcpu_state { | enum vcpu_state { | ||||
VCPU_IDLE, | VCPU_IDLE, | ||||
VCPU_FROZEN, | VCPU_FROZEN, | ||||
VCPU_RUNNING, | VCPU_RUNNING, | ||||
VCPU_SLEEPING, | VCPU_SLEEPING, | ||||
}; | }; | ||||
int vcpu_set_state(struct vm *vm, int vcpu, enum vcpu_state state, | int vcpu_set_state(struct vm *vm, int vcpu, enum vcpu_state state, | ||||
bool from_idle); | bool from_idle); | ||||
enum vcpu_state vcpu_get_state(struct vcpu *vcpu, int *hostcpu); | enum vcpu_state vcpu_get_state(struct vcpu *vcpu, int *hostcpu); | ||||
static int __inline | static int __inline | ||||
vcpu_is_running(struct vm *vm, int vcpu, int *hostcpu) | vcpu_is_running(struct vcpu *vcpu, int *hostcpu) | ||||
{ | { | ||||
return (vcpu_get_state(vm_vcpu(vm, vcpu), hostcpu) == VCPU_RUNNING); | return (vcpu_get_state(vcpu, hostcpu) == VCPU_RUNNING); | ||||
} | } | ||||
#ifdef _SYS_PROC_H_ | #ifdef _SYS_PROC_H_ | ||||
static int __inline | static int __inline | ||||
vcpu_should_yield(struct vm *vm, int vcpu) | vcpu_should_yield(struct vcpu *vcpu) | ||||
{ | { | ||||
struct thread *td; | struct thread *td; | ||||
td = curthread; | td = curthread; | ||||
return (td->td_ast != 0 || td->td_owepreempt != 0); | return (td->td_ast != 0 || td->td_owepreempt != 0); | ||||
} | } | ||||
#endif | #endif | ||||
Show All 27 Lines | |||||
* If a VM-exit handler completes the event delivery successfully then it | * If a VM-exit handler completes the event delivery successfully then it | ||||
* should call vm_exit_intinfo() to extinguish the pending event. For e.g., | * should call vm_exit_intinfo() to extinguish the pending event. For e.g., | ||||
* if the task switch emulation is triggered via a task gate then it should | * if the task switch emulation is triggered via a task gate then it should | ||||
* 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 vcpu *vcpu, 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 | ||||
* 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 vcpu *vcpu, 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); | ||||
/* | /* | ||||
* Function used to keep track of the guest's TSC offset. The | * Function used to keep track of the guest's TSC offset. The | ||||
* offset is used by the virutalization extensions to provide a consistent | * offset is used by the virutalization extensions to provide a consistent | ||||
* value for the Time Stamp Counter to the guest. | * 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); | void vm_set_tsc_offset(struct vcpu *vcpu, 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 All 15 Lines | |||||
*/ | */ | ||||
int vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *paging, | int vm_copy_setup(struct vcpu *vcpu, struct vm_guest_paging *paging, | ||||
uint64_t gla, size_t len, int prot, struct vm_copyinfo *copyinfo, | uint64_t gla, size_t len, int prot, struct vm_copyinfo *copyinfo, | ||||
int num_copyinfo, int *is_fault); | int num_copyinfo, int *is_fault); | ||||
void vm_copy_teardown(struct vm_copyinfo *copyinfo, int num_copyinfo); | void vm_copy_teardown(struct vm_copyinfo *copyinfo, int num_copyinfo); | ||||
void vm_copyin(struct vm_copyinfo *copyinfo, void *kaddr, size_t len); | void vm_copyin(struct vm_copyinfo *copyinfo, void *kaddr, size_t len); | ||||
void vm_copyout(const void *kaddr, struct vm_copyinfo *copyinfo, size_t len); | void vm_copyout(const void *kaddr, struct vm_copyinfo *copyinfo, size_t len); | ||||
int vcpu_trace_exceptions(struct vm *vm, int vcpuid); | int vcpu_trace_exceptions(struct vcpu *vcpu); | ||||
int vcpu_trap_wbinvd(struct vm *vm, int vcpuid); | int vcpu_trap_wbinvd(struct vcpu *vcpu); | ||||
#endif /* KERNEL */ | #endif /* KERNEL */ | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#define VM_MAXCPU 16 /* maximum virtual cpus */ | #define VM_MAXCPU 16 /* maximum virtual cpus */ | ||||
#endif | #endif | ||||
/* | /* | ||||
* Identifiers for optional vmm capabilities | * Identifiers for optional vmm capabilities | ||||
▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void vm_inject_pf(struct vcpu *vcpu, int error_code, uint64_t cr2); | void vm_inject_pf(struct vcpu *vcpu, int error_code, uint64_t cr2); | ||||
#else | #else | ||||
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(struct vcpu *vcpu) | ||||
{ | { | ||||
vm_inject_fault(vm, vcpuid, IDT_UD, 0, 0); | vm_inject_fault(vcpu, IDT_UD, 0, 0); | ||||
} | } | ||||
static __inline void | static __inline void | ||||
vm_inject_gp(void *vm, int vcpuid) | vm_inject_gp(struct vcpu *vcpu) | ||||
{ | { | ||||
vm_inject_fault(vm, vcpuid, IDT_GP, 1, 0); | vm_inject_fault(vcpu, IDT_GP, 1, 0); | ||||
} | } | ||||
static __inline void | static __inline void | ||||
vm_inject_ac(void *vm, int vcpuid, int errcode) | vm_inject_ac(struct vcpu *vcpu, int errcode) | ||||
{ | { | ||||
vm_inject_fault(vm, vcpuid, IDT_AC, 1, errcode); | vm_inject_fault(vcpu, IDT_AC, 1, errcode); | ||||
} | } | ||||
static __inline void | static __inline void | ||||
vm_inject_ss(void *vm, int vcpuid, int errcode) | vm_inject_ss(struct vcpu *vcpu, int errcode) | ||||
{ | { | ||||
vm_inject_fault(vm, vcpuid, IDT_SS, 1, errcode); | vm_inject_fault(vcpu, IDT_SS, 1, errcode); | ||||
} | } | ||||
void vm_inject_pf(void *vm, int vcpuid, int error_code, uint64_t cr2); | void vm_inject_pf(void *vm, int vcpuid, int error_code, uint64_t cr2); | ||||
#endif | #endif | ||||
#endif /* _VMM_H_ */ | #endif /* _VMM_H_ */ |