diff options
author | ionescu007 <aionescu+git@gmail.com> | 2016-09-03 18:50:58 +0300 |
---|---|---|
committer | ionescu007 <aionescu+git@gmail.com> | 2016-09-03 18:50:58 +0300 |
commit | 84c5f91b4c2c86438dfa703f514c5dbf05eddf03 (patch) | |
tree | 9cc2c578a70e8add2618a74f70a6eccb3d15bd4c /vmx.h | |
parent | d580e2e5b8bac8b814927242ce773f366db62fde (diff) |
Support VMWARE/non-EPT sytems. More portability support with non-NT systems. Refactoring. Reject NULL/LDT selectors when building VMCS.
Support systems without 1GB HugePage EPT support (such as Vmware) by
simply not enabling EPT for the.
Refactor header files and some definitions again to support non-NT.
Deallocation routines on some platform need to have a size. Refactor
alloc and free so this is easy to maintain portably.
Make ShvVmxLaunchOnVpreturn a status code instead of VOID, so we can
actually know if launch failed instead of just relying on CPUID (which,
if the hypervisor was already loaded, misidentified that a second load
failed, and instead assumed success).
Refactor the launch/off-on-failure code into a ShvVmxLaunch routine.
Fix some comments to reflect the new portability layer/refactoring.
Factor out OS-specific load/unload logic
(ShvOsPrepareProcessor/ShvOsUnprepareProcessor)
Fix ShvUtilConvertGdtEntry to reject selectors with the TI bit set, or
NULL selectors, and correctly mark them as unusable.
Diffstat (limited to 'vmx.h')
-rw-r--r-- | vmx.h | 40 |
1 files changed, 29 insertions, 11 deletions
@@ -24,14 +24,18 @@ Environment: #pragma warning(disable:4201) #pragma warning(disable:4214) -#define DPL_USER 3 -#define DPL_SYSTEM 0 -#define MSR_GS_BASE 0xC0000101 -#define MSR_DEBUG_CTL 0x1D9 -#define RPL_MASK 3 -#define MTRR_TYPE_WB 6 -#define EFLAGS_ALIGN_CHECK 0x40000 -#define PAGE_SIZE 4096 +#define DPL_USER 3 +#define DPL_SYSTEM 0 +#define MSR_GS_BASE 0xC0000101 +#define MSR_DEBUG_CTL 0x1D9 +#define RPL_MASK 3 +#define SELECTOR_TABLE_INDEX 0x04 +#define MTRR_TYPE_WB 6 +#define EFLAGS_ALIGN_CHECK 0x40000 +#define AMD64_TSS 9 +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif typedef struct _KDESCRIPTOR { @@ -79,6 +83,20 @@ typedef union _KGDTENTRY64 }; } KGDTENTRY64, *PKGDTENTRY64; +#pragma pack(push,4) +typedef struct _KTSS64 +{ + UINT32 Reserved0; + UINT64 Rsp0; + UINT64 Rsp1; + UINT64 Rsp2; + UINT64 Ist[8]; + UINT64 Reserved1; + UINT16 Reserved2; + UINT16 IoMapBase; +} KTSS64, *PKTSS64; +#pragma pack(pop) + #define CPU_BASED_VIRTUAL_INTR_PENDING 0x00000004 #define CPU_BASED_USE_TSC_OFFSETING 0x00000008 #define CPU_BASED_HLT_EXITING 0x00000080 @@ -410,7 +428,7 @@ enum vmcs_field { typedef struct _VMX_GDTENTRY64 { - uintptr_t Base; + UINT64 Base; UINT32 Limit; union { @@ -511,8 +529,8 @@ typedef struct _VMX_HUGE_PDPTE }; } VMX_HUGE_PDPTE, *PVMX_HUGE_PDPTE; -C_ASSERT(sizeof(VMX_EPTP) == sizeof(UINT64)); -C_ASSERT(sizeof(VMX_EPML4E) == sizeof(UINT64)); +static_assert(sizeof(VMX_EPTP) == sizeof(UINT64), "EPTP Size Mismatch"); +static_assert(sizeof(VMX_EPML4E) == sizeof(UINT64), "EPML4E Size Mismatch"); #define PML4E_ENTRY_COUNT 512 #define PDPTE_ENTRY_COUNT 512 |