-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "updates for new build system" (#2)
- Loading branch information
1 parent
c8470c8
commit 10d61d4
Showing
13 changed files
with
415 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
# Change Log | ||
|
||
## [Unreleased] | ||
### Added | ||
- Updated the example to reflect the new build system | ||
- Updated documentation | ||
|
||
## [1.0.0] - 2016-04-05 | ||
### Added | ||
- Initial Example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,46 @@ | ||
# Bareflank Hypervisor MSR Bitmap Example | ||
# Bareflank Hypervisor Example | ||
|
||
## Description | ||
|
||
This example demonstrates how to extend the Bareflank hypervisor to use | ||
Intel's MSR Bitmaps to increase performance. For more information on how | ||
Bareflank extensions work, please see the following: | ||
This example demonstrates how to extend the Bareflank hypervisor to utilize the MSR bitmap feature of Intel virtualization. For more information on how Bareflank extensions work, please see the following: | ||
|
||
[API Documentation](http://bareflank.github.io/hypervisor/html/) | ||
|
||
## Compilation / Usage | ||
|
||
To setup our extension, we can either clone the extension into the Bareflank | ||
root folder and run make, or we can use the configure script to create an | ||
out-of-tree build environment that has our extension setup for easy development. | ||
Note that using the later approach, we can have more than one build | ||
environment (the following assumes this is running on Linux). | ||
First, you must clone the repo into your existing Bareflank repo. To see instructions on how to setup Bareflank, please see the following: | ||
|
||
``` | ||
cd ~/ | ||
git clone https://github.com/Bareflank/hypervisor.git | ||
git clone https://github.com/Bareflank/hypervisor_example_msr_bitmap.git | ||
cd ~/hypervisor | ||
[Bareflank Hypervisor](https://github.com/Bareflank/hypervisor) | ||
|
||
./tools/scripts/setup-<xxx>.sh --no-configure | ||
sudo reboot | ||
At the moment, out-of-tree compilation is not supported. | ||
|
||
cd ~/ | ||
mkdir build | ||
cd ~/build | ||
``` | ||
cd ~/hypervisor | ||
git clone https://github.com/Bareflank/hypervisor_example_msr_bitmap | ||
``` | ||
|
||
~/hypervisor/configure -m ~/hypervisor_example_msr_bitmap/bin/msr_bitmap.modules -e ~/hypervisor_example_msr_bitmap | ||
Once the example repo is cloned, you can now build the example. Bareflank automatically looks for the examples, or any folder that starts with "src_", and builds these folders along with Bareflank itself. | ||
|
||
``` | ||
make | ||
make unittest | ||
``` | ||
|
||
To test out our extended version of Bareflank, all we need to do is run the | ||
make shortcuts as usual: | ||
Finally, you can run the example. This can be done by running bfm manually, and providing the path to your custom modules list: | ||
|
||
``` | ||
make linux_load | ||
make quick | ||
pushd bfm/bin/native | ||
sudo LD_LIBRARY_PATH=. ./bfm load hypervisor_example_msr_bitmap/bin/msr_bitmap.modules | ||
sudo LD_LIBRARY_PATH=. ./bfm start | ||
sudo LD_LIBRARY_PATH=. ./bfm status | ||
sudo LD_LIBRARY_PATH=. ./bfm dump | ||
popd | ||
``` | ||
|
||
or you can use the shortcuts: | ||
|
||
``` | ||
make load MODULES=hypervisor_example_msr_bitmap/bin/msr_bitmap.modules | ||
make start | ||
make status | ||
make dump | ||
make stop | ||
make linux_unload | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# | ||
# Bareflank Hypervisor Examples | ||
# | ||
# Copyright (C) 2015 Assured Information Security, Inc. | ||
# Author: Rian Quinn <[email protected]> | ||
# Author: Brendan Kerrigan <[email protected]> | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
################################################################################ | ||
# Target Information | ||
################################################################################ | ||
|
||
TARGET_NAME:=vmcs_intel_x64_msr_bitmap | ||
TARGET_TYPE:=lib | ||
TARGET_COMPILER:=cross | ||
|
||
################################################################################ | ||
# Compiler Flags | ||
################################################################################ | ||
|
||
CROSS_CCFLAGS+= | ||
CROSS_CXXFLAGS+= | ||
CROSS_ASMFLAGS+= | ||
CROSS_LDFLAGS+= | ||
CROSS_ARFLAGS+= | ||
CROSS_DEFINES+= | ||
|
||
################################################################################ | ||
# Output | ||
################################################################################ | ||
|
||
CROSS_OBJDIR:=.build | ||
CROSS_OUTDIR:=../bin | ||
|
||
################################################################################ | ||
# Sources | ||
################################################################################ | ||
|
||
SOURCES+=vmcs_intel_x64_msr_bitmap.cpp | ||
SOURCES+=bitmap.cpp | ||
|
||
INCLUDE_PATHS+=./ | ||
INCLUDE_PATHS+=../ | ||
INCLUDE_PATHS+=../../include/ | ||
INCLUDE_PATHS+=../../bfvmm/include/ | ||
|
||
LIBS+= | ||
|
||
LIBRARY_PATHS+= | ||
|
||
################################################################################ | ||
# Environment Specific | ||
################################################################################ | ||
|
||
VMM_SOURCES+= | ||
VMM_INCLUDE_PATHS+= | ||
VMM_LIBS+= | ||
VMM_LIBRARY_PATHS+= | ||
|
||
WINDOWS_SOURCES+= | ||
WINDOWS_INCLUDE_PATHS+= | ||
WINDOWS_LIBS+= | ||
WINDOWS_LIBRARY_PATHS+= | ||
|
||
LINUX_SOURCES+= | ||
LINUX_INCLUDE_PATHS+= | ||
LINUX_LIBS+= | ||
LINUX_LIBRARY_PATHS+= | ||
|
||
################################################################################ | ||
# Common | ||
################################################################################ | ||
|
||
include ../../common/common_target.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// Bareflank Hypervisor | ||
// | ||
// Copyright (C) 2015 Assured Information Security, Inc. | ||
// Author: Rian Quinn <[email protected]> | ||
// Author: Brendan Kerrigan <[email protected]> | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
#include <bitmap.h> | ||
#include <memory_manager/memory_manager.h> | ||
|
||
bitmap::bitmap(uint32_t num_bits) | ||
{ | ||
m_length = num_bits >> 3; | ||
|
||
if (num_bits & 7) | ||
m_length++; | ||
|
||
m_bitmap = std::make_unique<uint8_t[]>(m_length); | ||
|
||
m_virt_addr = (uint64_t)m_bitmap.get(); | ||
m_phys_addr = (uint64_t)g_mm->virt_to_phys(m_bitmap.get()); | ||
} | ||
|
||
bitmap::bitmap() | ||
{ | ||
// Default to a full page bitmap | ||
uint32_t num_bits = 4096*8; | ||
m_length = num_bits >> 3; | ||
|
||
if (num_bits & 7) | ||
m_length++; | ||
|
||
m_bitmap = std::make_unique<uint8_t[]>(m_length); | ||
|
||
m_virt_addr = (uint64_t)m_bitmap.get(); | ||
m_phys_addr = (uint64_t)g_mm->virt_to_phys(m_bitmap.get()); | ||
} | ||
|
||
|
||
void bitmap::set_bit(uint32_t n) noexcept | ||
{ | ||
if ((n >> 3) > m_length) | ||
return; | ||
|
||
m_bitmap.get()[n >> 3] |= (1 << (n & 7)); | ||
} | ||
|
||
void bitmap::clear_bit(uint32_t n) noexcept | ||
{ | ||
if ((n >> 3) > m_length) | ||
return; | ||
|
||
m_bitmap.get()[n >> 3] &= ~(1 << (n & 7)); | ||
} | ||
|
||
bool bitmap::bit(uint32_t n) const noexcept | ||
{ | ||
if ((n >> 3) > m_length) | ||
return false; | ||
|
||
if (m_bitmap.get()[n >> 3] & (1 << (n & 7))) | ||
return true; | ||
|
||
return false; | ||
} |
Oops, something went wrong.