Examples for: Learning KVM - implement your own kernel
Examples for: Learning KVM - implement your own kernel
The source code are examples on my blog: Learning KVM - implement your own kernel.
I've described how to implement a KVM-based hypervisor and the key points to implement a kernel on my blog. You can leave comments in the blog or file issues here if you have questions or find any bug.
The KVM-based hypervisor, its role is like qemu-system.
A extremely simple kernel, supports few syscalls.
Simple ELF(s) for testing our kernel. Pre-built user program was provided, and you can re-generate by the following commands:
$ pip3 install pwntools
$ user/gen.py
NOTE: You have to install Python 3.x in advance.
Check if your CPU supports virtualization:
$ egrep '(vmx|svm)' /proc/cpuinfo
NOTE: CPUs in a VM might not support virtualization (i.e. no nested virtualization). For example, EC2 on AWS doesn't support using KVM.
Check if the KVM device exists:
$ ls -la /dev/kvm
If /dev/kvm is not found, you can enable it (on Ubuntu) with:
$ sudo apt install qemu-kvm
If you are not root, you need to add yourself into the kvm group to have permission for accessing /dev/kvm.
$ sudo usermod -a -G kvm `whoami`
Remember to logout and login to have the group changing effective.
…
I only tested the code on Ubuntu 18.04, but I expect it to work on all KVM-supported x86 Linux distributions. Please file an issue if you find it's not true.
No open issues yet, or sync has not completed.