From 42cabf6965aaffd77ae6bac29b658ee5b072b8ed Mon Sep 17 00:00:00 2001 From: Sainath Grandhi Date: Thu, 9 Aug 2018 15:58:58 -0700 Subject: [PATCH] hv: Handling IO exits in ACRN for partition mode There is no SOS and device model in strict partition mode. ACRN emulates IO for virtual devices. Any access to IO not backed by HV should return all FFs on read and writes should be discarded. Signed-off-by: Sainath Grandhi --- hypervisor/arch/x86/io.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hypervisor/arch/x86/io.c b/hypervisor/arch/x86/io.c index b90f89377..f61b77851 100644 --- a/hypervisor/arch/x86/io.c +++ b/hypervisor/arch/x86/io.c @@ -107,6 +107,18 @@ int32_t dm_emulate_mmio_post(struct vcpu *vcpu) return emulate_mmio_post(vcpu, io_req); } +#ifdef CONFIG_PARTITION_MODE +static void io_instr_dest_handler(struct io_request *io_req) +{ + struct pio_request *pio_req = &io_req->reqs.pio; + + if (pio_req->direction == REQUEST_READ) { + pio_req->value = 0xFFFFFFFFU; + } + io_req->processed = REQ_STATE_COMPLETE; +} +#endif + void emulate_io_post(struct vcpu *vcpu) { union vhm_request_buffer *req_buf; @@ -296,6 +308,15 @@ emulate_io(struct vcpu *vcpu, struct io_request *io_req) } if (status == -ENODEV) { +#ifdef CONFIG_PARTITION_MODE + /* + * No handler from HV side, return all FFs on read + * and discard writes. + */ + io_instr_dest_handler(io_req); + status = 0; + +#else /* * No handler from HV side, search from VHM in Dom0 * @@ -309,6 +330,7 @@ emulate_io(struct vcpu *vcpu, struct io_request *io_req) (pio_req->direction != REQUEST_READ) ? "read" : "write", pio_req->address, pio_req->size); } +#endif } return status;