mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-23 09:47:44 +00:00
HV: io: refactoring vmexit handler on I/O instruction
This patch refactors how I/O instructions are emulated, in order for a unify the I/O emulation path. The major control flow includes: 1. pio_instr_vmexit_handler (entry point for handling vmexit on I/O instruction): Extract port address, register size, direction and value (for write only), fill in an I/O request (of type io_request), invokes do_io to handle that and update the guest registers if the request has been successfully handled when do_io returns. 2. emulate_io: Handle the given I/O request. The request is handled or sent to VHM if it returns 0 (the actual status can be found in io_req->processed). On errors a negative error code is returned. 3. emulate_pio_by_handler: Look for the PIO handler for the given request and invoke that handler. Return 0 if a proper handler is found and invoked (the status of the emulation can be found in io_req->processed), -EIO when the request spans across devices, and -ENODEV when no handler is found. 4. emulate_pio_post: Update guest registers after the emulation is done. Currently this can happen either right after do_io() or after the vcpu is resumed. Status check on the I/O request and follow-up actions on failure will also go here. Note: Currently do_io can return 0 with io_req->processed being REQ_STATE_PENDING if the request is sent to VHM for further processing. In this case the current vcpu will be paused after handling this vm_exit, and dm_emulate_pio_post will be invoked to do the rest after this vcpu is resumed. When vcpus are scheduled back to exactly where they are scheduled out later, do_io should be responsible for the post_work and the processing of do_io results shall be mostly the same. v2 -> v3: * Rename: emulate_pio_by_handler -> hv_emulate_pio. * Properly mask the value passed to port I/O handler. v1 -> v2: * Rename: do_io -> emulate_io. * Rename io_instr_vmexit_handler -> pio_instr_vmexit_handler to reflect the fact that it handles port I/O only. Signed-off-by: Junjie Mao <junjie.mao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -108,7 +108,7 @@ struct mem_io_node {
|
||||
};
|
||||
|
||||
/* External Interfaces */
|
||||
int io_instr_vmexit_handler(struct vcpu *vcpu);
|
||||
int32_t pio_instr_vmexit_handler(struct vcpu *vcpu);
|
||||
void setup_io_bitmap(struct vm *vm);
|
||||
void free_io_emulation_resource(struct vm *vm);
|
||||
void allow_guest_io_access(struct vm *vm, uint32_t address_arg, uint32_t nbytes);
|
||||
|
Reference in New Issue
Block a user