Deleted Added
full compact
vmm.h (264619) vmm.h (266339)
1/*-
2 * Copyright (c) 2011 NetApp, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2011 NetApp, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: stable/10/sys/amd64/include/vmm.h 264619 2014-04-17 18:00:07Z jhb $
26 * $FreeBSD: stable/10/sys/amd64/include/vmm.h 266339 2014-05-17 19:11:08Z jhb $
27 */
28
29#ifndef _VMM_H_
30#define _VMM_H_
31
32#ifdef _KERNEL
33
34#define VM_MAX_NAMELEN 32

--- 7 unchanged lines hidden (view full) ---

42struct vioapic;
43struct vlapic;
44struct vmspace;
45struct vm_object;
46struct pmap;
47
48enum x2apic_state;
49
27 */
28
29#ifndef _VMM_H_
30#define _VMM_H_
31
32#ifdef _KERNEL
33
34#define VM_MAX_NAMELEN 32

--- 7 unchanged lines hidden (view full) ---

42struct vioapic;
43struct vlapic;
44struct vmspace;
45struct vm_object;
46struct pmap;
47
48enum x2apic_state;
49
50typedef int (*vmm_init_func_t)(void);
50typedef int (*vmm_init_func_t)(int ipinum);
51typedef int (*vmm_cleanup_func_t)(void);
52typedef void (*vmm_resume_func_t)(void);
53typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap);
54typedef int (*vmi_run_func_t)(void *vmi, int vcpu, register_t rip,
51typedef int (*vmm_cleanup_func_t)(void);
52typedef void (*vmm_resume_func_t)(void);
53typedef void * (*vmi_init_func_t)(struct vm *vm, struct pmap *pmap);
54typedef int (*vmi_run_func_t)(void *vmi, int vcpu, register_t rip,
55 struct pmap *pmap);
55 struct pmap *pmap, void *rendezvous_cookie);
56typedef void (*vmi_cleanup_func_t)(void *vmi);
57typedef int (*vmi_get_register_t)(void *vmi, int vcpu, int num,
58 uint64_t *retval);
59typedef int (*vmi_set_register_t)(void *vmi, int vcpu, int num,
60 uint64_t val);
61typedef int (*vmi_get_desc_t)(void *vmi, int vcpu, int num,
62 struct seg_desc *desc);
63typedef int (*vmi_set_desc_t)(void *vmi, int vcpu, int num,
64 struct seg_desc *desc);
65typedef int (*vmi_inject_event_t)(void *vmi, int vcpu,
66 int type, int vector,
67 uint32_t code, int code_valid);
68typedef int (*vmi_get_cap_t)(void *vmi, int vcpu, int num, int *retval);
69typedef int (*vmi_set_cap_t)(void *vmi, int vcpu, int num, int val);
70typedef struct vmspace * (*vmi_vmspace_alloc)(vm_offset_t min, vm_offset_t max);
71typedef void (*vmi_vmspace_free)(struct vmspace *vmspace);
56typedef void (*vmi_cleanup_func_t)(void *vmi);
57typedef int (*vmi_get_register_t)(void *vmi, int vcpu, int num,
58 uint64_t *retval);
59typedef int (*vmi_set_register_t)(void *vmi, int vcpu, int num,
60 uint64_t val);
61typedef int (*vmi_get_desc_t)(void *vmi, int vcpu, int num,
62 struct seg_desc *desc);
63typedef int (*vmi_set_desc_t)(void *vmi, int vcpu, int num,
64 struct seg_desc *desc);
65typedef int (*vmi_inject_event_t)(void *vmi, int vcpu,
66 int type, int vector,
67 uint32_t code, int code_valid);
68typedef int (*vmi_get_cap_t)(void *vmi, int vcpu, int num, int *retval);
69typedef int (*vmi_set_cap_t)(void *vmi, int vcpu, int num, int val);
70typedef struct vmspace * (*vmi_vmspace_alloc)(vm_offset_t min, vm_offset_t max);
71typedef void (*vmi_vmspace_free)(struct vmspace *vmspace);
72typedef struct vlapic * (*vmi_vlapic_init)(void *vmi, int vcpu);
73typedef void (*vmi_vlapic_cleanup)(void *vmi, struct vlapic *vlapic);
72
73struct vmm_ops {
74 vmm_init_func_t init; /* module wide initialization */
75 vmm_cleanup_func_t cleanup;
76 vmm_resume_func_t resume;
77
78 vmi_init_func_t vminit; /* vm-specific initialization */
79 vmi_run_func_t vmrun;
80 vmi_cleanup_func_t vmcleanup;
81 vmi_get_register_t vmgetreg;
82 vmi_set_register_t vmsetreg;
83 vmi_get_desc_t vmgetdesc;
84 vmi_set_desc_t vmsetdesc;
85 vmi_inject_event_t vminject;
86 vmi_get_cap_t vmgetcap;
87 vmi_set_cap_t vmsetcap;
88 vmi_vmspace_alloc vmspace_alloc;
89 vmi_vmspace_free vmspace_free;
74
75struct vmm_ops {
76 vmm_init_func_t init; /* module wide initialization */
77 vmm_cleanup_func_t cleanup;
78 vmm_resume_func_t resume;
79
80 vmi_init_func_t vminit; /* vm-specific initialization */
81 vmi_run_func_t vmrun;
82 vmi_cleanup_func_t vmcleanup;
83 vmi_get_register_t vmgetreg;
84 vmi_set_register_t vmsetreg;
85 vmi_get_desc_t vmgetdesc;
86 vmi_set_desc_t vmsetdesc;
87 vmi_inject_event_t vminject;
88 vmi_get_cap_t vmgetcap;
89 vmi_set_cap_t vmsetcap;
90 vmi_vmspace_alloc vmspace_alloc;
91 vmi_vmspace_free vmspace_free;
92 vmi_vlapic_init vlapic_init;
93 vmi_vlapic_cleanup vlapic_cleanup;
90};
91
92extern struct vmm_ops vmm_ops_intel;
93extern struct vmm_ops vmm_ops_amd;
94
95int vm_create(const char *name, struct vm **retvm);
96void vm_destroy(struct vm *vm);
97const char *vm_name(struct vm *vm);

--- 29 unchanged lines hidden (view full) ---

127int vm_get_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state *state);
128int vm_set_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state state);
129int vm_apicid2vcpuid(struct vm *vm, int apicid);
130void vm_activate_cpu(struct vm *vm, int vcpu);
131cpuset_t vm_active_cpus(struct vm *vm);
132struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid);
133
134/*
94};
95
96extern struct vmm_ops vmm_ops_intel;
97extern struct vmm_ops vmm_ops_amd;
98
99int vm_create(const char *name, struct vm **retvm);
100void vm_destroy(struct vm *vm);
101const char *vm_name(struct vm *vm);

--- 29 unchanged lines hidden (view full) ---

131int vm_get_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state *state);
132int vm_set_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state state);
133int vm_apicid2vcpuid(struct vm *vm, int apicid);
134void vm_activate_cpu(struct vm *vm, int vcpu);
135cpuset_t vm_active_cpus(struct vm *vm);
136struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid);
137
138/*
139 * Rendezvous all vcpus specified in 'dest' and execute 'func(arg)'.
140 * The rendezvous 'func(arg)' is not allowed to do anything that will
141 * cause the thread to be put to sleep.
142 *
143 * If the rendezvous is being initiated from a vcpu context then the
144 * 'vcpuid' must refer to that vcpu, otherwise it should be set to -1.
145 *
146 * The caller cannot hold any locks when initiating the rendezvous.
147 *
148 * The implementation of this API may cause vcpus other than those specified
149 * by 'dest' to be stalled. The caller should not rely on any vcpus making
150 * forward progress when the rendezvous is in progress.
151 */
152typedef void (*vm_rendezvous_func_t)(struct vm *vm, int vcpuid, void *arg);
153void vm_smp_rendezvous(struct vm *vm, int vcpuid, cpuset_t dest,
154 vm_rendezvous_func_t func, void *arg);
155
156static __inline int
157vcpu_rendezvous_pending(void *rendezvous_cookie)
158{
159
160 return (*(uintptr_t *)rendezvous_cookie != 0);
161}
162
163/*
135 * Return 1 if device indicated by bus/slot/func is supposed to be a
136 * pci passthrough device.
137 *
138 * Return 0 otherwise.
139 */
140int vmm_is_pptdev(int bus, int slot, int func);
141
142void *vm_iommu_domain(struct vm *vm);

