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-09-03 18:55:08 +0300
committerionescu007 <aionescu+git@gmail.com>2016-09-03 18:55:08 +0300
commita0ec38ceb9fccc6f91ac7c194be65d16c115d157 (patch)
tree303e812974dec7f475ef6f50507ba9ecfc4a9424
parent84c5f91b4c2c86438dfa703f514c5dbf05eddf03 (diff)
Final factoring -- separate portable from non-portable ASM code.
-rw-r--r--shv.vcxproj1
-rw-r--r--shvvmxhvx64.asm47
-rw-r--r--shvx64.asm49
3 files changed, 55 insertions, 42 deletions
diff --git a/shv.vcxproj b/shv.vcxproj
index b70bb57..98bf27a 100644
--- a/shv.vcxproj
+++ b/shv.vcxproj
@@ -69,6 +69,7 @@
<ClInclude Include="vmx.h" />
</ItemGroup>
<ItemGroup>
+ <MASM Include="shvvmxhvx64.asm" />
<MASM Include="shvx64.asm" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
diff --git a/shvvmxhvx64.asm b/shvvmxhvx64.asm
new file mode 100644
index 0000000..1e75175
--- /dev/null
+++ b/shvvmxhvx64.asm
@@ -0,0 +1,47 @@
+;++
+;
+; Copyright (c) Alex Ionescu. All rights reserved.
+;
+; Module:
+;
+; shvvmxhvx64.asm
+;
+; Abstract:
+;
+; This module implements AMD64-specific code for NT support of SimpleVisor.
+;
+; Author:
+;
+; Alex Ionescu (@aionescu) 16-Mar-2016 - Initial version
+;
+; Environment:
+;
+; Kernel mode only.
+;
+;--
+
+include ksamd64.inc
+
+ LEAF_ENTRY _str, _TEXT$00
+ str word ptr [rcx] ; Store TR value
+ ret ; Return
+ LEAF_END _str, _TEXT$00
+
+ LEAF_ENTRY _sldt, _TEXT$00
+ sldt word ptr [rcx] ; Store LDTR value
+ ret ; Return
+ LEAF_END _sldt, _TEXT$00
+
+ LEAF_ENTRY ShvVmxCleanup, _TEXT$00
+ mov ds, cx ; set DS to parameter 1
+ mov es, cx ; set ES to parameter 1
+ mov fs, dx ; set FS to parameter 2
+ ret ; return
+ LEAF_END ShvVmxCleanup, _TEXT$00
+
+ LEAF_ENTRY __lgdt, _TEXT$00
+ lgdt fword ptr [rcx] ; load the GDTR with the value in parameter 1
+ ret ; return
+ LEAF_END __lgdt, _TEXT$00
+
+ end
diff --git a/shvx64.asm b/shvx64.asm
index 2c50c95..e010e66 100644
--- a/shvx64.asm
+++ b/shvx64.asm
@@ -8,7 +8,7 @@
;
; Abstract:
;
-; This module implements AMD64-specific routines for the Simple Hyper Visor.
+; This module implements the AMD64-specific SimpleVisor VMENTRY routine.
;
; Author:
;
@@ -20,59 +20,24 @@
;
;--
-include ksamd64.inc
+ .code
extern ShvVmxEntryHandler:proc
- extern RtlCaptureContext:proc
-
- LEAF_ENTRY _str, _TEXT$00
-
- str word ptr [rcx] ; Store TR value
- ret ; Return
-
- LEAF_END _str, _TEXT$00
-
- LEAF_ENTRY _sldt, _TEXT$00
-
- sldt word ptr [rcx] ; Store LDTR value
- ret ; Return
-
- LEAF_END _sldt, _TEXT$00
-
- NESTED_ENTRY ShvVmxEntry, _TEXT$00
-
- push_reg rcx ; save RCX, as we will need to override it once
- END_PROLOGUE ; we are done messing with the stack
+ extern ShvOsCaptureContext:proc
+ ShvVmxEntry PROC
+ push rcx ; save the RCX register, which we spill below
lea rcx, [rsp+8h] ; store the context in the stack, bias for
; the return address and the push we just did.
- call RtlCaptureContext ; save the current register state.
+ call ShvOsCaptureContext ; save the current register state.
; note that this is a specially written function
; which has the following key characteristics:
; 1) it does not taint the value of RCX
; 2) it does not spill any registers, nor
; expect home space to be allocated for it
-
jmp ShvVmxEntryHandler ; jump to the C code handler. we assume that it
; compiled with optimizations and does not use
; home space, which is true of release builds.
-
- NESTED_END ShvVmxEntry, _TEXT$00
-
- LEAF_ENTRY ShvVmxCleanup, _TEXT$00
-
- mov ds, cx ; set DS to parameter 1
- mov es, cx ; set ES to parameter 1
- mov fs, dx ; set FS to parameter 2
- ret ; return
-
- LEAF_END ShvVmxCleanup, _TEXT$00
-
- LEAF_ENTRY __lgdt, _TEXT$00
-
- lgdt fword ptr [rcx] ; load the GDTR with the value in parameter 1
- ret ; return
-
- LEAF_END __lgdt, _TEXT$00
+ ShvVmxEntry ENDP
end