Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

Commit

Permalink
Unified IOCTL definitions
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandro Sanchez Bach <[email protected]>
  • Loading branch information
AlexAltea committed Nov 8, 2018
1 parent 6bebba6 commit 4fd6614
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 128 deletions.
47 changes: 11 additions & 36 deletions include/darwin/hax_interface_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,42 +33,17 @@

#include <mach/mach_types.h>

/* The mac specific interface to qemu because of mac's
* special handling like hax tunnel allocation etc */
/* HAX model level ioctl */
#define HAX_IOCTL_VERSION _IOWR(0, 0x20, struct hax_module_version)
#define HAX_IOCTL_CREATE_VM _IOWR(0, 0x21, uint32_t)
#define HAX_IOCTL_DESTROY_VM _IOW(0, 0x22, uint32_t)
#define HAX_IOCTL_CAPABILITY _IOR(0, 0x23, struct hax_capabilityinfo)
#define HAX_IOCTL_SET_MEMLIMIT _IOWR(0, 0x24, struct hax_set_memlimit)

// Only for backward compatibility with old Qemu.
#define HAX_VM_IOCTL_VCPU_CREATE_ORIG _IOR(0, 0x80, int)

#define HAX_VM_IOCTL_VCPU_CREATE _IOWR(0, 0x80, uint32_t)
#define HAX_VM_IOCTL_ALLOC_RAM _IOWR(0, 0x81, struct hax_alloc_ram_info)
#define HAX_VM_IOCTL_SET_RAM _IOWR(0, 0x82, struct hax_set_ram_info)
#define HAX_VM_IOCTL_VCPU_DESTROY _IOR(0, 0x83, uint32_t)
#define HAX_VM_IOCTL_ADD_RAMBLOCK _IOW(0, 0x85, struct hax_ramblock_info)
#define HAX_VM_IOCTL_SET_RAM2 _IOWR(0, 0x86, struct hax_set_ram_info2)
#define HAX_VM_IOCTL_PROTECT_RAM _IOWR(0, 0x87, struct hax_protect_ram_info)

#define HAX_VCPU_IOCTL_RUN _IO(0, 0xc0)
#define HAX_VCPU_IOCTL_SET_MSRS _IOWR(0, 0xc1, struct hax_msr_data)
#define HAX_VCPU_IOCTL_GET_MSRS _IOWR(0, 0xc2, struct hax_msr_data)

#define HAX_VCPU_IOCTL_SET_FPU _IOW(0, 0xc3, struct fx_layout)
#define HAX_VCPU_IOCTL_GET_FPU _IOR(0, 0xc4, struct fx_layout)

#define HAX_VCPU_IOCTL_SETUP_TUNNEL _IOWR(0, 0xc5, struct hax_tunnel_info)
#define HAX_VCPU_IOCTL_INTERRUPT _IOWR(0, 0xc6, uint32_t)
#define HAX_VCPU_IOCTL_SET_REGS _IOWR(0, 0xc7, struct vcpu_state_t)
#define HAX_VCPU_IOCTL_GET_REGS _IOWR(0, 0xc8, struct vcpu_state_t)

/* API 2.0 */
#define HAX_VM_IOCTL_NOTIFY_QEMU_VERSION _IOW(0, 0x84, struct hax_qemu_version)

#define HAX_VCPU_IOCTL_DEBUG _IOW(0, 0xc9, struct hax_debug_t)
#define HAX_IOCTL_HAX_IO(access, code, type) \
_IO(0, code)
#define HAX_IOCTL_HAX_IOR(access, code, type) \
_IOR(0, code, type)
#define HAX_IOCTL_HAX_IOW(access, code, type) \
_IOW(0, code, type)
#define HAX_IOCTL_HAX_IOWR(access, code, type) \
_IOWR(0, code, type)

#define HAX_IOCTL(access, code, type) \
HAX_IOCTL_##access(0, code, type)

