Skip to content

Commit

Permalink
More VMX
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Chourdakis committed Dec 31, 2018
1 parent e088fad commit 9cfea61
Show file tree
Hide file tree
Showing 12 changed files with 744 additions and 8 deletions.
2 changes: 2 additions & 0 deletions asm.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@
<None Include="data32.asm" />
<None Include="data64.asm" />
<None Include="gdt.asm" />
<None Include="guest16.asm" />
<None Include="guest32.asm" />
<None Include="idt.asm" />
<None Include="iso.ps1" />
<None Include="mutex16.asm" />
Expand Down
6 changes: 6 additions & 0 deletions asm.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,11 @@
<None Include="vmxhost64.asm">
<Filter>VMX</Filter>
</None>
<None Include="guest16.asm">
<Filter>16 bit code</Filter>
</None>
<None Include="guest32.asm">
<Filter>32 bit code</Filter>
</None>
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions bx_enh_dbg.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ isLittleEndian = TRUE
DefaultAsmLines = 512
DumpWSIndex = 0
DockOrder = 0x132
ListWidthPix[0] = 399
ListWidthPix[1] = 561
ListWidthPix[2] = 49
ListWidthPix[0] = 419
ListWidthPix[1] = 551
ListWidthPix[2] = 39
FontName = System
FontSize = -16
MainWindow = 52, 52, 1077, 585
MainWindow = 778, 117, 1803, 650
23 changes: 23 additions & 0 deletions code16.asm
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,29 @@ LoopPRMFound2:
mov [PhysicalPagingOffset64],eax


end if

; --------------------------------------- VMX EPT Find Page Entry ---------------------------------------
if TEST_VMX_1 > 0

xor ecx,ecx
LoopPMR5:
xor eax,eax
mov ax,VMXPAGE64
shl eax,4
add eax,Ept64Null
add eax,ecx
mov ebx,eax
shr eax,12
shl eax,12
cmp eax,ebx
jz LoopPRMFound5
inc ecx
jmp LoopPMR5
LoopPRMFound5:
mov [PhysicalEptOffset64],eax


end if

; --------------------------------------- Quick Unreal ---------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ TEST_MULTI = 1
TEST_RM_SIPI = 1
TEST_PM_SIPI = 1
TEST_LM_SIPI = 1
TEST_VMX_1 = 1
TEST_VMX_1 = 0
1 change: 1 addition & 0 deletions data16.asm
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ idt_size=$-(interruptsall)
; --------------------------------------- PAGE ---------------------------------------
PhysicalPagingOffset32 dd 0
PhysicalPagingOffset64 dd 0
PhysicalEptOffset64 dd 0
14 changes: 14 additions & 0 deletions data64.asm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ VMXStructureData3 dq 0 ; Second VMCS
VMXRevision dd 0 ; Save Revision here
VMXStructureSize dd 0 ; Save structure size here

; Temp Data
TempData db 128 dup(0)

; --------------------------------------- 64 bit Data another segment---------------------------------------
SEGMENT ABSD64 USE64

Expand All @@ -25,6 +28,17 @@ ORG 0

Page64Null dq 30000 dup (0)

;
; --------------------------------------- VMX 64 bit EPT ---------------------------------------
SEGMENT VMXPAGE64 USE64
ORG 0

Ept64Null dq 8192 dup (0);

;EPT_PML4T dq 512 dup (0) ; 512 64-bit entries for EPT Top Level Page Directory
;EPT_PDPT dq 512 dup (0) ; 512 64-bit entries for EPT Page Directory Pointer Table
;EPT_PDT dq 512 dup (0) ; 512 64-bit entries for EPT Page Directory Table
;EPT_PG dq 512 dup (0) ; 512 64-bit entries for EPT Page Table



2 changes: 2 additions & 0 deletions entry.asm
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ INCLUDE 'data64.asm'
INCLUDE 'stack16.asm'
INCLUDE 'stack32.asm'
INCLUDE 'stack64.asm'
INCLUDE 'guest16.asm'
INCLUDE 'code16.asm'
INCLUDE 'a20.asm'
INCLUDE 'idt.asm'
INCLUDE 'gdt.asm'
INCLUDE 'guest32.asm'
INCLUDE 'code32.asm'
INCLUDE 'code64.asm'

Expand Down
Binary file modified entry.exe
Binary file not shown.
49 changes: 49 additions & 0 deletions guest16.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
SEGMENT VMX16 USE16



; VMX Entry for our Virtual Machine
; This is a Real Mode segment

; Note that since the memory is see through, BIOS and DOS interrupts work here!

StartVM:

; Remember we used a protected mode selector to get here?
; Jump to a real mode segment now so CS gets a proper value

; xchg bx,bx
nop
nop

db 0eah
dw PM_VM_Entry,VMX16
PM_VM_Entry:

nop
nop
nop
nop
nop
jmp T_1
nop
nop
EntryByte:
nop
nop
nop
T_1:

mov ax,cs
mov ds,ax
mov ss,ax
mov es,ax
mov sp,0xFFF0

; Write a test byte here
mov byte [ds:EntryByte],0xFA

vmcall ; Forces exit



34 changes: 34 additions & 0 deletions guest32.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
SEGMENT VMX32 USE32

; VMX Entry for our Virtual Machine
; This is a Protected Mode segment

StartVM2: ; This is a protected mode start - 32 bit so registers are already loaded


nop
nop
nop

nop
nop
jmp T_2
nop
nop
EntryByte2:
nop
nop
nop
T_2:


; Write a test byte here
;mov byte [ds:EntryByte2],0xFA

vmcall ; Forces exit






Loading

0 comments on commit 9cfea61

Please sign in to comment.