HV: io: unify vhm_request req and mem_io in vcpu

The current struct vcpu has two members, namely 'struct vhm_request req' and
'struct mem_io mmio', that hold similar info, including the address, direction, size,
value and status of mmio reqeusts.

As a step towards a unified framework for both MMIO/PIO, this patch unifies
these two members by a tailored version of vhm_reqeust, mostly with the reserved
fields dropped. The definitions to request types, directions and process status
are reused.

Handling errors during emulations will be revisited after the I/O emulation
paths are unified. Thus for this patch the mmio.mmio_status in inherited by
io_req.processed which is not yet properly processed.

Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Junjie Mao
2018-07-24 19:05:47 +08:00
committed by lijinxia
parent 1915eec632
commit 88f74b5dbb
12 changed files with 180 additions and 181 deletions

View File

@@ -596,32 +596,31 @@ vioapic_pincount(struct vm *vm)
}
}
int vioapic_mmio_access_handler(struct vcpu *vcpu, struct mem_io *mmio,
int vioapic_mmio_access_handler(struct vcpu *vcpu, struct io_request *io_req,
__unused void *handler_private_data)
{
struct vm *vm = vcpu->vm;
uint64_t gpa = mmio->paddr;
struct mmio_request *mmio = &io_req->reqs.mmio;
uint64_t gpa = mmio->address;
int ret = 0;
/* Note all RW to IOAPIC are 32-Bit in size */
if (mmio->access_size == 4U) {
uint32_t data = mmio->value;
if (mmio->size == 4UL) {
uint32_t data = (uint32_t)mmio->value;
if (mmio->read_write == HV_MEM_IO_READ) {
if (mmio->direction == REQUEST_READ) {
vioapic_mmio_read(vm,
gpa,
&data);
mmio->value = (uint64_t)data;
mmio->mmio_status = MMIO_TRANS_VALID;
} else if (mmio->read_write == HV_MEM_IO_WRITE) {
io_req->processed = REQ_STATE_SUCCESS;
} else if (mmio->direction == REQUEST_WRITE) {
vioapic_mmio_write(vm,
gpa,
data);
mmio->mmio_status = MMIO_TRANS_VALID;
io_req->processed = REQ_STATE_SUCCESS;
} else {
/* Can never happen due to the range of read_write. */
/* Can never happen due to the range of direction. */
}
} else {
pr_err("All RW to IOAPIC must be 32-bits in size");