|
| 1 | +.. xenvm: |
| 2 | +
|
| 3 | +ARMv8 Xen Virtual Machine Example |
| 4 | +################################# |
| 5 | + |
| 6 | +Overview |
| 7 | +******** |
| 8 | + |
| 9 | +This board allows to run Zephyr as Xen guest on any ARMv8 board that supports |
| 10 | +ARM Virtualization Extensions. This is example configuration, as almost any VM |
| 11 | +configuration is unique in many aspects. |
| 12 | + |
| 13 | +.. figure:: xen_project_logo.png |
| 14 | + :align: center |
| 15 | + :alt: XenVM |
| 16 | + |
| 17 | + Xen virtual Guest (Credit: Xen Project) |
| 18 | + |
| 19 | +It provides minimal set of devices: |
| 20 | + |
| 21 | +* ARM Generic timer |
| 22 | +* GICv2 |
| 23 | +* SBSA (subset of PL011) UART controller |
| 24 | + |
| 25 | + |
| 26 | +Hardware |
| 27 | +******** |
| 28 | +Supported Features |
| 29 | +================== |
| 30 | + |
| 31 | +The following hardware features are supported: |
| 32 | + |
| 33 | ++--------------+-------------+----------------------+ |
| 34 | +| Interface | Controller | Driver/Component | |
| 35 | ++==============+=============+======================+ |
| 36 | +| GIC | virtualized | interrupt controller | |
| 37 | ++--------------+-------------+----------------------+ |
| 38 | +| SBSA UART | emulated | serial port | |
| 39 | ++--------------+-------------+----------------------+ |
| 40 | +| ARM TIMER | virtualized | system clock | |
| 41 | ++--------------+-------------+----------------------+ |
| 42 | + |
| 43 | +The kernel currently does not support other hardware features on this platform. |
| 44 | + |
| 45 | +Devices |
| 46 | +======== |
| 47 | +System Clock |
| 48 | +------------ |
| 49 | + |
| 50 | +This board configuration uses a system clock frequency of 8.32 MHz. This is the |
| 51 | +default value, which should be corrected for user's actual hardware. |
| 52 | + |
| 53 | +You can determine clock frequency of your ARM Generic Timer by inspecting Xen |
| 54 | +boot log: |
| 55 | + |
| 56 | +:: |
| 57 | + |
| 58 | + (XEN) [ 0.147541] Generic Timer IRQ: phys=30 hyp=26 virt=27 Freq: 8320 KHz |
| 59 | + |
| 60 | +Serial Port |
| 61 | +----------- |
| 62 | + |
| 63 | +This board configuration uses a single serial communication channel using SBSA |
| 64 | +UART. This is a minimal UART implementation provided by Xen. Xen PV Console is |
| 65 | +not supported at this moment. |
| 66 | + |
| 67 | +Interrupt Controller |
| 68 | +-------------------- |
| 69 | + |
| 70 | +By default, GICv2 is selected. If your hardware is based on GICv3, you can |
| 71 | +configure Zephyr to use it, by amending device tree and Kconfig |
| 72 | +option in "xenvm" SoC as well as guest configuration file. |
| 73 | + |
| 74 | +CPU Core type |
| 75 | +------------- |
| 76 | + |
| 77 | +Default core in this configuration is Cortex A72. Depending on yours actual |
| 78 | +hardware you might want to change this option in the same way as Interrupt |
| 79 | +Controller configuration. |
| 80 | + |
| 81 | +Known Problems or Limitations |
| 82 | +============================== |
| 83 | + |
| 84 | +Xen configures guests in runtime by providing device tree that describes guest |
| 85 | +environment. On other hand, Zephyr uses static configuration that should be know |
| 86 | +at build time. So there are chances, that Zephyr image created with default |
| 87 | +configuration would not boot on your hardware. In this case you need to update |
| 88 | +configuration by altering device tree and Kconfig options. This will be covered |
| 89 | +in detail in next section. |
| 90 | + |
| 91 | +No Xen-specific features are supported at the moment. This includes: |
| 92 | + |
| 93 | +* Xen Enlighten memory page |
| 94 | +* XenBus |
| 95 | +* Xen event channels |
| 96 | +* Xen grant tables |
| 97 | +* Xen PV drivers (including PV console) |
| 98 | + |
| 99 | +Building and Running |
| 100 | +******************** |
| 101 | + |
| 102 | +Use this configuration to run basic Zephyr applications and kernel tests as Xen |
| 103 | +guest, for example, with the :ref:`synchronization_sample`: |
| 104 | + |
| 105 | + |
| 106 | +.. code-block:: |
| 107 | +
|
| 108 | + $ west build -b xenvm samples/synchronization |
| 109 | +
|
| 110 | +This will build an image with the synchronization sample app. Next, you need to |
| 111 | +create guest configuration file :code:`zephyr.conf`. There is example: |
| 112 | + |
| 113 | +.. code-block:: |
| 114 | +
|
| 115 | + kernel="zephyr.bin" |
| 116 | + name="zephyr" |
| 117 | + vcpus=1 |
| 118 | + memory=16 |
| 119 | + gic_version="v2" |
| 120 | + on_crash="preserve" |
| 121 | + vuart="sbsa_uart" |
| 122 | +
|
| 123 | +You need to upload both :code:`zephyr.bin` and :code:`zephyr.conf` to your Dom0 |
| 124 | +and then you can run Zephyr by issuing |
| 125 | + |
| 126 | +.. code-block:: |
| 127 | +
|
| 128 | + $ xl create zephyr.conf |
| 129 | +
|
| 130 | +Next you need to attach to SBSA virtual console: |
| 131 | + |
| 132 | +.. code-block:: |
| 133 | +
|
| 134 | + $ xl console -t vuart zephyr |
| 135 | +
|
| 136 | +You will see Zephyr output: |
| 137 | + |
| 138 | +.. code-block:: console |
| 139 | +
|
| 140 | + *** Booting Zephyr OS build zephyr-v2.4.0-1137-g5803ee1e8183 *** |
| 141 | + thread_a: Hello World from cpu 0 on xenvm! |
| 142 | + thread_b: Hello World from cpu 0 on xenvm! |
| 143 | + thread_a: Hello World from cpu 0 on xenvm! |
| 144 | + thread_b: Hello World from cpu 0 on xenvm! |
| 145 | + thread_a: Hello World from cpu 0 on xenvm! |
| 146 | +
|
| 147 | +Exit xen virtual console by pressing :kbd:`CTRL+[` |
| 148 | + |
| 149 | +Updating configuration |
| 150 | +********************** |
| 151 | + |
| 152 | +As was said earlier, Xen describes hardware using device tree and expects that |
| 153 | +guest will parse device tree in runtime. On other hand, Zephyr supports only |
| 154 | +static, build time configuration. While provided configuration should work on |
| 155 | +almost any ARMv8 host running in aarch64 mode, there is no guarantee, that Xen |
| 156 | +will not change some values (like RAM base address) in the future. |
| 157 | + |
| 158 | +Also, frequency of system timer is board specific and should be updated when running |
| 159 | +Zephyr xenvm image on new hardware. |
| 160 | + |
| 161 | +One can make Xen to dump generated DTB by using :code:`LIBXL_DEBUG_DUMP_DTB` |
| 162 | +environment variable, like so: |
| 163 | + |
| 164 | +.. code-block:: |
| 165 | +
|
| 166 | + $ LIBXL_DEBUG_DUMP_DTB=domu-libxl.dtb xl create zephyr.conf |
| 167 | +
|
| 168 | +Then, generated "domu-libxl.dtb" file can be de-compiled using "dtc" tool. |
| 169 | + |
| 170 | +Use information from de-compiled DTB file to update all related entries in |
| 171 | +provided "xenvm.dts" file. If memory layout is also changed, you may need to |
| 172 | +update :code:`CONFIG_SRAM_BASE_ADDRESS` as well. |
| 173 | + |
| 174 | +References |
| 175 | +********** |
| 176 | + |
| 177 | +`Xen ARM with Virtualization Extensions <https://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions>`_ |
| 178 | + |
| 179 | +`xl.conf (guest configuration file) manual <https://xenbits.xen.org/docs/unstable/man/xl.cfg.5.html>`_ |
0 commit comments