mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-01-06 16:15:00 +00:00
HV: io: drop REQ_STATE_FAILED
Now the DM has adopted the new VHM request state transitions and REQ_STATE_FAILED is obsolete since neither VHM nor kernel mediators will set the state to FAILED. This patch drops the definition to REQ_STATE_FAILED in the hypervisor, makes ''processed'' unsigned to make the compiler happy about typing and simplifies error handling in the following ways. * (dm_)emulate_(pio|mmio)_post no longer returns an error code, by introducing a constraint that these functions must be called after an I/O request completes (which is the case in the current design) and assuming handlers/VHM/DM will always give a value for reads (typically all 1's if the requested address is invalid). * emulate_io() now returns a positive value IOREQ_PENDING to indicate that the request is sent to VHM. This mitigates a potential race between dm_emulate_pio() and pio_instr_vmexit_handler() which can cause emulate_pio_post() being called twice for the same request. * Remove the ''processed'' member in io_request. Previously this mirrors the state of the VHM request which terminates at either COMPLETE or FAILED. After the FAILED state is removed, the terminal state will always be constantly COMPLETE. Thus the mirrored ''processed'' member is no longer useful. Note that emulate_instruction() will always succeed after a reshuffle, and this patch takes that assumption in advance. This does not hurt as that returned value is not currently handled. This patch makes it explicit that I/O emulation is not expected to fail. One issue remains, though, which occurs when a non-aligned cross-boundary access happens. Currently the hypervisor, VHM and DM adopts different policy: * Hypervisor: inject #GP if it detects that the access crossed boundary * VHM: deliver to DM if the access does not complete falls in the range of a client * DM: a handler covering part of the to-be-accessed region is picked and assertion failure can be triggered. A high-level design covering all these components (in addition to instruction emulation) is needed for this. Thus this patch does not yet cover the issue. Tracked-On: #875 Signed-off-by: Junjie Mao <junjie.mao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -30,7 +30,6 @@
|
||||
#define REQ_STATE_PENDING 0
|
||||
#define REQ_STATE_COMPLETE 1
|
||||
#define REQ_STATE_PROCESSING 2
|
||||
#define REQ_STATE_FAILED -1
|
||||
|
||||
#define REQ_PORTIO 0U
|
||||
#define REQ_MMIO 1U
|
||||
@@ -97,8 +96,6 @@ union vhm_io_request {
|
||||
* The state transitions of a VHM request are:
|
||||
*
|
||||
* FREE -> PENDING -> PROCESSING -> COMPLETE -> FREE -> ...
|
||||
* \ /
|
||||
* +--> FAILED -+
|
||||
*
|
||||
* When a request is in COMPLETE or FREE state, the request is owned by the
|
||||
* hypervisor. SOS (VHM or DM) shall not read or write the internals of the
|
||||
@@ -154,12 +151,6 @@ union vhm_io_request {
|
||||
*
|
||||
* 2. Due to similar reasons, setting state to COMPLETE is the last operation
|
||||
* of request handling in VHM or clients in SOS.
|
||||
*
|
||||
* The state FAILED is an obsolete state to indicate that the I/O request cannot
|
||||
* be handled. In such cases the mediators and DM should switch the state to
|
||||
* COMPLETE with the value set to all 1s for read, and skip the request for
|
||||
* writes. This state WILL BE REMOVED after the mediators and DM are updated to
|
||||
* follow this rule.
|
||||
*/
|
||||
struct vhm_request {
|
||||
/**
|
||||
@@ -208,7 +199,7 @@ struct vhm_request {
|
||||
*
|
||||
* Byte offset: 136.
|
||||
*/
|
||||
int32_t processed;
|
||||
uint32_t processed;
|
||||
} __aligned(256);
|
||||
|
||||
union vhm_request_buffer {
|
||||
|
||||
Reference in New Issue
Block a user