← Documents Documentation/virt/acrn/io-request.rst GitHub 원문 ↗

Linux 6.18.37 · 가상화 / ACRN

ACRN I/O 요청 처리

ACRN의 4-KByte 공유 페이지, vCPU별 요청 슬롯, I/O 클라이언트 배포와 상태 전이를 설명합니다.

Source pathDocumentation/virt/acrn/io-request.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

io-request.rst:1-97

요청 슬롯은 vCPU별 고정 위치와 명시적 상태 전이를 함께 사용합니다. 주소 범위 기반 클라이언트 선택과 default client fallback을 분리하고, COMPLETE 전환 뒤에만 hypercall로 완료를 알리는 순서가 중복 처리와 소유권 혼선을 막습니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 I/O request handling
4 ====================
5
6 An I/O request of a User VM, which is constructed by the hypervisor, is
7 distributed by the ACRN Hypervisor Service Module to an I/O client
8 corresponding to the address range of the I/O request. Details of I/O request
9 handling are described in the following sections.
10
11 1. I/O request
12 --------------
13
14 For each User VM, there is a shared 4-KByte memory region used for I/O requests
15 communication between the hypervisor and Service VM. An I/O request is a
16 256-byte structure buffer, which is 'struct acrn_io_request', that is filled by
17 an I/O handler of the hypervisor when a trapped I/O access happens in a User
18 VM. ACRN userspace in the Service VM first allocates a 4-KByte page and passes
19 the GPA (Guest Physical Address) of the buffer to the hypervisor. The buffer is
20 used as an array of 16 I/O request slots with each I/O request slot being 256
21 bytes. This array is indexed by vCPU ID.
22
23 2. I/O clients
24 --------------
25
26 An I/O client is responsible for handling User VM I/O requests whose accessed
27 GPA falls in a certain range. Multiple I/O clients can be associated with each
28 User VM. There is a special client associated with each User VM, called the
29 default client, that handles all I/O requests that do not fit into the range of
30 any other clients. The ACRN userspace acts as the default client for each User
31 VM.
32
33 Below illustration shows the relationship between I/O requests shared buffer,
34 I/O requests and I/O clients.
35
36 ::
37
38 +------------------------------------------------------+
39 | Service VM |
40 |+--------------------------------------------------+ |
41 || +----------------------------------------+ | |
42 || | shared page ACRN userspace | | |
43 || | +-----------------+ +------------+ | | |
44 || +----+->| acrn_io_request |<-+ default | | | |
45 || | | | +-----------------+ | I/O client | | | |
46 || | | | | ... | +------------+ | | |
47 || | | | +-----------------+ | | |
48 || | +-|--------------------------------------+ | |
49 ||---|----|-----------------------------------------| |
50 || | | kernel | |
51 || | | +----------------------+ | |
52 || | | | +-------------+ HSM | | |
53 || | +--------------+ | | | |
54 || | | | I/O clients | | | |
55 || | | | | | | |
56 || | | +-------------+ | | |
57 || | +----------------------+ | |
58 |+---|----------------------------------------------+ |
59 +----|-------------------------------------------------+
60 |
61 +----|-------------------------------------------------+
62 | +-+-----------+ |
63 | | I/O handler | ACRN Hypervisor |
64 | +-------------+ |
65 +------------------------------------------------------+
66
67 3. I/O request state transition
68 -------------------------------
69
70 The state transitions of an ACRN I/O request are as follows.
71
72 ::
73
74 FREE -> PENDING -> PROCESSING -> COMPLETE -> FREE -> ...
75
76 - FREE: this I/O request slot is empty
77 - PENDING: a valid I/O request is pending in this slot
78 - PROCESSING: the I/O request is being processed
79 - COMPLETE: the I/O request has been processed
80
81 An I/O request in COMPLETE or FREE state is owned by the hypervisor. HSM and
82 ACRN userspace are in charge of processing the others.
83
84 4. Processing flow of I/O requests
85 ----------------------------------
86
87 a. The I/O handler of the hypervisor will fill an I/O request with PENDING
88 state when a trapped I/O access happens in a User VM.
89 b. The hypervisor makes an upcall, which is a notification interrupt, to
90 the Service VM.
91 c. The upcall handler schedules a worker to dispatch I/O requests.
92 d. The worker looks for the PENDING I/O requests, assigns them to different
93 registered clients based on the address of the I/O accesses, updates
94 their state to PROCESSING, and notifies the corresponding client to handle.
95 e. The notified client handles the assigned I/O requests.
96 f. The HSM updates I/O requests states to COMPLETE and notifies the hypervisor
97 of the completion via hypercalls.
98

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

