4 * Copyright (c) 2011 Intel Corporation
6 * Jiang Yunhong<yunhong.jiang@intel.com>
7 * Xin Xiaohui<xiaohui.xin@intel.com>
8 * Zhang Xiantao<xiantao.zhang@intel.com>
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__
));
312 struct hax_ramblock_info
{
316 } __attribute__ ((__packed__
));
318 #define HAX_RAM_INFO_ROM 0x01 /* Read-Only */
319 #define HAX_RAM_INFO_INVALID 0x80 /* Unmapped, usually used for MMIO */
320 struct hax_set_ram_info
{
326 } __attribute__ ((__packed__
));
328 #define HAX_CAP_STATUS_WORKING 0x1
329 #define HAX_CAP_STATUS_NOTWORKING 0x0
330 #define HAX_CAP_WORKSTATUS_MASK 0x1
332 #define HAX_CAP_FAILREASON_VT 0x1
333 #define HAX_CAP_FAILREASON_NX 0x2
335 #define HAX_CAP_MEMQUOTA 0x2
336 #define HAX_CAP_UG 0x4
337 #define HAX_CAP_64BIT_RAMBLOCK 0x8
339 struct hax_capabilityinfo
{
340 /* bit 0: 1 - working
341 * 0 - not working, possibly because NT/NX disabled
342 * bit 1: 1 - memory limitation working
343 * 0 - no memory limitation
346 /* valid when not working
347 * bit 0: VT not enabeld
348 * bit 1: NX not enabled*/
352 } __attribute__ ((__packed__
));
354 struct hax_fastmmio
{
358 uint64_t gpa2
; /* since HAX API v4 */
368 } __attribute__ ((__packed__
));