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 <yonghua.huang@intel.com>
This commit is contained in:
Yonghua Huang 2018-05-15 17:17:21 +08:00 committed by Jack Ren
parent 9efbf1212f
commit c597a0fc2f

View File

@ -108,10 +108,12 @@ int io_instr_vmexit_handler(struct vcpu *vcpu)
if ((port >= handler->desc.addr + handler->desc.len) || if ((port >= handler->desc.addr + handler->desc.len) ||
(port + sz <= handler->desc.addr)) (port + sz <= handler->desc.addr))
continue; continue;
else if (!((port >= handler->desc.addr) && ((port + sz)
/* Dom0 do not require IO emulation */ <= (handler->desc.addr + handler->desc.len)))) {
if (is_vm0(vm)) pr_fatal("Err:IO, port 0x%04x, size=%u spans devices",
status = 0; port, sz);
return -EIO;
}
if (direction == 0) { if (direction == 0) {
if (handler->desc.io_write == NULL) if (handler->desc.io_write == NULL)
@ -149,14 +151,11 @@ int io_instr_vmexit_handler(struct vcpu *vcpu)
} }
if (status != 0) { 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); direction ? "read" : "write", port, sz);
} }
/* Catch any problems */
ASSERT(status == 0, "Invalid IO access");
return status; return status;
} }