diff options
author | ionescu007 <aionescu+git@gmail.com> | 2016-08-29 20:49:52 +0300 |
---|---|---|
committer | ionescu007 <aionescu+git@gmail.com> | 2016-08-29 20:49:52 +0300 |
commit | f35f5b35bf3dfda2b65b92ccf47a2e7953351563 (patch) | |
tree | c3d86202061df9b017f7338f5d5c20cc313d5cb6 /shv.h | |
parent | dd64f6a1cdc6d7a396d0e9c9fd2f875685effb37 (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.h | 59 |
1 files changed, 50 insertions, 9 deletions
@@ -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__) |