Commit graph

82 commits

Author SHA1 Message Date
Rian Quinn
01842b4c77
Convert Hypervisor to use Delegates (#610)
This patch converts the hypervisor to use delegates, dramatically
reducing the complexity of the hypervisor, while also providing a
cleaner interface for extensions.

[RFC]: https://github.com/Bareflank/hypervisor/issues/602

Signed-off-by: “rianquinn” <“rianquinn@gmail.com”>
2018-02-14 05:25:49 -07:00
Connor Davis
2806b3307c tests: Fix build errors (#589)
bfm: Add include header for test support
bfvmm: Add narrow cast for pl011 tests
2018-01-30 11:07:55 -07:00
Rian Quinn
ee7b537564
Re-enable Codecov (#582)
This patch re-enables codecov so that it can calculate our
current code coverage. This will likely result in failed tests
until code coverage is fixed.

Signed-off-by: “rianquinn” <“rianquinn@gmail.com”>
2018-01-27 08:01:24 -07:00
Rian Quinn
38178563fc
Include Path / Library Fix (#581)
This patch fixes two specific issues with extensions:
- The init_project macro was including <path>/../include which it
shouldn't be because we don't know how an extension will be setup, and
this could accidentially include unintended files.
- The add_vmm_exectuable provided to way to link shared and static
libraries at the same time, and as a result, was cumbersome to use.

Signed-off-by: “rianquinn” <“rianquinn@gmail.com”>
2018-01-23 17:34:19 -07:00
Rian Quinn
aab477a590
Build System Bug Fixes (#575)
This patch addresses several bugs with the build system:
- Lack of Windows support
- Clang Tidy was not working properly
- Making modifications to the source code would compile, but would not
re-link resulting in issues
- Removed excess file copying
- Make clean now works
- Removed unused or confusing folders in the build folder as part of the
build process. It is now much easier to traverse the build folder for
dependencies
- The targets didn't work with extensions. This has been fixed.

In addition, the following was also done under this patch
- Intrinsics was moved to the top level and out of the VMM
- Platform files are now in a folder called "platform" instead of
"arch"
- All subprojects have the same include/src/tests files structure
- All intel specific code is properly organized to match intended
namespacing
- Removed dead code
- A small part of the VMCS was converted to use the delegate pattern
- All dependencies are now downloaded at configure time instead of
compile time.
- The cache directory is now cached by Travis CI
- CMake output better matches old build system
- Added make rebuild and separate clean targets to remove various parts
of the build depending on needs.
- Added targets for Clean, Tidy, Rebuild and Format for each subproject
- Re-organized the cmake logic so that macros are not spread out
- New validation removes unneeded complexity
- Removed the need for the compiler wrapper, and in doing so, we now
provide a simpilar set of toolchain files
- Removed the need for Git repos. All external dependencies are
downloaded using a zip or tarball
- Libcxx and Libcxxabi are now in their own files. Much similar logic
- Unit test CMake files have been greatly simplified
- Each subproject is unaware of it's prefix and no long use VMM,
USERSPACE or TEST variables in their cmake files
- Fixed bugs with the flags
- Renamed the varbiables in the default.cmake config to be more
consistent and easier to follow in the rest of the code

Signed-off-by: “rianquinn” <“rianquinn@gmail.com”>
2018-01-22 12:45:07 -07:00
JaredWright
048fac7ddc [BUG] build system - duplicate vmm main exectuables #537
1) Removed duplicate naming of vmm exectuables in shared vs. static
builds

2) Added cmake configurations that specify the default path and name for
a vmm to be loaded by bfm as a default

Signed-off-by: JaredWright <jared.wright12@gmail.com>
2017-12-01 11:17:45 -08:00
Jared Wright
c1c35c7e93 New cmake build system (#532)
Redesigned the cmake build system to support more flexible build
configurations. Major changes include: new and renamed build configuration
parameters, configuration validation and rule checking, more granular
support for choosing which projects/unit tests to build, updated
external dependency management, restructuring of compiler flags, support
for ninja, and support for cmake-gui/ccmake.

Co-author: cpavlina <pavlinac@ainfosec.com>

[RFC] #498

Signed-off-by: JaredWright <jared.wright12@gmail.com>
Signed-off-by: cpavlina <pavlinac@ainfosec.com>
2017-11-29 12:05:59 -07:00
Rian Quinn
68144f8d2a
arch cleanup (#519)
Signed-off-by: “rianquinn” <“rianquinn@gmail.com”>
2017-10-31 12:38:26 -06:00
Rian Quinn
d88b6c370b Header Updates (#504)
This patch cleans up the headers of each file, and removes the
authors fields as they are not needed and are confusing.

Signed-off-by: rianquinn <“rianquinn@gmail.com”>
2017-10-07 13:45:24 -06:00
Rian Quinn
9bea7c4a9f Windows 7 Support (#492)
Signed-off-by: Rian Quinn <“rianquinn@gmail.com”>
2017-09-22 08:39:59 -07:00
Rian Quinn
0dbf1d62f9 Windows Support (#489)
This patch provides support for Windows in v1.2

Signed-off-by: Rian Quinn <“rianquinn@gmail.com”>
2017-09-20 08:34:47 -07:00
Rian Quinn
dbbfa86e34 BFM cleanup. (#475)
Completes the BFM source code and finishes it's unit tests. This
also addresses issues with the build system.

Signed-off-by: Rian Quinn <“rianquinn@gmail.com”>
2017-08-27 14:42:25 -06:00
Rian Quinn
70d594400d msbuild_updates (#473)
Signed-off-by: Rian Quinn <rianquinn@gmail.com>
2017-08-21 11:01:43 -06:00
Rian Quinn
d92a78f7d5 cygwin updates (#472)
Signed-off-by: Rian Quinn <“rianquinn@gmail.com”>
2017-08-19 05:58:29 -06:00
Rian Quinn
40a448d8fe Merge Repos into the Hypervisor Repo (#470)
This PR mereges all of the repos into a single repo for simplificty. It
also adds static / shared library build types, release / debug builds,
and ensures parallel builds work properly.

Signed-off-by: Rian Quinn <“rianquinn@gmail.com”>
2017-08-17 10:49:49 -06:00
Rian Quinn
41d8bb6dd3 initial super build script
Signed-off-by: Rian Quinn <“rianquinn@gmail.com”>
2017-05-04 20:41:03 -06:00
“Rian
9f7ccad82e Bug Fixes
This patch provides the following bug fixes:
    - msr_bitmaps should be msr_bitmap (there is only one)
    - fix vmm.modules
    - fix bug in create_cross_compilers script (gcc was in there)

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2017-02-08 12:47:37 -07:00
“Rian
45b01082db VM Launch Mods #3
This patch provides additional mods specific to VM launching. The
main change here is the removal of cli / sti, cleaning up potential
issues with vmresume, and adding a vmlaunch that accepts the same
infomartion as vmresume, greatly simplifying how a launch occurs.

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2017-02-05 09:42:51 -05:00
Rian Quinn
029d20b54c VM Launch Mods #2 (#416)
This patch provide a bunch of mods needed to launch virtual
machines. These include:
- The ability to setup more than one sysroot, which can be
  used by an extension to create it's own sysroots.
- A complete re-write of the ELF loader to simplify it's code
  base and provide support for additional binary types including
  binaries with and without PIE, as well as shared libraries.
  The ELF loader also includes code to get various different
  properties associated with the ELF file including dependencies,
  permission info, and how it was compiled
- various different bug fixes

Note: This patch offically drops support for GCC in favor of
  Clang

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2017-01-27 16:06:27 -05:00
Rian Quinn
ec6cd43ca0 VMLauch Mods (#401)
This patch adds a traditional vmlaunch which is needed to start
guests with the VMCS. Now, you can declare a guest state as a
guest and not a host (the default), and vmlauch will be executed
without the demotion.

To support this, the vCPU has been relaxed so that it can be
not only be started, but it can also be resumed (i.e. run twice).
We also provided RIP / RSP fields in the state class so that
these registers can be defined for guest support.

Finally the VMCall completetion code has been moved so that
a vmcall can be completed from a different VM Exit.

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2017-01-05 09:26:45 -05:00
“Rian
af58433cf5 Update Hippomocks
This updates hippomocks to the latest and greatest
cpp11 branch which fixes a lot of bugs.

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-12-07 16:06:56 -07:00
“Rian
df13306f58 Turn on Pretty Print
Use pretty print for printing JSON that has been
returned by the hypervisor

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-12-04 08:49:47 -07:00
“Rian
c70a93b435 Deprecate GCC 5
This patch set removes GCC 5 and defaults to Clang 3.8 as the
cross compiler. In addition, newlib has been updated, and is now
linked in as a shared library instead of a static library.
Finally, when Clang is used, only Clang is used, unlike
before were GCC was used to compile Newlib

[ISSUE]: https://github.com/Bareflank/hypervisor/issues/336

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-11-22 16:06:46 -07:00
“Rian
763f803881 Add Libcxx Unit Tests
This patch adds unit tests for all of the supported containers
in version 1.1. Currently, unordered_map and multimap are not
supported. In version 1.2 we plan to provide support for
unordered_map. Also note that more unit tests will come to
complete some of the other STL type functionality.

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-11-18 08:14:47 -07:00
brendank310
789a388b19 Merge pull request #311 from rianquinn/coverity_mods_2
Fix Coverity Scan Issues
2016-11-16 14:44:19 -05:00
“Rian
82b7849527 Fix Coverity Scan Issues
This patch fixes issues identified with coverity scan. Most
of these were actual issues that needed correction.

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-11-14 17:11:11 -07:00
“Rian
818a6ed671 Remove Double Compile
This cleans up the dependencies of libcxx and libcxxabi, and
moves the compilation of bfcrt and bfunwind to after libcxx.
This not only cleans up a lot of the scripts and hackish
crap in the repo, but it also removes the double compile
problems. You can now:

./configure
make
make // <-- This should not recompile anything

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-11-14 12:14:29 -07:00
Rian Quinn
b4d0ee20ca VMCall Interface (#281)
This provides the support for 'vmcall'. BFM has been modified
to support the vmcall interface, but custom applications can
use this interface to do whatever they want, including calling
vmcall from user-space if so desired.

This patch also provides new code in the memory manager to
handle mapping memory from the Host OS into the hypervisor.

Finally, this patch fixes a host of bugs including a bug
with TLS, and cleans up the code that was touched in
prep for 1.1

[ISSUE]: https://github.com/Bareflank/hypervisor/issues/182
[ISSUE]: https://github.com/Bareflank/hypervisor/issues/274

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-11-08 20:42:12 -05:00
Rico Antonio Felix
786a439a0e bfm: Optimized execution time for split function
Signed-off-by: Rico <“ricoantoniofelix@yahoo.com”>
2016-10-18 14:49:26 -04:00
“Rian
f4b641871b Continued Work on #241 #2
This patch provides additional work to cleanup the intriniscs
logic to remove the #defines in favor of a cleaner, more organized
approach

[ISSUE]: #241

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-10-07 13:15:26 -06:00
Rian Quinn
006dab4bc0 Add JSON Support (#237)
This patch adds JSON support to Bareflank, and gets rid of the
custom module file implementation in favor of JSON. The JSON
code is based on the following with flout / double support
removed:

https://github.com/nlohmann/json

[ISSUE]: https://github.com/Bareflank/hypervisor/issues/207

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-10-04 13:16:37 -04:00
Rian Quinn
d72ac0c2f9 Initial Clang Support / Windows Cleanup (#222)
* LLVM / Clang Support

This patch provides support for compiling Bareflank with
Clang / LLVM.

GCC is still needed to compile NewLib (they are tied at the hip),
and we are currently still using LD from Binutils as LLD from
LLVM is still in heavy development. For this reason, GCC has
been paired with Clang / LLVM as follows:
- Clang 3.8 with GCC 5.2.0
- Clang 3.9 with GCC 6.2.0

Someday, once C++17 and LLD are ready, and we have our own
libc, we will updated Bareflank to use Clang / LLVM
exclusively as this would remove the need for docker as our
own cross compilers (for x86 at least).

To try out LLVM / Clang, use the --use_llvm_clang flag when
setting up, or running configure. Docker has been updated
and the local compiler scripts will also build clang as
needed.

Signed-off-by: “Rian <“rianquinn@gmail.com”>

* Windows Cleanup

Fix compilation issues with Windows. This patch also reverts
TLS code that was breaking Windows as well as Linux in some
cases. The TLS code will have to be reengineered to use a
different approach. For now this should bring some stability
(although on_success and on_failure might have issues)

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-09-30 14:48:25 -04:00
Rico Antonio Felix
f7d5042539 ioctl.h: Corrected various errors in the API documentation
Signed-off-by: “Rico <“ricoantoniofelix@yahoo.com”>
2016-09-09 18:58:07 -04:00
Rico Antonio Felix
ee82adeec8 command_line_parser.h: Corrected various errors in the API documentation
Signed-off-by: “Rico <“ricoantoniofelix@yahoo.com”>
2016-09-09 18:40:28 -04:00
Rico Antonio Felix
0b46785cea split.h: Reworded API documentation
Signed-off-by: “Rico <“ricoantoniofelix@yahoo.com”>
2016-09-09 18:29:57 -04:00
Rico Antonio Felix
bcef8f25ed file.h: Correct typographical error in API documentation
Signed-off-by: “Rico <“ricoantoniofelix@yahoo.com”>
2016-09-09 17:39:43 -04:00
Rian Quinn
b956335232 Fix endl (#190)
* Remove std::endl

This patch removes uses of std::endl

[ISSUE]: https://github.com/Bareflank/hypervisor/issues/180

Signed-off-by: “Rian <“rianquinn@gmail.com”>

* Remove std::endl

[ISSUE]: https://github.com/Bareflank/hypervisor/issues/180

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-09-08 09:11:26 -04:00
Rian Quinn
d280799398 Update README.md 2016-09-06 14:36:02 -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
14dfb2d3ed Update ioctl.cpp 2016-08-19 09:30:03 -06:00
Rian Quinn
f28c288c55 Update ioctl.cpp 2016-08-19 09:29:42 -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
7deeca63aa Coverity Support (#159)
This patch set add support for static analysis. Specifically,
we have enabled Coverity, fixed the bugs that it found, and
have added the badge. This patch set addresses all of the issues
that were seen by Coverity.

There are other issues that are pending as clang-tidy has
identified a lot of issues the Coverity has not, so a future
PR will address clang-tidy specific issues.

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-08-12 10:39:36 -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
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
87b8db5b26 Multi-Core Support
This patch provides basic multi-core support for version 1.1.
Some of this logic will change once we begin the process of
adding basic guest support in 1.2

Signed-off-by: “Rian <“rianquinn@gmail.com”>
2016-06-27 13:44:56 -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