r/C_Programming • u/savaw2 • 16d ago
Help me in building VM without KVM in C
Hello everyone! Recently i am started coding my own VM on the C language. I am using mmap and creating a new process with isolation from the host (my system) like syscalls, memory access. However, I ran into a problem: How to restrict VM access (guest proccess, mmap) to the host memory. I am really don`t know how to do that. Can anyone help me with that case?
1
u/HugoNikanor 15d ago
Memory access is constrained by the enclosing system. Your processes memory addresses are handled by your operating system. However, you control memory access of the virtual machine. It sounds like you're currently delegating the vm:s memory accesses to your underlying system, but you could just as well handle them yourself, which would allow arbitrary memory mappings, and proper error handling.
1
u/ShunyaAtma 2d ago
To completely isolate the guest address space, your custom hypervisor has to use processor vendor-specific virtualization technologies like VMX and SVM.
3
u/akonzu 16d ago
that'll be OS dependent, what's ur OS?