I/O 요청 배포 개요

1-10

하이퍼바이저가 구성한 User VM의 I/O 요청은 ACRN Hypervisor Service Module이 그 요청의 주소 범위에 대응하는 I/O 클라이언트로 배포합니다. 이어지는 절은 요청 저장 형식, 클라이언트 선택, 상태 전이와 처리 절차를 설명합니다.

.. SPDX-License-Identifier: GPL-2.0

I/O request handling
====================

An I/O request of a User VM, which is constructed by the hypervisor, is
distributed by the ACRN Hypervisor Service Module to an I/O client
corresponding to the address range of the I/O request. Details of I/O request
handling are described in the following sections.

1. I/O 요청과 공유 페이지

11-22

각 User VM에는 하이퍼바이저와 Service VM이 I/O 요청을 주고받는 4-KByte 공유 메모리 영역이 있습니다. 트랩된 I/O 접근이 발생하면 하이퍼바이저의 I/O handler가 256바이트 구조체 버퍼인 `struct acrn_io_request`를 채웁니다.

Service VM의 ACRN userspace는 먼저 4-KByte 페이지를 할당하고 그 버퍼의 GPA(Guest Physical Address)를 하이퍼바이저에 전달합니다. 이 버퍼는 각각 256바이트인 I/O 요청 슬롯 16개의 배열로 사용되며 vCPU ID로 인덱싱됩니다.

공유 I/O 요청 영역
항목
공유 영역4 KByte
요청 구조체`struct acrn_io_request`
슬롯 크기256 bytes
슬롯 수16
인덱스vCPU ID

4-KByte 페이지의 고정 배치를 정리합니다.

1. I/O request
--------------

For each User VM, there is a shared 4-KByte memory region used for I/O requests
communication between the hypervisor and Service VM. An I/O request is a
256-byte structure buffer, which is 'struct acrn_io_request', that is filled by
an I/O handler of the hypervisor when a trapped I/O access happens in a User
VM. ACRN userspace in the Service VM first allocates a 4-KByte page and passes
the GPA (Guest Physical Address) of the buffer to the hypervisor. The buffer is
used as an array of 16 I/O request slots with each I/O request slot being 256
bytes. This array is indexed by vCPU ID.

2. I/O 클라이언트

23-34

I/O 클라이언트는 접근 GPA가 자신에게 등록된 범위에 속하는 User VM I/O 요청을 처리합니다. 하나의 User VM에는 여러 I/O 클라이언트를 연결할 수 있습니다.

각 User VM에는 어느 다른 클라이언트의 범위에도 들어가지 않는 요청을 맡는 특별한 default client가 있습니다. ACRN userspace가 각 User VM의 default client 역할을 합니다.

2. I/O clients
--------------

An I/O client is responsible for handling User VM I/O requests whose accessed
GPA falls in a certain range. Multiple I/O clients can be associated with each
User VM. There is a special client associated with each User VM, called the
default client, that handles all I/O requests that do not fit into the range of
any other clients. The ACRN userspace acts as the default client for each User
VM.

Below illustration shows the relationship between I/O requests shared buffer,
I/O requests and I/O clients.

공유 버퍼와 I/O 클라이언트 관계

35-66

하이퍼바이저의 I/O handler가 공유 페이지의 `acrn_io_request` 슬롯을 갱신합니다. Service VM 커널의 HSM은 등록된 I/O 클라이언트로 요청을 연결하고, 범위가 일치하지 않는 요청은 ACRN userspace의 default I/O client가 처리합니다.

ACRN I/O 요청 전달 경로
ACRN Hypervisor의 I/O handler가 트랩된 접근을 요청 슬롯에 기록Service VM과 공유하는 4-KByte 페이지의 vCPU별 acrn_io_request 선택HSM이 접근 주소를 등록된 I/O client 범위와 대조일치하는 HSM I/O client가 있으면 해당 클라이언트에 배정일치 범위가 없으면 ACRN userspace의 default I/O client에 배정

원문의 ASCII 관계도를 요청 생산자부터 처리 클라이언트까지 구조화했습니다.


