]> rtime.felk.cvut.cz Git - jailhouse.git/blob - README.md
jailhouse: inmates: bench: Add -R option -- repeats count.
[jailhouse.git] / README.md
1 JAILHOUSE
2 =========
3
4 Jailhouse is a partitioning Hypervisor based on Linux. It is able to run
5 bare-metal applications or (adapted) operating systems besides Linux. For this
6 purpose it configures CPU and device virtualization features of the hardware
7 platform in a way that none of these domains, called "cells" here, can
8 interfere with each other in an unacceptable way.
9
10 Jailhouse is optimized for simplicity rather than feature richness. Unlike
11 full-featured Linux-based hypervisors like KVM or Xen, Jailhouse does not
12 support overcommitment of resources like CPUs, RAM or devices. It performs no
13 scheduling and only virtualizes those resources in software, that are essential
14 for a platform and cannot be partitioned in hardware.
15
16 Once Jailhouse is activated, it runs bare-metal, i.e. it takes full control
17 over the hardware and needs no external support. However, in contrast to other
18 bare-metal hypervisors, it is loaded and configured by a normal Linux system.
19 Its management interface is based on Linux infrastructure. So you boot Linux
20 first, then you enable Jailhouse and finally you split off parts of the
21 system's resources and assign them to additional cells.
22
23
24 WARNING: This is work in progress! Don't expect things to be complete in any
25 dimension. Use at your own risk. And keep the reset button in reach.
26
27
28 Community Resources
29 -------------------
30
31 Project home:
32
33  - https://github.com/siemens/jailhouse
34
35 Source code:
36
37  - https://github.com/siemens/jailhouse.git
38  - git@github.com:siemens/jailhouse.git
39
40 Frequently Asked Questions (FAQ):
41
42  - See [FAQ file](FAQ.md)
43
44 Mailing list:
45
46   - jailhouse-dev@googlegroups.com
47
48   - Subscription:
49     - jailhouse-dev+subscribe@googlegroups.com
50     - https://groups.google.com/forum/#!forum/jailhouse-dev/join
51
52   - Archives
53     - http://news.gmane.org/gmane.linux.jailhouse
54
55 Continuous integration:
56
57   - https://travis-ci.org/siemens/jailhouse
58
59   - Status:
60     - ![](https://travis-ci.org/siemens/jailhouse.svg?branch=master) on master
61     - ![](https://travis-ci.org/siemens/jailhouse.svg?branch=next) on next
62
63 Static code analysis:
64
65   - https://scan.coverity.com/projects/4114
66
67   - Status:
68     - ![](https://scan.coverity.com/projects/4114/badge.svg) on coverity_scan
69
70 See the [contribution documentation](CONTRIBUTING.md) for details
71 on how to write Jailhouse patches and propose them for upstream integration.
72
73
74 Requirements (preliminary)
75 --------------------------
76
77 x86 architecture:
78
79   - Intel system:
80
81     - support for 64-bit and VMX, more precisely
82       - EPT (extended page tables)
83       - unrestricted guest mode
84       - preemption timer
85
86     - Intel IOMMU (VT-d) with interrupt remapping support
87       (except when running inside QEMU)
88
89   - or AMD system:
90
91     - support for 64-bit and SVM (AMD-V), and also
92       - NPT (nested page tables); required
93       - Decode Assists; recommended
94
95     - AMD IOMMU (AMD-Vi) is unsupported now but will be required in future
96
97   - at least 2 logical CPUs
98
99   - x86-64 Linux kernel (tested against >= 3.14)
100
101     - VT-d IOMMU usage (DMAR) has to be disabled in the Linux kernel, e.g. via
102       the command line parameter:
103
104           intel_iommu=off
105
106     - To exploit the faster x2APIC, interrupt remapping needs to be on in the
107       kernel (check for CONFIG_IRQ_REMAP)
108
109 ARM architecture:
110
111   - Abstract:
112
113     - ARMv7 with virtualization extensions
114
115     - Appropriate boot loader support (typically U-Boot)
116       - Linux is started in HYP mode
117       - PSCI support for CPU offlining
118
119     - at least 2 logical CPUs
120
121   - Board support:
122
123     - Banana Pi ([see more](Documentation/setup-on-banana-pi-arm-board.md))
124
125     - NVIDIA Jetson TK1
126
127     - ARM Versatile Express with Cortex-A15 or A7 cores
128       (includes ARM Fast Model)
129
130 On x86, hardware capabilities can be validated by running
131
132     jailhouse hardware check sysconfig.cell
133
134 using the binary system configuration created for the target (see
135 [below](#configuration)).
136
137
138 Build & Installation
139 --------------------
140
141 Simply run make, optionally specifying the target kernel directory:
142
143     make [KDIR=/path/to/kernel/objects]
144
145 Except for the hypervisor image `jailhouse*.bin` that has to be available in the
146 firmware search path (invoke `make firmware_install` for this), you can run
147 Jailhouse from the build directory. Alternatively, install everything on the
148 target machine by calling `make install` from the top-level directory.
149
150
151 Configuration
152 -------------
153
154 Jailhouse requires one configuration file for the complete system and one for
155 each additional cell besides the primary Linux. These .cell files have to be
156 passed to the jailhouse command line tool for enabling the hypervisor or
157 creating new cells.
158
159 A system configuration can be created on the target system by running the
160 following command:
161
162     jailhouse config create sysconfig.c
163
164 In order to translate this into the required binary form, place this file in
165 the configs/ directory. The build system will pick up every .c file from there
166 and generate a corresponding .cell file.
167
168 Depending on the target system, the C structures may require some adjustments to
169 make Jailhouse work properly or to reduce the desired access rights of the Linux
170 root cell.
171
172 Configurations for additional (non-root) cells currently require manual
173 creation. To study the structures, use one of the demo cell configurations files
174 as reference, e.g. configs/apic-demo.c or configs/e1000-demo.c.
175
176
177 Demonstration in QEMU/KVM
178 -------------------------
179
180 The included system configuration qemu-vm.c can be used to run Jailhouse in
181 QEMU/KVM virtual machine on x86 hosts (Intel and AMD are supported). Currently
182 it requires Linux 3.18 or newer on the host side (Intel is fine with 3.17).
183 QEMU is required in a recent version (2.1) as well if you want to use the
184 configuration file included in the source tree.
185
186 You also need a Linux guest image with a recent kernel (tested with >= 3.9) and
187 the ability to build a module for this kernel. Further steps depend on the type
188 of CPU you have on your system.
189
190 For Intel CPUs: Make sure the kvm-intel module was loaded with nested=1 to
191 enable nested VMX support. Start the virtual machine as follows:
192
193     qemu-system-x86_64 -machine q35 -m 1G -enable-kvm -smp 4 \
194         -cpu kvm64,-kvm_pv_eoi,-kvm_steal_time,-kvm_asyncpf,-kvmclock,+vmx \
195         -drive file=LinuxInstallation.img,format=raw|qcow2|...,id=disk,if=none \
196         -device ide-hd,drive=disk -serial stdio -serial vc \
197         -device intel-hda,addr=1b.0 -device hda-duplex
198
199 For AMD CPUs: Make sure the kvm-amd module was loaded with nested=1 to enable
200 nested SVM support. Start the virtual machine as follows:
201
202     qemu-system-x86_64 -machine q35 -m 1G -enable-kvm -smp 4 \
203         -cpu host,-kvm_pv_eoi,-kvm_steal_time,-kvm_asyncpf,-kvmclock \
204         -drive file=LinuxInstallation.img,format=raw|qcow2|...,id=disk,if=none \
205         -device ide-hd,drive=disk -serial stdio -serial vc \
206         -device intel-hda,addr=1b.0 -device hda-duplex
207
208 Inside the VM, make sure that `jailhouse-*.bin`, generated by the build process,
209 are available for firmware loading (typically /lib/firmware), see above for
210 installation steps.
211
212 The hypervisor requires a contiguous piece of RAM for itself and each
213 additional cell. This currently has to be pre-allocated during boot-up. So you
214 need to add
215
216     memmap=66M$0x3b000000
217
218 as parameter to the command line of the virtual machine's kernel. The Jailhouse
219 QEMU cell config will block use of the serial port by the guest OS, so make
220 sure that the guest kernel command line does NOT have its console set to log
221 to the serial port (ie remove any 'console=ttyS0' arguments from the grub
222 config). Reboot the guest and load jailhouse.ko. Then enable Jailhouse like
223 this:
224
225     jailhouse enable /path/to/qemu-vm.cell
226
227 Next you can create a cell with a demonstration application as follows:
228
229     jailhouse cell create /path/to/apic-demo.cell
230     jailhouse cell load apic-demo /path/to/apic-demo.bin -a 0xf0000
231     jailhouse cell start apic-demo
232
233 apic-demo.bin is left by the built process in the inmates/demos/x86 directory.
234 This application will program the APIC timer interrupt to fire at 10 Hz,
235 measuring the jitter against the PM timer and displaying the result on the
236 console. Given that this demonstration runs in a virtual machine, obviously
237 no decent latencies should be expected.
238
239 After creation, cells are addressed via the command line tool by providing
240 their names or their runtime-assigned IDs. You can obtain information about
241 active cells this way:
242
243     jailhouse cell list
244
245 Cell destruction is performed by specifying the configuration file of the
246 desired cell. This command will destroy the apic-demo:
247
248     jailhouse cell destroy apic-demo
249
250 Note that the first destruction or shutdown request on the apic-demo cell will
251 fail. The reason is that this cell contains logic to demonstrate an ordered
252 shutdown as well as the ability of a cell to reject shutdown requests.
253
254 The apic-demo cell has another special property for demonstration purposes: As
255 long as it is running, no cell reconfigurations can be performed - the
256 apic-demo locks the hypervisor in this regard. In order to destroy another cell
257 or create an additional one, shut down the apic-demo first.
258
259     jailhouse cell shutdown apic-demo  # call again if error is returned
260
261 To demonstrate the execution of a second, non-Linux cell, issue the following
262 commands:
263
264     jailhouse cell create /path/to/pci-demo.cell
265     jailhouse cell load pci-demo /path/to/pci-demo.bin -a 0xf0000
266     jailhouse cell start pci-demo
267
268 The pci-demo will use the second serial port provided by QEMU. You will find
269 its output in a virtual console of the QEMU window. The purpose of this demo is
270 to show basic PCI device configuration and MSI handling.
271
272 While cell configurations are locked, it is still possible, though, to reload
273 the content of existing cell (provided they accept their shutdown first). To
274 reload and restart the tiny-demo, issue the following commands:
275
276     jailhouse cell start apic-demo
277     jailhouse cell load pci-demo /path/to/pci-demo.bin -a 0xf0000
278     jailhouse cell start pci-demo
279
280 Finally, Jailhouse is can be stopped completely again:
281
282     jailhouse disable  # call again on error due to running apic-demo
283
284 All non-Linux cells running at that point will be destroyed, and resources
285 will be returned to Linux.