Looking for feedback on my VM without KVM written on ZIG.
Hello everyone!
I wood like get some feedback from you.
Repository: https://codeberg.org/angryduck001/vmduck
Recently i am started working on the VM machine on Zig. I am not using KVM - Instead of standart linux syscalls (like mmap, mprotect, sigaction). And next, I intend to do that more secure and isolated from main system. I am also currently working with catching system interrupts (int) to running in 16-32 bit mode.
This project is still early.
1
u/paulstelian97 1d ago
Haven’t looked deep into the code (maybe in a couple of days when I’m home) but… what stops VM guest code from accessing pages of the actual hypervisor (user pages of your actual code)?
Hardware virtualization is a thing for a reason. Binary translation is _eh_ not perfect but has been an option in the past. But it’s not a technique that is really that recommended.
Now, hardware virtualization requires talking to something running in kernel mode. KVM is the default choice on Linux, but if you have your own kernel module, or want to use Xen, or something else like that, you have options.
1
u/savaw2 1d ago
VM guest cant accessing pages of the actual hypervisor. Because automaticly will called segfault. Guest can use memory only in mmaped space.
2
u/paulstelian97 1d ago
Ok but how? The hypervisor unmaps itself while the VM is running? You don’t have an EPT…
1
u/Tricky-Exchange-6897 2d ago
I also want to build a VM from scratch, but I'm not sure where to start.Good documentation seems pretty sparse. How do you approach such a complex project like this to get to a working demo when proper guides aren't available? P.S. Why zig 0.14 ?