acrn-hypervisor/hypervisor/arch/x86
Junjie Mao 50e4bc1758 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>
2018-07-31 10:22:03 +08:00
..
configs HV: config: add Kconfig and defconfigs for sbl & uefi 2018-06-08 17:21:13 +08:00
debug HV: prototyping non-static function 2018-07-16 10:35:54 +08:00
guest HV:treewide:rename struct key_info, pir_desc, map_params 2018-07-30 10:18:39 +08:00
assign.c HV:treewide:fix "Reference parameter to procedure is reassigned" 2018-07-27 12:17:12 +08:00
cpu_primary.S HV:treewide:Replace HOST_GDT_RING0_CODE/DATA_SEL with constant 2018-07-18 12:31:42 +08:00
cpu_state_tbl.c fix x86 dir integer violations 2018-07-25 15:29:34 +08:00
cpu.c hv:Reshuffle console/uart code 2018-07-30 16:25:16 +08:00
cpuid.c HV:treewide:fix "Attempt to change parameter passed by value" 2018-07-26 09:35:52 +08:00
ept.c HV:treewide:rename struct key_info, pir_desc, map_params 2018-07-30 10:18:39 +08:00
gdt.c fix x86 dir integer violations 2018-07-25 15:29:34 +08:00
idt.S hv: cpu: using struct cpu_gp_regs for general-purpose regs in inter_excp_ctx 2018-07-25 13:05:38 +08:00
io.c HV: io: refactoring vmexit handler on I/O instruction 2018-07-31 10:22:03 +08:00
ioapic.c HV:treewide:fix "Reference parameter to procedure is reassigned" 2018-07-27 12:17:12 +08:00
irq.c HV:treewide:fix "Reference parameter to procedure is reassigned" 2018-07-27 12:17:12 +08:00
Kconfig HV: build: make relocation-related code configurable 2018-07-11 19:18:26 +08:00
lapic.c fix x86 dir integer violations 2018-07-25 15:29:34 +08:00
mmu.c HV:treewide:rename struct key_info, pir_desc, map_params 2018-07-30 10:18:39 +08:00
mtrr.c hv: mmu: minor fix about hv mmu && ept modify 2018-07-24 12:48:45 +08:00
notify.c HV: Fix new MISRAC violations for brackets 2018-07-16 11:02:38 +08:00
pagetable.c hv: ept: add lookup_address to lookup the page table 2018-07-26 12:46:34 +08:00
pm.c HV: pm: cleanup for misra integral type violations 2018-07-12 17:31:11 +08:00
retpoline-thunk.S license: Replace license text with SPDX tag 2018-06-01 10:43:06 +08:00
softirq.c HV: Rename functions beginning with "_" 2018-07-30 10:11:54 +08:00
timer.c HV:treewide:rename struct timer as struct hv_timer 2018-07-30 10:16:36 +08:00
trampoline.S HV:treewide:Replace HOST_GDT_RING0_CODE/DATA_SEL with constant 2018-07-18 12:31:42 +08:00
trusty2.c HV:treewide:rename struct key_info, pir_desc, map_params 2018-07-30 10:18:39 +08:00
trusty.c HV:treewide:rename struct key_info, pir_desc, map_params 2018-07-30 10:18:39 +08:00
virq.c HV: Rename functions beginning with "_" 2018-07-30 10:11:54 +08:00
vmexit.c HV: io: refactoring vmexit handler on I/O instruction 2018-07-31 10:22:03 +08:00
vmx_asm.S hv: cpu: align general-purpose register layout with vmx 2018-07-25 13:05:38 +08:00
vmx.c fix x86 dir integer violations 2018-07-25 15:29:34 +08:00
vtd.c HV:treewide:Fixing pointer castings 2018-07-24 10:56:24 +08:00
wakeup.S hv: cpu: align general-purpose register layout with vmx 2018-07-25 13:05:38 +08:00