From ed3316206485d1f91665b2613e34e06175e3b5ad Mon Sep 17 00:00:00 2001 From: Wenchao Wang Date: Tue, 24 Mar 2020 10:19:47 +0800 Subject: [PATCH] Revert "Add cr8 to hax ioctl interface" This reverts commit 329dc40a7b222288371b771a7c606a15c06302df. --- core/include/hax_core_interface.h | 1 - core/include/vcpu.h | 2 -- core/include/vm.h | 1 - core/vcpu.c | 13 ------------- core/vm.c | 3 --- include/hax.h | 2 +- include/vcpu_state.h | 2 -- platforms/linux/components.c | 6 ++---- platforms/windows/hax_entry.c | 6 +++--- 9 files changed, 6 insertions(+), 30 deletions(-) diff --git a/core/include/hax_core_interface.h b/core/include/hax_core_interface.h index f764ae3c..0ad425d7 100644 --- a/core/include/hax_core_interface.h +++ b/core/include/hax_core_interface.h @@ -45,7 +45,6 @@ int vcpu_put_fpu(struct vcpu_t *vcpu, struct fx_layout *fl); int vcpu_get_fpu(struct vcpu_t *vcpu, struct fx_layout *fl); int vcpu_set_regs(struct vcpu_t *vcpu, struct vcpu_state_t *vs); int vcpu_get_regs(struct vcpu_t *vcpu, struct vcpu_state_t *vs); -int vcpu_get_state_size(struct vcpu_t *vcpu); void vcpu_debug(struct vcpu_t *vcpu, struct hax_debug_t *debug); void * get_vcpu_host(struct vcpu_t *vcpu); diff --git a/core/include/vcpu.h b/core/include/vcpu.h index dcaa07c6..33bb326d 100644 --- a/core/include/vcpu.h +++ b/core/include/vcpu.h @@ -171,7 +171,6 @@ struct vcpu_t { struct vm_t *vm; struct hax_mmu *mmu; struct vcpu_state_t *state; - uint64_t _cr8; struct hax_tunnel *tunnel; uint8_t *io_buf; struct hax_page *vmcs_page; @@ -259,7 +258,6 @@ int vcpu_get_fpu(struct vcpu_t *vcpu, struct fx_layout *fl); int vcpu_put_fpu(struct vcpu_t *vcpu, struct fx_layout *fl); int vcpu_get_msr(struct vcpu_t *vcpu, uint64_t entry, uint64_t *val); int vcpu_put_msr(struct vcpu_t *vcpu, uint64_t entry, uint64_t val); -int vcpu_get_state_size(struct vcpu_t *vcpu); void vcpu_debug(struct vcpu_t *vcpu, struct hax_debug_t *debug); /* The declaration for OS wrapper code */ diff --git a/core/include/vm.h b/core/include/vm.h index a4178178..36a831c8 100644 --- a/core/include/vm.h +++ b/core/include/vm.h @@ -60,7 +60,6 @@ struct vm_t { uint64_t flags; #define VM_FEATURES_FASTMMIO_BASIC 0x1 #define VM_FEATURES_FASTMMIO_EXTRA 0x2 -#define VM_FEATURES_CR8 0x4 uint32_t features; int vm_id; #define VPID_SEED_BITS 64 diff --git a/core/vcpu.c b/core/vcpu.c index cac000fc..1556d943 100644 --- a/core/vcpu.c +++ b/core/vcpu.c @@ -3940,13 +3940,6 @@ static int _copy_desc(segment_desc_t *old, segment_desc_t *new) return flags; } -int vcpu_get_state_size(struct vcpu_t *vcpu) -{ - if (vcpu->vm->features & VM_FEATURES_CR8) - return sizeof(struct vcpu_state_t); - return offsetof(struct vcpu_state_t, _cr8); -} - int vcpu_get_regs(struct vcpu_t *vcpu, struct vcpu_state_t *ustate) { struct vcpu_state_t *state = vcpu->state; @@ -3982,9 +3975,6 @@ int vcpu_get_regs(struct vcpu_t *vcpu, struct vcpu_state_t *ustate) _copy_desc(&state->_gdt, &ustate->_gdt); _copy_desc(&state->_idt, &ustate->_idt); - if (vcpu->vm->features & VM_FEATURES_CR8) - ustate->_cr8 = state->_cr8; - return 0; } @@ -4110,9 +4100,6 @@ int vcpu_set_regs(struct vcpu_t *vcpu, struct vcpu_state_t *ustate) VMWRITE_DESC(vcpu, IDTR, state->_idt); } - if (vcpu->vm->features & VM_FEATURES_CR8) - state->_cr8 = ustate->_cr8; - if ((vmcs_err = put_vmcs(vcpu, &flags))) { vcpu_set_panic(vcpu); hax_log(HAX_LOGPANIC, "put_vmcs failed on vcpu_set_regs: %x\n", diff --git a/core/vm.c b/core/vm.c index 31d0ad5f..979f4b84 100644 --- a/core/vm.c +++ b/core/vm.c @@ -73,9 +73,6 @@ int hax_vm_set_qemuversion(struct vm_t *vm, struct hax_qemu_version *ver) vm->features |= VM_FEATURES_FASTMMIO_BASIC; if (ver->cur_version >= 0x4) { vm->features |= VM_FEATURES_FASTMMIO_EXTRA; - if (ver->cur_version >= 0x5) { - vm->features |= VM_FEATURES_CR8; - } } } return 0; diff --git a/include/hax.h b/include/hax.h index d5d41739..c82863b0 100644 --- a/include/hax.h +++ b/include/hax.h @@ -39,7 +39,7 @@ // declaration struct vcpu_t; -#define HAX_CUR_VERSION 0x0005 +#define HAX_CUR_VERSION 0x0004 #define HAX_COMPAT_VERSION 0x0001 /* TBD */ diff --git a/include/vcpu_state.h b/include/vcpu_state.h index ea59112c..e4507066 100644 --- a/include/vcpu_state.h +++ b/include/vcpu_state.h @@ -188,8 +188,6 @@ struct vcpu_state_t { uint32_t _activity_state; uint32_t pad; interruptibility_state_t _interruptibility_state; - - uint64_t _cr8; } PACKED; void dump(void); diff --git a/platforms/linux/components.c b/platforms/linux/components.c index 1560f4f3..0f4140b9 100644 --- a/platforms/linux/components.c +++ b/platforms/linux/components.c @@ -411,8 +411,7 @@ static long hax_vcpu_ioctl(struct file *filp, unsigned int cmd, } case HAX_VCPU_SET_REGS: { struct vcpu_state_t vc_state; - int size = vcpu_get_state_size(cvcpu); - if (copy_from_user(&vc_state, argp, size)) { + if (copy_from_user(&vc_state, argp, sizeof(vc_state))) { ret = -EFAULT; break; } @@ -421,9 +420,8 @@ static long hax_vcpu_ioctl(struct file *filp, unsigned int cmd, } case HAX_VCPU_GET_REGS: { struct vcpu_state_t vc_state; - int size = vcpu_get_state_size(cvcpu); ret = vcpu_get_regs(cvcpu, &vc_state); - if (copy_to_user(argp, &vc_state, size)) { + if (copy_to_user(argp, &vc_state, sizeof(vc_state))) { ret = -EFAULT; break; } diff --git a/platforms/windows/hax_entry.c b/platforms/windows/hax_entry.c index 4dc7c306..2d184b6b 100644 --- a/platforms/windows/hax_entry.c +++ b/platforms/windows/hax_entry.c @@ -387,7 +387,7 @@ NTSTATUS HaxVcpuControl(PDEVICE_OBJECT DeviceObject, } case HAX_VCPU_SET_REGS: { struct vcpu_state_t *vc_state; - if (inBufLength < vcpu_get_state_size(cvcpu)) { + if(inBufLength < sizeof(struct vcpu_state_t)) { ret = STATUS_INVALID_PARAMETER; goto done; } @@ -398,8 +398,7 @@ NTSTATUS HaxVcpuControl(PDEVICE_OBJECT DeviceObject, } case HAX_VCPU_GET_REGS: { struct vcpu_state_t *vc_state; - infret = vcpu_get_state_size(cvcpu); - if (outBufLength < infret) { + if(outBufLength < sizeof(struct vcpu_state_t)) { ret = STATUS_INVALID_PARAMETER; goto done; @@ -407,6 +406,7 @@ NTSTATUS HaxVcpuControl(PDEVICE_OBJECT DeviceObject, vc_state = (struct vcpu_state_t *)outBuf; // vcpu_get_regs() cannot fail vcpu_get_regs(cvcpu, vc_state); + infret = sizeof(struct vcpu_state_t); break; } case HAX_VCPU_IOCTL_INTERRUPT: {