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 /ntint.h
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 'ntint.h')
-rw-r--r--ntint.h88
1 files changed, 3 insertions, 85 deletions
diff --git a/ntint.h b/ntint.h
index ce6eda5..6ffb5a4 100644
--- a/ntint.h
+++ b/ntint.h
@@ -32,56 +32,6 @@ typedef struct _KDESCRIPTOR {
PVOID Base;
} KDESCRIPTOR, *PKDESCRIPTOR;
-typedef struct _KDESCRIPTOR32 {
- USHORT Pad[3];
- USHORT Limit;
- ULONG Base;
-} KDESCRIPTOR32, *PKDESCRIPTOR32;
-
-//
-// Define special kernel registers and the initial MXCSR value.
-//
-
-typedef struct _KSPECIAL_REGISTERS {
- ULONG64 Cr0;
- ULONG64 Cr2;
- ULONG64 Cr3;
- ULONG64 Cr4;
- ULONG64 KernelDr0;
- ULONG64 KernelDr1;
- ULONG64 KernelDr2;
- ULONG64 KernelDr3;
- ULONG64 KernelDr6;
- ULONG64 KernelDr7;
- KDESCRIPTOR Gdtr;
- KDESCRIPTOR Idtr;
- USHORT Tr;
- USHORT Ldtr;
- ULONG MxCsr;
- ULONG64 DebugControl;
- ULONG64 LastBranchToRip;
- ULONG64 LastBranchFromRip;
- ULONG64 LastExceptionToRip;
- ULONG64 LastExceptionFromRip;
- ULONG64 Cr8;
- ULONG64 MsrGsBase;
- ULONG64 MsrGsSwap;
- ULONG64 MsrStar;
- ULONG64 MsrLStar;
- ULONG64 MsrCStar;
- ULONG64 MsrSyscallMask;
- ULONG64 Xcr0;
-} KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS;
-
-//
-// Define processor state structure.
-//
-
-typedef struct _KPROCESSOR_STATE {
- KSPECIAL_REGISTERS SpecialRegisters;
- CONTEXT ContextFrame;
-} KPROCESSOR_STATE, *PKPROCESSOR_STATE;
-
//
// Define descriptor privilege levels for user and system.
//
@@ -121,6 +71,9 @@ typedef struct _KPROCESSOR_STATE {
#define KGDT64_R3_CMTEB 0x50
#define KGDT64_R0_LDT 0x60
+#define MSR_GS_BASE 0xC0000101
+#define MSR_DEBUG_CTL 0x1D9
+
#define RPL_MASK 3
#define MTRR_TYPE_WB 6
@@ -196,38 +149,3 @@ RtlRestoreContext(
_In_ PCONTEXT ContextRecord,
_In_opt_ struct _EXCEPTION_RECORD * ExceptionRecord
);
-
-NTKERNELAPI
-VOID
-__cdecl
-KeSaveStateForHibernate (
- _In_ PKPROCESSOR_STATE State
- );
-
-#if (NTDDI_VERSION < NTDDI_WINTHRESHOLD)
-BOOLEAN
-FORCEINLINE
-HviIsAnyHypervisorPresent (
- VOID
- )
-{
- INT cpuInfo[4];
-
- __cpuid(cpuInfo, 1);
-
- if (cpuInfo[2] & 0x80000000)
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
-}
-#else
-NTKERNELAPI
-BOOLEAN
-HviIsAnyHypervisorPresent (
- VOID
- );
-#endif