diff --git a/HyperBone.vcxproj b/HyperBone.vcxproj
index 293ec71..d85f7e2 100644
--- a/HyperBone.vcxproj
+++ b/HyperBone.vcxproj
@@ -104,45 +104,45 @@
DbgengKernelDebugger
- $(SolutionDir)\bin\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)bin\$(Platform)\$(ConfigurationName)\
http://timestamp.verisign.com/scripts/timstamp.dll
- $(SolutionDir)\obj\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)obj\$(Platform)\$(ConfigurationName)\
$(TargetName)
- $(SolutionDir)\bin\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)bin\$(Platform)\$(ConfigurationName)\
http://timestamp.verisign.com/scripts/timstamp.dll
- $(SolutionDir)\obj\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)obj\$(Platform)\$(ConfigurationName)\
$(TargetName)
- $(SolutionDir)\bin\$(Platform)\$(ConfigurationName)\
- $(SolutionDir)\obj\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)bin\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)obj\$(Platform)\$(ConfigurationName)\
$(TargetName)
- $(SolutionDir)\bin\$(Platform)\$(ConfigurationName)\
- $(SolutionDir)\obj\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)bin\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)obj\$(Platform)\$(ConfigurationName)\
$(TargetName)
- $(SolutionDir)\bin\$(Platform)\$(ConfigurationName)\
- $(SolutionDir)\obj\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)bin\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)obj\$(Platform)\$(ConfigurationName)\
$(TargetName)
- $(SolutionDir)\bin\$(Platform)\$(ConfigurationName)\
- $(SolutionDir)\obj\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)bin\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)obj\$(Platform)\$(ConfigurationName)\
$(TargetName)
- $(SolutionDir)\bin\$(Platform)\$(ConfigurationName)\
- $(SolutionDir)\obj\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)bin\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)obj\$(Platform)\$(ConfigurationName)\
$(TargetName)
- $(SolutionDir)\bin\$(Platform)\$(ConfigurationName)\
- $(SolutionDir)\obj\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)bin\$(Platform)\$(ConfigurationName)\
+ $(SolutionDir)obj\$(Platform)\$(ConfigurationName)\
$(TargetName)
@@ -176,9 +176,7 @@
$(OutDir)$(TargetName)$(TargetExt)
FltMgr.lib;%(AdditionalDependencies)
-
- copy /y "$(TargetPath)" \\Win81_x64\c$\$(TargetFileName)
-
+
@@ -193,9 +191,7 @@
$(OutDir)$(TargetName)$(TargetExt)
FltMgr.lib;%(AdditionalDependencies)
-
- copy /y "$(TargetPath)" \\Win10_x64\c$\$(TargetFileName)
-
+
@@ -204,10 +200,7 @@
_WIN8_;%(PreprocessorDefinitions)
4054;4055;%(DisableSpecificWarnings)
-
-
-
-
+
$(OutDir)$(TargetName)$(TargetExt)
FltMgr.lib;%(AdditionalDependencies)
@@ -227,9 +220,7 @@
_WIN7_;%(PreprocessorDefinitions)
4054;4055;%(DisableSpecificWarnings)
-
- copy /y "$(TargetPath)" \\Win7_x64\c$\$(TargetFileName)
-
+
$(OutDir)$(TargetName)$(TargetExt)
FltMgr.lib;%(AdditionalDependencies)
@@ -242,10 +233,7 @@
_WIN7_;%(PreprocessorDefinitions)
4054;4055;%(DisableSpecificWarnings)
-
-
-
-
+
$(OutDir)$(TargetName)$(TargetExt)
FltMgr.lib;%(AdditionalDependencies)
@@ -284,10 +272,7 @@
_WIN8_;%(PreprocessorDefinitions)
4054;4055;%(DisableSpecificWarnings)
-
-
-
-
+
$(OutDir)$(TargetName)$(TargetExt)
FltMgr.lib;%(AdditionalDependencies)
diff --git a/src/Arch/Intel/VMX.c b/src/Arch/Intel/VMX.c
index 9c1c575..a0b0ee2 100644
--- a/src/Arch/Intel/VMX.c
+++ b/src/Arch/Intel/VMX.c
@@ -482,8 +482,11 @@ VOID VmxSetupVMCS( IN PVCPU VpData )
// makes use of both of these instructions if the CPU supports it. By using
// VmxpAdjustMsr, these options will be ignored if this processor does
// not actually support the instructions to begin with.
+
vmCpuCtl2Requested.Fields.EnableRDTSCP = TRUE;
+ vmCpuCtl2Requested.Fields.EnableINVPCID = TRUE;
vmCpuCtl2Requested.Fields.EnableXSAVESXSTORS = TRUE;
+
// Begin by setting the link pointer to the required value for 4KB VMCS.
__vmx_vmwrite( VMCS_LINK_POINTER, MAXULONG64 );
@@ -532,7 +535,7 @@ VOID VmxSetupVMCS( IN PVCPU VpData )
// Exception bitmap
ULONG ExceptionBitmap = 0;
//ExceptionBitmap |= 1 << VECTOR_DEBUG_EXCEPTION;
- ExceptionBitmap |= 1 << VECTOR_BREAKPOINT_EXCEPTION;
+ //ExceptionBitmap |= 1 << VECTOR_BREAKPOINT_EXCEPTION;
__vmx_vmwrite( EXCEPTION_BITMAP, ExceptionBitmap );
diff --git a/src/Arch/Intel/VmxExitHandlers.c b/src/Arch/Intel/VmxExitHandlers.c
index 68b0d12..23203f7 100644
--- a/src/Arch/Intel/VmxExitHandlers.c
+++ b/src/Arch/Intel/VmxExitHandlers.c
@@ -156,6 +156,8 @@ DECLSPEC_NORETURN EXTERN_C VOID VmxpExitHandler( IN PCONTEXT Context )
guestContext.GpRegs = Context;
guestContext.ExitPending = FALSE;
+ //Context->Rsp = guestContext.GuestRsp;
+
(g_ExitHandler[guestContext.ExitReason])(&guestContext);
if (guestContext.ExitPending)
@@ -212,6 +214,7 @@ VOID VmExitINVD( IN PGUEST_STATE GuestState )
/// Guest VM state
VOID VmExitCPUID( IN PGUEST_STATE GuestState )
{
+ KdBreakPoint();
CPUID cpu_info = { 0 };
__cpuidex( (int*)&cpu_info, (int)GuestState->GpRegs->Rax, (int)GuestState->GpRegs->Rcx );
@@ -338,26 +341,34 @@ VOID VmExitCR( IN PGUEST_STATE GuestState )
{
PMOV_CR_QUALIFICATION data = (PMOV_CR_QUALIFICATION)&GuestState->ExitQualification;
PULONG64 regPtr = (PULONG64)&GuestState->GpRegs->Rax + data->Fields.Register;
+ ULONG64 regValue = *((PULONG64)&GuestState->GpRegs->Rax + data->Fields.Register);
VPID_CTX ctx = { 0 };
switch (data->Fields.AccessType)
{
case TYPE_MOV_TO_CR:
{
+ if (data->Fields.Register == 4)
+ {
+ regValue = GuestState->GuestRsp;
+ }
+
switch (data->Fields.ControlRegister)
{
case 0:
- __vmx_vmwrite( GUEST_CR0, *regPtr );
- __vmx_vmwrite( CR0_READ_SHADOW, *regPtr );
+ __vmx_vmwrite( GUEST_CR0, regValue);
+ __vmx_vmwrite( CR0_READ_SHADOW, regValue);
break;
case 3:
- __vmx_vmwrite( GUEST_CR3, *regPtr );
+
+ regValue &= ~(1ULL << 63);
+ __vmx_vmwrite( GUEST_CR3, regValue);
if (g_Data->Features.VPID)
__invvpid( INV_ALL_CONTEXTS, &ctx );
break;
case 4:
- __vmx_vmwrite( GUEST_CR4, *regPtr );
- __vmx_vmwrite( CR4_READ_SHADOW, *regPtr );
+ __vmx_vmwrite( GUEST_CR4, regValue);
+ __vmx_vmwrite( CR4_READ_SHADOW, regValue);
break;
default:
DPRINT( "HyperBone: CPU %d: %s: Unsupported register %d\n", CPU_IDX, __FUNCTION__, data->Fields.ControlRegister );
@@ -385,6 +396,12 @@ VOID VmExitCR( IN PGUEST_STATE GuestState )
ASSERT( FALSE );
break;
}
+
+ if (data->Fields.Register == 4)
+ {
+ __vmx_vmwrite(GUEST_RSP, *regPtr);
+ }
+
}
break;
@@ -614,9 +631,9 @@ VOID VmExitMTF( IN PGUEST_STATE GuestState )
VOID VmExitStartFailed( IN PGUEST_STATE GuestState )
{
DPRINT(
- "HyperBone: CPU %d: %s: Failed to enter VM, reason %d, code %d\n",
+ "HyperBone: CPU %d: %s: Failed to enter VM, reason %d, code %d, guest RIP %p\n",
CPU_IDX, __FUNCTION__,
- GuestState->ExitReason, GuestState->ExitQualification
+ GuestState->ExitReason, GuestState->ExitQualification,GuestState->GuestRip
);
KeBugCheckEx( HYPERVISOR_ERROR, BUG_CHECK_INVALID_VM, GuestState->ExitReason, GuestState->ExitQualification, 0 );