::

     +------------------------------------------------------+
     |                                       Service VM     |
     |+--------------------------------------------------+  |
     ||      +----------------------------------------+  |  |
     ||      | shared page            ACRN userspace  |  |  |
     ||      |    +-----------------+  +------------+ |  |  |
     ||   +----+->| acrn_io_request |<-+  default   | |  |  |
     ||   |  | |  +-----------------+  | I/O client | |  |  |
     ||   |  | |  |       ...       |  +------------+ |  |  |
     ||   |  | |  +-----------------+                 |  |  |
     ||   |  +-|--------------------------------------+  |  |
     ||---|----|-----------------------------------------|  |
     ||   |    |                             kernel      |  |
     ||   |    |            +----------------------+     |  |
     ||   |    |            | +-------------+  HSM |     |  |
     ||   |    +--------------+             |      |     |  |
     ||   |                 | | I/O clients |      |     |  |
     ||   |                 | |             |      |     |  |
     ||   |                 | +-------------+      |     |  |
     ||   |                 +----------------------+     |  |
     |+---|----------------------------------------------+  |
     +----|-------------------------------------------------+
          |
     +----|-------------------------------------------------+
     |  +-+-----------+                                     |
     |  | I/O handler |              ACRN Hypervisor        |
     |  +-------------+                                     |
     +------------------------------------------------------+

3. I/O 요청 상태 전이

67-83

ACRN I/O 요청은 `FREE -> PENDING -> PROCESSING -> COMPLETE -> FREE` 순서로 순환합니다. `FREE`는 빈 슬롯, `PENDING`은 유효한 요청 대기, `PROCESSING`은 처리 중, `COMPLETE`는 처리 완료를 뜻합니다.

`COMPLETE` 또는 `FREE` 상태의 요청은 하이퍼바이저가 소유합니다. 나머지 `PENDING`과 `PROCESSING` 상태의 처리 책임은 HSM과 ACRN userspace에 있습니다.

I/O 요청 상태 수명 주기
FREE: 하이퍼바이저가 소유한 빈 슬롯PENDING: 하이퍼바이저가 채운 유효 요청PROCESSING: HSM 또는 userspace 클라이언트가 처리 중COMPLETE: 처리가 끝나 하이퍼바이저에 반환FREE: 하이퍼바이저가 슬롯을 다시 사용

소유권과 처리 단계가 상태에 따라 이동합니다.

요청 상태와 담당
상태의미담당
`FREE`요청 슬롯이 비어 있음Hypervisor
`PENDING`유효한 요청이 대기 중HSM / ACRN userspace
`PROCESSING`요청 처리 중HSM / I/O client
`COMPLETE`요청 처리 완료Hypervisor

각 상태의 의미와 주 담당자를 정리합니다.

3. I/O request state transition
-------------------------------

The state transitions of an ACRN I/O request are as follows.

::

   FREE -> PENDING -> PROCESSING -> COMPLETE -> FREE -> ...

- FREE: this I/O request slot is empty
- PENDING: a valid I/O request is pending in this slot
- PROCESSING: the I/O request is being processed
- COMPLETE: the I/O request has been processed

An I/O request in COMPLETE or FREE state is owned by the hypervisor. HSM and
ACRN userspace are in charge of processing the others.

4. I/O 요청 처리 흐름

84-97

User VM에서 트랩되는 I/O 접근이 발생하면 하이퍼바이저 I/O handler가 요청을 `PENDING` 상태로 채웁니다. 하이퍼바이저는 알림 인터럽트인 upcall을 Service VM으로 보내고, upcall handler는 요청 배포 worker를 예약합니다.

worker는 `PENDING` 요청을 찾아 I/O 접근 주소에 따라 등록된 클라이언트에 배정하고 상태를 `PROCESSING`으로 바꾼 뒤 해당 클라이언트에 알립니다. 클라이언트가 요청을 처리하면 HSM이 상태를 `COMPLETE`로 갱신하고 hypercall로 완료 사실을 하이퍼바이저에 알립니다.

I/O 요청 처리 순서
User VM의 I/O 접근이 trap되고 I/O handler가 PENDING 요청 생성Hypervisor가 Service VM에 notification interrupt인 upcall 전달Upcall handler가 요청 배포 worker 예약Worker가 주소 범위별 I/O client를 선택하고 PROCESSING으로 전환선택된 client가 요청 처리HSM이 COMPLETE로 갱신하고 hypercall로 Hypervisor에 완료 통지

트랩 발생부터 하이퍼바이저 완료 통지까지의 순서입니다.

4. Processing flow of I/O requests
----------------------------------

a. The I/O handler of the hypervisor will fill an I/O request with PENDING
   state when a trapped I/O access happens in a User VM.
b. The hypervisor makes an upcall, which is a notification interrupt, to
   the Service VM.
c. The upcall handler schedules a worker to dispatch I/O requests.
d. The worker looks for the PENDING I/O requests, assigns them to different
   registered clients based on the address of the I/O accesses, updates
   their state to PROCESSING, and notifies the corresponding client to handle.
e. The notified client handles the assigned I/O requests.
f. The HSM updates I/O requests states to COMPLETE and notifies the hypervisor
   of the completion via hypercalls.