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 1 commit
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
61 changes: 2 additions & 59 deletions core/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "include/cpuid.h"
#include "include/vcpu.h"
#include "include/debug.h"
#include "include/dump_vmcs.h"
#include "include/dump.h"
#include "include/vtlb.h"
#include "include/intr.h"
#include "include/ept.h"
Expand Down Expand Up @@ -136,26 +136,7 @@ void cpu_init_vmx(void *arg)
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

Expand Down Expand Up @@ -282,44 +263,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__))
Expand Down
69 changes: 68 additions & 1 deletion core/dump_vmcs.c → core/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

#include "include/vmx.h"
#include "include/dump_vmcs.h"
#include "include/dump.h"
#include "include/compiler.h"
#include "../include/hax.h"

Expand Down Expand Up @@ -340,3 +340,70 @@ void dump_vmcs(struct vcpu_t *vcpu)
vmread_dump(vcpu, enc, name);
}
}

void dump_vmx_info(struct info_t *info)
{
hax_log("VMCS Rev %d\n", info->_vmcs_revision_id);

hax_log("VMX basic info : 0x%016llX\n",
info->_basic_info);
hax_log("VMX misc info : 0x%08llX\n",
info->_miscellaneous);
hax_log("VMX revision control : %d\n",
info->_vmcs_revision_id);
hax_log("VMX exit ctls : 0x%X, 0x%X\n",
info->exit_ctls_0, info->exit_ctls_1);
hax_log("VMX entry ctls : 0x%X, 0x%X\n",
info->entry_ctls_0, info->entry_ctls_1);
hax_log("VMX pin ctls : 0x%X, 0x%X\n",
info->pin_ctls_0, info->pin_ctls_1);
hax_log("VMX cpu prim ctrls : 0x%X, 0x%X\n",
info->pcpu_ctls_0, info->pcpu_ctls_1);
hax_log("VMX cpu sec ctrl : 0x%X, 0x%X\n",
info->scpu_ctls_0, info->scpu_ctls_1);
hax_log("VMX fixed CR0 bits : 0x%llX, %llX\n",
info->_cr0_fixed_0, info->_cr0_fixed_1);
hax_log("VMX fixed CR4 bits : 0x%llX, %llX\n",
info->_cr4_fixed_0, info->_cr4_fixed_1);
hax_log("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);
}*/
3 changes: 0 additions & 3 deletions core/hax.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -595,5 +594,3 @@ int hax_module_exit(void)

return 0;
}

int hax_put_vcpu(struct vcpu_t *vcpu);
8 changes: 5 additions & 3 deletions core/include/dump_vmcs.h → core/include/dump.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +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);

#endif // HAX_CORE_DUMP_VMCS_H_
void dump_vmx_info(struct info_t *info);

#endif // HAX_CORE_DUMP_H_
2 changes: 1 addition & 1 deletion core/vcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions platforms/windows/haxm-core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<ClCompile Include="..\..\core\chunk.c" />
<ClCompile Include="..\..\core\cpu.c" />
<ClCompile Include="..\..\core\cpuid.c" />
<ClCompile Include="..\..\core\dump_vmcs.c" />
<ClCompile Include="..\..\core\dump.c" />
<ClCompile Include="..\..\core\emulate.c" />
<ClCompile Include="..\..\core\ept.c" />
<ClCompile Include="..\..\core\ept2.c" />
Expand Down Expand Up @@ -160,9 +160,6 @@
<None Exclude="@(None)" Include="*.def;*.bat;*.hpj;*.asmx" />
<None Include="packages.haxm-core.config" />
</ItemGroup>
<ItemGroup>
<ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" />
</ItemGroup>
<!-- /Necessary to pick up proper files from local directory when in the IDE-->
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down