--- 10 unchanged lines hidden (view full) ---

153
154static int __inline
155vcpu_is_running(struct vm *vm, int vcpu, int *hostcpu)
156{
157 return (vcpu_get_state(vm, vcpu, hostcpu) == VCPU_RUNNING);
158}
159
160void *vcpu_stats(struct vm *vm, int vcpu);
164 * Return 1 if device indicated by bus/slot/func is supposed to be a
165 * pci passthrough device.
166 *
167 * Return 0 otherwise.
168 */
169int vmm_is_pptdev(int bus, int slot, int func);
170
171void *vm_iommu_domain(struct vm *vm);

--- 10 unchanged lines hidden (view full) ---

182
183static int __inline
184vcpu_is_running(struct vm *vm, int vcpu, int *hostcpu)
185{
186 return (vcpu_get_state(vm, vcpu, hostcpu) == VCPU_RUNNING);
187}
188
189void *vcpu_stats(struct vm *vm, int vcpu);
161void vcpu_notify_event(struct vm *vm, int vcpuid);
190void vcpu_notify_event(struct vm *vm, int vcpuid, bool lapic_intr);
162struct vmspace *vm_get_vmspace(struct vm *vm);
163int vm_assign_pptdev(struct vm *vm, int bus, int slot, int func);
164int vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func);
165#endif /* KERNEL */
166
167#include <machine/vmm_instruction_emul.h>
168
169#define VM_MAXCPU 16 /* maximum virtual cpus */

