blob: 19898559bdd967537aed6395895e95a38e24fd08 [file] [log] [blame] [view]
Andrew Scull23042042018-08-22 17:44:56 +01001# Getting started
2
Andrew Scull23042042018-08-22 17:44:56 +01003## Getting the source code
4
Andrew Walbran6f8fd4c2019-08-05 13:28:17 +01005```shell
Andrew Scullcd3e77e2018-12-19 15:35:40 +00006git clone --recurse-submodules https://hafnium.googlesource.com/hafnium && (cd hafnium && f=`git rev-parse --git-dir`/hooks/commit-msg ; curl -Lo $f https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; chmod +x $f)
Andrew Scull23042042018-08-22 17:44:56 +01007```
8
9To upload a commit for review:
10
Andrew Walbran6f8fd4c2019-08-05 13:28:17 +010011```shell
Andrew Scull23042042018-08-22 17:44:56 +010012git push origin HEAD:refs/for/master
13```
Andrew Walbran0ba13bb2019-05-13 10:57:25 +010014
Andrew Walbran6f8fd4c2019-08-05 13:28:17 +010015Browse source at https://hafnium.googlesource.com/hafnium. Review CLs at
16https://hafnium-review.googlesource.com/.
Andrew Walbran0ba13bb2019-05-13 10:57:25 +010017
Andrew Scullb81de702019-07-09 13:46:50 +010018See details of [how to contribute](../CONTRIBUTING.md).
Andrew Scull23042042018-08-22 17:44:56 +010019
20## Compiling the hypervisor
21
Andrew Walbran10276722018-09-10 14:33:18 +010022Install prerequisites:
23
Andrew Walbran6f8fd4c2019-08-05 13:28:17 +010024```shell
Fuad Tabba9ca9a312019-07-23 17:14:34 +010025sudo apt install make binutils-aarch64-linux-gnu aarch64-linux-gnu-gcc device-tree-compiler libssl-dev flex bison
Andrew Walbran10276722018-09-10 14:33:18 +010026```
27
Andrew Scull23e93a82018-10-26 14:56:04 +010028By default, the hypervisor is built with clang for a few target platforms along
Alfredo Mazzinghib2bb1d32019-02-08 11:12:51 +000029with tests. Each project in the `project` directory specifies a root
30configurations of the build. Adding a project is the preferred way to extend
31support to new platforms. The target project that is built is selected by the
32`PROJECT` make variable, the default project is 'reference'.
Andrew Scull23042042018-08-22 17:44:56 +010033
Andrew Walbran6f8fd4c2019-08-05 13:28:17 +010034```shell
Alfredo Mazzinghib2bb1d32019-02-08 11:12:51 +000035make PROJECT=<project_name>
Andrew Scull23042042018-08-22 17:44:56 +010036```
37
David Brazdil5ecf75f2019-07-21 10:39:47 +020038The compiled image can be found under `out/<project>`, for example the QEMU
39image is at `out/reference/qemu_aarch64_clang/hafnium.bin`.
Andrew Scull23042042018-08-22 17:44:56 +010040
Andrew Scull23042042018-08-22 17:44:56 +010041## Running on QEMU
42
43You will need at least version 2.9 for QEMU. The following command line can be
44used to run Hafnium on it:
45
Andrew Walbran6f8fd4c2019-08-05 13:28:17 +010046```shell
Andrew Scull25d897e2019-06-27 12:57:02 +010047qemu-system-aarch64 -M virt,gic_version=3 -cpu cortex-a57 -nographic -machine virtualization=true -kernel out/reference/qemu_aarch64_clang/hafnium.bin
Andrew Scull23042042018-08-22 17:44:56 +010048```
49
50Though it is admittedly not very useful because it doesn't have any virtual
51machines to run. Follow the [Hafnium RAM disk](HafniumRamDisk.md) instructions
52to create an initial RAM disk for Hafnium with Linux as the primary VM.
53
David Brazdil0dbb41f2019-09-09 18:03:35 +010054Next, you need to create a manifest which will describe the VM to Hafnium.
55Follow the [Manifest](Manifest.md) instructions and build a DTBO with:
56```
57/dts-v1/;
58/plugin/;
59
60&{/} {
61 hypervisor {
62 vm1 {
63 debug_name = "Linux VM";
64 };
65 };
66};
67```
68
69Dump the DTB used by QEMU:
70```shell
71qemu-system-aarch64 -M virt,gic_version=3 -cpu cortex-a57 -nographic -machine virtualization=true -kernel out/reference/qemu_aarch64_clang/hafnium.bin -initrd initrd.img -append "rdinit=/sbin/init" -machine dumpdtb=qemu.dtb
72```
73and follow instructions in [Manifest](Manifest.md) to overlay it with the manifest.
74
Andrew Scull23042042018-08-22 17:44:56 +010075The following command line will run Hafnium, with the RAM disk just created,
76which will then boot into the primary Linux VM:
77
Andrew Walbran6f8fd4c2019-08-05 13:28:17 +010078```shell
David Brazdil0dbb41f2019-09-09 18:03:35 +010079qemu-system-aarch64 -M virt,gic_version=3 -cpu cortex-a57 -nographic -machine virtualization=true -kernel out/reference/qemu_aarch64_clang/hafnium.bin -initrd initrd.img -append "rdinit=/sbin/init" -dtb=qemu_with_manifest.dtb
Andrew Scull23042042018-08-22 17:44:56 +010080```
81
82## Running tests
83
84After building, presubmit tests can be run with the following command line:
85
Andrew Walbran6f8fd4c2019-08-05 13:28:17 +010086```shell
Andrew Scull23042042018-08-22 17:44:56 +010087./kokoro/ubuntu/test.sh
88```
89
90Read about [testing](Testing.md) for more details about the tests.