Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 1 | # Hafnium RAM disk |
| 2 | |
| 3 | Hafnium expects to find the following files in the root directory of its RAM |
| 4 | disk: |
| 5 | |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 6 | * `vmlinuz` -- the kernel of the primary VM. |
| 7 | * `initrd.img` -- the initial ramdisk of the primary VM. |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame^] | 8 | * `manifest.dtb` -- hypervisor configuration file. |
| 9 | * kernels for the secondary VMs, whose names are described in the manifest. |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 10 | |
| 11 | Follow the [preparing Linux](PreparingLinux.md) instructions to produce |
| 12 | `vmlinuz` and `initrd.img` for a basic Linux primary VM. |
| 13 | |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame^] | 14 | ## Manifest file |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 15 | |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame^] | 16 | The format is currently a simple Device Tree: |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 17 | |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame^] | 18 | ``` |
| 19 | /dts-v1/; |
| 20 | |
| 21 | / { |
| 22 | hypervisor { |
| 23 | vm1 { |
| 24 | debug_name = "name"; |
| 25 | }; |
| 26 | |
| 27 | vm2 { |
| 28 | debug_name = "name"; |
| 29 | kernel_filename = "filename"; |
| 30 | vcpu_count = <N>; |
| 31 | mem_size = <M>; |
| 32 | }; |
| 33 | ... |
| 34 | }; |
| 35 | }; |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 36 | ``` |
| 37 | |
| 38 | For example, the following defines two secondary VMs, the first one with 1MB of |
| 39 | memory, 2 CPUs and kernel image called `kernel0`, while the second one has 2MB |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 40 | of memory, 4 CPUs and a kernel image called `kernel1`. |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 41 | |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame^] | 42 | ``` |
| 43 | /dts-v1/; |
| 44 | |
| 45 | / { |
| 46 | hypervisor { |
| 47 | vm1 { |
| 48 | debug_name = "primary VM"; |
| 49 | }; |
| 50 | |
| 51 | vm2 { |
| 52 | debug_name = "secondary VM 1"; |
| 53 | kernel_filename = "kernel0"; |
| 54 | vcpu_count = <2>; |
| 55 | mem_size = <0x100000>; |
| 56 | }; |
| 57 | |
| 58 | vm3 { |
| 59 | debug_name = "secondary VM 2"; |
| 60 | kernel_filename = "kernel1"; |
| 61 | vcpu_count = <4>; |
| 62 | mem_size = <0x200000>; |
| 63 | }; |
| 64 | }; |
| 65 | }; |
| 66 | ``` |
| 67 | |
| 68 | Hafnium expects the manifest in Device Tree Blob format. Compile it with: |
Andrew Walbran | 6f8fd4c | 2019-08-05 13:28:17 +0100 | [diff] [blame] | 69 | ```shell |
David Brazdil | 7a462ec | 2019-08-15 12:27:47 +0100 | [diff] [blame^] | 70 | dtc -I dts -O dtb --out-version 17 -o manifest.dtb <manifest_source_file> |
Andrew Scull | 2304204 | 2018-08-22 17:44:56 +0100 | [diff] [blame] | 71 | ``` |
| 72 | |
| 73 | ## Create a RAM disk for Hafnium |
| 74 | |
| 75 | Assuming that a subdirectory called `initrd` contains the files listed in the |
| 76 | previous section, we can build `initrd.img` with the following command: |
| 77 | |
| 78 | ```shell |
| 79 | cd initrd; find . | cpio -o > ../initrd.img; cd - |
| 80 | ``` |