Skip to content
This repository was archived by the owner on Jan 28, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion core/include/hax_core_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions core/include/vcpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
1 change: 0 additions & 1 deletion core/include/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions core/vcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions core/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion include/hax.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
// declaration
struct vcpu_t;

#define HAX_CUR_VERSION 0x0005
#define HAX_CUR_VERSION 0x0004
#define HAX_COMPAT_VERSION 0x0001

/* TBD */
Expand Down
2 changes: 0 additions & 2 deletions include/vcpu_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions platforms/linux/components.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions platforms/windows/hax_entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -398,15 +398,15 @@ 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;

}
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: {
Expand Down