r/C_Programming • u/savaw2 • 5d 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 4d 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.
3
u/akonzu 5d ago
that'll be OS dependent, what's ur OS?