4 * Copyright (c) 2011 Intel Corporation
10 * This work is licensed under the terms of the GNU GPL, version 2 or later.
11 * See the COPYING file in the top-level directory.
15 /* Interface with HAX kernel module */
17 #ifndef _HAX_INTERFACE_H
18 #define _HAX_INTERFACE_H
20 /* fx_layout has 3 formats table 3-56, 512bytes */
49 } __attribute__ ((aligned(8)));
54 } __attribute__ ((__packed__));
57 * Fixed array is not good, but it makes Mac support a bit easier by avoiding
58 * memory map or copyin staff.
60 #define HAX_MAX_MSR_ARRAY 0x20
65 struct vmx_msr entries[HAX_MAX_MSR_ARRAY];
66 } __attribute__ ((__packed__));
68 union interruptibility_state_t {
71 uint32_t sti_blocking:1;
72 uint32_t movss_blocking:1;
73 uint32_t smi_blocking:1;
74 uint32_t nmi_blocking:1;
80 typedef union interruptibility_state_t interruptibility_state_t;
82 /* Segment descriptor */
83 struct segment_desc_t {
97 uint32_t operand_size:1;
98 uint32_t granularity:1;
107 typedef struct segment_desc_t segment_desc_t;
109 struct vcpu_state_t {
214 uint32_t _sysenter_cs;
215 uint64_t _sysenter_eip;
216 uint64_t _sysenter_esp;
218 uint32_t _activity_state;
220 interruptibility_state_t _interruptibility_state;
223 /* HAX exit status */
225 /* IO port request */
227 /* MMIO instruction emulation */
229 /* QEMU emulation mode request, currently means guest enter non-PG mode */
232 * Interrupt window open, qemu can inject interrupt now
233 * Also used when signal pending since at that time qemu usually need
237 /* Unknown vmexit, mostly trigger reboot */
238 HAX_EXIT_UNKNOWN_VMEXIT,
239 /* HALT from guest */
241 /* Reboot request, like because of tripple fault in guest */
242 HAX_EXIT_STATECHANGE,
243 /* the vcpu is now only paused when destroy, so simply return to hax */
249 * The interface definition:
250 * 1. vcpu_run execute will return 0 on success, otherwise mean failed
251 * 2. exit_status return the exit reason, as stated in enum exit_status
252 * 3. exit_reason is the vmx exit reason
255 uint32_t _exit_reason;
257 uint32_t _exit_status;
258 uint32_t user_event_pending;
259 int ready_for_interrupt_injection;
260 int request_interrupt_window;
263 /* 0: read, 1: write */
264 #define HAX_EXIT_IO_IN 1
265 #define HAX_EXIT_IO_OUT 0
283 } __attribute__ ((__packed__));
285 struct hax_module_version {
286 uint32_t compat_version;
287 uint32_t cur_version;
288 } __attribute__ ((__packed__));
290 /* This interface is support only after API version 2 */
291 struct hax_qemu_version {
292 /* Current API version in QEMU */
293 uint32_t cur_version;
294 /* The minimum API version supported by QEMU */
295 uint32_t min_version;
296 } __attribute__ ((__packed__));
298 /* The mac specfic interface to qemu, mostly is ioctl related */
299 struct hax_tunnel_info {
304 } __attribute__ ((__packed__));
306 struct hax_alloc_ram_info {
310 } __attribute__ ((__packed__));
311 #define HAX_RAM_INFO_ROM 0x01 /* Read-Only */
312 #define HAX_RAM_INFO_INVALID 0x80 /* Unmapped, usually used for MMIO */
313 struct hax_set_ram_info {
319 } __attribute__ ((__packed__));
321 #define HAX_CAP_STATUS_WORKING 0x1
322 #define HAX_CAP_STATUS_NOTWORKING 0x0
323 #define HAX_CAP_WORKSTATUS_MASK 0x1
325 #define HAX_CAP_FAILREASON_VT 0x1
326 #define HAX_CAP_FAILREASON_NX 0x2
328 #define HAX_CAP_MEMQUOTA 0x2
329 #define HAX_CAP_UG 0x4
331 struct hax_capabilityinfo {
332 /* bit 0: 1 - working
333 * 0 - not working, possibly because NT/NX disabled
334 * bit 1: 1 - memory limitation working
335 * 0 - no memory limitation
338 /* valid when not working
339 * bit 0: VT not enabeld
340 * bit 1: NX not enabled*/
344 } __attribute__ ((__packed__));
346 struct hax_fastmmio {
350 uint64_t gpa2; /* since HAX API v4 */
360 } __attribute__ ((__packed__));