Commit graph

41 commits

Author SHA1 Message Date
“Rian
5b01e8ce80 Bad Alloc Testing
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”>
2016-09-05 16:17:34 -06:00
Rian Quinn
73308916a6 Commit Or Rollback Revert (#166)
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”>
2016-09-01 17:03:48 -04:00
“Rian
1a6e483332 Google Sanatizers / Clang Tidy Cleanup
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”>
2016-08-30 11:32:36 -06:00
Rian Quinn
5bebbc13da Clang-Tidy Cleanup (#160)
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”>
2016-08-19 10:48:24 -04:00
Rian Quinn
70e2175048 API Updates / Cleanup (#158)
* 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”>
2016-08-11 10:12:33 -04:00
Rian Quinn
cf81b3d01b Remove XSAVE (#151)
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”>
2016-08-02 10:51:57 -04:00
spockfish
6d69a8ac80 Initial support for openSUSE
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>
2016-08-01 09:48:39 +02:00
Rian Quinn
5759140d48 Posix Thread Mutex Support (#137)
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”>
2016-07-26 11:49:02 -04:00
Rian Quinn
36a5cda3ef Windows Sanity (#136)
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”>
2016-07-26 10:53:02 -04:00
spockfish
9abcaf127c initial support for openSUSE (#138) 2016-07-26 10:51:02 -04:00
Rian Quinn
432faeb30e Cleanup Scripts (#135)
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”>
2016-07-25 10:59:28 -04:00
spockfish
dd6ae47330 setup-fedora.sh
fix typo
2016-07-21 20:04:34 +02:00
“Rian
6684ad94a9 Windows Code Update
- 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”>
2016-07-20 16:12:52 -06:00
“Rian
21da24d6ec Windows Driver Cleanup
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”>
2016-07-18 13:44:39 -06:00
Rian Quinn
6a83c98b13 Windows astyle update (#126)
* 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”>
2016-07-15 09:31:37 -04:00
“Rian
32e209829e Flags Update
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”>
2016-07-04 07:22:14 -06:00
“Rian
0e2ab3ef9d Memory Protections
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”>
2016-07-01 09:29:21 -06:00
Rian Quinn
e7ccb7b049 Isolation (#117)
* 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”>
2016-06-24 14:21:46 -04:00
Rian Quinn
85538c9673 IDT Rework (#113)
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>
2016-05-08 19:00:08 -04:00
Rian Quinn
5a8e62d079 Fix Fedora Kernel Panic
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>
2016-04-27 16:23:04 -04:00
Rian Quinn
d73207cfe9 Wrapper bug (#110)
* 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>
2016-04-26 14:57:57 -04:00
Rian Quinn
b393da6e9a A Debian 8.4 Support
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
2016-04-03 13:57:35 -04:00
Rian Quinn
e246cb11a3 Ubuntu / Debian / Fedora Support
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>
2016-03-29 23:36:24 -04:00
Rian Quinn
47a44d03d4 CRT Unit Tests
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>
2016-03-24 09:37:51 -04:00
Rian Quinn
39ad4a636e VCPU Update
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>
2016-03-24 09:37:51 -04:00
Rian Quinn
4c9064bada Bug #79 Fix
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>
2016-03-19 00:45:44 -04:00
Rian Quinn
2865374c32 VMCS Exception Support
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>
2016-03-04 13:55:00 -05:00
Rian Quinn
cd991386af Exception Support
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>
2016-02-28 18:32:30 -05:00
Rian Quinn
aef94e137f New ELF Loader
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>
2016-02-16 16:27:22 -08:00
Rian Quinn
590ddcafa2 MDL Support / General Cleanup
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>
2016-01-25 05:36:06 -08:00
Rian Quinn
222ee18b24 Libcxx Support
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>
2016-01-20 08:32:36 -08:00
Rian Quinn
23c5a9e655 Update debian-cross-compiler.sh 2016-01-16 09:05:41 -05:00
Rian Quinn
87a5acef47 Update debian-cross-compiler.sh 2016-01-16 09:05:17 -05:00
Rian Quinn
b6fc3b4fea GCC No Red Zone Support
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>
2016-01-08 02:37:31 -08:00
Brendan Kerrigan
9cc1816b6a Resolve merge conflicts in Makefile
Signed-off-by: Brendan Kerrigan <kerriganb@ainfosec.com>
2015-12-08 12:10:07 -05:00
Rian Quinn
28bcf27693 Update Travis CI to GCC 5.2
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>
2015-11-24 08:45:50 -08:00
Rian Quinn
28a1aaea29 Install instructions and Cygwin script
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>
2015-11-12 16:43:28 -05:00
Rian Quinn
2b604d4d9b Fix issue with Windows support
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>
2015-11-10 22:47:29 -05:00
Rian Quinn
8d0b0862dd Travis CI Support
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>
2015-11-09 12:58:26 -08:00
Brendan Kerrigan
2f3235ac31 Updated the Linux docs to include libisl-dev, and corrected the package name for libmpc.
Also updated and committed the convenience script for Linux.

Signed-off-by: Brendan Kerrigan <kerriganb@ainfosec.com>
2015-10-29 14:11:47 -04:00
Brendan Kerrigan
b980e68b7a Added convenience script to create a cross compiler easily on Debian 8.0
Signed-off-by: Brendan Kerrigan <kerriganb@ainfosec.com>
2015-10-29 13:32:58 -04:00