From c597a0fc2f068a25b1b6d0c729578e580370f2a9 Mon Sep 17 00:00:00 2001 From: Yonghua Huang Date: Tue, 15 May 2018 17:17:21 +0800 Subject: [PATCH] I/O VM-exit handler cleanup - add check for spanning i/o devices access - remove ASSERT in I/O instr. VM exit handler Signed-off-by: Yonghua Huang --- hypervisor/arch/x86/io.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hypervisor/arch/x86/io.c b/hypervisor/arch/x86/io.c index 7c23ac7ca..a0f484a92 100644 --- a/hypervisor/arch/x86/io.c +++ b/hypervisor/arch/x86/io.c @@ -108,10 +108,12 @@ int io_instr_vmexit_handler(struct vcpu *vcpu) if ((port >= handler->desc.addr + handler->desc.len) || (port + sz <= handler->desc.addr)) continue; - - /* Dom0 do not require IO emulation */ - if (is_vm0(vm)) - status = 0; + else if (!((port >= handler->desc.addr) && ((port + sz) + <= (handler->desc.addr + handler->desc.len)))) { + pr_fatal("Err:IO, port 0x%04x, size=%u spans devices", + port, sz); + return -EIO; + } if (direction == 0) { if (handler->desc.io_write == NULL) @@ -149,14 +151,11 @@ int io_instr_vmexit_handler(struct vcpu *vcpu) } if (status != 0) { - pr_fatal("IO %s access to port 0x%04x, size=%u", + pr_fatal("Err:IO %s access to port 0x%04x, size=%u", direction ? "read" : "write", port, sz); } - /* Catch any problems */ - ASSERT(status == 0, "Invalid IO access"); - return status; }