]> rtime.felk.cvut.cz Git - jailhouse.git/blob - README.md
README/configs: Improve Jetson TK1 documentation
[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 Mailing list:
41
42   - jailhouse-dev@googlegroups.com
43
44   - Subscription:
45     - jailhouse-dev+subscribe@googlegroups.com
46     - https://groups.google.com/forum/#!forum/jailhouse-dev/join
47
48   - Archives
49     - http://news.gmane.org/gmane.linux.jailhouse
50
51 Continuous integration:
52
53   - https://travis-ci.org/siemens/jailhouse
54
55   - Status:
56     - ![](https://travis-ci.org/siemens/jailhouse.svg?branch=master) on master
57     - ![](https://travis-ci.org/siemens/jailhouse.svg?branch=next) on next
58
59 Static code analysis:
60
61   - https://scan.coverity.com/projects/4114
62
63   - Status:
64     - ![](https://scan.coverity.com/projects/4114/badge.svg) on coverity_scan
65
66 See the [contribution documentation](CONTRIBUTING.md) for details
67 on how to write Jailhouse patches and propose them for upstream integration.
68
69
70 Requirements (preliminary)
71 --------------------------
72
73 x86 architecture:
74
75   - Intel system:
76
77     - support for 64-bit and VMX, more precisely
78       - EPT (extended page tables)
79       - unrestricted guest mode
80       - preemption timer
81
82     - Intel IOMMU (VT-d) with interrupt remapping support
83       (except when running inside QEMU)
84
85   - or AMD system:
86
87     - support for 64-bit and SVM (AMD-V), and also
88       - NPT (nested page tables); required
89       - Decode Assists; recommended
90
91     - AMD IOMMU (AMD-Vi) is unsupported now but will be required in future
92
93   - at least 2 logical CPUs
94
95   - x86-64 Linux kernel (tested against >= 3.14)
96
97     - VT-d IOMMU usage (DMAR) has to be disabled in the Linux kernel, e.g. via
98       the command line parameter:
99
100           intel_iommu=off
101
102     - To exploit the faster x2APIC, interrupt remapping needs to be on in the
103       kernel (check for CONFIG_IRQ_REMAP)
104
105 ARM architecture:
106
107   - Abstract:
108
109     - ARMv7 with virtualization extensions
110
111     - Appropriate boot loader support (typically U-Boot)
112       - Linux is started in HYP mode
113       - PSCI support for CPU offlining
114
115     - at least 2 logical CPUs
116
117   - Board support:
118
119     - Banana Pi (see also [below](#setup-on-banana-pi-arm-board))
120
121     - NVIDIA Jetson TK1
122
123     - ARM Versatile Express with Cortex-A15 or A7 cores
124       (includes ARM Fast Model)
125
126
127 Build & Installation
128 --------------------
129
130 Simply run make, optionally specifying the target kernel directory:
131
132     make [KDIR=/path/to/kernel/objects]
133
134 Except for the hypervisor image `jailhouse*.bin` that has to be available in the
135 firmware search path (invoke `make firmware_install` for this), you can run
136 Jailhouse from the build directory. Alternatively, install everything on the
137 target machine by calling `make install` from the top-level directory.
138
139
140 Configuration
141 -------------
142
143 Jailhouse requires one configuration file for the complete system and one for
144 each additional cell beside Linux. The configuration is currently being
145 defined manually by filling C structures. To study the structure, use
146 configs/qemu-vm.c for a system configuration and configs/apic-demo.c for a cell
147 configuration as reference. The build system will pick up every .c file from
148 the configs/ directory and generate a corresponding .cell file. .cell files can
149 then be passed to the jailhouse command line tool for enabling the hypervisor
150 and creating new cells.
151
152
153 Demonstration in QEMU/KVM
154 -------------------------
155
156 The included system configuration qemu-vm.c can be used to run Jailhouse in
157 QEMU/KVM virtual machine on x86 hosts (Intel and AMD are supported). Currently
158 it requires Linux 3.18 or newer on the host side (Intel is fine with 3.17).
159 QEMU is required in a recent version (2.1) as well if you want to use the
160 configuration file included in the source tree.
161
162 You also need a Linux guest image with a recent kernel (tested with >= 3.9) and
163 the ability to build a module for this kernel. Further steps depend on the type
164 of CPU you have on your system.
165
166 For Intel CPUs: Make sure the kvm-intel module was loaded with nested=1 to
167 enable nested VMX support. Start the virtual machine as follows:
168
169     qemu-system-x86_64 -machine q35 -m 1G -enable-kvm -smp 4 \
170         -cpu kvm64,-kvm_pv_eoi,-kvm_steal_time,-kvm_asyncpf,-kvmclock,+vmx,+x2apic \
171         -drive file=LinuxInstallation.img,id=disk,if=none \
172         -device ide-hd,drive=disk -serial stdio -serial vc \
173         -device intel-hda,addr=1b.0 -device hda-duplex
174
175 For AMD CPUs: Make sure the kvm-amd module was loaded with nested=1 to enable
176 nested SVM support. Start the virtual machine as follows:
177
178     qemu-system-x86_64 -machine q35 -m 1G -enable-kvm -smp 4 \
179         -cpu host,-kvm_pv_eoi,-kvm_steal_time,-kvm_asyncpf,-kvmclock,+svm,+x2apic \
180         -drive file=LinuxInstallation.img,id=disk,if=none \
181         -device ide-hd,drive=disk -serial stdio -serial vc \
182         -device intel-hda,addr=1b.0 -device hda-duplex
183
184 Inside the VM, make sure that jailhouse-*.bin, generated by the build process,
185 are available for firmware loading (typically /lib/firmware), see above for
186 installation steps.
187
188 The hypervisor requires a contiguous piece of RAM for itself and each
189 additional cell. This currently has to be pre-allocated during boot-up. So you
190 need to add
191
192     memmap=66M$0x3b000000
193
194 as parameter to the command line of the virtual machine's kernel. Reboot the
195 guest and load jailhouse.ko. Then enable Jailhouse like this:
196
197     jailhouse enable /path/to/qemu-vm.cell
198
199 Next you can create a cell with a demonstration application as follows:
200
201     jailhouse cell create /path/to/apic-demo.cell
202     jailhouse cell load apic-demo /path/to/apic-demo.bin -a 0xf0000
203     jailhouse cell start apic-demo
204
205 apic-demo.bin is left by the built process in the inmates/demos/x86 directory.
206 This application will program the APIC timer interrupt to fire at 10 Hz,
207 measuring the jitter against the PM timer and displaying the result on the
208 console. Given that this demonstration runs in a virtual machine, obviously
209 no decent latencies should be expected.
210
211 After creation, cells are addressed via the command line tool by providing
212 their names or their runtime-assigned IDs. You can obtain information about
213 active cells this way:
214
215     jailhouse cell list
216
217 Cell destruction is performed by specifying the configuration file of the
218 desired cell. This command will destroy the apic-demo:
219
220     jailhouse cell destroy apic-demo
221
222 Note that the first destruction or shutdown request on the apic-demo cell will
223 fail. The reason is that this cell contains logic to demonstrate an ordered
224 shutdown as well as the ability of a cell to reject shutdown requests.
225
226 The apic-demo cell has another special property for demonstration purposes: As
227 long as it is running, no cell reconfigurations can be performed - the
228 apic-demo locks the hypervisor in this regard. In order to destroy another cell
229 or create an additional one, shut down the apic-demo first.
230
231     jailhouse cell shutdown apic-demo  # call again if error is returned
232
233 To demonstrate the execution of a second, non-Linux cell, issue the following
234 commands:
235
236     jailhouse cell create /path/to/pci-demo.cell
237     jailhouse cell load pci-demo /path/to/pci-demo.bin -a 0xf0000
238     jailhouse cell start pci-demo
239
240 The pci-demo will use the second serial port provided by QEMU. You will find
241 its output in a virtual console of the QEMU window. The purpose of this demo is
242 to show basic PCI device configuration and MSI handling.
243
244 While cell configurations are locked, it is still possible, though, to reload
245 the content of existing cell (provided they accept their shutdown first). To
246 reload and restart the tiny-demo, issue the following commands:
247
248     jailhouse cell start apic-demo
249     jailhouse cell load pci-demo /path/to/pci-demo.bin -a 0xf0000
250     jailhouse cell start pci-demo
251
252 Finally, Jailhouse is can be stopped completely again:
253
254     jailhouse disable  # call again on error due to running apic-demo
255
256 All non-Linux cells running at that point will be destroyed, and resources
257 will be returned to Linux.
258
259
260 Setup on Banana Pi ARM board
261 ----------------------------
262
263 The Banana Pi is a cheap Raspberry-Pi-like ARM board with an Allwinner A20 SoC
264 (dual-core Cortex-A7). It runs mainline Linux kernels and U-Boot and is
265 comparably well hackable. Further information can be found on
266 http://linux-sunxi.org.
267
268 For Jailhouse, a U-Boot (pre-)release more recent than v2015.04-rc1 is
269 required. Tested and know to work is git revision bd2a4888b1.
270
271 The Linux kernel version should be at least 3.19-rcX. The configuration used
272 for continuous integration builds can serve as reference, see
273 `ci/kernel-config-banana-pi`. The kernel has to be booted with the following
274 additional parameters, e.g. by adjusting the U-Boot environment accordingly:
275
276     mem=958M vmalloc=512M
277
278 The recommended cross-toolchain is available from Linaro, see
279 http://www.linaro.org/downloads.
280
281 Before building Jailhouse, copy the configuration header file
282 `ci/jailhouse-config-banana-pi.h` to `hypervisor/include/jailhouse/config.h`.
283 Then run make:
284
285     make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- \
286          KDIR=/path/to/arm-kernel/objects
287
288 Binaries can be installed directly to the target root file system if it is
289 mounted on the host:
290
291     make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- \
292          KDIR=/path/to/arm-kernel/objects DESTDIR=/mount-point install
293
294 Cell configurations and demo inmates will not be installed this way and have to
295 be transferred manually as needed. Make sure you have `configs/bananapi.cell`
296 and, as desired, the inmates configs (`configs/bananapi-*.cell`) and binaries
297 (`inmates/demos/arm/*.bin`) available on the target.
298
299 Jailhouse and inmates are started on ARM just like on x86. The only difference
300 is that inmates have to be loaded at offset 0. Just leave out the `-a`
301 parameter when invoking `jailhouse cell load`.