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”>
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”>
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 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 addresses an issue with the unwinder unit test where the
load address of the unit test was not being calculated, and
if "-fpie" was being used, this would result in a crash.
[ISSUE]: https://github.com/Bareflank/hypervisor/issues/323
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”>
Up until now, the unwinder was not included in the Clagn Tidy
checks because it needed some cleanup. This patch provides that
Signed-off-by: “Rian <“rianquinn@gmail.com”>
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”>
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”>
We never implemented the opcodes in this patch, and they are
showing up during testing. The main reason we didn't implement
these was because it was assumed that GCC would not implement
stack operations in the EH Frame FDEs because they use a
malloc/free, which doesn't make sense if the throw came
from std::bad_alloc.
To overcome this limitation of malloc/free, we implemented the
stack frame "remember/restore" calls using a temp stack without
malloc/free. The down side to this is if the temp stack is not
large enough, the unwinder will fail, but the possibility of
this is extremely small, and even if it does occur, I added a
macro that can be increased if needed.
One thing that is interesting is it appears GCC is spitting
out bad DRAWF instructions for the case that was seen.
GCC is calling DW_CFA_restore on registers that do not have
initial instructions in the CIE, which results in 0.
The test cases still work because GCC is wrapping the bad
calls to DW_CFA_restore in a DW_CFA_remember_state /
DW_CFA_restore_state so in the end, the DW_CFA_restore are
simply ignored. Either way, this patch completes the missing
DWARF CFA instructons so we now implement them all.
Finally, we addressed an earlier issue with the expression
support that we thought was an issue with GCC but turned
out to be an issue with the unwinder. We were using
"<" instead of "<=" so we missed the last opcode which was
needed.
Signed-off-by: “Rian <“rianquinn@gmail.com”>
* DWARF Expression Suport
GCC 6.1 appears to add DWARF expressions for stack realignment
which is needed to support the addition of SSE instructions.
This patch provides the needed expression support for exceptions.
It should be noted that there appears to be a bug in GCC 6.1
that we have hacked around for now. For more information, please
see:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71978
Signed-off-by: “Rian <“rianquinn@gmail.com”>
* add #define for expression stack size
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 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”>
* 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 includes:
- VMCS Guest Checks for the control logic
- Fixes to the dwarf code to support the guest checks
- Some scaffolding for the unit tests to verify how testing
can be done for the singleton classes
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>