Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Hypervisor support #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,17 @@ add_executable(openswe1r
)

if(USE_VM)
target_compile_definitions(openswe1r PUBLIC -DUC_KVM)
target_sources(openswe1r PUBLIC
uc_kvm.c
)
if (WIN32)
target_compile_definitions(openswe1r PUBLIC -DUC_WHV)
target_sources(openswe1r PUBLIC
uc_whv.c
)
else()
target_compile_definitions(openswe1r PUBLIC -DUC_KVM)
target_sources(openswe1r PUBLIC
uc_kvm.c
)
endif()
else()
target_link_libraries(openswe1r
${LIBUNICORN_LIBRARY}
Expand Down
6 changes: 3 additions & 3 deletions uc_kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ uc_err uc_open(uc_arch arch, uc_mode mode, uc_engine **uc) {

// Load a small bios which boots CPU into protected mode
uint8_t* bios = memalign(0x100000, bios_size);
FILE* f = fopen("uc_kvm_loader", "rb");
FILE* f = fopen("uc_vm_loader", "rb");
assert(f != NULL);
fread(bios, 1, bios_size, f);
fclose(f);
Expand All @@ -208,7 +208,7 @@ uc_err uc_open(uc_arch arch, uc_mode mode, uc_engine **uc) {
}

// Prepare CPU State
struct kvm_regs regs = { 0 };
struct kvm_regs regs = { 0 };

regs.rax = 0;
regs.rbx = 0;
Expand All @@ -229,7 +229,7 @@ uc_err uc_open(uc_arch arch, uc_mode mode, uc_engine **uc) {
ioctl(u->vcpu_fd, KVM_RUN, 0);
printf("exit reason: %d\n", u->run->exit_reason);
printRegs(u);
assert(u->run->exit_reason == KVM_EXIT_IO);
assert(u->run->exit_reason == KVM_EXIT_HLT);

// Enable signals
sigset_t set;
Expand Down
8 changes: 4 additions & 4 deletions uc_kvm_loader.asm → uc_vm_loader.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
; Licensed under GPLv2 or any later version
; Refer to the included LICENSE.txt file.

; Build using: nasm uc_kvm_loader.asm -o build/uc_kvm_loader
; Inspect using (16 bit): objdump -D -bbinary -mi8086 -Mintel --adjust-vma=0xFFFFF0000 build/uc_kvm_loader
; Inspect using (32 bit): objdump -D -bbinary -mi386 -Mintel --adjust-vma=0xFFFFF0000 build/uc_kvm_loader
; Build using: nasm uc_vm_loader.asm -o build/uc_vm_loader
; Inspect using (16 bit): objdump -D -bbinary -mi8086 -Mintel --adjust-vma=0xFFFFF0000 build/uc_vm_loader
; Inspect using (32 bit): objdump -D -bbinary -mi386 -Mintel --adjust-vma=0xFFFFF0000 build/uc_vm_loader

org 0xFFFFF000

Expand All @@ -29,7 +29,7 @@ reload_cs:
mov ds, eax
mov es, eax
mov ss, eax
out dx,ax
hlt

align 16
gdtr:
Expand Down
Loading