This patch adds support for unordered_map. Specifically it adds support
for libm which is needed by unordered_map as it abuses the ceil
function for integer rounding in it's hash function.
Signed-off-by: “rianquinn” <“rianquinn@gmail.com”>
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”>
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>
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”>
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”>
This patch removes the need for the cross compilers. You can now
install clang using your distro's package manager, and the scripts
will tell clang to cross compile, linking with the linker of your
choice, or defaulting to "ld". Note that the default clang that
is expected is clang 3.8, but you can set the compiler to whatever
you want, including GCC if you create the cross compiler youself.
The ELF loader was not working with ld.gold or ld.lld because these
linkers craete a rela.plt and use the old .ctors / .dtors sections.
They also do not properly label the eh_frame section. This patch
uses an updated ELF loader that is actually slated for 1.2, but has
these bug fixes in it.
Signed-off-by: Rian Quinn <“rianquinn@gmail.com”>
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”>
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”>
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”>
This commit replaces each occurence of EXPECT_TRUE,
EXPECT_FALSE, EXPECT_EXCEPTION, and EXPECT_NO_EXCEPTION
in the Bareflank tree with their snake-case counterparts
introduced in (#209).
Also, expect_exception_with_args and expect_no_exception_with_args
now take a default path_id argument that is printed along with
__LINE__ and __FUNC__ info when a test fails within the
run_vmcs_with_args loop. The user can then easily identify which
path caused the failure by refering to the appropriate setup function.
This patch fixes issues identified with coverity scan. Most
of these were actual issues that needed correction.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
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”>
Clang was not being used for native compilation when it should
have been on Linux. There was also a flag that should not
have been added that this removes. Finally this ensures the
unit tests actually compile and run with clang.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
* 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”>
This patch removes the need for delete[] in the bfdriver
unit tests. We already made this change in the unwinder tests
but never got around to it on the driver side. Interestingly
enough, this was the last remaining delete, everything else
at this point uses shared_ptr or unique_ptr.
[ISSUE]: https://github.com/Bareflank/hypervisor/issues/176
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 provides a new Travis CI Matrix for building and
testing the source tree. This also includes support for
automatically submitting to Coverity Scan.
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”>
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”>
* 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”>
The previous VCPU implementation was put in place for 1.0
because we didn't have support for "gs" based state save
area. Now that we have that, we no longer need to call the
vcpu manager on every VM exit.
In addition, for version 1.2, we will need the ability to
create vcpuids that are no longer linear, and thus, an
array and hard coded MAX will not work. This patch removes
these limitations, and provides a means to have as many
vCPUs as needed in the future.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
I think this was actually addressed right before we released
version 1.0, but we never fixed this line of code. Bascially,
libc++ was not being compiled correctly, so the alignment
was wrong. Now that we are compiling it correctly, the alignment
is as expected, so we can re-enable this check
Signed-off-by: “Rian <“rianquinn@gmail.com”>
Originally, the error codes were self contained which made sense
at the time, but as the project has grown, the number of error
codes has increased leading to a lot of redudancy in common.c as
well as overlapping error codes in a couple of cases. This patch
moves all of the error codes toa single file, makes sure the
return types are consistent, and provides a single error code
to string conversion function
Signed-off-by: “Rian <“rianquinn@gmail.com”>
The unit test for the ELF loader had a bug in it that
caused issues when compiling on OpenSUSE.
[ISSUE]: https://github.com/Bareflank/hypervisor/issues/132
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”>
* 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”>
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>
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>
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>
This patch provides exception support to the VMXON module. It
also addresses and issue with exception support that prevented
one module from throwing an exception, and another module from
catching the exception. Finally, this patch cleans up how we
organize the exception logic
Signed-off-by: Rian Quinn <quinnr@ainfosec.com>