GithubHelp home page GithubHelp logo

mikalv / kvm-kext Goto Github PK

View Code? Open in Web Editor NEW

This project forked from geohot/kvm-kext

0.0 2.0 0.0 2.14 MB

An implementation of /dev/kvm for Mac OS X

Shell 0.42% C 82.75% C++ 13.88% Assembly 2.27% Makefile 0.68%

kvm-kext's Introduction

kvm-kext

An implementation of the kvm interface on OS X. Exposes /dev/kvm in almost the same way Linux does(see below for differences).

Project for 15-412 by George Hotz. Released under GPLv2. Helper functions borrowed from the Linux Kernel. Currently capable of booting the virtual Linux system in bintest/bootfd.img.

Do not rely on this for any sort of secure virtualization. /dev/kvm is currently world owned.

Description

kvm (for Kernel-based Virtual Machine) is an interface to run virtual machines with acceleration by the hardware. kvm-kext implements enough of the kvm API to run 32-bit Linux accelerated by Intel VMX on OS X and put a console on a serial port.

Usage

Installing KEXT

  • ./build.sh should build and install the kext
  • See Homebrew/legacy-homebrew#31164 for cause of issues with 10.10
  • Use "nvram boot-args=kext-dev-mode=1" to fix. This is a dangerous command.
  • Currently doesn't codesign since the above fix doesn't require it.

Using homebrew to fetch QEMU build prerequisites

  • Install homebrew and run "brew doctor"
  • "brew install apple-gcc42"
  • "for i in $(brew deps qemu); do brew install $i; done"

Building QEMU with kvm support

  • ./get-qemu.sh should just work, doesn't install
  • Based on qemu-2.2.0 and makes two minor patches

Booting Test Linux

  • ./test.sh

Differences from Linux API

  • OS X's ioctl cannot return numbers other than 0 or -1, so we look in errno
  • The FD functions do not create new FDs, so you have to set the return value to the current fd in userspace. Consequently, only one VM and CPU are allowed per open of /dev/kvm.
  • The ioctl's with a 0 length array as the last parameter have to also pass in their user space address.
  • KVM_SET_PIT and KVM_SET_IRQCHIP incorrectly used IOR in the Linux header, so the numbers don't match Linux.

mmaping of drivers is not allowed in OS X, so we add an ioctl KVM_MMAP_VCPU to behave like mmaping the VCPU.

See include/kvm-kext-fixes.h for fixes to these issues

Known Issues

  • The timer interrupt is generated using the host timer. Is this correct behavior?
  • There's still a bug causing a kernel panic sometimes, mitigated somewhat by a big mutex and disabling interrupts in kvm_irq_line. Don't know why this fixes it.
  • All memory passed into KVM_SET_USER_MEMORY_REGION is wired in when that ioctl is run.
  • The FPU is unimplemented, might leak state between host and guest?
  • APICs and DRs don't work at all.
  • Much of the API is still unimplemented.
  • QEMU VGA doesn't seem to work, unsure why. MMIO?

kvm-kext's People

Contributors

geohot avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.