Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 1 | # Getting started |
| 2 | |
Andrew Walbran | b784997 | 2019-11-15 15:23:43 +0000 | [diff] [blame] | 3 | [TOC] |
| 4 | |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 5 | ## Getting the source code |
| 6 | |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 7 | ```shell |
Andrew Scull | cd3e77e | 2018-12-19 15:35:40 +0000 | [diff] [blame] | 8 | git 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 Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 9 | ``` |
| 10 | |
| 11 | To upload a commit for review: |
| 12 | |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 13 | ```shell |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 14 | git push origin HEAD:refs/for/master |
| 15 | ``` |
Andrew Walbran | 0ba13bb | 2019-05-13 10:57:25 +0100 | [diff] [blame] | 16 | |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 17 | Browse source at https://hafnium.googlesource.com/hafnium. Review CLs at |
| 18 | https://hafnium-review.googlesource.com/. |
Andrew Walbran | 0ba13bb | 2019-05-13 10:57:25 +0100 | [diff] [blame] | 19 | |
Andrew Scull | b81de70 | 2019-07-09 13:46:50 +0100 | [diff] [blame] | 20 | See details of [how to contribute](../CONTRIBUTING.md). |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 21 | |
| 22 | ## Compiling the hypervisor |
| 23 | |
Andrew Walbran | 1027672 | 2018-09-10 14:33:18 +0100 | [diff] [blame] | 24 | Install prerequisites: |
| 25 | |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 26 | ```shell |
Andrew Walbran | 9e901ff | 2020-01-30 15:22:51 +0000 | [diff] [blame] | 27 | sudo apt install make libssl-dev flex bison python3 python3-serial |
Andrew Walbran | 1027672 | 2018-09-10 14:33:18 +0100 | [diff] [blame] | 28 | ``` |
| 29 | |
Andrew Scull | 23e93a8 | 2018-10-26 14:56:04 +0100 | [diff] [blame] | 30 | By default, the hypervisor is built with clang for a few target platforms along |
Alfredo Mazzinghi | b2bb1d3 | 2019-02-08 11:12:51 +0000 | [diff] [blame] | 31 | with tests. Each project in the `project` directory specifies a root |
| 32 | configurations of the build. Adding a project is the preferred way to extend |
| 33 | support to new platforms. The target project that is built is selected by the |
| 34 | `PROJECT` make variable, the default project is 'reference'. |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 35 | |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 36 | ```shell |
Alfredo Mazzinghi | b2bb1d3 | 2019-02-08 11:12:51 +0000 | [diff] [blame] | 37 | make PROJECT=<project_name> |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 38 | ``` |
| 39 | |
David Brazdil | 5ecf75f | 2019-07-21 10:39:47 +0200 | [diff] [blame] | 40 | The compiled image can be found under `out/<project>`, for example the QEMU |
| 41 | image is at `out/reference/qemu_aarch64_clang/hafnium.bin`. |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 42 | |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 43 | ## Running on QEMU |
| 44 | |
| 45 | You will need at least version 2.9 for QEMU. The following command line can be |
| 46 | used to run Hafnium on it: |
| 47 | |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 48 | ```shell |
Andrew Scull | 25d897e | 2019-06-27 12:57:02 +0100 | [diff] [blame] | 49 | qemu-system-aarch64 -M virt,gic_version=3 -cpu cortex-a57 -nographic -machine virtualization=true -kernel out/reference/qemu_aarch64_clang/hafnium.bin |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 50 | ``` |
| 51 | |
| 52 | Though it is admittedly not very useful because it doesn't have any virtual |
David Brazdil | a2358d4 | 2020-01-27 18:51:38 +0000 | [diff] [blame] | 53 | machines to run. |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 54 | |
David Brazdil | 0dbb41f | 2019-09-09 18:03:35 +0100 | [diff] [blame] | 55 | Next, you need to create a manifest which will describe the VM to Hafnium. |
David Brazdil | a2358d4 | 2020-01-27 18:51:38 +0000 | [diff] [blame] | 56 | Follow the [Manifest](Manifest.md) instructions and build a DTB with: |
David Brazdil | 0dbb41f | 2019-09-09 18:03:35 +0100 | [diff] [blame] | 57 | ``` |
| 58 | /dts-v1/; |
David Brazdil | 0dbb41f | 2019-09-09 18:03:35 +0100 | [diff] [blame] | 59 | |
David Brazdil | a2358d4 | 2020-01-27 18:51:38 +0000 | [diff] [blame] | 60 | / { |
David Brazdil | 0dbb41f | 2019-09-09 18:03:35 +0100 | [diff] [blame] | 61 | hypervisor { |
Serban Constantinescu | beb0ec7 | 2019-11-07 13:42:56 +0000 | [diff] [blame] | 62 | compatible = "hafnium,hafnium"; |
David Brazdil | 0dbb41f | 2019-09-09 18:03:35 +0100 | [diff] [blame] | 63 | vm1 { |
| 64 | debug_name = "Linux VM"; |
Andrew Scull | 72b43c0 | 2019-09-18 13:53:45 +0100 | [diff] [blame] | 65 | kernel_filename = "vmlinuz"; |
Serban Constantinescu | beb0ec7 | 2019-11-07 13:42:56 +0000 | [diff] [blame] | 66 | ramdisk_filename = "initrd.img"; |
David Brazdil | 0dbb41f | 2019-09-09 18:03:35 +0100 | [diff] [blame] | 67 | }; |
| 68 | }; |
| 69 | }; |
| 70 | ``` |
| 71 | |
David Brazdil | a2358d4 | 2020-01-27 18:51:38 +0000 | [diff] [blame] | 72 | Follow the [Hafnium RAM disk](HafniumRamDisk.md) instructions |
| 73 | to create an initial RAM disk for Hafnium with Linux as the primary VM. |
David Brazdil | 0dbb41f | 2019-09-09 18:03:35 +0100 | [diff] [blame] | 74 | |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 75 | The following command line will run Hafnium, with the RAM disk just created, |
| 76 | which will then boot into the primary Linux VM: |
| 77 | |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 78 | ```shell |
David Brazdil | a2358d4 | 2020-01-27 18:51:38 +0000 | [diff] [blame] | 79 | qemu-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" |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 80 | ``` |
| 81 | |
| 82 | ## Running tests |
| 83 | |
| 84 | After building, presubmit tests can be run with the following command line: |
| 85 | |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 86 | ```shell |
Andrew Walbran | 219ceaf | 2020-01-10 15:44:29 +0000 | [diff] [blame] | 87 | ./kokoro/test.sh |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 88 | ``` |
| 89 | |
| 90 | Read about [testing](Testing.md) for more details about the tests. |