The Bareflank Hypervisor is an open source, lightweight hypervisor, lead by Assured Information Security, Inc. that provides the scaffolding needed to rapidly prototype new hypervisors. To ease development, Bareflank is written in C++, and includes support for exceptions and the C++ Standard Template Library (STL) via libc++. With the C++ STL, users can leverage shared pointers, complex data structures (e.g. hash tables, maps, lists, etc…), and several other modern C++ features. Existing open source hypervisors that are written in C are difficult to modify, and spend a considerable amount of time re-writing similar functionality instead of focusing on what matters most: hypervisor technologies. Furthermore, users can leverage inheritance to extend every part of the hypervisor to provide additional functionality above and beyond what is already provided.
To this end, Bareflank's primary goal is to remain simple, and minimalistic, providing only the scaffolding needed to construct more complete/complicated hypervisors including:
- Bare Metal Hypervisors (also known as type 1, like Xen)
- Late Launch Hypervisors (also known as type 2, like VirtualBox)
- Host-Only Hypervisors (no guests, like MoRE, SimpleVisor and HyperPlatform)
The core business logic will remain in the hypervisors that extend Bareflank, and not in Bareflank itself.
To support Bareflank's design approach, the entire project is licensed under the GNU Lesser General Public License v2.1 (LGPL), specifically enabling users of the project to both contribute back to the project, but also create proprietary extensions if so desired.
In addition to Bareflank’s lightweight, modular design, the entire hypervisor has been written using test driven development. As such, all of Bareflank’s code comes complete with a set of unit tests to validate that the provided code works as expected. These tests are validated using Coveralls, and Travis CI has been setup to test styling via Astyle, and static / dynamic analysis via Coverity, Clang Tidy, and Google's Sanitizers. In addition, we adhere to the CII Best Practices, and the C++ Core Guidelines including support for the Guideline Support Library.
Currently we have support for the following 64bit host operating systems on Intel SandyBridge and above hardware:
- Ubuntu 16.10
- Debian Stretch
- Fedora 25, 24
- OpenSUSE Leap 42.2
- Windows 10
- Windows 8.1
In the future, we would also like to support:
- macOS
- BSD
- UEFI
- ARM (64bit)
Most people think that hypervisors are meant to virtualize servers and provide a means to run Windows on a Mac, but there is a whole field of research where hypervisors are used without guest virtual machines. Since a hypervisor is capable of controlling the host OS running underneath it, (so called "ring -1"), hypervisors have been used for introspection, reverse engineering, anti-virus, containerization, diversity, and even architectural research like the MoRE hypervisor. All of these use cases start the same way, by spending months standing up the hypervisor itself before you can start working on your actual project. Existing open source hypervisors are so focused on supporting virtual machines and burdened with legacy support that they are painful to work with when conducting less traditional hypervisor research.
Bareflank's goal is to provide the scaffolding needed to create any type of hypervisor. To support this, Bareflank leverages C++ not only to provide a clear method for extending the hypervisor via inheritance, but also to provide access to the C++ STL to reduce the time it takes to prototype and implement new technologies. For example, suppose you’re writing an introspection hypervisor that needs to store the different system calls that are being made in a data structure for fast lookups. Doing this in an existing C based hypervisor might require you to create your own data structure. This same implementation is trivial with the STL's existing data structures. With Bareflank's design, you can focus on the goal of your project, and less on implementing the foundation needed to support your project.
Bareflank will always maintain the "bare minimum" needed to stand up a hypervisor. Additional repositories like the Extended APIs repo and the Hyperkernel repo have been created that extend the hypervisor to add additional API support for common research tasks (e.g. VT-x / VT-d APIs and guest support APIs). Long term, it is our hope that others will leverage Bareflank to create hypervisors capable of competing with existing type 1 and type 2 open source hypervisors, but Bareflank itself will remain focused on the bare minimum scaffolding.
Bareflank Hypervisor Website
Bareflank Hypervisor API Documentation
Checkout the latest demo for how to compile, use and extend the Bareflank Hypervisor
CppCon 2016: Making C++ and the STL Work in the Linux / Windows Kernels
NOTE: Our master branch is our working, experimental branch and might be unstable. If you would like to use Bareflank, we recommend using a tagged release which has been more thoroughly tested. Of course if you happen to find a bug, please let us know here. These instructions might vary from release to release, so if something doesn't work, please refer to the instructions provided in the tagged version.
Before you can compile, the build environment must be present. If you are on a supported Windows platform, you must first install cygwin, and run a cygwin terminal with admin rights. You must also copy the setup-x86_64.exe to "c:\cygwin64\bin". If you are on a supported Linux platform, all you need is a terminal. Once your setup, you should be able to run the following:
cd ~/
git clone https://github.com/bareflank/hypervisor.git
cd ~/hypervisor
git checkout -b v1.1.0
./tools/scripts/setup_<platform>.sh
If you are on Windows, there is one additional step that must be taken to turn on test signing. This step can be skipped if you plan to sign the driver with your own signing key.
bcdedit.exe /set testsigning ON
<reboot>
If your Linux distro has SELinux turned on, and you wish to run the unit tests, you must first put SELinux in permissive mode. Once you are done testing, it is probably wise to turn SELinux back on.
sudo setenforce 0
If you are not on a supported platform, you are more than welcome to modify an existing setup_<platform>.sh script to suite your needs. Its likely the hypervisor will work assuming you can get it to compile. Once the system is set up, run the following commands:
make
make test
To run the hypervisor, you need to first compile, and load one of the driver entry points. Bareflank uses the driver entry point to gain kernel level access to the system to load the hypervisor. On Windows and Linux, this is as simple as:
make driver_load
make load
make start
to get status information, use the following:
make status
make dump
ARGS="versions 1" make vmcall
to reverse this:
make stop
make unload
make driver_unload
For more detailed instructions please read the following (based on which OS you are using):
Since Bareflank only provides the bare minimum implementation, we have created two other repositories that extend Bareflank to provide additional capabilities that you might find useful. The Extended APIs repo provides additional APIs around Intel's VT-x / VT-d. Likely most users of Bareflank will find these APIs useful. The Hyperkernel leverages the Extended APIs and Bareflank to provide guest support. If your project requires guest support, you might also find this repo useful as well.
Extended APIs:
https://github.com/Bareflank/extended_apis
Hyperkernel:
https://github.com/Bareflank/hyperkernel
To provide examples of how you might extend Bareflank to provide your own custom functionality, we have provided a couple of examples:
Enable VPID:
https://github.com/Bareflank/hypervisor_example_vpid
CPUID Count:
https://github.com/Bareflank/hypervisor_example_cpuidcount
MSR Bitmap:
https://github.com/Bareflank/hypervisor_example_msr_bitmap
Extended APIs EPT Hook:
https://github.com/Bareflank/extended_apis_example_hook
The project roadmap can be located here
The Bareflank Hypervisor is licensed under the GNU Lesser General Public License v2.1 (LGPL).
If you’re interested in Bareflank, you might also be interested in the following hypervisor projects:
MoRE:
https://github.com/ainfosec/MoRE
SimpleVisor:
https://github.com/ionescu007/SimpleVisor
HyperPlatform:
https://github.com/tandasat/HyperPlatform