--- 92 unchanged lines hidden (view full) ---

262 VM_EXITCODE_WRMSR,
263 VM_EXITCODE_HLT,
264 VM_EXITCODE_MTRAP,
265 VM_EXITCODE_PAUSE,
266 VM_EXITCODE_PAGING,
267 VM_EXITCODE_INST_EMUL,
268 VM_EXITCODE_SPINUP_AP,
269 VM_EXITCODE_SPINDOWN_CPU,
191struct vmspace *vm_get_vmspace(struct vm *vm);
192int vm_assign_pptdev(struct vm *vm, int bus, int slot, int func);
193int vm_unassign_pptdev(struct vm *vm, int bus, int slot, int func);
194#endif /* KERNEL */
195
196#include <machine/vmm_instruction_emul.h>
197
198#define VM_MAXCPU 16 /* maximum virtual cpus */

--- 92 unchanged lines hidden (view full) ---

291 VM_EXITCODE_WRMSR,
292 VM_EXITCODE_HLT,
293 VM_EXITCODE_MTRAP,
294 VM_EXITCODE_PAUSE,
295 VM_EXITCODE_PAGING,
296 VM_EXITCODE_INST_EMUL,
297 VM_EXITCODE_SPINUP_AP,
298 VM_EXITCODE_SPINDOWN_CPU,
299 VM_EXITCODE_RENDEZVOUS,
300 VM_EXITCODE_IOAPIC_EOI,
270 VM_EXITCODE_MAX
271};
272
273struct vm_exit {
274 enum vm_exitcode exitcode;
275 int inst_length; /* 0 means unknown */
276 uint64_t rip;
277 union {

--- 40 unchanged lines hidden (view full) ---

318 } msr;
319 struct {
320 int vcpu;
321 uint64_t rip;
322 } spinup_ap;
323 struct {
324 uint64_t rflags;
325 } hlt;
301 VM_EXITCODE_MAX
302};
303
304struct vm_exit {
305 enum vm_exitcode exitcode;
306 int inst_length; /* 0 means unknown */
307 uint64_t rip;
308 union {

--- 40 unchanged lines hidden (view full) ---

349 } msr;
350 struct {
351 int vcpu;
352 uint64_t rip;
353 } spinup_ap;
354 struct {
355 uint64_t rflags;
356 } hlt;
357 struct {
358 int vector;
359 } ioapic_eoi;
326 } u;
327};
328
329#endif /* _VMM_H_ */
360 } u;
361};
362
363#endif /* _VMM_H_ */