This patch provides some small updates to enable catching and
handling when memory runs out (std::bad_alloc). Specifically,
when this happens, we can no longer use std::cout which
does many allocations in the process. Instead we exit
gracefully with an error code.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
We started using gsl::finally with a set of modifications that
were pitched to the Core Guidelines for consideration, and
this patch provides the code that seems to be more inline
with what they are looking for. This patch also addresses an
issue with thread local storage (we were not handling this
properly), and it addresses an issue with Astyle (it was
not actually being checked by Travis CI
Signed-off-by: “Rian <“rianquinn@gmail.com”>
This patch provides support for the google sanatizers for
dynamic analysis, as well as cleans up issues with clang tidy.
In addition, there is a new Travis CI target that tests for
clang tidy so that future PRs do not have the same issues.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
This patch cleans up a lot of issues identified using clang
tidy including C++ Core Guideline support. The only thing
that has not been tested with this patch is the unwinder which
will be addressed in later patches
Signed-off-by: “Rian <“rianquinn@gmail.com”>
* vCPU / Unwinder Cleanup
This is a pretty massive patch set that addresses two main issues
- The vCPU was two specific to the host-only use case
- The unwinder has bugs
The vCPU was specific to the host-only case because there was no
way for the make_vcpu function to create a vCPU that was not a
host-only vcpu. This patch corrects that issue. In addition, if
guest vCPUs are to be created, the ability to "resume" a guest
must also be provided, which this patch also has. There is still
some API changes that are needed. For example, we need a way to
send a void * to the make_vcpu function so that there is a way
to tell make_vcpu which type of vcpu to create.
While developing this patch, a couple issues with the unwinder
were discovered, one really big one being that we were using
C style casts in a LOT of the code. This patch hopefully
removes the bulk of them (and hopefully a static analysis tool
can find the rest if any). There was also an issue with the
way we were passing flags to libcxx and libcxxabi that caused
instabilities. Finally, we discovered that libcxx will simply
abort if the unwinder fails on a noexcept (duh), but some
of these failures should gracefully exit, and not hang the
system. As a result, functions need to be labeled noexcept
were it makes sense, and try catch blocks were added to
prevent system hangs.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
* Coveralls / Unit Test Coverage
This patch provides coveralls support which can be used to
identify what % of the code is actually unit tested. This
patch attempts to get to 100% coverage, but leaves out
coverage checks for:
- VMCS
- Unwinder
The unwinder is extremely difficult to unit test completely
as this would require fake FDEs which would not be pretty.
Instead, the unit test attmepts to validate that the unwinder
works from the top level API which is "throw" from different
situations.
The VMCS class needs some additional work to be testable as
it currently calls vmread / vmwrite and read_msr way, way
too much, which not only causes performance issues, but also
causes issues with unit testing as the intrinsics class
needs to be mocked, and tons of calls makes the unit test
too overspecified. Future patches will address this problem.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
In order to support -O3, we need to save the YMM registers as
the hypervisor will use these are part of the optimizations.
The problem is, XSAVE has some issues with the hypervisor that
are not simple to solve.
For example, before you can run XSAVE, you need to set xcr0 with
the bits you plan to support. Since Barefalnk is both a bare
metal, and late launch hypervisor, the host OS is responsible
for setting up xcr0, which might not set the same bits that
Bareflank needs to use. This means Bareflank must enable the
bits it plans to use. If the host OS ever changes these
Bareflank would stop working. To solve that problem requires
a bit of emulation.
XSAVE is also saving a bunch of stuff that we don't need,
increasing the time it takes to Exit / Enter.
To solve these problems (and more), the simple solution is
to save off the contents of the YMM registers manually.
This patch provides the changes to do this.
In addition, this patch also changed how promote works.
It was amazing that the original code worked in "C", but
once optimizations were enabled, it stopped working.
In some cases, adding volatile helped (for example,
with GCC 6.1), but with the rest of the compilers, it was
still broken. This patch moved the promote code to
assembly so that these instructions can be handled carefully
Signed-off-by: “Rian <“rianquinn@gmail.com”>
This adds support for openSUSE. Right now it only supports Tumbleweed.
The script does not use the lsb-release stuff, but parses /etc/os-release.
[ISSUE]: https://github.com/Bareflank/hypervisor/issues/139
Signed-off-by: Harry ten Berge <htenberge@gmail.com>
This pull request adds pthread support, which enables the use
of std::mutex and friends. Only the needed functions are used
so attempts to use std::thread will fail as this only adds
mutex support.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
Add some additional debugging to help with Windows development.
In this case, the serial port that the VMM is going to use
can now be seen from "make debug", and we added some bash
tab completion
Signed-off-by: “Rian <“rianquinn@gmail.com”>
For whatever reason, we had a couple of scripts that used "-"
instead of "_". This patch cleans the naming up so that things
are consistent. We also renamed the configure script to better
align with existing configure scripts
Signed-off-by: “Rian <“rianquinn@gmail.com”>
- Provides better support for real hardware
- Cleans up some scripts
- Fixes some bugs with the intrinsics code
- Fixes bug with unit tests
Signed-off-by: “Rian <“rianquinn@gmail.com”>
This patch provides some cleanup of the Windows driver so that
it better matches the Linux counterpart. Also, it cleans up
some issues with unit test failures
Signed-off-by: “Rian <“rianquinn@gmail.com”>
* Windows Driver Scripts
This patch provides the scripts needs to setup cygwin, and
compile the Windows drivers, as well as the cross compilers
for the VMM and BFM.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
* astyle update
Signed-off-by: “Rian <“rianquinn@gmail.com”>
* bug fix
Signed-off-by: “Rian <“rianquinn@gmail.com”>
Updated the compiler flags to enable better arch support for
Intel. Also added FXSAVE and FXRSTOR instructions to ensure
the entire reigster state is being saved. If we ever use
AVX, we will need to use XSAVE instead
Signed-off-by: “Rian <“rianquinn@gmail.com”>
This patch provides memory protections for the VMM. With this
set of patches, in the future, the VMM will be able to to use
EPT to protect itself.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
* New Build System
This patch provides a new build system that:
- provides support for docker to decrease the time it takes to
run a build. a local compiler can still be used if desired
- provide better support for other platforms
- provides support for out-of-tree compilation which also
allows for multiple build trees if desired
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
* Isolation Complete
This patch set adds the remaining code needed to isolate the
hypervisor from the host OS. Specifically, this provides
the hypervisor with it's own set of page tables.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
This patch contains the following:
- The IDT has been reworked to match the new GDT code
- The IDT is blank as interrupts are not supported currently
- CR0, CR4, RFLAGS and EFER are all manually set now and do
not use the host OS's settings.
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
This patch disabled interupts while the VMM is executing
in the kernel to prevent it from complaining about
the fact that the stack pointer is changing.
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
* Fix CTORS/DTORS
The local_init and local_fini functions were being executed out of
the info struct which (besides from being an ugly approach) was
causing issues with no-execute stacks. There was also a bug where
destructors were not being executed which was also fixed.
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
* Fix Libcxx Permissions
There was a bug in the wrapper script that was basically allowing
certain flags to be passed to LD that should not have been. The
result was LD was thinkng that "-n" was being passed, which caused
the permissions of libc++.so to be RWE, which is not good once we
start turning on permissions. I also added relro and now, which
tells LD that we have no intention of lazy loading, and moved the
alignment setting to the script so that everything linked has
the same alignment (which actually speed up loading process a little)
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
This patch provides support for the following Linux Distros
- Ubuntu 12.04, 14.04, 15.04, 15.10
- Debian Jessie
- Fedora 23, 22
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
This patch adds the unit tests for the C runtime support. It
also structures the CRT like the unwinder for consistency.
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
The following patch cleans up the VCPU code. During the
development of this patch, an issue came up with the way we
build the unit tests which was also cleaned up. Now, you
have to build the unit tests manually using make build_test
and these are done after all of the modules are built which
removes issues with cyclic dependencies
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
Fix issue with setup-debian.sh. This script fails to build the
hypervisor on previous versions of Ubuntu. The Travis CI script
was the only thing that had the script bits to fix the issue.
[ISSUE]: https://github.com/Bareflank/hypervisor/issues/79
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
This patch provides VMCS exception support. During it's
development, it was also identified that the libc++ code can
overwrite the kernel's stack as it's expecting a much larger
stack than the Linux kernel is providing. To overcome this
issue, this patch also includes code to guard the kernel's
by using a different stack while the VMM is execuitng.
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
The following patches provide bareflank with exception support.
This includes:
- A custom unwinder that is capable of unwinding the stack with
thread-saftey, while only requiring libc (which can also be
disabled)
- A set of unit tests to validate that throw exceptions works
- Changes to the VMM to support the custom unwinder, and
install catch all blocks incase an exception is not
caught.
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
The following patch provides a new ELF loader that has better
support for:
- New CTOR/DTOR logic that uses a similar approach to GCC
with a crt static library to provide init / fini functions
- Weak symbol support
- Better searching logic
- Better unit testing (far less over-specification)
- Cleaned up formatting
In addition, this patch includes a couple of nicities that were
used when developing this code
- Comment support in the vmm.modules file
- Cleaned up build script which adds support for dependencies
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
This patch adds MDL support. During the development of this patch,
the driver_entry unittest required a complete overhaul to prevent
future updates to the unittest from requiring a re-write. Thus,
this patch includes the following:
- MDL support (virt <--> phys)
- Overhauled unit tests for the ELF loader and driver entry.
These unit tests are now seperated, and are no longer
over specified
- Updated debug logic
- Cleaned up constants
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
This patch provides support for the C++ STL using libcxx including
the following:
- Modified build scripts to create the cross compiler and then
compile and install libcxx (great care was taken to ensure
this library is compiled with -mno-red-zone)
- Removal of the old std module as it is no longer needed
- init_array/fini_array support in the ELF loader
- Update unit tests
- Modified makefiles to remove references to the old std module
- Modified vcpu manager and memory manager to include the needed
functions to support newlib (i.e. write, malloc, free, etc...)
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
The following patch provides support for libgcc with no red zone.
We need libgcc to support C++, but we need to make sure that
everything we use is compiled with red zone turned off, include
GCC support libraries.
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
Travis CI needs to have the same compiler that we support in
the hypervisor to support unit testing. If it doesn't, the
code in the hypervisor will not compile on Travis CI (since
we use new features in GCC 5.2), and thus cannot be tested.
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
This patch provides instructions for setting up a Windows
development environment as well as a script for creating
the cross-compiler
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
Currently, Windows doesn't support the ELF loader. Other than
some missing headers, the biggest issue is Windows use of
MS x64 calling convention that prevents Windows code from
executing a symbol in the cross-compiled code. This patch
allows the Windows code to not only build, but it also provides
support for it to execute System V ABI compiled symbols.
[ISSUE]: https://github.com/Bareflank/hypervisor/issues/21
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
This commit provides initial support for Travis CI. To support
this, the Linux script was modified, as well as some of the code
in previous pull requests to make sure that everything can
compile on Ubuntu 12.04.
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>