1 .. SPDX-License-Identifier: GPL-2.0 1 .. SPDX-License-Identifier: GPL-2.0 2 2 3 I/O request handling 3 I/O request handling 4 ==================== 4 ==================== 5 5 6 An I/O request of a User VM, which is construc 6 An I/O request of a User VM, which is constructed by the hypervisor, is 7 distributed by the ACRN Hypervisor Service Mod 7 distributed by the ACRN Hypervisor Service Module to an I/O client 8 corresponding to the address range of the I/O 8 corresponding to the address range of the I/O request. Details of I/O request 9 handling are described in the following sectio 9 handling are described in the following sections. 10 10 11 1. I/O request 11 1. I/O request 12 -------------- 12 -------------- 13 13 14 For each User VM, there is a shared 4-KByte me 14 For each User VM, there is a shared 4-KByte memory region used for I/O requests 15 communication between the hypervisor and Servi 15 communication between the hypervisor and Service VM. An I/O request is a 16 256-byte structure buffer, which is 'struct ac 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 trappe 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 all 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 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 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. 21 bytes. This array is indexed by vCPU ID. 22 22 23 2. I/O clients 23 2. I/O clients 24 -------------- 24 -------------- 25 25 26 An I/O client is responsible for handling User 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 cli 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 28 User VM. There is a special client associated with each User VM, called the 29 default client, that handles all I/O requests 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 30 any other clients. The ACRN userspace acts as the default client for each User 31 VM. 31 VM. 32 32 33 Below illustration shows the relationship betw 33 Below illustration shows the relationship between I/O requests shared buffer, 34 I/O requests and I/O clients. 34 I/O requests and I/O clients. 35 35 36 :: 36 :: 37 37 38 +---------------------------------------- 38 +------------------------------------------------------+ 39 | S 39 | Service VM | 40 |+--------------------------------------- 40 |+--------------------------------------------------+ | 41 || +-------------------------------- 41 || +----------------------------------------+ | | 42 || | shared page ACRN use 42 || | shared page ACRN userspace | | | 43 || | +-----------------+ +------ 43 || | +-----------------+ +------------+ | | | 44 || +----+->| acrn_io_request |<-+ defa 44 || +----+->| acrn_io_request |<-+ default | | | | 45 || | | | +-----------------+ | I/O c 45 || | | | +-----------------+ | I/O client | | | | 46 || | | | | ... | +------ 46 || | | | | ... | +------------+ | | | 47 || | | | +-----------------+ 47 || | | | +-----------------+ | | | 48 || | +-|------------------------------ 48 || | +-|--------------------------------------+ | | 49 ||---|----|------------------------------ 49 ||---|----|-----------------------------------------| | 50 || | | k 50 || | | kernel | | 51 || | | +----------------- 51 || | | +----------------------+ | | 52 || | | | +-------------+ 52 || | | | +-------------+ HSM | | | 53 || | +--------------+ | 53 || | +--------------+ | | | | 54 || | | | I/O clients | 54 || | | | I/O clients | | | | 55 || | | | | 55 || | | | | | | | 56 || | | +-------------+ 56 || | | +-------------+ | | | 57 || | +----------------- 57 || | +----------------------+ | | 58 |+---|----------------------------------- 58 |+---|----------------------------------------------+ | 59 +----|----------------------------------- 59 +----|-------------------------------------------------+ 60 | 60 | 61 +----|----------------------------------- 61 +----|-------------------------------------------------+ 62 | +-+-----------+ 62 | +-+-----------+ | 63 | | I/O handler | ACRN Hype 63 | | I/O handler | ACRN Hypervisor | 64 | +-------------+ 64 | +-------------+ | 65 +---------------------------------------- 65 +------------------------------------------------------+ 66 66 67 3. I/O request state transition 67 3. I/O request state transition 68 ------------------------------- 68 ------------------------------- 69 69 70 The state transitions of an ACRN I/O request a 70 The state transitions of an ACRN I/O request are as follows. 71 71 72 :: 72 :: 73 73 74 FREE -> PENDING -> PROCESSING -> COMPLETE - 74 FREE -> PENDING -> PROCESSING -> COMPLETE -> FREE -> ... 75 75 76 - FREE: this I/O request slot is empty 76 - FREE: this I/O request slot is empty 77 - PENDING: a valid I/O request is pending in t 77 - PENDING: a valid I/O request is pending in this slot 78 - PROCESSING: the I/O request is being process 78 - PROCESSING: the I/O request is being processed 79 - COMPLETE: the I/O request has been processed 79 - COMPLETE: the I/O request has been processed 80 80 81 An I/O request in COMPLETE or FREE state is ow 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 82 ACRN userspace are in charge of processing the others. 83 83 84 4. Processing flow of I/O requests 84 4. Processing flow of I/O requests 85 ---------------------------------- 85 ---------------------------------- 86 86 87 a. The I/O handler of the hypervisor will fill 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 88 state when a trapped I/O access happens in a User VM. 89 b. The hypervisor makes an upcall, which is a 89 b. The hypervisor makes an upcall, which is a notification interrupt, to 90 the Service VM. 90 the Service VM. 91 c. The upcall handler schedules a worker to di 91 c. The upcall handler schedules a worker to dispatch I/O requests. 92 d. The worker looks for the PENDING I/O reques 92 d. The worker looks for the PENDING I/O requests, assigns them to different 93 registered clients based on the address of 93 registered clients based on the address of the I/O accesses, updates 94 their state to PROCESSING, and notifies the 94 their state to PROCESSING, and notifies the corresponding client to handle. 95 e. The notified client handles the assigned I/ 95 e. The notified client handles the assigned I/O requests. 96 f. The HSM updates I/O requests states to COMP 96 f. The HSM updates I/O requests states to COMPLETE and notifies the hypervisor 97 of the completion via hypercalls. 97 of the completion via hypercalls.
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.