98 lines · plain
1.. SPDX-License-Identifier: GPL-2.02 3I/O request handling4====================5 6An I/O request of a User VM, which is constructed by the hypervisor, is7distributed by the ACRN Hypervisor Service Module to an I/O client8corresponding to the address range of the I/O request. Details of I/O request9handling are described in the following sections.10 111. I/O request12--------------13 14For each User VM, there is a shared 4-KByte memory region used for I/O requests15communication between the hypervisor and Service VM. An I/O request is a16256-byte structure buffer, which is 'struct acrn_io_request', that is filled by17an I/O handler of the hypervisor when a trapped I/O access happens in a User18VM. ACRN userspace in the Service VM first allocates a 4-KByte page and passes19the GPA (Guest Physical Address) of the buffer to the hypervisor. The buffer is20used as an array of 16 I/O request slots with each I/O request slot being 25621bytes. This array is indexed by vCPU ID.22 232. I/O clients24--------------25 26An I/O client is responsible for handling User VM I/O requests whose accessed27GPA falls in a certain range. Multiple I/O clients can be associated with each28User VM. There is a special client associated with each User VM, called the29default client, that handles all I/O requests that do not fit into the range of30any other clients. The ACRN userspace acts as the default client for each User31VM.32 33Below illustration shows the relationship between I/O requests shared buffer,34I/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 673. I/O request state transition68-------------------------------69 70The 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 empty77- PENDING: a valid I/O request is pending in this slot78- PROCESSING: the I/O request is being processed79- COMPLETE: the I/O request has been processed80 81An I/O request in COMPLETE or FREE state is owned by the hypervisor. HSM and82ACRN userspace are in charge of processing the others.83 844. Processing flow of I/O requests85----------------------------------86 87a. The I/O handler of the hypervisor will fill an I/O request with PENDING88 state when a trapped I/O access happens in a User VM.89b. The hypervisor makes an upcall, which is a notification interrupt, to90 the Service VM.91c. The upcall handler schedules a worker to dispatch I/O requests.92d. The worker looks for the PENDING I/O requests, assigns them to different93 registered clients based on the address of the I/O accesses, updates94 their state to PROCESSING, and notifies the corresponding client to handle.95e. The notified client handles the assigned I/O requests.96f. The HSM updates I/O requests states to COMPLETE and notifies the hypervisor97 of the completion via hypercalls.98