#define HAX_KERNEL64_CS 0x80
#define HAX_KERNEL32_CS 0x08
Expand Down
60 changes: 60 additions & 0 deletions include/hax_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,66 @@
#include "windows/hax_interface_windows.h"
#endif

#define HAX_IOCTL_VERSION \
HAX_IOCTL(HAX_IOWR, 0x00, struct hax_module_version)
#define HAX_IOCTL_CREATE_VM \
HAX_IOCTL(HAX_IOWR, 0x01, uint32_t)
#define HAX_IOCTL_DESTROY_VM \
HAX_IOCTL(HAX_IOW, 0x02, uint32_t)
#define HAX_IOCTL_CAPABILITY \
HAX_IOCTL(HAX_IOR, 0x03, struct hax_capabilityinfo)
#define HAX_IOCTL_SET_MEMLIMIT \
HAX_IOCTL(HAX_IOWR, 0x04, struct hax_set_memlimit)

// Only for backward compatibility with old Qemu.
#define HAX_VM_IOCTL_VCPU_CREATE_ORIG \
HAX_IOCTL(HAX_IOR, 0x40, int)

#define HAX_VM_IOCTL_VCPU_CREATE \
HAX_IOCTL(HAX_IOWR, 0x40, uint32_t)
#define HAX_VM_IOCTL_ALLOC_RAM \
HAX_IOCTL(HAX_IOWR, 0x41, struct hax_alloc_ram_info)
#define HAX_VM_IOCTL_SET_RAM \
HAX_IOCTL(HAX_IOWR, 0x42, struct hax_set_ram_info)
#define HAX_VM_IOCTL_VCPU_DESTROY \
HAX_IOCTL(HAX_IOR, 0x43, uint32_t)
#define HAX_VM_IOCTL_ADD_RAMBLOCK \
HAX_IOCTL(HAX_IOW, 0x45, struct hax_ramblock_info)
#define HAX_VM_IOCTL_SET_RAM2 \
HAX_IOCTL(HAX_IOWR, 0x46, struct hax_set_ram_info2)
#define HAX_VM_IOCTL_PROTECT_RAM \
HAX_IOCTL(HAX_IOWR, 0x47, struct hax_protect_ram_info)

#define HAX_VCPU_IOCTL_RUN \
HAX_IOCTL(HAX_IO, 0x80, void*)
#define HAX_VCPU_IOCTL_SET_MSRS \
HAX_IOCTL(HAX_IOWR, 0x81, struct hax_msr_data)
#define HAX_VCPU_IOCTL_GET_MSRS \
HAX_IOCTL(HAX_IOWR, 0x82, struct hax_msr_data)

#define HAX_VCPU_IOCTL_SET_FPU \
HAX_IOCTL(HAX_IOW, 0x83, struct fx_layout)
#define HAX_VCPU_IOCTL_GET_FPU \
HAX_IOCTL(HAX_IOR, 0x84, struct fx_layout)

#define HAX_VCPU_IOCTL_SETUP_TUNNEL \
HAX_IOCTL(HAX_IOWR, 0x85, struct hax_tunnel_info)
#define HAX_VCPU_IOCTL_INTERRUPT \
HAX_IOCTL(HAX_IOWR, 0x86, uint32_t)
#define HAX_VCPU_IOCTL_SET_REGS \
HAX_IOCTL(HAX_IOWR, 0x87, struct vcpu_state_t)
#define HAX_VCPU_IOCTL_GET_REGS \
HAX_IOCTL(HAX_IOWR, 0x88, struct vcpu_state_t)
#define HAX_VCPU_IOCTL_KICKOFF \
HAX_IOCTL(HAX_IO, 0x89, void*)

/* API 2.0 */
#define HAX_VM_IOCTL_NOTIFY_QEMU_VERSION \
HAX_IOCTL(HAX_IOW, 0x48, struct hax_qemu_version)

#define HAX_VCPU_IOCTL_DEBUG \
HAX_IOCTL(HAX_IOW, 0x90, struct hax_debug_t)

