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
path: root/shv.h
diff options
context:
space:
mode:
authorionescu007 <aionescu+git@gmail.com>2016-08-29 20:49:52 +0300
committerionescu007 <aionescu+git@gmail.com>2016-08-29 20:49:52 +0300
commitf35f5b35bf3dfda2b65b92ccf47a2e7953351563 (patch)
treec3d86202061df9b017f7338f5d5c20cc313d5cb6 /shv.h
parentdd64f6a1cdc6d7a396d0e9c9fd2f875685effb37 (diff)
Separate Hypervisor Core from OS Layer. Don't touch IRQL in Hypervisor. Separate Load vs Unload callback. Misc. portability fixes.
Create a layer of OS-specific functions to handle the various requirements around memory allocation, context save/restore, entrypoint/unloadpoint, and multi-CPU execution and topology information. SimpleVisor no longer uses NT-specific functions (some structures and types still remain). Additionally, the hypervisor should not know that "NT" is running underneath, so it has no business touching the IRQL. As we won't call Windows functions, and as interrupts are disabled, this doesn't 'change' anything and is correct. Don't use the same callback for load and unload. We can make unload its own callback now, as we've separated out the DPC-specific logic. This makes the load callback cleaner as well. Remove NT_ASSERTS which don't work anyway, and use portable definitions/types when possible (more to do here). Return the failed CPU and status in all cases during load. Sometimes this wasn't done before.
Diffstat (limited to 'shv.h')
-rw-r--r--shv.h59
1 files changed, 50 insertions, 9 deletions
diff --git a/shv.h b/shv.h
index 7331a0c..e78e557 100644
--- a/shv.h
+++ b/shv.h
@@ -79,10 +79,24 @@ typedef struct _SHV_VP_STATE
ULONG_PTR GuestRsp;
ULONG_PTR GuestEFlags;
USHORT ExitReason;
- KIRQL GuestIrql;
BOOLEAN ExitVm;
} SHV_VP_STATE, *PSHV_VP_STATE;
+typedef struct _SHV_CALLBACK_CONTEXT
+{
+ ULONG64 Cr3;
+ volatile ULONG InitCount;
+ LONG FailedCpu;
+ NTSTATUS FailureStatus;
+} SHV_CALLBACK_CONTEXT, *PSHV_CALLBACK_CONTEXT;
+
+typedef
+VOID
+SHV_CPU_CALLBACK (
+ _In_ PSHV_CALLBACK_CONTEXT Context
+ );
+typedef SHV_CPU_CALLBACK *PSHV_CPU_CALLBACK;
+
VOID
ShvVmxEntry (
VOID
@@ -142,21 +156,48 @@ ShvVmxEptInitialize (
_In_ PSHV_VP_DATA VpData
);
+NTSTATUS
+ShvLoad (
+ VOID
+ );
+
+VOID
+ShvUnload (
+ VOID
+ );
+
+DECLSPEC_NORETURN
+VOID
+__cdecl
+ShvOsRestoreContext (
+ _In_ PCONTEXT ContextRecord
+ );
+
+VOID
+ShvOsFreeContiguousAlignedMemory (
+ _In_ PVOID BaseAddress
+ );
+
+PVOID
+ShvOsAllocateContigousAlignedMemory (
+ _In_ SIZE_T Size
+ );
+
DECLSPEC_NORETURN
VOID
ShvVpRestoreAfterLaunch (
VOID
);
-typedef struct _SHV_DPC_CONTEXT
-{
- ULONG64 Cr3;
- volatile ULONG InitCount;
- LONG FailedCpu;
- NTSTATUS FailureStatus;
-} SHV_DPC_CONTEXT, *PSHV_DPC_CONTEXT;
+VOID
+ShvOsRunCallbackOnProcessors (
+ _In_ PSHV_CPU_CALLBACK Routine,
+ _In_opt_ PVOID Context
+ );
-KDEFERRED_ROUTINE ShvVpCallbackDpc;
+SHV_CPU_CALLBACK ShvVpLoadCallback;
+SHV_CPU_CALLBACK ShvVpUnloadCallback;
extern PSHV_VP_DATA* ShvGlobalData;
+#define ShvOsDebugPrint(format, ...) DbgPrintEx(DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, format, __VA_ARGS__)