Part 1
요약·해설
지원표 2행, 명령·출력 8개, PV console·grant table과 timer/GIC configuration 제한을 보존했습니다.
ARMv8 · aarch64
GICv2 · GICv3
Xen PV
Static DTS · Kconfig
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
F4E091820CA118748A98F9ADE59BA827A5AC0E43C149F23E77FB9CD905119463
.. xenvm:
ARMv8 Xen Virtual Machine Example
#################################
Overview
********
This board allows to run Zephyr as Xen guest on any ARMv8 board that supports
ARM Virtualization Extensions. This is example configuration, as almost any VM
configuration is unique in many aspects.
It provides minimal set of devices:
* ARM Generic timer
* GICv2/GICv3
Hardware
********
Supported Features
==================
The following hardware features are supported:
+--------------+-------------+----------------------+
| Interface | Controller | Driver/Component |
+==============+=============+======================+
| GIC | virtualized | interrupt controller |
+--------------+-------------+----------------------+
| ARM TIMER | virtualized | system clock |
+--------------+-------------+----------------------+
The kernel currently does not support other hardware features on this platform.
The default configuration for this board can be found in these files:
- :zephyr_file:`boards/xen/xenvm/Kconfig.defconfig`
- :zephyr_file:`boards/xen/xenvm/xenvm_defconfig`
Devices
========
System Clock
------------
This board configuration uses a system clock frequency of 8.32 MHz. This is the
default value, which should be corrected for user's actual hardware.
You can determine clock frequency of your ARM Generic Timer by inspecting Xen
boot log:
::
(XEN) [ 0.147541] Generic Timer IRQ: phys=30 hyp=26 virt=27 Freq: 8320 KHz
Interrupt Controller
--------------------
Depending on the version of the GIC on your hardware, you may choose one of the
following board configuration variants:
- ``xenvm`` selects GICv2
- ``xenvm//gicv3`` selects GICv3
CPU Core type
-------------
Default core in this configuration is Cortex A72. Depending on yours actual
hardware you might want to change this option in the same way as Interrupt
Controller configuration.
Known Problems or Limitations
==============================
Xen configures guests in runtime by providing device tree that describes guest
environment. On other hand, Zephyr uses static configuration that should be know
at build time. So there are chances, that Zephyr image created with default
configuration would not boot on your hardware. In this case you need to update
configuration by altering device tree and Kconfig options. This will be covered
in detail in next section.
Most of Xen-specific features are not supported at the moment. This includes:
* XenBus (under development)
* Xen PV drivers
Now only following features are supported:
* Xen Enlighten memory page
* Xen event channels
* Xen PV console (2 versions: regular ring buffer based for DomU and consoleio for Dom0)
* Xen early console_io interface (mainly for debug purposes - requires debug version of Xen)
* Xen grant tables (granting access for own grants and map/unmap foreign grants)
Building and Running
********************
Use this configuration to run basic Zephyr applications and kernel tests as Xen
guest, for example, with the :zephyr:code-sample:`synchronization` sample:
- if your hardware is based on GICv2:
.. code-block::
$ west build -b xenvm samples/synchronization
- if your hardware is based on GICv3:
.. code-block::
$ west build -b xenvm//gicv3 samples/synchronization
This will build an image with the synchronization sample app. Next, you need to
create guest configuration file :code:`zephyr.conf`. There is example:
.. code-block::
kernel="zephyr.bin"
name="zephyr"
vcpus=1
memory=16
gic_version="v2"
on_crash="preserve"
When using ``xenvm//gicv3`` configuration, you need to remove the ``gic_version``
parameter or set it to ``"v3"``.
You need to upload both :code:`zephyr.bin` and :code:`zephyr.conf` to your Dom0
and then you can run Zephyr by issuing
.. code-block::
$ xl create zephyr.conf
Next you need to attach to PV console:
.. code-block::
$ xl console zephyr
Also this can be performed via single command:
.. code-block::
$ xl create -c zephyr.conf
You will see Zephyr output:
.. code-block:: console
*** Booting Zephyr OS build zephyr-v2.4.0-1137-g5803ee1e8183 ***
thread_a: Hello World from cpu 0 on xenvm!
thread_b: Hello World from cpu 0 on xenvm!
thread_a: Hello World from cpu 0 on xenvm!
thread_b: Hello World from cpu 0 on xenvm!
thread_a: Hello World from cpu 0 on xenvm!
Exit xen virtual console by pressing :kbd:`CTRL+]`
Updating configuration
**********************
As was said earlier, Xen describes hardware using device tree and expects that
guest will parse device tree in runtime. On other hand, Zephyr supports only
static, build time configuration. While provided configuration should work on
almost any ARMv8 host running in aarch64 mode, there is no guarantee, that Xen
will not change some values (like RAM base address) in the future.
Also, frequency of system timer is board specific and should be updated when running
Zephyr xenvm image on new hardware.
One can make Xen to dump generated DTB by using :code:`LIBXL_DEBUG_DUMP_DTB`
environment variable, like so:
.. code-block::
$ LIBXL_DEBUG_DUMP_DTB=domu-libxl.dtb xl create zephyr.conf
Then, generated "domu-libxl.dtb" file can be de-compiled using "dtc" tool.
Use information from de-compiled DTB file to update all related entries in
provided "xenvm.dts" file. If memory layout is also changed, you may need to
update :code:`CONFIG_SRAM_BASE_ADDRESS` as well.
References
**********
`Xen ARM with Virtualization Extensions <https://wiki.xenproject.org/wiki/Xen_ARM_with_Virtualization_Extensions>`_
`xl.conf (guest configuration file) manual <https://xenbits.xen.org/docs/unstable/man/xl.cfg.5.html>`_
Part 3
한국어 전문 번역
개요
이 board configuration은 Arm Virtualization Extensions를 지원하는 모든 ARMv8 board에서 Zephyr를 Xen guest로 실행할 수 있게 합니다. 거의 모든 VM configuration은 여러 면에서 고유하므로, 이 구성은 범용 완제품이 아니라 출발점이 되는 예제입니다.
최소 device 집합으로 ARM Generic Timer와 GICv2/GICv3를 제공합니다.
하드웨어
지원 기능
| Interface | Controller | Driver/Component |
|---|---|---|
| GIC | virtualized | interrupt controller |
| ARM TIMER | virtualized | system clock |
현재 kernel은 이 platform에서 다른 hardware 기능을 지원하지 않습니다. Default configuration은 boards/xen/xenvm/Kconfig.defconfig와 boards/xen/xenvm/xenvm_defconfig에 있습니다.
Device
System clock
이 board configuration의 system clock 기본 주파수는 8.32MHz입니다. 이는 예시 기본값이므로 실제 사용 hardware에 맞게 수정해야 합니다. Xen boot log에서 ARM Generic Timer 주파수를 확인할 수 있습니다.
(XEN) [ 0.147541] Generic Timer IRQ: phys=30 hyp=26 virt=27 Freq: 8320 KHzInterrupt controller
Hardware의 GIC version에 따라 board variant를 선택합니다.
xenvm: GICv2 선택xenvm//gicv3: GICv3 선택
CPU core type
Default core는 Cortex-A72입니다. 실제 hardware가 다르면 interrupt controller variant를 고르는 것과 같은 방식으로 core option을 변경해야 합니다.
알려진 문제와 제한
Xen은 guest 환경을 설명하는 devicetree를 runtime에 제공하지만 Zephyr는 build time에 결정되는 static configuration을 사용합니다. 따라서 default configuration으로 만든 Zephyr image가 실제 hardware에서 boot하지 않을 수 있습니다. 이 경우 다음 절의 절차대로 devicetree와 Kconfig option을 수정해야 합니다.
현재 Xen 전용 기능 대부분은 지원되지 않습니다. XenBus는 개발 중이며 Xen PV driver도 아직 지원되지 않습니다.
현재 지원하는 Xen 기능은 다음과 같습니다.
- Xen Enlighten memory page
- Xen event channel
- Xen PV console: DomU용 일반 ring buffer 방식과 Dom0용 consoleio 두 종류
- Xen early console_io interface: 주로 debug용이며 debug build Xen 필요
- Xen grant table: 자체 grant 접근 허용과 foreign grant map/unmap
빌드와 실행
이 configuration으로 기본 Zephyr application과 kernel test를 Xen guest에서 실행할 수 있습니다. 다음은 synchronization sample 예입니다.
GICv2 host
$ west build -b xenvm samples/synchronizationGICv3 host
$ west build -b xenvm//gicv3 samples/synchronization빌드 후 synchronization sample이 든 image가 생성됩니다. 이어서 guest configuration file zephyr.conf를 만듭니다.
kernel="zephyr.bin"
name="zephyr"
vcpus=1
memory=16
gic_version="v2"
on_crash="preserve"xenvm//gicv3를 사용하면 gic_version parameter를 제거하거나 "v3"로 설정합니다. zephyr.bin과 zephyr.conf를 Dom0에 올린 뒤 다음 명령으로 실행합니다.
$ xl create zephyr.confPV console에 연결합니다.
$ xl console zephyr생성과 console 연결을 한 명령으로 수행할 수도 있습니다.
$ xl create -c zephyr.conf다음과 같은 Zephyr 출력이 나타납니다.
*** Booting Zephyr OS build zephyr-v2.4.0-1137-g5803ee1e8183 ***
thread_a: Hello World from cpu 0 on xenvm!
thread_b: Hello World from cpu 0 on xenvm!
thread_a: Hello World from cpu 0 on xenvm!
thread_b: Hello World from cpu 0 on xenvm!
thread_a: Hello World from cpu 0 on xenvm!CTRL+]를 눌러 Xen virtual console에서 나옵니다.
Configuration 갱신
Xen은 guest가 runtime에 devicetree를 parsing할 것을 기대하지만 Zephyr는 static build-time configuration만 지원합니다. 제공된 configuration은 aarch64 mode로 실행하는 거의 모든 ARMv8 host에서 동작하도록 만들어졌지만, Xen이 향후 RAM base address 같은 값을 바꾸지 않는다는 보장은 없습니다. System timer 주파수도 board마다 다르므로 새 hardware에서 xenvm image를 실행할 때 수정해야 합니다.
LIBXL_DEBUG_DUMP_DTB environment variable을 사용하면 Xen이 생성한 DTB를 저장할 수 있습니다.
$ LIBXL_DEBUG_DUMP_DTB=domu-libxl.dtb xl create zephyr.conf생성된 domu-libxl.dtb를 dtc로 decompile한 뒤, 그 정보를 이용해 xenvm.dts의 관련 항목을 모두 갱신합니다. Memory layout도 바뀌었다면 CONFIG_SRAM_BASE_ADDRESS도 수정해야 할 수 있습니다.
참고 자료
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.