services/virtualization/ivshmem.html · services/virtualization/ivshmem.rst 공식 원문 ↗

Zephyr 3.7.0 · Virtualization · ivshmem

Inter-VM Shared Memory

여러 VM에 같은 memory를 노출하고 필요하면 doorbell interrupt로 알립니다.

Official pathservices/virtualization/ivshmem.html
Source fileservices/virtualization/ivshmem.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

Inter-VM Shared Memory의 공식 원문 구조, 설정 조건과 실행 흐름을 생략 없이 설명합니다.

Path

services/virtualization/ivshmem.html

Version

Zephyr 3.7.0

Status

Full translation

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 FD209B7BD1DD856D821EF462A19687757D0F9B50405CFDBDCCC261C3E794C5A5
.. _ivshmem_driver:

Inter-VM Shared Memory
######################

.. contents::
   :local:
   :depth: 2

Overview
********

As Zephyr is enabled to run as a guest OS on Qemu and
`ACRN <https://projectacrn.github.io/latest/tutorials/using_zephyr_as_uos.html>`_
it might be necessary to make VMs aware of each other, or aware of the host.
This is made possible by exposing a shared memory among parties via a feature
called ivshmem, which stands for inter-VM Shared Memory.

The two types are supported: a plain shared memory (ivshmem-plain) or a shared
memory with the ability for a VM to generate an interruption on another, and
thus to be interrupted as well itself (ivshmem-doorbell).

Please refer to the official `Qemu ivshmem documentation
<https://www.qemu.org/docs/master/system/devices/ivshmem.html>`_ for more information.

Support
*******

Zephyr supports both versions: plain and doorbell. Ivshmem driver can be built
by enabling :kconfig:option:`CONFIG_IVSHMEM`. By default, this will expose the plain
version. :kconfig:option:`CONFIG_IVSHMEM_DOORBELL` needs to be enabled to get the
doorbell version.

Because the doorbell version uses MSI-X vectors to support notification vectors,
the :kconfig:option:`CONFIG_IVSHMEM_MSI_X_VECTORS` has to be tweaked to the number of
vectors that will be needed.

Note that a tiny shell module can be exposed to test the ivshmem feature by
enabling :kconfig:option:`CONFIG_IVSHMEM_SHELL`.

ivshmem-v2
**********

Zephyr also supports ivshmem-v2:

https://github.com/siemens/jailhouse/blob/master/Documentation/ivshmem-v2-specification.md

This is primarily used for IPC in the Jailhouse hypervisor
(e.g. :zephyr:code-sample:`eth-ivshmem`). It is also possible to use ivshmem-v2 without
Jailhouse by building the Siemens fork of QEMU, and modifying the QEMU launch flags:

https://github.com/siemens/qemu/tree/wip/ivshmem2

API Reference
*************

.. doxygengroup:: ivshmem

Part 3

한국어 전문 번역

Overview

Zephyr는 QEMU와 ACRN에서 guest OS로 실행할 수 있습니다. VM끼리 또는 guest와 host가 서로를 인식하고 data를 교환해야 할 때 ivshmem(inter-VM Shared Memory)이 참여자에게 같은 shared memory를 노출합니다.

두 mode를 지원합니다. ivshmem-plain은 memory만 공유합니다. ivshmem-doorbell은 공유 memory에 더해 한 VM이 다른 VM에 interrupt를 발생시키고 자신도 notification을 받을 수 있습니다.

ivshmem communication modes
VM AShared region에 data write
ivshmem-plain: polling · shared state
Shared MemoryHost가 여러 VM에 같은 PCI BAR memory를 노출
ivshmem-doorbell: MSI-X vector
VM BInterrupt notification 뒤 data read
ivshmem-v2
State · R/O · R/W sectionsJailhouse IPC layout

PCI device model과 host option 세부 사항은 QEMU 공식 ivshmem 문서를 함께 참고합니다.

Support

CONFIG_IVSHMEM을 켜면 driver가 build되며 기본은 plain version입니다. Doorbell notification이 필요하면 CONFIG_IVSHMEM_DOORBELL을 활성화합니다.

Doorbell은 MSI-X vector로 notification을 전달하므로 필요한 vector 수에 맞춰 CONFIG_IVSHMEM_MSI_X_VECTORS를 조정해야 합니다. 너무 적으면 peer/channel별 notification을 배정할 수 없습니다.

CONFIG_IVSHMEM_SHELL을 켜면 작은 shell module을 노출해 shared memory와 doorbell 동작을 시험할 수 있습니다.

ivshmem-v2

Zephyr는 Siemens가 정의한 ivshmem-v2도 지원합니다. 주 용도는 Jailhouse hypervisor 안 IPC이며 eth-ivshmem sample이 대표 예입니다.

Jailhouse 없이도 Siemens QEMU fork의 wip/ivshmem2 branch를 build하고 QEMU launch flag를 바꾸면 ivshmem-v2를 사용할 수 있습니다. v2는 state, read-only, read-write/output section이 분리될 수 있으므로 legacy contiguous-memory API 대신 section별 API를 사용해야 합니다.

API Reference

IVSHMEM_V2_PROTO_UNDEFINED
ivshmem-v2 protocol이 지정되지 않은 상태를 나타냅니다.
IVSHMEM_V2_PROTO_NET
ivshmem-v2 shared region이 network protocol layout을 사용함을 나타냅니다.
ivshmem_get_mem_f
Driver implementation이 legacy plain/doorbell shared memory base와 size를 반환하는 function type입니다.
ivshmem_get_id_f
Driver가 현재 VM의 doorbell peer ID를 반환하는 function type입니다.
ivshmem_get_vectors_f
Driver가 사용할 수 있는 notification vector 수를 반환하는 function type입니다.
ivshmem_int_peer_f
Peer VM ID와 MSI-X vector를 지정해 interrupt를 보내는 driver function type입니다.
ivshmem_register_handler_f
Vector notification을 받을 k_poll_signal을 등록·해제하는 driver function type입니다.
ivshmem_get_mem
Legacy ivshmem의 mapped address를 memmap에 쓰고 byte size를 반환합니다. v2는 R/W와 R/O area가 연속이라는 보장이 없어 이 API를 지원하지 않습니다.
ivshmem_get_id
Doorbell mode의 현재 VM ID를 반환합니다. Doorbell이 아니면 0입니다.
ivshmem_get_vectors
현재 device에서 사용할 수 있는 interrupt vector 수를 반환합니다.
ivshmem_int_peer
peer_id VM에 지정 vector로 interrupt를 보냅니다. 성공은 0, 실패는 음수 errno입니다.
ivshmem_register_handler
Vector가 울릴 때 raise할 준비된 k_poll_signal을 등록합니다. Positive signal status에는 발생 vector가 들어가므로 모든 vector가 signal 하나를 공유하거나 vector별 signal을 둘 수 있습니다. NULL은 해당 vector handler를 해제합니다.
ivshmem_driver_api
Shared memory 조회, VM identity, vector count, peer interrupt와 handler registration callback을 묶는 driver API table입니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.