Skip to content

Commit d746f29

Browse files
committed
Merge pull request #111 from rianquinn/fix_stack_pointer_kernel_ooppss
Fix Fedora Kernel Panic
2 parents d73207c + 5a8e62d commit d746f29

File tree

7 files changed

+146
-43
lines changed

7 files changed

+146
-43
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Change Log
2+
3+
## [1.0.0] - 2016-27-04
4+
### Added
5+
- Linux support
6+
- Custom C runtime library for constructor / destructor support and registering
7+
exception handlers
8+
- Custom driver entry logic for loading the VMM
9+
- Custom ELF loader for loading the VMM modules
10+
- Userspace managament application (BFM) for starting / stopping the
11+
hypervisor
12+
- Custom kernel-safe unwind library for adding exception support to the VMM
13+
- Basic VMM with support for Intel x86_64. The VMM places the Host OS into
14+
a virtual machine and back out. Currently can be extended to provide
15+
additional functionality
16+
- Custom build environment
17+
- Complete set of unit tests
18+
- Documentation
19+
- Scripts for setting up Unbuntu, Debian and Fedora build environments.

README.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,39 +40,39 @@ that the provided code works as expected.
4040

4141
## Motivation
4242

43-
Most people think that hypervisors are meant to virtualize servers and
44-
provide a means to run Windows on a Mac, but there is a whole field
45-
of research were hypervisors are used without guest virtual
46-
machines. Since a hypervisor is capable of controlling the host OS
47-
running underneath it, (so called "ring -1"), hypervisors have been
48-
used for introspection, reverse engineering, anti-virus, containerization,
49-
diversity, and even architectural research like the
50-
[MoRE](https://github.com/ainfosec/MoRE) hypervisor. All of these use
51-
cases start the same way, by spending months standing up the hypervisor
52-
itself before you can start working on your actual project. Existing open
53-
source hypervisors are so focused on supporting virtual machines and
54-
burdened with legacy support that they are painful to work with when
55-
conducting less traditional hypervisor research.
56-
57-
Bareflank's goal is to provide the scaffolding needed to create any type of
58-
hypervisor. To support this, Bareflank leverages C++ not only to provide
59-
a clear method for extending the hypervisor via inheritance, but also to
60-
provide access to the C++ STL to reduce the time it takes to prototype and
61-
implement new technologies. For example, suppose your writing an
43+
Most people think that hypervisors are meant to virtualize servers and
44+
provide a means to run Windows on a Mac, but there is a whole field
45+
of research were hypervisors are used without guest virtual
46+
machines. Since a hypervisor is capable of controlling the host OS
47+
running underneath it, (so called "ring -1"), hypervisors have been
48+
used for introspection, reverse engineering, anti-virus, containerization,
49+
diversity, and even architectural research like the
50+
[MoRE](https://github.com/ainfosec/MoRE) hypervisor. All of these use
51+
cases start the same way, by spending months standing up the hypervisor
52+
itself before you can start working on your actual project. Existing open
53+
source hypervisors are so focused on supporting virtual machines and
54+
burdened with legacy support that they are painful to work with when
55+
conducting less traditional hypervisor research.
56+
57+
Bareflank's goal is to provide the scaffolding needed to create any type of
58+
hypervisor. To support this, Bareflank leverages C++ not only to provide
59+
a clear method for extending the hypervisor via inheritance, but also to
60+
provide access to the C++ STL to reduce the time it takes to prototype and
61+
implement new technologies. For example, suppose your writing an
6262
introspection hypervisor that needs to store the different system calls that
63-
are being made in a hash table for fast lookups. Doing this in an existing C
64-
based hypervisor might require you to create your own hash table implementation.
65-
This same implementation is trivial with the STL's existing data structures.
66-
With Bareflank's design, you can focus on the goal of your project, and less
67-
on implementing the foundation needed to support your project.
63+
are being made in a hash table for fast lookups. Doing this in an existing C
64+
based hypervisor might require you to create your own hash table implementation.
65+
This same implementation is trivial with the STL's existing data structures.
66+
With Bareflank's design, you can focus on the goal of your project, and less
67+
on implementing the foundation needed to support your project.
6868

69-
Bareflank will always maintain the "bare minimum" needed to stand up a
69+
Bareflank will always maintain the "bare minimum" needed to stand up a
7070
hypervisor. Future repositories/projects will be created that extend
71-
the hypervisor to add additional API support for common research tasks (e.g.
72-
VT-x APIs, LibVMI APIs, and even guest support APIs). Long term, it is our
73-
hope that others will leverage Bareflank to create hypervisors
74-
capable of competing with existing type 1 and type 2 open source hypervisors,
75-
but Bareflank itself will remain focused on the bare minimum scaffolding.
71+
the hypervisor to add additional API support for common research tasks (e.g.
72+
VT-x APIs, LibVMI APIs, and even guest support APIs). Long term, it is our
73+
hope that others will leverage Bareflank to create hypervisors
74+
capable of competing with existing type 1 and type 2 open source hypervisors,
75+
but Bareflank itself will remain focused on the bare minimum scaffolding.
7676

7777
## Website
7878

@@ -142,18 +142,18 @@ functionality, we have provided a couple of examples:
142142
[Enable VPID](https://github.com/Bareflank/hypervisor_example_vpid) <br>
143143
[CPUID Count](https://github.com/Bareflank/hypervisor_example_cpuidcount)
144144

145-
## Roadmap (updated 4-21-2016)
145+
## Roadmap (updated 4-27-2016)
146146

147147
### Version 1.0
148148

149-
Target: April 2016
149+
Released: April 27, 2016
150150

151151
* ~~ELF Loader~~
152152
* ~~Userspace Managment Application (bfm)~~
153153
* ~~Unwinder~~
154154
* ~~Initial C++ Environment~~
155155
* ~~Linux Driver Entry~~
156-
* Basic VMM
156+
* ~~Basic VMM~~
157157
* ~~Testing (Ubuntu, Debian, Fedora, CentOS)~~
158158

159159
### Version 1.1

TODO.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,10 @@ Misc:
1919
- Modify the common.c code in the driver entry to handle memory protections
2020
properly. Specifically, we want to make sure that we are respecting the
2121
read/execute and read/write memory protections that are labeled by the
22-
ELF program loader. This isn't useful until we break apart libc++.so such
23-
that it's not marked r/w/x (likely to be solved with the new libc)
22+
ELF program loader.
2423
- Add system beep code for additional debugging
2524
- Add support for the PCI debugger
2625

27-
Version 1.0 TODO:
28-
- Need to have all of the VMCS checks unit tested
29-
3026
Version 1.1 TODO:
3127
- Need to have a completely isolated exit handler. It should have it's own
3228
CR3, IDT, and GDT.
@@ -47,7 +43,7 @@ Version 1.2 TODO:
4743
- Multiple guest support running http://www.includeos.org/ or some other
4844
unikernel. Note that the actual guest support will likely be in a different
4945
repo, but Bareflank itself will need some changes to support this (for
50-
example, some organizational changes to the vcpu to run a guest).
46+
example, some organizational changes to the vcpu to run a guest).
5147
- Hyperkernel support
5248

5349
Known Issues:

bfdrivers/src/arch/linux/entry.c

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include <linux/kallsyms.h>
88
#include <linux/cpumask.h>
99
#include <linux/sched.h>
10+
#include <linux/notifier.h>
11+
#include <linux/reboot.h>
1012

1113
#include <debug.h>
1214
#include <common.h>
@@ -35,13 +37,19 @@ struct mm_struct *g_mmu_context = NULL;
3537
static int
3638
dev_open(struct inode *inode, struct file *file)
3739
{
40+
(void) inode;
41+
(void) file;
42+
3843
DEBUG("dev_open succeeded\n");
3944
return 0;
4045
}
4146

4247
static int
4348
dev_release(struct inode *inode, struct file *file)
4449
{
50+
(void) inode;
51+
(void) file;
52+
4553
DEBUG("dev_release succeeded\n");
4654
return 0;
4755
}
@@ -274,13 +282,21 @@ ioctl_vmm_status(int64_t *status)
274282
return BF_IOCTL_SUCCESS;
275283
}
276284

285+
static void
286+
helper_fini(void)
287+
{
288+
set_cpu_affinity(current->pid, cpumask_of(0));
289+
common_fini();
290+
}
291+
277292
static long
278293
dev_unlocked_ioctl(struct file *file,
279294
unsigned int cmd,
280295
unsigned long arg)
281296
{
282-
const struct cpumask *cpu0 = cpumask_of(0);
283-
set_cpu_affinity(current->pid, cpu0);
297+
(void) file;
298+
299+
set_cpu_affinity(current->pid, cpumask_of(0));
284300

285301
switch (cmd)
286302
{
@@ -328,14 +344,34 @@ static struct miscdevice bareflank_dev =
328344
};
329345

330346
/* ========================================================================== */
331-
/* Entry */
347+
/* Entry / Exit */
332348
/* ========================================================================== */
333349

350+
int
351+
dev_reboot(struct notifier_block *nb,
352+
unsigned long code, void *unused)
353+
{
354+
(void) nb;
355+
(void) code;
356+
(void) unused;
357+
358+
helper_fini();
359+
360+
return NOTIFY_DONE;
361+
}
362+
363+
static struct notifier_block bareflank_notifier_block =
364+
{
365+
.notifier_call = dev_reboot
366+
};
367+
334368
int
335369
dev_init(void)
336370
{
337371
int ret;
338372

373+
register_reboot_notifier(&bareflank_notifier_block);
374+
339375
set_cpu_affinity = (set_affinity_fn)kallsyms_lookup_name("sched_setaffinity");
340376
if (set_cpu_affinity == NULL)
341377
{
@@ -362,8 +398,10 @@ dev_init(void)
362398
void
363399
dev_exit(void)
364400
{
365-
common_fini();
401+
helper_fini();
402+
366403
misc_deregister(&bareflank_dev);
404+
unregister_reboot_notifier(&bareflank_notifier_block);
367405

368406
DEBUG("dev_exit succeeded\n");
369407
return;

include/mainpage.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/// -# @ref unit_tests
66
/// -# @ref extending_bareflank
77
/// -# @ref vmm_reference
8+
/// -# @ref serial
89
///
910
/// @section description Description
1011
///
@@ -288,3 +289,42 @@
288289
/// @ref debug_ring <br>
289290
/// @ref serial_port_intel_x64 <br>
290291
///
292+
/// @section serial Serial Setup
293+
///
294+
/// With VMWare, Bareflank will use serial0 to output bfxxx / std::cout /
295+
/// std::cerr by default. On some VMWare systems, the printer uses serial0,
296+
/// so you might have to remove (disabling is not enough) the printer prior
297+
/// to adding the serial device. Worst case, you can modify the .vmx file
298+
/// manually to setup serial0.
299+
///
300+
/// On physical hardware however, you might have to define the serial port
301+
/// during compilation to something other than the default (or if you
302+
/// want to use a different VMWare serial port). To tell Bareflank to use
303+
/// a different port, you need to define the default port prior to
304+
/// compiling Bareflank.
305+
///
306+
/// export CROSS_CXXFLAGS="-DDEFAULT_COM_PORT=0x<port #>"
307+
///
308+
/// By default this is set to "COM1_PORT" or "0x3f8". You can set this to
309+
/// any of the following:
310+
/// - COM1_PORT
311+
/// - COM2_PORT
312+
/// - COM3_PORT
313+
/// - COM4_PORT
314+
/// - 0x<port #>
315+
///
316+
/// On some Intel systems with PCI serial devices the port numbers are:
317+
/// - 0xe000
318+
/// - 0xe010
319+
///
320+
/// You can use the above method to define all of the parameters for serial
321+
/// as well. The default values are listed below, and you can change them
322+
/// to anything you wish:
323+
/// - DEFAULT_COM_PORT=COM1_PORT
324+
/// - DEFAULT_BAUD_RATE=baud_rate_115200
325+
/// - DEFAULT_DATA_BITS=char_length_8
326+
/// - DEFAULT_STOP_BITS=stop_bits_1
327+
/// - DEFAULT_PARITY_BITS=parity_none
328+
///
329+
/// For more information, please see serial_port_intel_x64.h
330+
///

tools/scripts/setup-fedora.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ case $(lsb_release -sr) in
5959
sudo dnf install -y libstdc++-static
6060
sudo dnf install -y kernel-devel
6161
sudo dnf install -y kernel-headers
62+
sudo dnf update -y kernel
6263

6364
;;
6465

@@ -73,3 +74,9 @@ esac
7374
# ------------------------------------------------------------------------------
7475

7576
./tools/scripts/create-cross-compiler.sh
77+
78+
# ------------------------------------------------------------------------------
79+
# Reboot
80+
# ------------------------------------------------------------------------------
81+
82+
echo "WARNING: A reboot is required before you can build the hypervisor!!!!!"

tools/scripts/setup-ubuntu.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ fi
3737
# ------------------------------------------------------------------------------
3838

3939
case $(lsb_release -sr) in
40+
16.04)
41+
;&
42+
4043
15.10)
4144
;&
4245

0 commit comments

Comments
 (0)