DM: add spanning devices check for i/o access

- i/o access whose handler is not registered should
  not be allowed.

Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
Yonghua Huang 2018-05-18 18:57:12 +08:00 committed by lijinxia
parent b55511abd6
commit 9e61accbed

View File

@ -99,20 +99,27 @@ emulate_inout(struct vmctx *ctx, int *pvcpu, struct pio_request *pio_request,
int bytes, flags, in, port; int bytes, flags, in, port;
inout_func_t handler; inout_func_t handler;
void *arg; void *arg;
int retval; int i, retval;
bytes = pio_request->size; bytes = pio_request->size;
in = (pio_request->direction == REQUEST_READ); in = (pio_request->direction == REQUEST_READ);
port = pio_request->address; port = pio_request->address;
assert(port < MAX_IOPORTS); assert(port + bytes - 1 < MAX_IOPORTS);
assert(bytes == 1 || bytes == 2 || bytes == 4); assert(bytes == 1 || bytes == 2 || bytes == 4);
handler = inout_handlers[port].handler; handler = inout_handlers[port].handler;
if (strict && handler == default_inout) if (strict) {
if (handler == default_inout)
return -1; return -1;
for (i = 1; i < bytes; i++) {
if (inout_handlers[port + i].handler != handler)
return -1;
}
}
flags = inout_handlers[port].flags; flags = inout_handlers[port].flags;
arg = inout_handlers[port].arg; arg = inout_handlers[port].arg;