#include "vcpu_state.h"

struct vmx_msr {
Expand Down
47 changes: 11 additions & 36 deletions include/linux/hax_interface_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,42 +34,17 @@

#include <asm/ioctl.h>

/* The mac specific interface to qemu because of mac's
* special handling like hax tunnel allocation etc */
/* HAX model level ioctl */
#define HAX_IOCTL_VERSION _IOWR(0, 0x20, struct hax_module_version)
#define HAX_IOCTL_CREATE_VM _IOWR(0, 0x21, uint32_t)
#define HAX_IOCTL_DESTROY_VM _IOW(0, 0x22, uint32_t)
#define HAX_IOCTL_CAPABILITY _IOR(0, 0x23, struct hax_capabilityinfo)
#define HAX_IOCTL_SET_MEMLIMIT _IOWR(0, 0x24, struct hax_set_memlimit)

// Only for backward compatibility with old Qemu.
#define HAX_VM_IOCTL_VCPU_CREATE_ORIG _IOR(0, 0x80, int)

#define HAX_VM_IOCTL_VCPU_CREATE _IOWR(0, 0x80, uint32_t)
#define HAX_VM_IOCTL_ALLOC_RAM _IOWR(0, 0x81, struct hax_alloc_ram_info)
#define HAX_VM_IOCTL_SET_RAM _IOWR(0, 0x82, struct hax_set_ram_info)
#define HAX_VM_IOCTL_VCPU_DESTROY _IOR(0, 0x83, uint32_t)
#define HAX_VM_IOCTL_ADD_RAMBLOCK _IOW(0, 0x85, struct hax_ramblock_info)
#define HAX_VM_IOCTL_SET_RAM2 _IOWR(0, 0x86, struct hax_set_ram_info2)
#define HAX_VM_IOCTL_PROTECT_RAM _IOWR(0, 0x87, struct hax_protect_ram_info)

#define HAX_VCPU_IOCTL_RUN _IO(0, 0xc0)
#define HAX_VCPU_IOCTL_SET_MSRS _IOWR(0, 0xc1, struct hax_msr_data)
#define HAX_VCPU_IOCTL_GET_MSRS _IOWR(0, 0xc2, struct hax_msr_data)

#define HAX_VCPU_IOCTL_SET_FPU _IOW(0, 0xc3, struct fx_layout)
#define HAX_VCPU_IOCTL_GET_FPU _IOR(0, 0xc4, struct fx_layout)

#define HAX_VCPU_IOCTL_SETUP_TUNNEL _IOWR(0, 0xc5, struct hax_tunnel_info)
#define HAX_VCPU_IOCTL_INTERRUPT _IOWR(0, 0xc6, uint32_t)
#define HAX_VCPU_IOCTL_SET_REGS _IOWR(0, 0xc7, struct vcpu_state_t)
#define HAX_VCPU_IOCTL_GET_REGS _IOWR(0, 0xc8, struct vcpu_state_t)

/* API 2.0 */
#define HAX_VM_IOCTL_NOTIFY_QEMU_VERSION _IOW(0, 0x84, struct hax_qemu_version)

#define HAX_VCPU_IOCTL_DEBUG _IOW(0, 0xc9, struct hax_debug_t)
#define HAX_IOCTL_HAX_IO(access, code, type) \
_IO(0, code)
#define HAX_IOCTL_HAX_IOR(access, code, type) \
_IOR(0, code, type)
#define HAX_IOCTL_HAX_IOW(access, code, type) \
_IOW(0, code, type)
#define HAX_IOCTL_HAX_IOWR(access, code, type) \
_IOWR(0, code, type)

#define HAX_IOCTL(access, code, type) \
HAX_IOCTL_##access(0, code, type)

#define HAX_KERNEL64_CS 0x80
#define HAX_KERNEL32_CS 0x08
Expand Down
5 changes: 5 additions & 0 deletions include/windows/hax_interface_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
#ifndef HAX_WINDOWS_HAX_INTERFACE_WINDOWS_H_
#define HAX_WINDOWS_HAX_INTERFACE_WINDOWS_H_

#define HAX_DEVICE_TYPE 0x4000

#define HAX_IOCTL(access, code, type) \
CTL_CODE(HAX_DEVICE_TYPE, (0x800 | code), METHOD_BUFFERED, FILE_ANY_ACCESS)

/*
* This is for MAC compatible mode, so should not be used
* But how can we make sure it is really not used??
Expand Down
56 changes: 0 additions & 56 deletions platforms/windows/hax_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,60 +110,4 @@ int smpc_dpc_exit(void);

extern PDRIVER_OBJECT HaxDriverObject;

#define HAX_DEVICE_TYPE 0x4000

#define HAX_IOCTL_VERSION \
CTL_CODE(HAX_DEVICE_TYPE, 0x900, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_IOCTL_CREATE_VM \
CTL_CODE(HAX_DEVICE_TYPE, 0x901, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_IOCTL_CAPABILITY \
CTL_CODE(HAX_DEVICE_TYPE, 0x910, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_IOCTL_SET_MEMLIMIT \
CTL_CODE(HAX_DEVICE_TYPE, 0x911, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define HAX_VM_IOCTL_VCPU_CREATE \
CTL_CODE(HAX_DEVICE_TYPE, 0x902, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VM_IOCTL_ALLOC_RAM \
CTL_CODE(HAX_DEVICE_TYPE, 0x903, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VM_IOCTL_SET_RAM \
CTL_CODE(HAX_DEVICE_TYPE, 0x904, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VM_IOCTL_VCPU_DESTROY \
CTL_CODE(HAX_DEVICE_TYPE, 0x905, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VM_IOCTL_ADD_RAMBLOCK \
CTL_CODE(HAX_DEVICE_TYPE, 0x913, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VM_IOCTL_SET_RAM2 \
CTL_CODE(HAX_DEVICE_TYPE, 0x914, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VM_IOCTL_PROTECT_RAM \
CTL_CODE(HAX_DEVICE_TYPE, 0x915, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define HAX_VCPU_IOCTL_RUN \
CTL_CODE(HAX_DEVICE_TYPE, 0x906, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VCPU_IOCTL_SET_MSRS \
CTL_CODE(HAX_DEVICE_TYPE, 0x907, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VCPU_IOCTL_GET_MSRS \
CTL_CODE(HAX_DEVICE_TYPE, 0x908, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define HAX_VCPU_IOCTL_SET_FPU \
CTL_CODE(HAX_DEVICE_TYPE, 0x909, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VCPU_IOCTL_GET_FPU \
CTL_CODE(HAX_DEVICE_TYPE, 0x90a, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define HAX_VCPU_IOCTL_SETUP_TUNNEL \
CTL_CODE(HAX_DEVICE_TYPE, 0x90b, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VCPU_IOCTL_INTERRUPT \
CTL_CODE(HAX_DEVICE_TYPE, 0x90c, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VCPU_IOCTL_SET_REGS \
CTL_CODE(HAX_DEVICE_TYPE, 0x90d, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VCPU_IOCTL_GET_REGS \
CTL_CODE(HAX_DEVICE_TYPE, 0x90e, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define HAX_VCPU_IOCTL_KICKOFF \
CTL_CODE(HAX_DEVICE_TYPE, 0x90f, METHOD_BUFFERED, FILE_ANY_ACCESS)

/* API version 2.0 */
#define HAX_VM_IOCTL_NOTIFY_QEMU_VERSION \
CTL_CODE(HAX_DEVICE_TYPE, 0x910, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define HAX_VCPU_IOCTL_DEBUG \
CTL_CODE(HAX_DEVICE_TYPE, 0x916, METHOD_BUFFERED, FILE_ANY_ACCESS)

#endif // HAX_WINDOWS_HAX_ENTRY_H_

0 comments on commit 4fd6614

Please sign in to comment.