io_emul: reshuffle io emulation path

This is the following patch after removing pending_pre_work, it make sure
all io emulation is done on its own cpu.

For hv emulated request, it follows the steps:
	hv_emulate_pio->emulate_pio_complete
	hv_emulate_mmio->emulate_mmio_complete

For dm emulated request, it follows the steps:
	acrn_insert_request->dm_emulate_io_complete
while in acrn_insert_request, it could trigger scheduling out then resume by
hcall_notify_ioreq_finish, or busy wait for ioreq completion if polling mode
is enabled.

Tracked-On: #2394
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Acked-by: Xu, Anthony <anthony.xu@intel.com>
This commit is contained in:
Jason Chen CJ
2019-01-22 11:35:15 +08:00
committed by wenlingz
parent fb41ea5cfb
commit 15030f6f2c
6 changed files with 34 additions and 112 deletions

View File

@@ -22,56 +22,6 @@
#define RTC_PIO_IDX (PM1B_CNT_PIO_IDX + 1U)
#define EMUL_PIO_IDX_MAX (RTC_PIO_IDX + 1U)
/**
* @brief General post-work for MMIO emulation
*
* @param vcpu The virtual CPU that triggers the MMIO access
* @param io_req The I/O request holding the details of the MMIO access
*
* @pre io_req->type == REQ_MMIO
*
* @remark This function must be called when \p io_req is completed, after
* either a previous call to emulate_io() returning 0 or the corresponding VHM
* request transferring to the COMPLETE state.
*/
void emulate_mmio_post(const struct acrn_vcpu *vcpu, const struct io_request *io_req);
/**
* @brief Post-work of VHM requests for MMIO emulation
*
* @param vcpu The virtual CPU that triggers the MMIO access
*
* @pre vcpu->req.type == REQ_MMIO
*
* @remark This function must be called after the VHM request corresponding to
* \p vcpu being transferred to the COMPLETE state.
*/
void dm_emulate_mmio_post(struct acrn_vcpu *vcpu);
/**
* @brief General post-work for all kinds of VHM requests for I/O emulation
*
* @param vcpu The virtual CPU that triggers the MMIO access
*/
void emulate_io_post(struct acrn_vcpu *vcpu);
/**
* @brief Emulate \p io_req for \p vcpu
*
* Handle an I/O request by either invoking a hypervisor-internal handler or
* deliver to VHM.
*
* @param vcpu The virtual CPU that triggers the MMIO access
* @param io_req The I/O request holding the details of the MMIO access
*
* @retval 0 Successfully emulated by registered handlers.
* @retval IOREQ_PENDING The I/O request is delivered to VHM.
* @retval -EIO The request spans multiple devices and cannot be emulated.
* @retval -EINVAL \p io_req has an invalid type.
* @retval <0 on other errors during emulation.
*/
int32_t emulate_io(struct acrn_vcpu *vcpu, struct io_request *io_req);
/**
* @brief The handler of VM exits on I/O instructions
*

View File

@@ -17,10 +17,6 @@
* @{
*/
/* The return value of emulate_io() indicating the I/O request is delivered to
* VHM but not finished yet. */
#define IOREQ_PENDING 1
/**
* @brief Internal representation of a I/O request.
*/
@@ -177,7 +173,7 @@ struct mem_io_node {
*
* @pre vcpu != NULL && io_req != NULL
*/
int32_t acrn_insert_request_wait(struct acrn_vcpu *vcpu, const struct io_request *io_req);
int32_t acrn_insert_request(struct acrn_vcpu *vcpu, const struct io_request *io_req);
/**
* @brief Reset all IO requests status of the VM