diff --git a/core/cpu.c b/core/cpu.c index 171a0d73..470ad096 100644 --- a/core/cpu.c +++ b/core/cpu.c @@ -34,7 +34,8 @@ #include "include/cpuid.h" #include "include/vcpu.h" #include "include/debug.h" -#include "include/dump_vmcs.h" +#include "include/dump.h" +#include "include/name.h" #include "include/vtlb.h" #include "include/intr.h" #include "include/ept.h" @@ -131,42 +132,23 @@ void cpu_init_vmx(void *arg) /* get VMX capabilities */ vmx_read_info(&vmx_info); #if 0 - //hax_log("-----------cpu %d---------------\n", cpu_data->cpu_id); + //hax_info("-----------cpu %d---------------\n", cpu_data->cpu_id); if ((cpu_data->cpu_id == 0 || memcmp(&vmx_info, &hax_cpu_data[0]->vmx_info, sizeof(vmx_info)) != 0)) { - hax_log("HAX: VMCS Rev %d\n", vmx_info._vmcs_revision_id); - - hax_log("HAX: VMX basic info : %016llx\n", vmx_info._basic_info); - hax_log("HAX: VMX misc info : %08llx\n", vmx_info._miscellaneous); - hax_log("HAX: VMX revision control: %d\n", vmx_info._vmcs_revision_id); - hax_log("HAX: VMX exit ctls : %x, %x\n", vmx_info.exit_ctls_0, - vmx_info.exit_ctls_1); - hax_log("HAX: VMX entry ctls : %x, %x\n", vmx_info.entry_ctls_0, - vmx_info.entry_ctls_1); - hax_log("HAX: VMX pin ctls : %x, %x\n", vmx_info.pin_ctls_0, - vmx_info.pin_ctls_1); - hax_log("HAX: VMX cpu prim ctrls : %x, %x\n", vmx_info.pcpu_ctls_0, - vmx_info.pcpu_ctls_1); - hax_log("HAX: VMX cpu sec ctrl : %x, %x\n", vmx_info.scpu_ctls_0, - vmx_info.scpu_ctls_1); - hax_log("HAX: VMX fixed CR0 bits : %llx, %llx\n", vmx_info._cr0_fixed_0, - vmx_info._cr0_fixed_1); - hax_log("HAX: VMX fixed CR4 bits : %llx, %llx\n", vmx_info._cr4_fixed_0, - vmx_info._cr4_fixed_1); - hax_log("HAX: VMX EPT/VPID caps : %016llx\n", vmx_info._ept_cap); + dump_vmx_info(&vmx_info); } #endif if (vmx_info._vmcs_region_length > HAX_PAGE_SIZE) - hax_log("HAX: VMCS of %d bytes not supported by this Hypervisor. " + hax_info("VMCS of %d bytes not supported by this Hypervisor. " "Max supported %u bytes\n", vmx_info._vmcs_region_length, (uint32_t)HAX_PAGE_SIZE); vmxon = (vmcs_t *)hax_page_va(cpu_data->vmxon_page); vmxon->_revision_id = vmx_info._vmcs_revision_id; - //hax_log("HAX: enabled VMX mode (vmxon = %p)\n", + //hax_info("enabled VMX mode (vmxon = %p)\n", // hax_page_va(cpu_data->vmxon_page)); vmx_read_info(&cpu_data->vmx_info); @@ -282,44 +264,6 @@ static int cpu_vmexit_handler(struct vcpu_t *vcpu, exit_reason_t exit_reason, } return ret; } -/*Remove this function. It only for debug*/ -/*void dump_cs_ds(uint16_t cs, uint16_t ds) -{ - struct system_desc_t desc; - struct seg_desc_t *seg_desc; - - get_kernel_gdt(&desc); - - seg_desc = (struct seg_desc_t *)((mword)desc._base) + (cs >> 3); - - hax_debug("\nsel: %x\n", cs >> 3); - hax_debug("type: %x\n", seg_desc->_type); - hax_debug("s: %x\n", seg_desc->_s); - hax_debug("present: %x\n", seg_desc->_present); - hax_debug("avl: %x\n", seg_desc->_avl); - hax_debug("long: %x\n", seg_desc->_longmode); - hax_debug("d/b: %x\n", seg_desc->_d); - hax_debug("g: %x\n", seg_desc->_granularity); - hax_debug("base0: %x\n", seg_desc->_base0); - hax_debug("limit: %x\n", seg_desc->_limit0); - hax_debug("dpl: %x\n", seg_desc->_limit0); - - hax_debug("raw: %llx\n", seg_desc->_raw); - seg_desc = (struct seg_desc_t *)((mword)desc._base) + (ds >> 3); - - hax_debug("\nsel: %x\n", ds >> 3); - hax_debug("type: %x\n", seg_desc->_type); - hax_debug("s: %x\n", seg_desc->_s); - hax_debug("present: %x\n", seg_desc->_present); - hax_debug("avl: %x\n", seg_desc->_avl); - hax_debug("long: %x\n", seg_desc->_longmode); - hax_debug("d/b: %x\n", seg_desc->_d); - hax_debug("g: %x\n", seg_desc->_granularity); - hax_debug("base0: %x\n", seg_desc->_base0); - hax_debug("limit: %x\n", seg_desc->_limit0); - hax_debug("dpl: %x\n", seg_desc->_dpl); - hax_debug("raw: %llx\n", seg_desc->_raw); -}*/ #ifdef CONFIG_DARWIN __attribute__ ((__noinline__)) @@ -450,7 +394,7 @@ int cpu_vmx_execute(struct vcpu_t *vcpu, struct hax_tunnel *htun) res = cpu_vmx_run(vcpu, htun); if (res) { - hax_debug("cpu_vmx_run error, code:%xlx\n", res); + hax_error("cpu_vmx_run error, code:%x\n", res); if ((vmcs_err = put_vmcs(vcpu, &flags))) { hax_panic_vcpu(vcpu, "put_vmcs fail: %x\n", vmcs_err); hax_panic_log(vcpu); @@ -601,7 +545,7 @@ uint32_t load_vmcs(struct vcpu_t *vcpu, preempt_flag *flags) if (asm_vmptrld(&vmcs_phy) != VMX_SUCCEED) { - hax_error("HAX: vmptrld failed (%08llx)\n", vmcs_phy); + hax_error("vmptrld failed (%08llx)\n", vmcs_phy); cpu_vmxroot_leave(); log_vmxon_err_type3 = 1; hax_enable_preemption(flags); @@ -625,7 +569,7 @@ void restore_host_cr4_vmxe(struct per_cpu_data *cpu_data) if (cpu_data->vmm_flag & VMXON_HAX) { // TODO: Need to understand why this happens (on both Windows and // macOS) - hax_debug("HAX: VMM flag (VMON_HAX) is not clear!\n"); + hax_debug("VMM flag (VMON_HAX) is not clear!\n"); } set_cr4(get_cr4() | CR4_VMXE); } else { @@ -649,7 +593,7 @@ uint32_t put_vmcs(struct vcpu_t *vcpu, preempt_flag *flags) vmcs_phy = hax_page_pa(cpu_data->vmcs_page); if (asm_vmclear(&vmcs_phy) != VMX_SUCCEED) { - hax_error("HAX: vmclear failed (%llx)\n", vmcs_phy); + hax_error("vmclear failed (%llx)\n", vmcs_phy); log_vmclear_err = 1; } @@ -700,22 +644,22 @@ void load_vmcs_common(struct vcpu_t *vcpu) static void cpu_vmentry_failed(struct vcpu_t *vcpu, vmx_result_t result) { - hax_debug("HAX: VM entry failed: result=%x RIP=%08lx\n", - result, (mword)vmread(vcpu, GUEST_RIP)); + uint64_t error, reason; + + hax_error("VM entry failed: RIP=%08lx\n", + (mword)vmread(vcpu, GUEST_RIP)); //dump_vmcs(); + reason = vmread(vcpu, VM_EXIT_INFO_REASON); if (result == VMX_FAIL_VALID) { - hax_log("HAX: Prev exit: %llx error code: %llx\n", - vmread(vcpu, VM_EXIT_INFO_REASON), - vmread(vcpu, VMX_INSTRUCTION_ERROR_CODE)); + error = vmread(vcpu, VMX_INSTRUCTION_ERROR_CODE); + hax_error("VMfailValid. Prev exit: %llx. Error code: %llu (%s)\n", + reason, error, name_vmx_error(error)); } else { - hax_log("HAX: Prev exit: %llx no error code\n", - vmread(vcpu, VM_EXIT_INFO_REASON)); + hax_error("VMfailInvalid. Prev exit: %llx no error code\n", + reason); } - - hax_log("HAX: VM entry failed\n"); - hax_log("end of cpu_vmentry_failed\n"); } vmx_result_t cpu_vmxroot_leave(void) diff --git a/core/dump.c b/core/dump.c new file mode 100644 index 00000000..2aed9a6d --- /dev/null +++ b/core/dump.c @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2009 Intel Corporation + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "include/compiler.h" +#include "include/name.h" +#include "include/vmx.h" +#include "include/dump.h" +#include "../include/hax.h" + +static uint32_t dump_vmcs_list[] = { + VMX_PIN_CONTROLS, + VMX_PRIMARY_PROCESSOR_CONTROLS, + VMX_SECONDARY_PROCESSOR_CONTROLS, + VMX_EXCEPTION_BITMAP, + VMX_PAGE_FAULT_ERROR_CODE_MASK, + VMX_PAGE_FAULT_ERROR_CODE_MATCH, + VMX_EXIT_CONTROLS, + VMX_EXIT_MSR_STORE_COUNT, + VMX_EXIT_MSR_LOAD_COUNT, + VMX_ENTRY_CONTROLS, + VMX_ENTRY_MSR_LOAD_COUNT, + VMX_ENTRY_INTERRUPT_INFO, + VMX_ENTRY_EXCEPTION_ERROR_CODE, + VMX_ENTRY_INSTRUCTION_LENGTH, + VMX_TPR_THRESHOLD, + + VMX_CR0_MASK, + VMX_CR4_MASK, + VMX_CR0_READ_SHADOW, + VMX_CR4_READ_SHADOW, + VMX_CR3_TARGET_COUNT, + VMX_CR3_TARGET_VAL_BASE, // x6008-x6206 + + VMX_VPID, + VMX_IO_BITMAP_A, + VMX_IO_BITMAP_B, + VMX_MSR_BITMAP, + VMX_EXIT_MSR_STORE_ADDRESS, + VMX_EXIT_MSR_LOAD_ADDRESS, + VMX_ENTRY_MSR_LOAD_ADDRESS, + VMX_TSC_OFFSET, + VMX_VAPIC_PAGE, + VMX_APIC_ACCESS_PAGE, + VMX_EPTP, + VMX_PREEMPTION_TIMER, + + VMX_INSTRUCTION_ERROR_CODE, + + VM_EXIT_INFO_REASON, + VM_EXIT_INFO_INTERRUPT_INFO, + VM_EXIT_INFO_EXCEPTION_ERROR_CODE, + VM_EXIT_INFO_IDT_VECTORING, + VM_EXIT_INFO_IDT_VECTORING_ERROR_CODE, + VM_EXIT_INFO_INSTRUCTION_LENGTH, + VM_EXIT_INFO_INSTRUCTION_INFO, + VM_EXIT_INFO_QUALIFICATION, + VM_EXIT_INFO_IO_ECX, + VM_EXIT_INFO_IO_ESI, + VM_EXIT_INFO_IO_EDI, + VM_EXIT_INFO_IO_EIP, + VM_EXIT_INFO_GUEST_LINEAR_ADDRESS, + VM_EXIT_INFO_GUEST_PHYSICAL_ADDRESS, + + HOST_RIP, + HOST_RSP, + HOST_CR0, + HOST_CR3, + HOST_CR4, + + HOST_CS_SELECTOR, + HOST_DS_SELECTOR, + HOST_ES_SELECTOR, + HOST_FS_SELECTOR, + HOST_GS_SELECTOR, + HOST_SS_SELECTOR, + HOST_TR_SELECTOR, + HOST_FS_BASE, + HOST_GS_BASE, + HOST_TR_BASE, + HOST_GDTR_BASE, + HOST_IDTR_BASE, + + HOST_SYSENTER_CS, + HOST_SYSENTER_ESP, + HOST_SYSENTER_EIP, + + GUEST_RIP, + GUEST_RFLAGS, + GUEST_RSP, + GUEST_CR0, + GUEST_CR3, + GUEST_CR4, + + GUEST_ES_SELECTOR, + GUEST_CS_SELECTOR, + GUEST_SS_SELECTOR, + GUEST_DS_SELECTOR, + GUEST_FS_SELECTOR, + GUEST_GS_SELECTOR, + GUEST_LDTR_SELECTOR, + GUEST_TR_SELECTOR, + + GUEST_ES_AR, + GUEST_CS_AR, + GUEST_SS_AR, + GUEST_DS_AR, + GUEST_FS_AR, + GUEST_GS_AR, + GUEST_LDTR_AR, + GUEST_TR_AR, + + GUEST_ES_BASE, + GUEST_CS_BASE, + GUEST_SS_BASE, + GUEST_DS_BASE, + GUEST_FS_BASE, + GUEST_GS_BASE, + GUEST_LDTR_BASE, + GUEST_TR_BASE, + GUEST_GDTR_BASE, + GUEST_IDTR_BASE, + + GUEST_ES_LIMIT, + GUEST_CS_LIMIT, + GUEST_SS_LIMIT, + GUEST_DS_LIMIT, + GUEST_FS_LIMIT, + GUEST_GS_LIMIT, + GUEST_LDTR_LIMIT, + GUEST_TR_LIMIT, + GUEST_GDTR_LIMIT, + GUEST_IDTR_LIMIT, + + GUEST_VMCS_LINK_PTR, + GUEST_DEBUGCTL, + GUEST_PAT, + GUEST_EFER, + GUEST_PERF_GLOBAL_CTRL, + GUEST_PDPTE0, + GUEST_PDPTE1, + GUEST_PDPTE2, + GUEST_PDPTE3, + + GUEST_DR7, + GUEST_PENDING_DBE, + GUEST_SYSENTER_CS, + GUEST_SYSENTER_ESP, + GUEST_SYSENTER_EIP, + GUEST_SMBASE, + GUEST_INTERRUPTIBILITY, + GUEST_ACTIVITY_STATE, +}; + +void dump_vmcs(struct vcpu_t *vcpu) +{ + uint32_t i, enc, n; + const char *name; + + uint32_t *list = dump_vmcs_list; + n = ARRAY_ELEMENTS(dump_vmcs_list); + + for (i = 0; i < n; i++) { + enc = list[i]; + name = name_vmcs_component(enc); + vmread_dump(vcpu, enc, name); + } +} + +void dump_vmx_info(struct info_t *info) +{ + hax_info("VMCS Rev %d\n", info->_vmcs_revision_id); + + hax_info("VMX basic info : 0x%016llX\n", + info->_basic_info); + hax_info("VMX misc info : 0x%016llX\n", + info->_miscellaneous); + hax_info("VMX revision control : %u\n", + info->_vmcs_revision_id); + hax_info("VMX exit ctls : 0x%X, 0x%X\n", + info->exit_ctls_0, info->exit_ctls_1); + hax_info("VMX entry ctls : 0x%X, 0x%X\n", + info->entry_ctls_0, info->entry_ctls_1); + hax_info("VMX pin ctls : 0x%X, 0x%X\n", + info->pin_ctls_0, info->pin_ctls_1); + hax_info("VMX cpu prim ctrls : 0x%X, 0x%X\n", + info->pcpu_ctls_0, info->pcpu_ctls_1); + hax_info("VMX cpu sec ctrl : 0x%X, 0x%X\n", + info->scpu_ctls_0, info->scpu_ctls_1); + hax_info("VMX fixed CR0 bits : 0x%llX, %llX\n", + info->_cr0_fixed_0, info->_cr0_fixed_1); + hax_info("VMX fixed CR4 bits : 0x%llX, %llX\n", + info->_cr4_fixed_0, info->_cr4_fixed_1); + hax_info("VMX EPT/VPID caps : 0x%016llX\n", + info->_ept_cap); +} + +/*Remove this function. It only for debug*/ +/*void dump_cs_ds(uint16_t cs, uint16_t ds) +{ + struct system_desc_t desc; + struct seg_desc_t *seg_desc; + + get_kernel_gdt(&desc); + + seg_desc = (struct seg_desc_t *)((mword)desc._base) + (cs >> 3); + + hax_debug("\nsel: %x\n", cs >> 3); + hax_debug("type: %x\n", seg_desc->_type); + hax_debug("s: %x\n", seg_desc->_s); + hax_debug("present: %x\n", seg_desc->_present); + hax_debug("avl: %x\n", seg_desc->_avl); + hax_debug("long: %x\n", seg_desc->_longmode); + hax_debug("d/b: %x\n", seg_desc->_d); + hax_debug("g: %x\n", seg_desc->_granularity); + hax_debug("base0: %x\n", seg_desc->_base0); + hax_debug("limit: %x\n", seg_desc->_limit0); + hax_debug("dpl: %x\n", seg_desc->_limit0); + + hax_debug("raw: %llx\n", seg_desc->_raw); + seg_desc = (struct seg_desc_t *)((mword)desc._base) + (ds >> 3); + + hax_debug("\nsel: %x\n", ds >> 3); + hax_debug("type: %x\n", seg_desc->_type); + hax_debug("s: %x\n", seg_desc->_s); + hax_debug("present: %x\n", seg_desc->_present); + hax_debug("avl: %x\n", seg_desc->_avl); + hax_debug("long: %x\n", seg_desc->_longmode); + hax_debug("d/b: %x\n", seg_desc->_d); + hax_debug("g: %x\n", seg_desc->_granularity); + hax_debug("base0: %x\n", seg_desc->_base0); + hax_debug("limit: %x\n", seg_desc->_limit0); + hax_debug("dpl: %x\n", seg_desc->_dpl); + hax_debug("raw: %llx\n", seg_desc->_raw); +}*/ diff --git a/core/dump_vmcs.c b/core/dump_vmcs.c deleted file mode 100644 index ac655859..00000000 --- a/core/dump_vmcs.c +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright (c) 2009 Intel Corporation - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "include/vmx.h" -#include "include/dump_vmcs.h" -#include "include/compiler.h" -#include "../include/hax.h" - -extern unsigned char **vmcs_names; -extern uint32_t vmcs_hash(uint32_t enc); - -static uint32_t dump_vmcs_list[] = { - VMX_PIN_CONTROLS, - VMX_PRIMARY_PROCESSOR_CONTROLS, - VMX_SECONDARY_PROCESSOR_CONTROLS, - VMX_EXCEPTION_BITMAP, - VMX_PAGE_FAULT_ERROR_CODE_MASK, - VMX_PAGE_FAULT_ERROR_CODE_MATCH, - VMX_EXIT_CONTROLS, - VMX_EXIT_MSR_STORE_COUNT, - VMX_EXIT_MSR_LOAD_COUNT, - VMX_ENTRY_CONTROLS, - VMX_ENTRY_MSR_LOAD_COUNT, - VMX_ENTRY_INTERRUPT_INFO, - VMX_ENTRY_EXCEPTION_ERROR_CODE, - VMX_ENTRY_INSTRUCTION_LENGTH, - VMX_TPR_THRESHOLD, - - VMX_CR0_MASK, - VMX_CR4_MASK, - VMX_CR0_READ_SHADOW, - VMX_CR4_READ_SHADOW, - VMX_CR3_TARGET_COUNT, - VMX_CR3_TARGET_VAL_BASE, // x6008-x6206 - - VMX_VPID, - VMX_IO_BITMAP_A, - VMX_IO_BITMAP_B, - VMX_MSR_BITMAP, - VMX_EXIT_MSR_STORE_ADDRESS, - VMX_EXIT_MSR_LOAD_ADDRESS, - VMX_ENTRY_MSR_LOAD_ADDRESS, - VMX_TSC_OFFSET, - VMX_VAPIC_PAGE, - VMX_APIC_ACCESS_PAGE, - VMX_EPTP, - VMX_PREEMPTION_TIMER, - - VMX_INSTRUCTION_ERROR_CODE, - - VM_EXIT_INFO_REASON, - VM_EXIT_INFO_INTERRUPT_INFO, - VM_EXIT_INFO_EXCEPTION_ERROR_CODE, - VM_EXIT_INFO_IDT_VECTORING, - VM_EXIT_INFO_IDT_VECTORING_ERROR_CODE, - VM_EXIT_INFO_INSTRUCTION_LENGTH, - VM_EXIT_INFO_INSTRUCTION_INFO, - VM_EXIT_INFO_QUALIFICATION, - VM_EXIT_INFO_IO_ECX, - VM_EXIT_INFO_IO_ESI, - VM_EXIT_INFO_IO_EDI, - VM_EXIT_INFO_IO_EIP, - VM_EXIT_INFO_GUEST_LINEAR_ADDRESS, - VM_EXIT_INFO_GUEST_PHYSICAL_ADDRESS, - - HOST_RIP, - HOST_RSP, - HOST_CR0, - HOST_CR3, - HOST_CR4, - - HOST_CS_SELECTOR, - HOST_DS_SELECTOR, - HOST_ES_SELECTOR, - HOST_FS_SELECTOR, - HOST_GS_SELECTOR, - HOST_SS_SELECTOR, - HOST_TR_SELECTOR, - HOST_FS_BASE, - HOST_GS_BASE, - HOST_TR_BASE, - HOST_GDTR_BASE, - HOST_IDTR_BASE, - - HOST_SYSENTER_CS, - HOST_SYSENTER_ESP, - HOST_SYSENTER_EIP, - - GUEST_RIP, - GUEST_RFLAGS, - GUEST_RSP, - GUEST_CR0, - GUEST_CR3, - GUEST_CR4, - - GUEST_ES_SELECTOR, - GUEST_CS_SELECTOR, - GUEST_SS_SELECTOR, - GUEST_DS_SELECTOR, - GUEST_FS_SELECTOR, - GUEST_GS_SELECTOR, - GUEST_LDTR_SELECTOR, - GUEST_TR_SELECTOR, - - GUEST_ES_AR, - GUEST_CS_AR, - GUEST_SS_AR, - GUEST_DS_AR, - GUEST_FS_AR, - GUEST_GS_AR, - GUEST_LDTR_AR, - GUEST_TR_AR, - - GUEST_ES_BASE, - GUEST_CS_BASE, - GUEST_SS_BASE, - GUEST_DS_BASE, - GUEST_FS_BASE, - GUEST_GS_BASE, - GUEST_LDTR_BASE, - GUEST_TR_BASE, - GUEST_GDTR_BASE, - GUEST_IDTR_BASE, - - GUEST_ES_LIMIT, - GUEST_CS_LIMIT, - GUEST_SS_LIMIT, - GUEST_DS_LIMIT, - GUEST_FS_LIMIT, - GUEST_GS_LIMIT, - GUEST_LDTR_LIMIT, - GUEST_TR_LIMIT, - GUEST_GDTR_LIMIT, - GUEST_IDTR_LIMIT, - - GUEST_VMCS_LINK_PTR, - GUEST_DEBUGCTL, - GUEST_PAT, - GUEST_EFER, - GUEST_PERF_GLOBAL_CTRL, - GUEST_PDPTE0, - GUEST_PDPTE1, - GUEST_PDPTE2, - GUEST_PDPTE3, - - GUEST_DR7, - GUEST_PENDING_DBE, - GUEST_SYSENTER_CS, - GUEST_SYSENTER_ESP, - GUEST_SYSENTER_EIP, - GUEST_SMBASE, - GUEST_INTERRUPTIBILITY, - GUEST_ACTIVITY_STATE, -}; - -static int encode_type(uint32_t encode) -{ - return (encode >> 13) & 0x3; -} - -#define VMCS_NAME_NUMBER 256 -/* including the trailing 0 */ -#define VMCS_NAME_MAX_ENTRY 0x40 - -unsigned char *get_vmcsname_entry(int num) -{ - unsigned char *entry; - entry = (unsigned char *)vmcs_names + num * VMCS_NAME_MAX_ENTRY; - return entry; -} - -void dump_vmcs(struct vcpu_t *vcpu) -{ - uint32_t i, enc, n; - unsigned char *name; - - uint32_t *list = dump_vmcs_list; - n = ARRAY_ELEMENTS(dump_vmcs_list); - - for (i = 0; i < n; i++) { - enc = list[i]; - name = get_vmcsname_entry(vmcs_hash(enc)); - vmread_dump(vcpu, enc, (char *)name); - } -} - -static void setup_vmcs_name(int item, char *s) -{ - char *dest; - int i = 0; - int len = strlen(s) + 1; - - if (!vmcs_names) - return; - dest = (char *)vmcs_names + item * VMCS_NAME_MAX_ENTRY; - - if (len >= VMCS_NAME_MAX_ENTRY) - len = VMCS_NAME_MAX_ENTRY; - - while(((*dest++ = *s++) != '\0') && (i < len)) - i++; -} - -void dump_vmcs_exit(void) -{ - if (!vmcs_names) - return; - hax_vfree(vmcs_names, VMCS_NAME_NUMBER * VMCS_NAME_MAX_ENTRY); -} - -int dump_vmcs_init(void) -{ - vmcs_names = hax_vmalloc( VMCS_NAME_NUMBER * VMCS_NAME_MAX_ENTRY, 0); - - if (!vmcs_names) - return -ENOMEM; - - setup_vmcs_name(10, "VMX_PIN_CONTROLS"); - setup_vmcs_name(6, "VMX_PRIMARY_PROCESSOR_CONTROLS"); - setup_vmcs_name(35, "VMX_SECONDARY_PROCESSOR_CONTROLS"); - setup_vmcs_name(2, "VMX_EXCEPTION_BITMAP"); - setup_vmcs_name(18, "VMX_PAGE_FAULT_ERROR_CODE_MASK"); - setup_vmcs_name(14, "VMX_PAGE_FAULT_ERROR_CODE_MATCH"); - setup_vmcs_name(62, "VMX_EXIT_CONTROLS"); - setup_vmcs_name(87, "VMX_EXIT_MSR_STORE_COUNT"); - setup_vmcs_name(132, "VMX_EXIT_MSR_LOAD_COUNT"); - setup_vmcs_name(140, "VMX_ENTRY_CONTROLS"); - setup_vmcs_name(136, "VMX_ENTRY_MSR_LOAD_COUNT"); - setup_vmcs_name(147, "VMX_ENTRY_INTERRUPT_INFO"); - setup_vmcs_name(77, "VMX_ENTRY_EXCEPTION_ERROR_CODE"); - setup_vmcs_name(69, "VMX_ENTRY_INSTRUCTION_LENGTH"); - setup_vmcs_name(73, "VMX_TPR_THRESHOLD"); - setup_vmcs_name(51, "VMX_CR0_MASK"); - setup_vmcs_name(47, "VMX_CR4_MASK"); - setup_vmcs_name(43, "VMX_CR0_READ_SHADOW"); - setup_vmcs_name(59, "VMX_CR4_READ_SHADOW"); - setup_vmcs_name(39, "VMX_CR3_TARGET_COUNT"); - setup_vmcs_name(55, "VMX_CR3_TARGET_VAL_BASE"); - setup_vmcs_name(56, "VMX_VPID"); - setup_vmcs_name(114, "VMX_IO_BITMAP_A"); - setup_vmcs_name(110, "VMX_IO_BITMAP_B"); - setup_vmcs_name(106, "VMX_MSR_BITMAP"); - setup_vmcs_name(122, "VMX_EXIT_MSR_STORE_ADDRESS"); - setup_vmcs_name(118, "VMX_EXIT_MSR_LOAD_ADDRESS"); - setup_vmcs_name(143, "VMX_ENTRY_MSR_LOAD_ADDRESS"); - setup_vmcs_name(236, "VMX_TSC_OFFSET"); - setup_vmcs_name(244, "VMX_VAPIC_PAGE"); - setup_vmcs_name(240, "VMX_APIC_ACCESS_PAGE"); - setup_vmcs_name(173, "VMX_EPTP"); - setup_vmcs_name(48, "VMX_PREEMPTION_TIMER"); - setup_vmcs_name(50, "VMX_INSTRUCTION_ERROR_CODE"); - setup_vmcs_name(46, "VM_EXIT_INFO_REASON"); - setup_vmcs_name(42, "VM_EXIT_INFO_INTERRUPT_INFO"); - setup_vmcs_name(58, "VM_EXIT_INFO_EXCEPTION_ERROR_CODE"); - setup_vmcs_name(54, "VM_EXIT_INFO_IDT_VECTORING"); - setup_vmcs_name(79, "VM_EXIT_INFO_IDT_VECTORING_ERROR_CODE"); - setup_vmcs_name(102, "VM_EXIT_INFO_INSTRUCTION_LENGTH"); - setup_vmcs_name(127, "VM_EXIT_INFO_INSTRUCTION_INFO"); - setup_vmcs_name(115, "VM_EXIT_INFO_QUALIFICATION"); - setup_vmcs_name(111, "VM_EXIT_INFO_IO_ECX"); - setup_vmcs_name(107, "VM_EXIT_INFO_IO_ESI"); - setup_vmcs_name(123, "VM_EXIT_INFO_IO_EDI"); - setup_vmcs_name(119, "VM_EXIT_INFO_IO_EIP"); - setup_vmcs_name(144, "VM_EXIT_INFO_GUEST_LINEAR_ADDRESS"); - setup_vmcs_name(53, "VM_EXIT_INFO_GUEST_PHYSICAL_ADDRESS"); - setup_vmcs_name(148, "HOST_RIP"); - setup_vmcs_name(137, "HOST_RSP"); - setup_vmcs_name(11, "HOST_CR0"); - setup_vmcs_name(7, "HOST_CR3"); - setup_vmcs_name(3, "HOST_CR4"); - setup_vmcs_name(96, "HOST_CS_SELECTOR"); - setup_vmcs_name(108, "HOST_DS_SELECTOR"); - setup_vmcs_name(100, "HOST_ES_SELECTOR"); - setup_vmcs_name(104, "HOST_FS_SELECTOR"); - setup_vmcs_name(129, "HOST_GS_SELECTOR"); - setup_vmcs_name(92, "HOST_SS_SELECTOR"); - setup_vmcs_name(152, "HOST_TR_SELECTOR"); - setup_vmcs_name(19, "HOST_FS_BASE"); - setup_vmcs_name(15, "HOST_GS_BASE"); - setup_vmcs_name(40, "HOST_TR_BASE"); - setup_vmcs_name(63, "HOST_GDTR_BASE"); - setup_vmcs_name(88, "HOST_IDTR_BASE"); - setup_vmcs_name(41, "HOST_SYSENTER_CS"); - setup_vmcs_name(133, "HOST_SYSENTER_ESP"); - setup_vmcs_name(141, "HOST_SYSENTER_EIP"); - setup_vmcs_name(33, "GUEST_RIP"); - setup_vmcs_name(44, "GUEST_RFLAGS"); - setup_vmcs_name(71, "GUEST_RSP"); - setup_vmcs_name(8, "GUEST_CR0"); - setup_vmcs_name(4, "GUEST_CR3"); - setup_vmcs_name(0, "GUEST_CR4"); - setup_vmcs_name(74, "GUEST_ES_SELECTOR"); - setup_vmcs_name(70, "GUEST_CS_SELECTOR"); - setup_vmcs_name(66, "GUEST_SS_SELECTOR"); - setup_vmcs_name(82, "GUEST_DS_SELECTOR"); - setup_vmcs_name(78, "GUEST_FS_SELECTOR"); - setup_vmcs_name(103, "GUEST_GS_SELECTOR"); - setup_vmcs_name(126, "GUEST_LDTR_SELECTOR"); - setup_vmcs_name(151, "GUEST_TR_SELECTOR"); - setup_vmcs_name(135, "GUEST_ES_AR"); - setup_vmcs_name(146, "GUEST_CS_AR"); - setup_vmcs_name(76, "GUEST_SS_AR"); - setup_vmcs_name(68, "GUEST_DS_AR"); - setup_vmcs_name(72, "GUEST_FS_AR"); - setup_vmcs_name(34, "GUEST_GS_AR"); - setup_vmcs_name(45, "GUEST_LDTR_AR"); - setup_vmcs_name(31, "GUEST_TR_AR"); - setup_vmcs_name(16, "GUEST_ES_BASE"); - setup_vmcs_name(12, "GUEST_CS_BASE"); - setup_vmcs_name(37, "GUEST_SS_BASE"); - setup_vmcs_name(60, "GUEST_DS_BASE"); - setup_vmcs_name(85, "GUEST_FS_BASE"); - setup_vmcs_name(130, "GUEST_GS_BASE"); - setup_vmcs_name(138, "GUEST_LDTR_BASE"); - setup_vmcs_name(134, "GUEST_TR_BASE"); - setup_vmcs_name(145, "GUEST_GDTR_BASE"); - setup_vmcs_name(75, "GUEST_IDTR_BASE"); - setup_vmcs_name(9, "GUEST_ES_LIMIT"); - setup_vmcs_name(5, "GUEST_CS_LIMIT"); - setup_vmcs_name(1, "GUEST_SS_LIMIT"); - setup_vmcs_name(17, "GUEST_DS_LIMIT"); - setup_vmcs_name(13, "GUEST_FS_LIMIT"); - setup_vmcs_name(38, "GUEST_GS_LIMIT"); - setup_vmcs_name(61, "GUEST_LDTR_LIMIT"); - setup_vmcs_name(86, "GUEST_TR_LIMIT"); - setup_vmcs_name(131, "GUEST_GDTR_LIMIT"); - setup_vmcs_name(139, "GUEST_IDTR_LIMIT"); - setup_vmcs_name(28, "GUEST_VMCS_LINK_PTR"); - setup_vmcs_name(24, "GUEST_DEBUGCTL"); - setup_vmcs_name(20, "GUEST_PAT"); - setup_vmcs_name(36, "GUEST_EFER"); - setup_vmcs_name(32, "GUEST_PERF_GLOBAL_CTRL"); - setup_vmcs_name(57, "GUEST_PDPTE0"); - setup_vmcs_name(80, "GUEST_PDPTE1"); - setup_vmcs_name(105, "GUEST_PDPTE2"); - setup_vmcs_name(150, "GUEST_PDPTE3"); - setup_vmcs_name(67, "GUEST_DR7"); - setup_vmcs_name(30, "GUEST_PENDING_DBE"); - setup_vmcs_name(49, "GUEST_SYSENTER_CS"); - setup_vmcs_name(26, "GUEST_SYSENTER_ESP"); - setup_vmcs_name(22, "GUEST_SYSENTER_EIP"); - setup_vmcs_name(52, "GUEST_SMBASE"); - setup_vmcs_name(27, "GUEST_INTERRUPTIBILITY"); - setup_vmcs_name(23, "GUEST_ACTIVITY_STATE"); - return 0; -} diff --git a/core/hax.c b/core/hax.c index 1a49a5bd..ef122a3e 100644 --- a/core/hax.c +++ b/core/hax.c @@ -35,7 +35,6 @@ #include "include/config.h" #include "include/hax_driver.h" #include "include/vm.h" -#include "include/dump_vmcs.h" #include "../include/hax.h" #include "../include/hax_release_ver.h" @@ -268,9 +267,6 @@ static int hax_vmx_init(void) if ((ret = hax_vmx_enable_check()) < 0) goto out_5; - if (dump_vmcs_init()) - goto out_5; - return 0; out_5: hax_disable_vmx(); @@ -294,7 +290,6 @@ static int hax_vmx_exit(void) hax_free_pages(msr_bitmap_page); hax_free_pages(io_bitmap_page_b); hax_free_pages(io_bitmap_page_a); - dump_vmcs_exit(); return 0; } @@ -599,5 +594,3 @@ int hax_module_exit(void) return 0; } - -int hax_put_vcpu(struct vcpu_t *vcpu); diff --git a/core/include/dump_vmcs.h b/core/include/dump.h similarity index 91% rename from core/include/dump_vmcs.h rename to core/include/dump.h index e45706cb..8f37af57 100644 --- a/core/include/dump_vmcs.h +++ b/core/include/dump.h @@ -28,11 +28,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef HAX_CORE_DUMP_VMCS_H_ -#define HAX_CORE_DUMP_VMCS_H_ +#ifndef HAX_CORE_DUMP_H_ +#define HAX_CORE_DUMP_H_ void dump_vmcs(struct vcpu_t *vcpu); -void dump_vmcs_exit(void); -int dump_vmcs_init(void); -#endif // HAX_CORE_DUMP_VMCS_H_ +void dump_vmx_info(struct info_t *info); + +#endif // HAX_CORE_DUMP_H_ diff --git a/core/include/name.h b/core/include/name.h new file mode 100644 index 00000000..36c6d3e2 --- /dev/null +++ b/core/include/name.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2018 Kryptos Logic + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef HAX_CORE_NAME_H_ +#define HAX_CORE_NAME_H_ + +const char *name_vmcs_component(int value); +const char *name_vmx_error(int value); +const char *name_vmx_exit(int value); + +#endif // HAX_CORE_NAME_H_ diff --git a/core/include/vmx.h b/core/include/vmx.h index ffa7ebf6..7a36244c 100644 --- a/core/include/vmx.h +++ b/core/include/vmx.h @@ -650,7 +650,7 @@ mword ASMCALL asm_vmread(uint32_t component); void ASMCALL asm_vmwrite(uint32_t component, mword val); uint64_t vmread(struct vcpu_t *vcpu, component_index_t component); -uint64_t vmread_dump(struct vcpu_t *vcpu, unsigned enc, char *name); +uint64_t vmread_dump(struct vcpu_t *vcpu, unsigned enc, const char *name); void vmx_vmwrite(struct vcpu_t *vcpu, const char *name, component_index_t component, uint64_t source_val); diff --git a/core/name.c b/core/name.c new file mode 100644 index 00000000..04d42d5f --- /dev/null +++ b/core/name.c @@ -0,0 +1,301 @@ +/* + * Copyright (c) 2018 Kryptos Logic + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "include/name.h" +#include "include/vmx.h" + +const char *name_vmcs_component(int value) +{ + // The following macro compactifies the VMCS component encoding to 9 bits, + // thus all major compilers will optimize the switch-case via jump tables. + // Compilers will ensure this is a perfect hash function, by preventing + // the two identical cases to exist. + // The original encoding is described by: + // Intel SDM Vol. 3C: Table 24-17. Structure of VMCS Component Encoding + // Our compact encoding is described by: + // [W WTTI IIII] W=Width, T=Type, I=Index + + // As of this writing, no VMCS component is encoded with an Index of more + // than 5 bits (Intel SDM Vol. 3D, Appendix B: Field Encoding in VMCS), + // even though 9 bits are allocated to Index. +#define HASH(x) \ + (((x) & 0x003E) >> 1) /* Index */ | \ + (((x) & 0x0C00) >> 5) /* Type */ | \ + (((x) & 0x6000) >> 6) /* Width */ +#define CASE(x) \ + case HASH(x): \ + return #x + + switch (HASH(value)) { + CASE(VMX_PIN_CONTROLS); + CASE(VMX_PRIMARY_PROCESSOR_CONTROLS); + CASE(VMX_SECONDARY_PROCESSOR_CONTROLS); + CASE(VMX_EXCEPTION_BITMAP); + CASE(VMX_PAGE_FAULT_ERROR_CODE_MASK); + CASE(VMX_PAGE_FAULT_ERROR_CODE_MATCH); + CASE(VMX_EXIT_CONTROLS); + CASE(VMX_EXIT_MSR_STORE_COUNT); + CASE(VMX_EXIT_MSR_LOAD_COUNT); + CASE(VMX_ENTRY_CONTROLS); + CASE(VMX_ENTRY_MSR_LOAD_COUNT); + CASE(VMX_ENTRY_INTERRUPT_INFO); + CASE(VMX_ENTRY_EXCEPTION_ERROR_CODE); + CASE(VMX_ENTRY_INSTRUCTION_LENGTH); + CASE(VMX_TPR_THRESHOLD); + CASE(VMX_CR0_MASK); + CASE(VMX_CR4_MASK); + CASE(VMX_CR0_READ_SHADOW); + CASE(VMX_CR4_READ_SHADOW); + CASE(VMX_CR3_TARGET_COUNT); + CASE(VMX_CR3_TARGET_VAL_BASE); + CASE(VMX_VPID); + CASE(VMX_IO_BITMAP_A); + CASE(VMX_IO_BITMAP_B); + CASE(VMX_MSR_BITMAP); + CASE(VMX_EXIT_MSR_STORE_ADDRESS); + CASE(VMX_EXIT_MSR_LOAD_ADDRESS); + CASE(VMX_ENTRY_MSR_LOAD_ADDRESS); + CASE(VMX_TSC_OFFSET); + CASE(VMX_VAPIC_PAGE); + CASE(VMX_APIC_ACCESS_PAGE); + CASE(VMX_EPTP); + CASE(VMX_PREEMPTION_TIMER); + CASE(VMX_INSTRUCTION_ERROR_CODE); + CASE(VM_EXIT_INFO_REASON); + CASE(VM_EXIT_INFO_INTERRUPT_INFO); + CASE(VM_EXIT_INFO_EXCEPTION_ERROR_CODE); + CASE(VM_EXIT_INFO_IDT_VECTORING); + CASE(VM_EXIT_INFO_IDT_VECTORING_ERROR_CODE); + CASE(VM_EXIT_INFO_INSTRUCTION_LENGTH); + CASE(VM_EXIT_INFO_INSTRUCTION_INFO); + CASE(VM_EXIT_INFO_QUALIFICATION); + CASE(VM_EXIT_INFO_IO_ECX); + CASE(VM_EXIT_INFO_IO_ESI); + CASE(VM_EXIT_INFO_IO_EDI); + CASE(VM_EXIT_INFO_IO_EIP); + CASE(VM_EXIT_INFO_GUEST_LINEAR_ADDRESS); + CASE(VM_EXIT_INFO_GUEST_PHYSICAL_ADDRESS); + CASE(HOST_RIP); + CASE(HOST_RSP); + CASE(HOST_CR0); + CASE(HOST_CR3); + CASE(HOST_CR4); + CASE(HOST_CS_SELECTOR); + CASE(HOST_DS_SELECTOR); + CASE(HOST_ES_SELECTOR); + CASE(HOST_FS_SELECTOR); + CASE(HOST_GS_SELECTOR); + CASE(HOST_SS_SELECTOR); + CASE(HOST_TR_SELECTOR); + CASE(HOST_FS_BASE); + CASE(HOST_GS_BASE); + CASE(HOST_TR_BASE); + CASE(HOST_GDTR_BASE); + CASE(HOST_IDTR_BASE); + CASE(HOST_SYSENTER_CS); + CASE(HOST_SYSENTER_ESP); + CASE(HOST_SYSENTER_EIP); + CASE(HOST_PAT); + CASE(HOST_EFER); + CASE(HOST_PERF_GLOBAL_CTRL); + CASE(GUEST_RIP); + CASE(GUEST_RFLAGS); + CASE(GUEST_RSP); + CASE(GUEST_CR0); + CASE(GUEST_CR3); + CASE(GUEST_CR4); + CASE(GUEST_ES_SELECTOR); + CASE(GUEST_CS_SELECTOR); + CASE(GUEST_SS_SELECTOR); + CASE(GUEST_DS_SELECTOR); + CASE(GUEST_FS_SELECTOR); + CASE(GUEST_GS_SELECTOR); + CASE(GUEST_LDTR_SELECTOR); + CASE(GUEST_TR_SELECTOR); + CASE(GUEST_ES_AR); + CASE(GUEST_CS_AR); + CASE(GUEST_SS_AR); + CASE(GUEST_DS_AR); + CASE(GUEST_FS_AR); + CASE(GUEST_GS_AR); + CASE(GUEST_LDTR_AR); + CASE(GUEST_TR_AR); + CASE(GUEST_ES_BASE); + CASE(GUEST_CS_BASE); + CASE(GUEST_SS_BASE); + CASE(GUEST_DS_BASE); + CASE(GUEST_FS_BASE); + CASE(GUEST_GS_BASE); + CASE(GUEST_LDTR_BASE); + CASE(GUEST_TR_BASE); + CASE(GUEST_GDTR_BASE); + CASE(GUEST_IDTR_BASE); + CASE(GUEST_ES_LIMIT); + CASE(GUEST_CS_LIMIT); + CASE(GUEST_SS_LIMIT); + CASE(GUEST_DS_LIMIT); + CASE(GUEST_FS_LIMIT); + CASE(GUEST_GS_LIMIT); + CASE(GUEST_LDTR_LIMIT); + CASE(GUEST_TR_LIMIT); + CASE(GUEST_GDTR_LIMIT); + CASE(GUEST_IDTR_LIMIT); + CASE(GUEST_VMCS_LINK_PTR); + CASE(GUEST_DEBUGCTL); + CASE(GUEST_PAT); + CASE(GUEST_EFER); + CASE(GUEST_PERF_GLOBAL_CTRL); + CASE(GUEST_PDPTE0); + CASE(GUEST_PDPTE1); + CASE(GUEST_PDPTE2); + CASE(GUEST_PDPTE3); + CASE(GUEST_DR7); + CASE(GUEST_PENDING_DBE); + CASE(GUEST_SYSENTER_CS); + CASE(GUEST_SYSENTER_ESP); + CASE(GUEST_SYSENTER_EIP); + CASE(GUEST_SMBASE); + CASE(GUEST_INTERRUPTIBILITY); + CASE(GUEST_ACTIVITY_STATE); + default: + return ""; + } +#undef HASH +#undef CASE +} + +const char *name_vmx_error(int value) +{ +#define CASE(x) \ + case x: return #x + + switch (value) { + CASE(VMX_ERROR_VMCALL_ROOT); + CASE(VMX_ERROR_VMCLEAR_PADDR_INVALID); + CASE(VMX_ERROR_VMCLEAR_VMXON_PTR); + CASE(VMX_ERROR_VMLAUNCH_VMCS_UNCLEAR); + CASE(VMX_ERROR_VMRESUME_VMCS_UNLAUNCHED); + CASE(VMX_ERROR_VMRESUME_AFTER_VMXOFF); + CASE(VMX_ERROR_ENTRY_CTRL_FIELDS_INVALID); + CASE(VMX_ERROR_ENTRY_HOST_FIELDS_INVALID); + CASE(VMX_ERROR_VMPTRLD_PADDR_INVALID); + CASE(VMX_ERROR_VMPTRLD_VMXON_PTR); + CASE(VMX_ERROR_VMPTRLD_VMCSREV_INVALID); + CASE(VMX_ERROR_VMREAD_VMWRITE_INVALID); + CASE(VMX_ERROR_VMWRITE_READONLY); + CASE(VMX_ERROR_VMXON_ROOT); + CASE(VMX_ERROR_ENTRY_VMCS_INVALID); + CASE(VMX_ERROR_ENTRY_VMCS_UNLAUNCHED); + CASE(VMX_ERROR_ENTRY_VMCS_NOT_VMXON); + CASE(VMX_ERROR_VMCALL_VMCS_UNCLEAR); + CASE(VMX_ERROR_VMCALL_EXIT_INVALID); + CASE(VMX_ERROR_VMCALL_MSEG_INVALID); + CASE(VMX_ERROR_VMXOFF_SMM_DUALMONITOR); + CASE(VMX_ERROR_VMCALL_SMM_INVALID); + CASE(VMX_ERROR_ENTRY_EXECCTRL_INVALID); + CASE(VMX_ERROR_ENTRY_MOV_SS); + CASE(VMX_ERROR_INVEPT_INVALID); + default: + return ""; + } +#undef CASE +} + +const char *name_vmx_exit(int value) +{ +#define CASE(x) \ + case x: return #x + + switch (value) { + CASE(VMX_EXIT_INT_EXCEPTION_NMI); + CASE(VMX_EXIT_EXT_INTERRUPT); + CASE(VMX_EXIT_TRIPLE_FAULT); + CASE(VMX_EXIT_INIT_EVENT); + CASE(VMX_EXIT_SIPI_EVENT); + CASE(VMX_EXIT_SMI_IO_EVENT); + CASE(VMX_EXIT_SMI_OTHER_EVENT); + CASE(VMX_EXIT_PENDING_INTERRUPT); + CASE(VMX_EXIT_PENDING_NMI); + CASE(VMX_EXIT_TASK_SWITCH); + CASE(VMX_EXIT_CPUID); + CASE(VMX_EXIT_GETSEC); + CASE(VMX_EXIT_HLT); + CASE(VMX_EXIT_INVD); + CASE(VMX_EXIT_INVLPG); + CASE(VMX_EXIT_RDPMC); + CASE(VMX_EXIT_RDTSC); + CASE(VMX_EXIT_RSM); + CASE(VMX_EXIT_VMCALL); + CASE(VMX_EXIT_VMCLEAR); + CASE(VMX_EXIT_VMLAUNCH); + CASE(VMX_EXIT_VMPTRLD); + CASE(VMX_EXIT_VMPTRST); + CASE(VMX_EXIT_VMREAD); + CASE(VMX_EXIT_VMRESUME); + CASE(VMX_EXIT_VMWRITE); + CASE(VMX_EXIT_VMXOFF); + CASE(VMX_EXIT_VMXON); + CASE(VMX_EXIT_CR_ACCESS); + CASE(VMX_EXIT_DR_ACCESS); + CASE(VMX_EXIT_IO); + CASE(VMX_EXIT_MSR_READ); + CASE(VMX_EXIT_MSR_WRITE); + CASE(VMX_EXIT_FAILED_VMENTER_GS); + CASE(VMX_EXIT_FAILED_VMENTER_MSR); + CASE(VMX_EXIT_MWAIT); + CASE(VMX_EXIT_MTF_EXIT); + CASE(VMX_EXIT_MONITOR); + CASE(VMX_EXIT_PAUSE); + CASE(VMX_EXIT_MACHINE_CHECK); + CASE(VMX_EXIT_TPR_BELOW_THRESHOLD); + CASE(VMX_EXIT_APIC_ACCESS); + CASE(VMX_EXIT_GDT_IDT_ACCESS); + CASE(VMX_EXIT_LDT_TR_ACCESS); + CASE(VMX_EXIT_EPT_VIOLATION); + CASE(VMX_EXIT_EPT_MISCONFIG); + CASE(VMX_EXIT_INVEPT); + CASE(VMX_EXIT_RDTSCP); + CASE(VMX_EXIT_VMX_TIMER_EXIT); + CASE(VMX_EXIT_INVVPID); + CASE(VMX_EXIT_WBINVD); + CASE(VMX_EXIT_XSETBV); + CASE(VMX_EXIT_APIC_WRITE); + CASE(VMX_EXIT_RDRAND); + CASE(VMX_EXIT_INVPCID); + CASE(VMX_EXIT_VMFUNC); + CASE(VMX_EXIT_ENCLS); + CASE(VMX_EXIT_RDSEED); + CASE(VMX_EXIT_XSAVES); + CASE(VMX_EXIT_XRSTORS); + default: + return ""; + } +#undef CASE +} diff --git a/core/vcpu.c b/core/vcpu.c index d85ddc22..293cac12 100644 --- a/core/vcpu.c +++ b/core/vcpu.c @@ -38,7 +38,7 @@ #include "include/cpuid.h" #include "include/vm.h" #include "include/debug.h" -#include "include/dump_vmcs.h" +#include "include/dump.h" #include "include/intr.h" #include "include/vtlb.h" @@ -408,7 +408,7 @@ struct vcpu_t *vcpu_create(struct vm_t *vm, void *vm_host, int vcpu_id) memset(vcpu, 0, sizeof(struct vcpu_t)); if (hax_vcpu_setup_hax_tunnel(vcpu, &info) < 0) { - hax_error("HAX: cannot setup hax_tunnel for vcpu.\n"); + hax_error("cannot setup hax_tunnel for vcpu.\n"); goto fail_1; } @@ -465,7 +465,7 @@ struct vcpu_t *vcpu_create(struct vm_t *vm, void *vm_host, int vcpu_id) // Initialize emulator vcpu_init_emulator(vcpu); - hax_debug("HAX: vcpu %d is created.\n", vcpu->vcpu_id); + hax_debug("vcpu %d is created.\n", vcpu->vcpu_id); return vcpu; fail_7: vcpu_vtlb_free(vcpu); @@ -484,7 +484,7 @@ struct vcpu_t *vcpu_create(struct vm_t *vm, void *vm_host, int vcpu_id) fail_1: hax_vfree(vcpu, sizeof(struct vcpu_t)); fail_0: - hax_error("HAX: Cannot allocate memory to create vcpu.\n"); + hax_error("Cannot allocate memory to create vcpu.\n"); return NULL; } @@ -525,7 +525,7 @@ static int _vcpu_teardown(struct vcpu_t *vcpu) hax_mutex_free(vcpu->tmutex); hax_vfree(vcpu, sizeof(struct vcpu_t)); - hax_info("HAX: vcpu %d is teardown.\n", vcpu_id); + hax_info("vcpu %d is teardown.\n", vcpu_id); return 0; } @@ -1472,7 +1472,7 @@ static void fill_common_vmcs(struct vcpu_t *vcpu) static void vcpu_prepare(struct vcpu_t *vcpu) { - hax_debug("HAX: vcpu_prepare current %x, CPU %x\n", vcpu->vcpu_id, + hax_debug("vcpu_prepare current %x, CPU %x\n", vcpu->vcpu_id, hax_cpuid()); hax_mutex_lock(vcpu->tmutex); fill_common_vmcs(vcpu); diff --git a/core/vm.c b/core/vm.c index 89d46ea0..5c5dd3dd 100644 --- a/core/vm.c +++ b/core/vm.c @@ -226,7 +226,7 @@ int hax_vm_core_open(struct vm_t *vm) int hax_teardown_vm(struct vm_t *vm) { if (!hax_list_empty(&(vm->vcpu_list))) { - hax_log("Try to teardown non-empty vm\n"); + hax_info("Try to teardown non-empty vm\n"); return -1; } #ifdef HAX_ARCH_X86_32 diff --git a/core/vmcs_names.c b/core/vmcs_names.c deleted file mode 100644 index 23361303..00000000 --- a/core/vmcs_names.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2009 Intel Corporation - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* This file is C instead of C++ so it can use designated initializers. */ - -#include "include/types.h" - -unsigned char **vmcs_names; - -extern uint32_t vmcs_hash(uint32_t enc); - -/* Table produced by gperf version 3.0.4 */ -uint32_t vmcs_hash(uint32_t enc) -{ - static const uint8_t table[] = { - 8, 48, 4, 255, 0, 255, 16, 255, 12, 66, - 37, 255, 60, 92, 85, 255, 130, 255, 138, 255, - 134, 255, 145, 255, 75, 255, 67, 255, 71, 255, - 33, 255, 44, 106, 30, 255, 26, 45, 22, 255, - 51, 20, 48, 255, 255, 21, 47, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 2, 255, 255, 255, 42, - 255, 255, 255, 1, 255, 255, 255, 33, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 43, 255, 255, - 255, 107, 255, 255, 255, 0, 255, 255, 255, 3, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 - }; - return table[(enc >> 8 & 0xff) + 1] + table[enc & 0xff]; -} diff --git a/core/vmx.c b/core/vmx.c index 97ac4cbc..ef960983 100644 --- a/core/vmx.c +++ b/core/vmx.c @@ -208,7 +208,7 @@ uint64_t vmread(struct vcpu_t *vcpu, component_index_t component) return val; } -uint64_t vmread_dump(struct vcpu_t *vcpu, unsigned enc, char *name) +uint64_t vmread_dump(struct vcpu_t *vcpu, unsigned enc, const char *name) { uint64_t val; diff --git a/include/darwin/hax_mac.h b/include/darwin/hax_mac.h index 404e4830..53451de4 100644 --- a/include/darwin/hax_mac.h +++ b/include/darwin/hax_mac.h @@ -191,8 +191,6 @@ extern int default_hax_log_level; printf("haxm_debug: " x); \ } -#define hax_log hax_info - #define hax_panic panic #define hax_panic_vcpu(v, x...) { \ diff --git a/include/windows/hax_windows.h b/include/windows/hax_windows.h index 4ee1bcc0..804e7966 100644 --- a/include/windows/hax_windows.h +++ b/include/windows/hax_windows.h @@ -200,9 +200,6 @@ void hax_error(char *fmt, ...); void hax_warning(char *fmt, ...); void hax_info(char *fmt, ...); void hax_debug(char *fmt, ...); -void hax_log(char *fmt, ...); - -#define hax_log hax_info #define hax_panic DbgPrint diff --git a/platforms/darwin/intelhaxm.xcodeproj/project.pbxproj b/platforms/darwin/intelhaxm.xcodeproj/project.pbxproj index 3f20f6d5..af25ad38 100644 --- a/platforms/darwin/intelhaxm.xcodeproj/project.pbxproj +++ b/platforms/darwin/intelhaxm.xcodeproj/project.pbxproj @@ -50,13 +50,13 @@ 6E2DBBCE18EB6155003B66C9 /* page_walker.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E2DBBCD18EB6155003B66C9 /* page_walker.h */; }; A669096B20F9985300739075 /* ia32.c in Sources */ = {isa = PBXBuildFile; fileRef = A669096A20F9985300739075 /* ia32.c */; }; B98ECFB613A059BB00485DDB /* cpu.c in Sources */ = {isa = PBXBuildFile; fileRef = B98ECF9C13A059BB00485DDB /* cpu.c */; }; - B98ECFB713A059BB00485DDB /* dump_vmcs.c in Sources */ = {isa = PBXBuildFile; fileRef = B98ECF9D13A059BB00485DDB /* dump_vmcs.c */; }; + B98ECFB713A059BB00485DDB /* dump.c in Sources */ = {isa = PBXBuildFile; fileRef = B98ECF9D13A059BB00485DDB /* dump.c */; }; B98ECFB813A059BB00485DDB /* hax.c in Sources */ = {isa = PBXBuildFile; fileRef = B98ECF9E13A059BB00485DDB /* hax.c */; }; B98ECFB913A059BB00485DDB /* compiler.h in Headers */ = {isa = PBXBuildFile; fileRef = B98ECFA013A059BB00485DDB /* compiler.h */; }; B98ECFBA13A059BB00485DDB /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = B98ECFA113A059BB00485DDB /* config.h */; }; B98ECFBB13A059BB00485DDB /* cpu.h in Headers */ = {isa = PBXBuildFile; fileRef = B98ECFA213A059BB00485DDB /* cpu.h */; }; B98ECFBC13A059BB00485DDB /* debug.h in Headers */ = {isa = PBXBuildFile; fileRef = B98ECFA313A059BB00485DDB /* debug.h */; }; - B98ECFBD13A059BB00485DDB /* dump_vmcs.h in Headers */ = {isa = PBXBuildFile; fileRef = B98ECFA413A059BB00485DDB /* dump_vmcs.h */; }; + B98ECFBD13A059BB00485DDB /* dump.h in Headers */ = {isa = PBXBuildFile; fileRef = B98ECFA413A059BB00485DDB /* dump.h */; }; B98ECFBE13A059BB00485DDB /* hax_driver.h in Headers */ = {isa = PBXBuildFile; fileRef = B98ECFA513A059BB00485DDB /* hax_driver.h */; }; B98ECFC013A059BB00485DDB /* ia32_defs.h in Headers */ = {isa = PBXBuildFile; fileRef = B98ECFA713A059BB00485DDB /* ia32_defs.h */; }; B98ECFC113A059BB00485DDB /* mtrr.h in Headers */ = {isa = PBXBuildFile; fileRef = B98ECFA813A059BB00485DDB /* mtrr.h */; }; @@ -68,7 +68,7 @@ B98ECFC913A059BB00485DDB /* vmx.h in Headers */ = {isa = PBXBuildFile; fileRef = B98ECFB013A059BB00485DDB /* vmx.h */; }; B98ECFCB13A059BB00485DDB /* vcpu.c in Sources */ = {isa = PBXBuildFile; fileRef = B98ECFB213A059BB00485DDB /* vcpu.c */; }; B98ECFCC13A059BB00485DDB /* vm.c in Sources */ = {isa = PBXBuildFile; fileRef = B98ECFB313A059BB00485DDB /* vm.c */; }; - B98ECFCD13A059BB00485DDB /* vmcs_names.c in Sources */ = {isa = PBXBuildFile; fileRef = B98ECFB413A059BB00485DDB /* vmcs_names.c */; }; + B98ECFCD13A059BB00485DDB /* name.c in Sources */ = {isa = PBXBuildFile; fileRef = B98ECFB413A059BB00485DDB /* name.c */; }; B98ECFCE13A059BB00485DDB /* vmx.c in Sources */ = {isa = PBXBuildFile; fileRef = B98ECFB513A059BB00485DDB /* vmx.c */; }; CF0539AD1EE536CB00FAD569 /* chunk.c in Sources */ = {isa = PBXBuildFile; fileRef = CF0539AC1EE536CB00FAD569 /* chunk.c */; }; CF148D601EE6BAEB0097A058 /* memslot.c in Sources */ = {isa = PBXBuildFile; fileRef = CF148D5F1EE6BAEB0097A058 /* memslot.c */; }; @@ -139,13 +139,13 @@ 6E2DBBCD18EB6155003B66C9 /* page_walker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = page_walker.h; sourceTree = ""; }; A669096A20F9985300739075 /* ia32.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ia32.c; path = ../../core/ia32.c; sourceTree = ""; }; B98ECF9C13A059BB00485DDB /* cpu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = cpu.c; path = ../../core/cpu.c; sourceTree = SOURCE_ROOT; }; - B98ECF9D13A059BB00485DDB /* dump_vmcs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = dump_vmcs.c; path = ../../core/dump_vmcs.c; sourceTree = SOURCE_ROOT; }; + B98ECF9D13A059BB00485DDB /* dump.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = dump.c; path = ../../core/dump.c; sourceTree = SOURCE_ROOT; }; B98ECF9E13A059BB00485DDB /* hax.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hax.c; path = ../../core/hax.c; sourceTree = SOURCE_ROOT; }; B98ECFA013A059BB00485DDB /* compiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = compiler.h; sourceTree = ""; }; B98ECFA113A059BB00485DDB /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = ""; }; B98ECFA213A059BB00485DDB /* cpu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cpu.h; sourceTree = ""; }; B98ECFA313A059BB00485DDB /* debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = debug.h; sourceTree = ""; }; - B98ECFA413A059BB00485DDB /* dump_vmcs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dump_vmcs.h; sourceTree = ""; }; + B98ECFA413A059BB00485DDB /* dump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dump.h; sourceTree = ""; }; B98ECFA513A059BB00485DDB /* hax_driver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hax_driver.h; sourceTree = ""; }; B98ECFA713A059BB00485DDB /* ia32_defs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ia32_defs.h; sourceTree = ""; }; B98ECFA813A059BB00485DDB /* mtrr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mtrr.h; sourceTree = ""; }; @@ -157,7 +157,7 @@ B98ECFB013A059BB00485DDB /* vmx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vmx.h; sourceTree = ""; }; B98ECFB213A059BB00485DDB /* vcpu.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vcpu.c; path = ../../core/vcpu.c; sourceTree = SOURCE_ROOT; }; B98ECFB313A059BB00485DDB /* vm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vm.c; path = ../../core/vm.c; sourceTree = SOURCE_ROOT; }; - B98ECFB413A059BB00485DDB /* vmcs_names.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vmcs_names.c; path = ../../core/vmcs_names.c; sourceTree = SOURCE_ROOT; }; + B98ECFB413A059BB00485DDB /* name.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = name.c; path = ../../core/name.c; sourceTree = SOURCE_ROOT; }; B98ECFB513A059BB00485DDB /* vmx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vmx.c; path = ../../core/vmx.c; sourceTree = SOURCE_ROOT; }; CF0539AC1EE536CB00FAD569 /* chunk.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = chunk.c; path = ../../core/chunk.c; sourceTree = ""; }; CF148D5F1EE6BAEB0097A058 /* memslot.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = memslot.c; path = ../../core/memslot.c; sourceTree = ""; }; @@ -232,14 +232,14 @@ 64B85BE81EF4D34D00223ABD /* ept2.c */, 645626201EEFF720005280EF /* ept_tree.c */, B98ECF9C13A059BB00485DDB /* cpu.c */, - B98ECF9D13A059BB00485DDB /* dump_vmcs.c */, + B98ECF9D13A059BB00485DDB /* dump.c */, B98ECF9E13A059BB00485DDB /* hax.c */, B98ECF9F13A059BB00485DDB /* include */, B98ECFB213A059BB00485DDB /* vcpu.c */, FA8F651D208BAD9A00C8E91F /* emulate.c */, FA8F651F208BC1BA00C8E91F /* emulate_ops.asm */, B98ECFB313A059BB00485DDB /* vm.c */, - B98ECFB413A059BB00485DDB /* vmcs_names.c */, + B98ECFB413A059BB00485DDB /* name.c */, B98ECFB513A059BB00485DDB /* vmx.c */, 43C9A9E6138DDA93000A1071 /* hax_host.h */, 1A224C3CFF42312311CA2CB7 /* com_intel_hax.c */, @@ -288,7 +288,7 @@ B98ECFA213A059BB00485DDB /* cpu.h */, 642FD41A20D9F74D00C197FF /* cpuid.h */, B98ECFA313A059BB00485DDB /* debug.h */, - B98ECFA413A059BB00485DDB /* dump_vmcs.h */, + B98ECFA413A059BB00485DDB /* dump.h */, B98ECFA513A059BB00485DDB /* hax_driver.h */, B98ECFA713A059BB00485DDB /* ia32_defs.h */, B98ECFA813A059BB00485DDB /* mtrr.h */, @@ -326,7 +326,7 @@ B98ECFBB13A059BB00485DDB /* cpu.h in Headers */, B98ECFBC13A059BB00485DDB /* debug.h in Headers */, 6448A2211EDFCDAB000B4B32 /* hax_host_mem.h in Headers */, - B98ECFBD13A059BB00485DDB /* dump_vmcs.h in Headers */, + B98ECFBD13A059BB00485DDB /* dump.h in Headers */, 6456261F1EEFF705005280EF /* ept2.h in Headers */, B98ECFBE13A059BB00485DDB /* hax_driver.h in Headers */, B98ECFC013A059BB00485DDB /* ia32_defs.h in Headers */, @@ -438,14 +438,14 @@ 64BB0CD220F36C470064593A /* vmx_ops.asm in Sources */, CF0539AD1EE536CB00FAD569 /* chunk.c in Sources */, 64B85BE91EF4D34D00223ABD /* ept2.c in Sources */, - B98ECFB713A059BB00485DDB /* dump_vmcs.c in Sources */, + B98ECFB713A059BB00485DDB /* dump.c in Sources */, B98ECFB813A059BB00485DDB /* hax.c in Sources */, B98ECFCB13A059BB00485DDB /* vcpu.c in Sources */, B98ECFCC13A059BB00485DDB /* vm.c in Sources */, FA8F651E208BAD9A00C8E91F /* emulate.c in Sources */, CFB6FDDB1ED43C540048A750 /* ramblock.c in Sources */, CFD697471ED2DC9700F10631 /* gpa_space.c in Sources */, - B98ECFCD13A059BB00485DDB /* vmcs_names.c in Sources */, + B98ECFCD13A059BB00485DDB /* name.c in Sources */, B98ECFCE13A059BB00485DDB /* vmx.c in Sources */, 43440F3113A3B69A002E1442 /* hax_mem_alloc.cpp in Sources */, 43440F3213A3B69A002E1442 /* hax_wrapper.cpp in Sources */, diff --git a/platforms/windows/hax_entry.c b/platforms/windows/hax_entry.c index 9cfb7b58..952a7773 100644 --- a/platforms/windows/hax_entry.c +++ b/platforms/windows/hax_entry.c @@ -191,7 +191,7 @@ NTSTATUS HaxClose(PDEVICE_OBJECT DeviceObject, PIRP Irp) NTSTATUS ret = STATUS_SUCCESS; devext = (struct hax_dev_ext *)DeviceObject->DeviceExtension; - hax_log("HaxClose device %x at process %p\n", devext->type, + hax_info("HaxClose device %x at process %p\n", devext->type, (ULONG_PTR)PsGetCurrentThread()); switch (devext->type) { case HAX_DEVEXT_TYPE_UP: @@ -201,7 +201,7 @@ NTSTATUS HaxClose(PDEVICE_OBJECT DeviceObject, PIRP Irp) case HAX_DEVEXT_TYPE_VM: vm = &devext->vmdev_ext; cvm = vm->cvm; - hax_log("Close VM %x\n", vm->vm_id); + hax_info("Close VM %x\n", vm->vm_id); if (cvm) hax_put_vm(cvm); break; @@ -433,7 +433,7 @@ NTSTATUS HaxVcpuControl(PDEVICE_OBJECT DeviceObject, default: hax_error("Unknow vcpu ioctl %lx\n", irpSp->Parameters.DeviceIoControl.IoControlCode); - hax_log("set regs ioctl %lx get regs %lx", HAX_VCPU_SET_REGS, + hax_info("set regs ioctl %lx get regs %lx", HAX_VCPU_SET_REGS, HAX_VCPU_GET_REGS ); ret = STATUS_INVALID_PARAMETER; break; @@ -487,7 +487,7 @@ NTSTATUS HaxVmControl(PDEVICE_OBJECT DeviceObject, struct hax_vm_windows *ext, vm_id = vm->vm_id; cvcpu = vcpu_create(cvm, vm, vcpu_id); if (!cvcpu) { - hax_log("Failed to create vcpu %x on vm %x\n", vcpu_id, vm_id); + hax_info("Failed to create vcpu %x on vm %x\n", vcpu_id, vm_id); ret = STATUS_UNSUCCESSFUL; goto done; } @@ -744,7 +744,7 @@ VOID HaxUnloadDriver(__in PDRIVER_OBJECT DriverObject) RtlInitUnicodeString(&ntWin32NameString, DOS_DEVICE_NAME); IoDeleteSymbolicLink(&ntWin32NameString); IoDeleteDevice(HaxDeviceObject); - hax_log("Unload the driver\n"); + hax_info("Unload the driver\n"); hax_host_exit(); write_event(HaxDriverUnloaded, DriverObject, NULL, 0); HaxDeviceObject = NULL; diff --git a/platforms/windows/haxm-core.vcxproj b/platforms/windows/haxm-core.vcxproj index d504da89..3de07ee1 100644 --- a/platforms/windows/haxm-core.vcxproj +++ b/platforms/windows/haxm-core.vcxproj @@ -113,12 +113,11 @@ - - + - + @@ -133,9 +132,10 @@ - + + @@ -161,9 +161,6 @@ - - -