diff --git a/include/hax_interface.h b/include/hax_interface.h index f07e6f65..1df706de 100644 --- a/include/hax_interface.h +++ b/include/hax_interface.h @@ -120,40 +120,36 @@ * - HAX_IOCTL_EXTENSION (0x80) Extension-specific ioctl. * - type: User argument type. */ -#define HAX_IOCTL_VERSION \ - HAX_IOCTL(HAX_IOWR, 0x00, struct hax_module_version) +#define HAX_IOCTL_GET_API_VERSION \ + HAX_IOCTL(HAX_IOR, 0x00, struct hax_module_version) #define HAX_IOCTL_CREATE_VM \ - HAX_IOCTL(HAX_IOWR, 0x01, uint32_t) + HAX_IOCTL(HAX_IOR, 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) -#define HAX_VM_IOCTL_VCPU_CREATE \ - HAX_IOCTL(HAX_IOWR, 0x00, uint32_t) -#define HAX_VM_IOCTL_ALLOC_RAM \ - HAX_IOCTL(HAX_IOWR, 0x01, struct hax_alloc_ram_info) +#define HAX_VM_IOCTL_CREATE_VCPU \ + HAX_IOCTL(HAX_IOW, 0x00, uint32_t) +#define HAX_VM_IOCTL_DESTROY_VCPU \ + HAX_IOCTL(HAX_IOW, 0x01, uint32_t) #define HAX_VM_IOCTL_SET_RAM \ - HAX_IOCTL(HAX_IOWR, 0x02, struct hax_set_ram_info) -#define HAX_VM_IOCTL_VCPU_DESTROY \ - HAX_IOCTL(HAX_IOR, 0x03, uint32_t) + HAX_IOCTL(HAX_IOW, 0x02, struct hax_set_ram_info) #define HAX_VM_IOCTL_ADD_RAMBLOCK \ - HAX_IOCTL(HAX_IOW, 0x04, struct hax_ramblock_info) + HAX_IOCTL(HAX_IOW, 0x03, struct hax_ramblock_info) #define HAX_VM_IOCTL_SET_RAM2 \ - HAX_IOCTL(HAX_IOWR, 0x05, struct hax_set_ram_info2) + HAX_IOCTL(HAX_IOW, 0x04, struct hax_set_ram_info2) #define HAX_VM_IOCTL_PROTECT_RAM \ - HAX_IOCTL(HAX_IOWR, 0x06, struct hax_protect_ram_info) + HAX_IOCTL(HAX_IOW, 0x05, struct hax_protect_ram_info) #define HAX_VCPU_IOCTL_RUN \ HAX_IOCTL(HAX_IO, 0x00, HAX_UNUSED) #define HAX_VCPU_IOCTL_SETUP_TUNNEL \ - HAX_IOCTL(HAX_IOWR, 0x01, struct hax_tunnel_info) + HAX_IOCTL(HAX_IOR, 0x01, struct hax_tunnel_info) #define HAX_VCPU_IOCTL_GET_REGS \ - HAX_IOCTL(HAX_IOWR, 0x02, struct vcpu_state_t) + HAX_IOCTL(HAX_IOR, 0x02, struct vcpu_state_t) #define HAX_VCPU_IOCTL_SET_REGS \ - HAX_IOCTL(HAX_IOWR, 0x03, struct vcpu_state_t) + HAX_IOCTL(HAX_IOW, 0x03, struct vcpu_state_t) #define HAX_VCPU_IOCTL_GET_FPU \ HAX_IOCTL(HAX_IOR, 0x04, struct fx_layout) #define HAX_VCPU_IOCTL_SET_FPU \ @@ -161,9 +157,9 @@ #define HAX_VCPU_IOCTL_GET_MSRS \ HAX_IOCTL(HAX_IOWR, 0x06, struct hax_msr_data) #define HAX_VCPU_IOCTL_SET_MSRS \ - HAX_IOCTL(HAX_IOWR, 0x07, struct hax_msr_data) + HAX_IOCTL(HAX_IOW, 0x07, struct hax_msr_data) #define HAX_VCPU_IOCTL_INTERRUPT \ - HAX_IOCTL(HAX_IOWR, 0x08, uint32_t) + HAX_IOCTL(HAX_IOW, 0x08, uint32_t) #define HAX_VCPU_IOCTL_DEBUG \ HAX_IOCTL(HAX_IOW, 0x09, struct hax_debug_t) diff --git a/include/windows/hax_interface_windows.h b/include/windows/hax_interface_windows.h index eb251b34..2419f6d8 100644 --- a/include/windows/hax_interface_windows.h +++ b/include/windows/hax_interface_windows.h @@ -33,10 +33,19 @@ #define HAX_DEVICE_TYPE 0x8000 +#define HAX_IO \ + (FILE_ANY_ACCESS) +#define HAX_IOR \ + (FILE_READ_DATA) +#define HAX_IOW \ + (FILE_WRITE_DATA) +#define HAX_IOWR \ + (FILE_WRITE_DATA | FILE_READ_DATA) + #define HAX_LEGACY_IOCTL(access, code_posix, code_windows, type) \ - CTL_CODE(0x4000, code, METHOD_BUFFERED, FILE_ANY_ACCESS) + CTL_CODE(0x4000, code_windows, METHOD_BUFFERED, FILE_ANY_ACCESS) #define HAX_IOCTL(access, code, type) \ - CTL_CODE(HAX_DEVICE_TYPE, (0x800 | code), METHOD_BUFFERED, FILE_ANY_ACCESS) + CTL_CODE(HAX_DEVICE_TYPE, (0x800 | code), METHOD_BUFFERED, access) /* * This is for MAC compatible mode, so should not be used diff --git a/platforms/darwin/com_intel_hax_ui.c b/platforms/darwin/com_intel_hax_ui.c index b95d0c5a..6486fd05 100644 --- a/platforms/darwin/com_intel_hax_ui.c +++ b/platforms/darwin/com_intel_hax_ui.c @@ -391,8 +391,7 @@ static int hax_vm_ioctl(dev_t dev, ulong cmd, caddr_t data, int flag, } break; } - case HAX_VM_IOCTL_ALLOC_RAM__LEGACY: - case HAX_VM_IOCTL_ALLOC_RAM: { + case HAX_VM_IOCTL_ALLOC_RAM__LEGACY: { struct hax_alloc_ram_info *info; info = (struct hax_alloc_ram_info *)data; hax_info("IOCTL_ALLOC_RAM: vm_id=%d, va=0x%llx, size=0x%x," @@ -525,7 +524,7 @@ static int hax_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, switch (cmd) { case HAX_IOCTL_VERSION__LEGACY: - case HAX_IOCTL_VERSION: { + case HAX_IOCTL_GET_API_VERSION: { struct hax_module_version *version; version = (struct hax_module_version *)data; version->cur_version = HAX_CUR_VERSION; @@ -539,8 +538,7 @@ static int hax_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, hax_get_capability(capab, sizeof(struct hax_capabilityinfo), NULL); break; } - case HAX_IOCTL_SET_MEMLIMIT__LEGACY: - case HAX_IOCTL_SET_MEMLIMIT: { + case HAX_IOCTL_SET_MEMLIMIT__LEGACY: { struct hax_set_memlimit *memlimit; memlimit = (struct hax_set_memlimit*)data; ret = hax_set_memlimit(memlimit, sizeof(struct hax_set_memlimit), diff --git a/platforms/linux/components.c b/platforms/linux/components.c index 65012086..54898930 100644 --- a/platforms/linux/components.c +++ b/platforms/linux/components.c @@ -538,8 +538,7 @@ static long hax_vm_ioctl(struct file *filp, unsigned int cmd, } break; } - case HAX_VM_IOCTL_ALLOC_RAM__LEGACY: - case HAX_VM_IOCTL_ALLOC_RAM: { + case HAX_VM_IOCTL_ALLOC_RAM__LEGACY: { struct hax_alloc_ram_info info; if (copy_from_user(&info, argp, sizeof(info))) { ret = -EFAULT; diff --git a/platforms/linux/hax_entry.c b/platforms/linux/hax_entry.c index 67b36bd9..433e12f4 100644 --- a/platforms/linux/hax_entry.c +++ b/platforms/linux/hax_entry.c @@ -70,7 +70,7 @@ static long hax_dev_ioctl(struct file *filp, unsigned int cmd, switch (cmd) { case HAX_IOCTL_VERSION__LEGACY: - case HAX_IOCTL_VERSION: { + case HAX_IOCTL_GET_API_VERSION: { struct hax_module_version version = {}; version.cur_version = HAX_CUR_VERSION; version.compat_version = HAX_COMPAT_VERSION; @@ -86,8 +86,7 @@ static long hax_dev_ioctl(struct file *filp, unsigned int cmd, return -EFAULT; break; } - case HAX_IOCTL_SET_MEMLIMIT__LEGACY: - case HAX_IOCTL_SET_MEMLIMIT: { + case HAX_IOCTL_SET_MEMLIMIT__LEGACY: { struct hax_set_memlimit memlimit = {}; if (copy_from_user(&memlimit, argp, sizeof(memlimit))) return -EFAULT; diff --git a/platforms/windows/hax_entry.c b/platforms/windows/hax_entry.c index 96c0267b..af4b840c 100644 --- a/platforms/windows/hax_entry.c +++ b/platforms/windows/hax_entry.c @@ -484,7 +484,7 @@ NTSTATUS HaxVmControl(PDEVICE_OBJECT DeviceObject, struct hax_vm_windows *ext, switch (irpSp->Parameters.DeviceIoControl.IoControlCode) { case HAX_VM_IOCTL_VCPU_CREATE__LEGACY: - case HAX_VM_IOCTL_VCPU_CREATE: { + case HAX_VM_IOCTL_CREATE_VCPU: { if (inBufLength < sizeof(uint32_t)) { ret = STATUS_INVALID_PARAMETER; goto done; @@ -500,8 +500,7 @@ NTSTATUS HaxVmControl(PDEVICE_OBJECT DeviceObject, struct hax_vm_windows *ext, ret = STATUS_SUCCESS; break; } - case HAX_VM_IOCTL_ALLOC_RAM__LEGACY: - case HAX_VM_IOCTL_ALLOC_RAM: { + case HAX_VM_IOCTL_ALLOC_RAM__LEGACY: { struct hax_alloc_ram_info *info; if (inBufLength < sizeof(struct hax_alloc_ram_info)) { ret = STATUS_INVALID_PARAMETER; @@ -651,7 +650,7 @@ NTSTATUS HaxDeviceControl(PDEVICE_OBJECT DeviceObject, switch (irpSp->Parameters.DeviceIoControl.IoControlCode) { case HAX_IOCTL_VERSION__LEGACY: - case HAX_IOCTL_VERSION: + case HAX_IOCTL_GET_API_VERSION: if (outBufLength < sizeof(struct hax_module_version)) { ret = STATUS_INVALID_PARAMETER; goto done; @@ -679,7 +678,6 @@ NTSTATUS HaxDeviceControl(PDEVICE_OBJECT DeviceObject, break; case HAX_IOCTL_SET_MEMLIMIT__LEGACY: - case HAX_IOCTL_SET_MEMLIMIT: if (inBufLength < sizeof(struct hax_set_memlimit)) { ret = STATUS_INVALID_PARAMETER; goto done;