Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ionescu007/SimpleVisor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorionescu007 <aionescu+git@gmail.com>2016-08-28 23:07:25 +0300
committerionescu007 <aionescu+git@gmail.com>2016-08-28 23:07:25 +0300
commitbbc18f49a677f7e452c14cf614bace6131411c5b (patch)
treeea0d47f0324ea42893ee052a3bfe9e34eac69271 /shvvmxhv.c
parent16b6c8ffe1beb92e250f3f094b89ce97a0f3a94a (diff)
Fix SimpleVisor to work on VMWare, stop using KeSaveStateForHibernate and misc. cleanups
SimpleVisor was previously using the presence of *ANY* hypervisor as a sign that it is already loaded. This breaks if the loaded hypervisor actually supports nesting and/or isn't SimpleVisor. As such, always try to enable SimpleVisor -- ShvVmxProbe will fail if we can't, and detect SimpleVisor explicitly using the Hyper-V Detection Interface (used by all hypervisors these days). Second, stop using KeSaveStateForHibernate. While it saved us the need for two more assembly instructions (str/sldt), it appears to have bugs around handling of DebugControl, on top of the other bugs we already had to work around. Instead, just use compiler instrincs to grab the required state, which is faster anyway. Move Intel VT-x specific structures into vmx.h instead of shv.h
Diffstat (limited to 'shvvmxhv.c')
-rw-r--r--shvvmxhv.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/shvvmxhv.c b/shvvmxhv.c
index 20eb4ae..ab8f281 100644
--- a/shvvmxhv.c
+++ b/shvvmxhv.c
@@ -105,7 +105,14 @@ ShvVmxHandleCpuid (
// Set the Hypervisor Present-bit in RCX, which Intel and AMD have both
// reserved for this indication.
//
- cpu_info[2] |= 0x80000000;
+ cpu_info[2] |= HYPERV_HYPERVISOR_PRESENT_BIT;
+ }
+ else if (VpState->VpRegs->Rax == HYPERV_CPUID_INTERFACE)
+ {
+ //
+ // Return our interface identifier
+ //
+ cpu_info[0] = ' vhS';
}
//
@@ -262,8 +269,8 @@ ShvVmxEntryHandler (
// eventually crash the system. Since we know what the original state
// of the GDTR and IDTR was, simply restore it now.
//
- __lgdt(&vpData->HostState.SpecialRegisters.Gdtr.Limit);
- __lidt(&vpData->HostState.SpecialRegisters.Idtr.Limit);
+ __lgdt(&vpData->SpecialRegisters.Gdtr.Limit);
+ __lidt(&vpData->SpecialRegisters.Idtr.Limit);
//
// Our DPC routine may have interrupted an arbitrary user process, and