Commit graph

28 commits

Author SHA1 Message Date
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
Chris Pavlina
9cd48e7ac7 Add more aarch64 relocations (#559)
Signed-off-by: Chris Pavlina <pavlinac@ainfosec.com>
2017-12-18 10:48:11 -07:00
Chris Pavlina
c707954e5f bfelf_loader: implement relocations for aarch64
Signed-off-by: Chris Pavlina <pavlinac@ainfosec.com>
2017-12-07 13:53:59 -07: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
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
496b135c72 missing bfdriver unit tests (#484)
Signed-off-by: Rian Quinn <“rianquinn@gmail.com”>
2017-09-05 15:44:21 -06:00
Rian Quinn
f3b3b984cb ELF loader cleanup / missing unit tests (#478)
Signed-off-by: Rian Quinn <“rianquinn@gmail.com”>
2017-08-29 13:51:00 -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 Quinn
ca39049ec3 Remove Cross Compilers / ELF Loader Update
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”>
2017-03-15 12:53:12 -06: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
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
“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
ad33837aee Error Code Cleanup (#144)
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”>
2016-07-28 12:50:16 -04:00
Brendan Kerrigan
9fa93c5ea2 [bfdrivers] Added initial driver for OSX
Signed-off-by: Brendan Kerrigan <kerriganb@ainfosec.com>
2016-05-09 11:23:54 -04:00
Rian Quinn
621ef695db Fix CTORS/DTORS (#109)
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>
2016-04-26 14:55:30 -04: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
Brendan Kerrigan
a5ed572eb1 [elf] Add support for symbol lookup via hash table, and prevent buffer overflow in the reltab and relatab
Signed-off-by: Brendan Kerrigan <kerriganb@ainfosec.com>
2016-02-08 10:33:15 -05: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
753766bb60 Global Constructor/Destructor Support
This patch adds global constructor / destructor support to the
system. It includes:
- ELF loader mods to process ctors / dtors
- Mods to the ELF loader unit tests to validate new logic
- Mods to the driver entry to use the new logic in the ELF
  loader
- Mods to the driver entry unit tests to validate the new
  logic works as expected
- Mods to the VMM to remove previous hacks that got around not
  having global constructors / destructors

Note as a side note, *p = &blah seems to now be resolved. It
appears that GCC was performing relocations in one of the
functions identified in the .ctors section.

Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
2016-01-09 06:36:04 -08:00
Rian Quinn
a9454e6128 New Build System
The old build system has a lot of problems, as was very
inconsistent from one module to the next. This new one,
cleans up a lot of the issues that we had with the old system
and also addresses several bugs that we had in the past. It
also sets us up for being able to properly unittest all of the
modules.

Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
2016-01-07 04:31:58 -08:00
Rian Quinn
97ade5e773 Work Towards VMCS Launch
There is a lot of work in this PR towards getting the VMCS to
launch. This includes:

- Most of the default VMCS initialization fields
- Most of the VMCS state debugging
- Most of the VMCS checks
- A basic exit handler
- LOTs of bug fixes and rework of the driver entry

Altough the launch is disabled, we have verified that we have a
working VMCS launch. There is still a decent amount of work to
get this working in master, as cleanup must be done prior to
offically enabling this feature.

Also, at the current moment we do not have an isolated exit
handler as it requires kernel resources to execute (i.e.
IDT, GDT, and CR3). This will be resolved in future versions
of the hypervisor.

Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
2015-12-24 06:42:13 -08:00
Rian Quinn
747da59ec0 BFM Dump Support
This patch adds support for dumping the debug ring
from the VMM. While attempting to add support for this code
a lot of mods were made to cleanup the C++ environment as
GCC adds symbols to shared libraries once things like
inheritance are used.

Also added support for static libraries for the unit tests.
This will enable the use of HippoMocks for mocking up C
functions (as shared libraries cannot be used in this case).

Finally sevral unit tests were either added or cleaned up
in this patch, with further changes still to come

Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
2015-12-04 07:14:29 -08:00
Rian Quinn
fcd7284e14 Driver Entry
This patch provides the initial driver entry code for Linux.
With this code, you should be able to launch a hypervisor
from the Linux OS using the Bareflank Manager.

Signed-off-by: Rian Quinn <quinnr@ainfosec.com>
2015-11-30 04:42:19 -08:00