xref: /illumos-gate/usr/src/uts/intel/io/vmm/sys/vmm_kernel.h (revision 0dd92943508086ca1800de461a7c66109737bcd5)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2011 NetApp, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD$
29  */
30 /*
31  * This file and its contents are supplied under the terms of the
32  * Common Development and Distribution License ("CDDL"), version 1.0.
33  * You may only use this file in accordance with the terms of version
34  * 1.0 of the CDDL.
35  *
36  * A full copy of the text of the CDDL should have accompanied this
37  * source.  A copy of the CDDL is also available via the Internet at
38  * http://www.illumos.org/license/CDDL.
39  *
40  * Copyright 2015 Pluribus Networks Inc.
41  * Copyright 2019 Joyent, Inc.
42  * Copyright 2023 Oxide Computer Company
43  * Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
44  */
45 
46 #ifndef _VMM_KERNEL_H_
47 #define	_VMM_KERNEL_H_
48 
49 #include <sys/sdt.h>
50 #include <x86/segments.h>
51 #include <sys/vmm.h>
52 #include <sys/vmm_data.h>
53 #include <sys/linker_set.h>
54 
55 SDT_PROVIDER_DECLARE(vmm);
56 
57 struct vm;
58 struct vm_exception;
59 struct seg_desc;
60 struct vm_exit;
61 struct vie;
62 struct vm_run;
63 struct vhpet;
64 struct vioapic;
65 struct vlapic;
66 struct vmspace;
67 struct vm_client;
68 struct vm_object;
69 struct vm_guest_paging;
70 struct vmm_data_req;
71 
72 typedef int	(*vmm_init_func_t)(void);
73 typedef int	(*vmm_cleanup_func_t)(void);
74 typedef void	(*vmm_resume_func_t)(void);
75 typedef void *	(*vmi_init_func_t)(struct vm *vm);
76 typedef int	(*vmi_run_func_t)(void *vmi, int vcpu, uint64_t rip);
77 typedef void	(*vmi_cleanup_func_t)(void *vmi);
78 typedef int	(*vmi_get_register_t)(void *vmi, int vcpu, int num,
79     uint64_t *retval);
80 typedef int	(*vmi_set_register_t)(void *vmi, int vcpu, int num,
81     uint64_t val);
82 typedef int	(*vmi_get_desc_t)(void *vmi, int vcpu, int num,
83     struct seg_desc *desc);
84 typedef int	(*vmi_set_desc_t)(void *vmi, int vcpu, int num,
85     const struct seg_desc *desc);
86 typedef int	(*vmi_get_cap_t)(void *vmi, int vcpu, int num, int *retval);
87 typedef int	(*vmi_set_cap_t)(void *vmi, int vcpu, int num, int val);
88 typedef struct vlapic *(*vmi_vlapic_init)(void *vmi, int vcpu);
89 typedef void	(*vmi_vlapic_cleanup)(void *vmi, struct vlapic *vlapic);
90 typedef void	(*vmi_savectx)(void *vmi, int vcpu);
91 typedef void	(*vmi_restorectx)(void *vmi, int vcpu);
92 typedef void	(*vmi_pause_t)(void *vmi, int vcpu);
93 
94 typedef int	(*vmi_get_msr_t)(void *vmi, int vcpu, uint32_t msr,
95     uint64_t *valp);
96 typedef int	(*vmi_set_msr_t)(void *vmi, int vcpu, uint32_t msr,
97     uint64_t val);
98 
99 struct vmm_ops {
100 	vmm_init_func_t		init;		/* module wide initialization */
101 	vmm_cleanup_func_t	cleanup;
102 	vmm_resume_func_t	resume;
103 
104 	vmi_init_func_t		vminit;		/* vm-specific initialization */
105 	vmi_run_func_t		vmrun;
106 	vmi_cleanup_func_t	vmcleanup;
107 	vmi_get_register_t	vmgetreg;
108 	vmi_set_register_t	vmsetreg;
109 	vmi_get_desc_t		vmgetdesc;
110 	vmi_set_desc_t		vmsetdesc;
111 	vmi_get_cap_t		vmgetcap;
112 	vmi_set_cap_t		vmsetcap;
113 	vmi_vlapic_init		vlapic_init;
114 	vmi_vlapic_cleanup	vlapic_cleanup;
115 	vmi_pause_t		vmpause;
116 
117 	vmi_savectx		vmsavectx;
118 	vmi_restorectx		vmrestorectx;
119 
120 	vmi_get_msr_t		vmgetmsr;
121 	vmi_set_msr_t		vmsetmsr;
122 };
123 
124 extern struct vmm_ops vmm_ops_intel;
125 extern struct vmm_ops vmm_ops_amd;
126 
127 int vm_create(uint64_t flags, struct vm **retvm);
128 void vm_destroy(struct vm *vm);
129 int vm_reinit(struct vm *vm, uint64_t);
130 uint16_t vm_get_maxcpus(struct vm *vm);
131 void vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores,
132     uint16_t *threads, uint16_t *maxcpus);
133 int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores,
134     uint16_t threads, uint16_t maxcpus);
135 
136 int vm_pause_instance(struct vm *);
137 int vm_resume_instance(struct vm *);
138 bool vm_is_paused(struct vm *);
139 
140 /*
141  * APIs that race against hardware.
142  */
143 int vm_track_dirty_pages(struct vm *, uint64_t, size_t, uint8_t *);
144 
145 /*
146  * APIs that modify the guest memory map require all vcpus to be frozen.
147  */
148 int vm_mmap_memseg(struct vm *vm, vm_paddr_t gpa, int segid, vm_ooffset_t off,
149     size_t len, int prot, int flags);
150 int vm_munmap_memseg(struct vm *vm, vm_paddr_t gpa, size_t len);
151 int vm_alloc_memseg(struct vm *vm, int ident, size_t len, bool sysmem);
152 void vm_free_memseg(struct vm *vm, int ident);
153 int vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa);
154 int vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len);
155 int vm_assign_pptdev(struct vm *vm, int pptfd);
156 int vm_unassign_pptdev(struct vm *vm, int pptfd);
157 
158 /*
159  * APIs that inspect the guest memory map require only a *single* vcpu to
160  * be frozen. This acts like a read lock on the guest memory map since any
161  * modification requires *all* vcpus to be frozen.
162  */
163 int vm_mmap_getnext(struct vm *vm, vm_paddr_t *gpa, int *segid,
164     vm_ooffset_t *segoff, size_t *len, int *prot, int *flags);
165 int vm_get_memseg(struct vm *vm, int ident, size_t *len, bool *sysmem,
166     struct vm_object **objptr);
167 vm_paddr_t vmm_sysmem_maxaddr(struct vm *vm);
168 bool vm_mem_allocated(struct vm *vm, int vcpuid, vm_paddr_t gpa);
169 
170 int vm_get_register(struct vm *vm, int vcpu, int reg, uint64_t *retval);
171 int vm_set_register(struct vm *vm, int vcpu, int reg, uint64_t val);
172 int vm_get_seg_desc(struct vm *vm, int vcpu, int reg,
173     struct seg_desc *ret_desc);
174 int vm_set_seg_desc(struct vm *vm, int vcpu, int reg,
175     const struct seg_desc *desc);
176 int vm_get_run_state(struct vm *vm, int vcpuid, uint32_t *state,
177     uint8_t *sipi_vec);
178 int vm_set_run_state(struct vm *vm, int vcpuid, uint32_t state,
179     uint8_t sipi_vec);
180 int vm_get_fpu(struct vm *vm, int vcpuid, void *buf, size_t len);
181 int vm_set_fpu(struct vm *vm, int vcpuid, void *buf, size_t len);
182 int vm_run(struct vm *vm, int vcpuid, const struct vm_entry *);
183 int vm_suspend(struct vm *vm, enum vm_suspend_how how);
184 int vm_inject_nmi(struct vm *vm, int vcpu);
185 bool vm_nmi_pending(struct vm *vm, int vcpuid);
186 void vm_nmi_clear(struct vm *vm, int vcpuid);
187 int vm_inject_extint(struct vm *vm, int vcpu);
188 bool vm_extint_pending(struct vm *vm, int vcpuid);
189 void vm_extint_clear(struct vm *vm, int vcpuid);
190 int vm_inject_init(struct vm *vm, int vcpuid);
191 int vm_inject_sipi(struct vm *vm, int vcpuid, uint8_t vec);
192 struct vlapic *vm_lapic(struct vm *vm, int cpu);
193 struct vioapic *vm_ioapic(struct vm *vm);
194 struct vhpet *vm_hpet(struct vm *vm);
195 int vm_get_capability(struct vm *vm, int vcpu, int type, int *val);
196 int vm_set_capability(struct vm *vm, int vcpu, int type, int val);
197 int vm_get_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state *state);
198 int vm_set_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state state);
199 int vm_apicid2vcpuid(struct vm *vm, int apicid);
200 int vm_activate_cpu(struct vm *vm, int vcpu);
201 int vm_suspend_cpu(struct vm *vm, int vcpu);
202 int vm_resume_cpu(struct vm *vm, int vcpu);
203 struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid);
204 struct vie *vm_vie_ctx(struct vm *vm, int vcpuid);
205 void vm_exit_suspended(struct vm *vm, int vcpuid, uint64_t rip);
206 void vm_exit_debug(struct vm *vm, int vcpuid, uint64_t rip);
207 void vm_exit_astpending(struct vm *vm, int vcpuid, uint64_t rip);
208 void vm_exit_reqidle(struct vm *vm, int vcpuid, uint64_t rip);
209 void vm_exit_run_state(struct vm *vm, int vcpuid, uint64_t rip);
210 int vm_service_mmio_read(struct vm *vm, int cpuid, uint64_t gpa, uint64_t *rval,
211     int rsize);
212 int vm_service_mmio_write(struct vm *vm, int cpuid, uint64_t gpa, uint64_t wval,
213     int wsize);
214 
215 #ifdef _SYS__CPUSET_H_
216 cpuset_t vm_active_cpus(struct vm *vm);
217 cpuset_t vm_debug_cpus(struct vm *vm);
218 cpuset_t vm_suspended_cpus(struct vm *vm);
219 #endif	/* _SYS__CPUSET_H_ */
220 
221 bool vcpu_entry_bailout_checks(struct vm *vm, int vcpuid, uint64_t rip);
222 bool vcpu_run_state_pending(struct vm *vm, int vcpuid);
223 int vcpu_arch_reset(struct vm *vm, int vcpuid, bool init_only);
224 
225 /*
226  * Return true if device indicated by bus/slot/func is supposed to be a
227  * pci passthrough device.
228  *
229  * Return false otherwise.
230  */
231 bool vmm_is_pptdev(int bus, int slot, int func);
232 
233 void *vm_iommu_domain(struct vm *vm);
234 
235 enum vcpu_state {
236 	VCPU_IDLE,
237 	VCPU_FROZEN,
238 	VCPU_RUNNING,
239 	VCPU_SLEEPING,
240 };
241 
242 int vcpu_set_state(struct vm *vm, int vcpu, enum vcpu_state state,
243     bool from_idle);
244 enum vcpu_state vcpu_get_state(struct vm *vm, int vcpu, int *hostcpu);
245 void vcpu_block_run(struct vm *, int);
246 void vcpu_unblock_run(struct vm *, int);
247 
248 uint64_t vcpu_tsc_offset(struct vm *vm, int vcpuid, bool phys_adj);
249 hrtime_t vm_normalize_hrtime(struct vm *, hrtime_t);
250 hrtime_t vm_denormalize_hrtime(struct vm *, hrtime_t);
251 
252 static __inline bool
253 vcpu_is_running(struct vm *vm, int vcpu, int *hostcpu)
254 {
255 	return (vcpu_get_state(vm, vcpu, hostcpu) == VCPU_RUNNING);
256 }
257 
258 #ifdef _SYS_THREAD_H
259 static __inline int
260 vcpu_should_yield(struct vm *vm, int vcpu)
261 {
262 
263 	if (curthread->t_astflag)
264 		return (1);
265 	else if (CPU->cpu_runrun)
266 		return (1);
267 	else
268 		return (0);
269 }
270 #endif /* _SYS_THREAD_H */
271 
272 typedef enum vcpu_notify {
273 	VCPU_NOTIFY_NONE,
274 	VCPU_NOTIFY_APIC,	/* Posted intr notification (if possible) */
275 	VCPU_NOTIFY_EXIT,	/* IPI to cause VM exit */
276 } vcpu_notify_t;
277 
278 void *vcpu_stats(struct vm *vm, int vcpu);
279 void vcpu_notify_event(struct vm *vm, int vcpuid);
280 void vcpu_notify_event_type(struct vm *vm, int vcpuid, vcpu_notify_t);
281 struct vmspace *vm_get_vmspace(struct vm *vm);
282 struct vm_client *vm_get_vmclient(struct vm *vm, int vcpuid);
283 struct vatpic *vm_atpic(struct vm *vm);
284 struct vatpit *vm_atpit(struct vm *vm);
285 struct vpmtmr *vm_pmtmr(struct vm *vm);
286 struct vrtc *vm_rtc(struct vm *vm);
287 
288 /*
289  * Inject exception 'vector' into the guest vcpu. This function returns 0 on
290  * success and non-zero on failure.
291  *
292  * Wrapper functions like 'vm_inject_gp()' should be preferred to calling
293  * this function directly because they enforce the trap-like or fault-like
294  * behavior of an exception.
295  *
296  * This function should only be called in the context of the thread that is
297  * executing this vcpu.
298  */
299 int vm_inject_exception(struct vm *vm, int vcpuid, uint8_t vector,
300     bool err_valid, uint32_t errcode, bool restart_instruction);
301 
302 /*
303  * This function is called after a VM-exit that occurred during exception or
304  * interrupt delivery through the IDT. The format of 'intinfo' is described
305  * in Figure 15-1, "EXITINTINFO for All Intercepts", APM, Vol 2.
306  *
307  * If a VM-exit handler completes the event delivery successfully then it
308  * should call vm_exit_intinfo() to extinguish the pending event. For e.g.,
309  * if the task switch emulation is triggered via a task gate then it should
310  * call this function with 'intinfo=0' to indicate that the external event
311  * is not pending anymore.
312  *
313  * Return value is 0 on success and non-zero on failure.
314  */
315 int vm_exit_intinfo(struct vm *vm, int vcpuid, uint64_t intinfo);
316 
317 /*
318  * This function is called before every VM-entry to retrieve a pending
319  * event that should be injected into the guest. This function combines
320  * nested events into a double or triple fault.
321  *
322  * Returns false if there are no events that need to be injected into the guest.
323  */
324 bool vm_entry_intinfo(struct vm *vm, int vcpuid, uint64_t *info);
325 
326 int vm_get_intinfo(struct vm *vm, int vcpuid, uint64_t *info1, uint64_t *info2);
327 
328 enum vm_reg_name vm_segment_name(int seg_encoding);
329 
330 struct vm_copyinfo {
331 	uint64_t	gpa;
332 	size_t		len;
333 	int		prot;
334 	void		*hva;
335 	void		*cookie;
336 };
337 
338 /*
339  * Set up 'copyinfo[]' to copy to/from guest linear address space starting
340  * at 'gla' and 'len' bytes long. The 'prot' should be set to PROT_READ for
341  * a copyin or PROT_WRITE for a copyout.
342  *
343  * retval	is_fault	Interpretation
344  *   0		   0		Success
345  *   0		   1		An exception was injected into the guest
346  * EFAULT	  N/A		Unrecoverable error
347  *
348  * The 'copyinfo[]' can be passed to 'vm_copyin()' or 'vm_copyout()' only if
349  * the return value is 0. The 'copyinfo[]' resources should be freed by calling
350  * 'vm_copy_teardown()' after the copy is done.
351  */
352 int vm_copy_setup(struct vm *vm, int vcpuid, struct vm_guest_paging *paging,
353     uint64_t gla, size_t len, int prot, struct vm_copyinfo *copyinfo,
354     uint_t num_copyinfo, int *is_fault);
355 void vm_copy_teardown(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo,
356     uint_t num_copyinfo);
357 void vm_copyin(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo,
358     void *kaddr, size_t len);
359 void vm_copyout(struct vm *vm, int vcpuid, const void *kaddr,
360     struct vm_copyinfo *copyinfo, size_t len);
361 
362 int vcpu_trace_exceptions(struct vm *vm, int vcpuid);
363 int vcpu_trap_wbinvd(struct vm *vm, int vcpuid);
364 
365 void vm_inject_ud(struct vm *vm, int vcpuid);
366 void vm_inject_gp(struct vm *vm, int vcpuid);
367 void vm_inject_ac(struct vm *vm, int vcpuid, uint32_t errcode);
368 void vm_inject_ss(struct vm *vm, int vcpuid, uint32_t errcode);
369 void vm_inject_pf(struct vm *vm, int vcpuid, uint32_t errcode, uint64_t cr2);
370 
371 /*
372  * Both SVM and VMX have complex logic for injecting events such as exceptions
373  * or interrupts into the guest.  Within those two backends, the progress of
374  * event injection is tracked by event_inject_state, hopefully making it easier
375  * to reason about.
376  */
377 enum event_inject_state {
378 	EIS_CAN_INJECT	= 0, /* exception/interrupt can be injected */
379 	EIS_EV_EXISTING	= 1, /* blocked by existing event */
380 	EIS_EV_INJECTED	= 2, /* blocked by injected event */
381 	EIS_GI_BLOCK	= 3, /* blocked by guest interruptability */
382 
383 	/*
384 	 * Flag to request an immediate exit from VM context after event
385 	 * injection in order to perform more processing
386 	 */
387 	EIS_REQ_EXIT	= (1 << 15),
388 };
389 
390 /* Possible result codes for MSR access emulation */
391 typedef enum vm_msr_result {
392 	VMR_OK		= 0, /* succesfully emulated */
393 	VMR_GP		= 1, /* #GP should be injected */
394 	VMR_UNHANLDED	= 2, /* handle in userspace, kernel cannot emulate */
395 } vm_msr_result_t;
396 
397 enum vm_cpuid_capability {
398 	VCC_NONE,
399 	VCC_NO_EXECUTE,
400 	VCC_FFXSR,
401 	VCC_TCE,
402 	VCC_LAST
403 };
404 
405 /* Possible flags and entry count limit definited in sys/vmm.h */
406 typedef struct vcpu_cpuid_config {
407 	uint32_t		vcc_flags;
408 	uint32_t		vcc_nent;
409 	struct vcpu_cpuid_entry	*vcc_entries;
410 } vcpu_cpuid_config_t;
411 
412 vcpu_cpuid_config_t *vm_cpuid_config(struct vm *, int);
413 int vm_get_cpuid(struct vm *, int, vcpu_cpuid_config_t *);
414 int vm_set_cpuid(struct vm *, int, const vcpu_cpuid_config_t *);
415 void vcpu_emulate_cpuid(struct vm *, int, uint64_t *, uint64_t *, uint64_t *,
416     uint64_t *);
417 void legacy_emulate_cpuid(struct vm *, int, uint32_t *, uint32_t *, uint32_t *,
418     uint32_t *);
419 void vcpu_cpuid_init(vcpu_cpuid_config_t *);
420 void vcpu_cpuid_cleanup(vcpu_cpuid_config_t *);
421 
422 bool vm_cpuid_capability(struct vm *, int, enum vm_cpuid_capability);
423 bool validate_guest_xcr0(uint64_t, uint64_t);
424 
425 void vmm_sol_glue_init(void);
426 void vmm_sol_glue_cleanup(void);
427 
428 void *vmm_contig_alloc(size_t);
429 void vmm_contig_free(void *, size_t);
430 
431 int vmm_mod_load(void);
432 int vmm_mod_unload(void);
433 
434 bool vmm_check_iommu(void);
435 
436 void vmm_call_trap(uint64_t);
437 
438 /*
439  * Because of tangled headers, this is not exposed directly via the vmm_drv
440  * interface, but rather mirrored as vmm_drv_iop_cb_t in vmm_drv.h.
441  */
442 typedef int (*ioport_handler_t)(void *, bool, uint16_t, uint8_t, uint32_t *);
443 
444 int vm_ioport_access(struct vm *vm, int vcpuid, bool in, uint16_t port,
445     uint8_t bytes, uint32_t *val);
446 
447 int vm_ioport_attach(struct vm *vm, uint16_t port, ioport_handler_t func,
448     void *arg, void **cookie);
449 int vm_ioport_detach(struct vm *vm, void **cookie, ioport_handler_t *old_func,
450     void **old_arg);
451 
452 int vm_ioport_hook(struct vm *, uint16_t, ioport_handler_t, void *, void **);
453 void vm_ioport_unhook(struct vm *, void **);
454 
455 enum vcpu_ustate {
456 	VU_INIT = 0,	/* initialized but has not yet attempted to run */
457 	VU_RUN,		/* running in guest context */
458 	VU_IDLE,	/* idle (HLTed, wait-for-SIPI, etc) */
459 	VU_EMU_KERN,	/* emulation performed in-kernel */
460 	VU_EMU_USER,	/* emulation performed in userspace */
461 	VU_SCHED,	/* off-cpu for interrupt, preempt, lock contention */
462 	VU_MAX
463 };
464 
465 void vcpu_ustate_change(struct vm *, int, enum vcpu_ustate);
466 
467 typedef struct vmm_kstats {
468 	kstat_named_t	vk_name;
469 } vmm_kstats_t;
470 
471 typedef struct vmm_vcpu_kstats {
472 	kstat_named_t	vvk_vcpu;
473 	kstat_named_t	vvk_time_init;
474 	kstat_named_t	vvk_time_run;
475 	kstat_named_t	vvk_time_idle;
476 	kstat_named_t	vvk_time_emu_kern;
477 	kstat_named_t	vvk_time_emu_user;
478 	kstat_named_t	vvk_time_sched;
479 } vmm_vcpu_kstats_t;
480 
481 #define	VMM_KSTAT_CLASS	"misc"
482 
483 int vmm_kstat_update_vcpu(struct kstat *, int);
484 
485 typedef struct vmm_data_req {
486 	uint16_t	vdr_class;
487 	uint16_t	vdr_version;
488 	uint32_t	vdr_flags;
489 	uint32_t	vdr_len;
490 	void		*vdr_data;
491 	uint32_t	*vdr_result_len;
492 } vmm_data_req_t;
493 
494 typedef int (*vmm_data_writef_t)(void *, const vmm_data_req_t *);
495 typedef int (*vmm_data_readf_t)(void *, const vmm_data_req_t *);
496 typedef int (*vmm_data_vcpu_writef_t)(struct vm *, int, const vmm_data_req_t *);
497 typedef int (*vmm_data_vcpu_readf_t)(struct vm *, int, const vmm_data_req_t *);
498 
499 typedef struct vmm_data_version_entry {
500 	uint16_t		vdve_class;
501 	uint16_t		vdve_version;
502 	uint16_t		vdve_len_expect;
503 	uint16_t		vdve_len_per_item;
504 	vmm_data_readf_t	vdve_readf;
505 	vmm_data_writef_t	vdve_writef;
506 	vmm_data_vcpu_readf_t	vdve_vcpu_readf;
507 	vmm_data_vcpu_writef_t	vdve_vcpu_writef;
508 } vmm_data_version_entry_t;
509 
510 #define	VMM_DATA_VERSION(sym)	SET_ENTRY(vmm_data_version_entries, sym)
511 
512 int vmm_data_read(struct vm *, int, const vmm_data_req_t *);
513 int vmm_data_write(struct vm *, int, const vmm_data_req_t *);
514 
515 #endif /* _VMM_KERNEL_H_ */
516