{"id":15003679,"url":"https://github.com/david942j/kvm-kernel-example","last_synced_at":"2025-04-06T00:10:40.136Z","repository":{"id":54483858,"uuid":"151266327","full_name":"david942j/kvm-kernel-example","owner":"david942j","description":"Examples for: Learning KVM - implement your own kernel","archived":false,"fork":false,"pushed_at":"2023-09-03T09:05:40.000Z","size":32,"stargazers_count":369,"open_issues_count":0,"forks_count":54,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-29T23:11:27.652Z","etag":null,"topics":["kernel","kvm","kvm-hypervisor","linux-kernel","vm"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/david942j.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-02T14:15:25.000Z","updated_at":"2025-03-23T17:31:02.000Z","dependencies_parsed_at":"2024-12-16T10:39:46.821Z","dependency_job_id":null,"html_url":"https://github.com/david942j/kvm-kernel-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/david942j%2Fkvm-kernel-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/david942j%2Fkvm-kernel-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/david942j%2Fkvm-kernel-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/david942j%2Fkvm-kernel-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/david942j","download_url":"https://codeload.github.com/david942j/kvm-kernel-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415973,"owners_count":20935387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kernel","kvm","kvm-hypervisor","linux-kernel","vm"],"created_at":"2024-09-24T19:00:16.580Z","updated_at":"2025-04-06T00:10:40.118Z","avatar_url":"https://github.com/david942j.png","language":"C","readme":"# KVM-Kernel Example\n\nThe source code are examples on my blog: [Learning KVM - implement your own kernel](https://david942j.blogspot.com/2018/10/note-learning-kvm-implement-your-own.html).\n\nI've described how to implement a KVM-based hypervisor and the key points to implement a kernel on my blog.\nYou can leave comments in the blog or file issues here if you have questions or find any bug.\n\n## Dir\n\n### Hypervisor\n\nThe KVM-based hypervisor, its role is like qemu-system.\n\n### Kernel\n\nA extremely simple kernel, supports few syscalls.\n\n### User\n\nSimple ELF(s) for testing our kernel.\nPre-built user program was provided, and you can re-generate by the following commands:\n```sh\n$ pip3 install pwntools\n$ user/gen.py\n```\nNOTE: You have to install Python 3.x in advance.\n\n## Setup\n\n### Check KVM support\n\nCheck if your CPU supports virtualization:\n```\n$ egrep '(vmx|svm)' /proc/cpuinfo\n```\nNOTE: CPUs in a VM might not support virtualization (i.e. no nested virtualization).\nFor example, EC2 on AWS doesn't support using KVM.\n\n### Install KVM device\n\nCheck if the KVM device exists:\n```\n$ ls -la /dev/kvm\n```\n\nIf `/dev/kvm` is not found, you can enable it (on Ubuntu) with:\n```\n$ sudo apt install qemu-kvm\n```\n\nIf you are not root, you need to add yourself into the `kvm` group to have permission for accessing `/dev/kvm`.\n```\n$ sudo usermod -a -G kvm `whoami`\n```\nRemember to logout and login to have the group changing effective.\n\n\n## How to run\n\n```sh\n$ git clone https://github.com/david942j/kvm-kernel-example\n$ cd kvm-kernel-example \u0026\u0026 make\n$ hypervisor/hypervisor.elf kernel/kernel.bin user/orw.elf /etc/os-release\n# NAME=\"Ubuntu\"\n# VERSION=\"18.04.1 LTS (Bionic Beaver)\"\n# ID=ubuntu\n# ID_LIKE=debian\n# PRETTY_NAME=\"Ubuntu 18.04.1 LTS\"\n# VERSION_ID=\"18.04\"\n# HOME_URL=\"https://www.ubuntu.com/\"\n# SUPPORT_URL=\"https://help.ubuntu.com/\"\n# BUG_REPORT_URL=\"https://bugs.launchpad.net/ubuntu/\"\n# PRIVACY_POLICY_URL=\"https://www.ubuntu.com/legal/terms-and-policies/privacy-policy\"\n# VERSION_CODENAME=bionic\n# UBUNTU_CODENAME=bionic\n# +++ exited with 0 +++\n```\n\n### Environment\n\nI 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.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid942j%2Fkvm-kernel-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavid942j%2Fkvm-kernel-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavid942j%2Fkvm-kernel-example/lists"}