Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/inout.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
#include <machine/vmm_instruction_emul.h> | #include <machine/vmm_instruction_emul.h> | ||||
#include <vmmapi.h> | #include <vmmapi.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <assert.h> | #include <assert.h> | ||||
#include "bhyverun.h" | #include "bhyverun.h" | ||||
#include "config.h" | |||||
#include "inout.h" | #include "inout.h" | ||||
SET_DECLARE(inout_port_set, struct inout_port); | SET_DECLARE(inout_port_set, struct inout_port); | ||||
#define MAX_IOPORTS (1 << 16) | #define MAX_IOPORTS (1 << 16) | ||||
#define VERIFY_IOPORT(port, size) \ | #define VERIFY_IOPORT(port, size) \ | ||||
assert((port) >= 0 && (size) > 0 && ((port) + (size)) <= MAX_IOPORTS) | assert((port) >= 0 && (size) > 0 && ((port) + (size)) <= MAX_IOPORTS) | ||||
Show All 39 Lines | register_default_iohandler(int start, int size) | ||||
iop.size = size; | iop.size = size; | ||||
iop.flags = IOPORT_F_INOUT | IOPORT_F_DEFAULT; | iop.flags = IOPORT_F_INOUT | IOPORT_F_DEFAULT; | ||||
iop.handler = default_inout; | iop.handler = default_inout; | ||||
register_inout(&iop); | register_inout(&iop); | ||||
} | } | ||||
int | int | ||||
emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit, int strict) | emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit) | ||||
{ | { | ||||
int addrsize, bytes, flags, in, port, prot, rep; | int addrsize, bytes, flags, in, port, prot, rep; | ||||
uint32_t eax, val; | uint32_t eax, val; | ||||
inout_func_t handler; | inout_func_t handler; | ||||
void *arg; | void *arg; | ||||
int error, fault, retval; | int error, fault, retval; | ||||
enum vm_reg_name idxreg; | enum vm_reg_name idxreg; | ||||
uint64_t gla, index, iterations, count; | uint64_t gla, index, iterations, count; | ||||
struct vm_inout_str *vis; | struct vm_inout_str *vis; | ||||
struct iovec iov[2]; | struct iovec iov[2]; | ||||
bytes = vmexit->u.inout.bytes; | bytes = vmexit->u.inout.bytes; | ||||
in = vmexit->u.inout.in; | in = vmexit->u.inout.in; | ||||
port = vmexit->u.inout.port; | port = vmexit->u.inout.port; | ||||
assert(port < MAX_IOPORTS); | assert(port < 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 (handler == default_inout && | ||||
get_config_bool_default("x86.strictio", false)) | |||||
return (-1); | return (-1); | ||||
flags = inout_handlers[port].flags; | flags = inout_handlers[port].flags; | ||||
arg = inout_handlers[port].arg; | arg = inout_handlers[port].arg; | ||||
if (in) { | if (in) { | ||||
if (!(flags & IOPORT_F_IN)) | if (!(flags & IOPORT_F_IN)) | ||||
return (-1); | return (-1); | ||||
▲ Show 20 Lines • Show All 164 Lines • Show Last 20 Lines |