Skip to content

Commit c597a0f

Browse files
yonghuahjren1
authored andcommitted
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>
1 parent 9efbf12 commit c597a0f

File tree

1 file changed

+7
-8
lines changed
  • hypervisor/arch/x86

1 file changed

+7
-8
lines changed

hypervisor/arch/x86/io.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ int io_instr_vmexit_handler(struct vcpu *vcpu)
108108
if ((port >= handler->desc.addr + handler->desc.len) ||
109109
(port + sz <= handler->desc.addr))
110110
continue;
111-
112-
/* Dom0 do not require IO emulation */
113-
if (is_vm0(vm))
114-
status = 0;
111+
else if (!((port >= handler->desc.addr) && ((port + sz)
112+
<= (handler->desc.addr + handler->desc.len)))) {
113+
pr_fatal("Err:IO, port 0x%04x, size=%u spans devices",
114+
port, sz);
115+
return -EIO;
116+
}
115117

116118
if (direction == 0) {
117119
if (handler->desc.io_write == NULL)
@@ -149,14 +151,11 @@ int io_instr_vmexit_handler(struct vcpu *vcpu)
149151
}
150152

151153
if (status != 0) {
152-
pr_fatal("IO %s access to port 0x%04x, size=%u",
154+
pr_fatal("Err:IO %s access to port 0x%04x, size=%u",
153155
direction ? "read" : "write", port, sz);
154156

155157
}
156158

157-
/* Catch any problems */
158-
ASSERT(status == 0, "Invalid IO access");
159-
160159
return status;
161160
}
162161

0 commit comments

Comments
 (0)