Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/inout.c
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | |||||
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 strict) | ||||
{ | { | ||||
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, 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; | ||||
Show All 39 Lines | while (iterations > 0) { | ||||
if (vie_calculate_gla(vis->paging.cpu_mode, | if (vie_calculate_gla(vis->paging.cpu_mode, | ||||
vis->seg_name, &vis->seg_desc, index, bytes, | vis->seg_name, &vis->seg_desc, index, bytes, | ||||
addrsize, prot, &gla)) { | addrsize, prot, &gla)) { | ||||
vm_inject_gp(ctx, vcpu); | vm_inject_gp(ctx, vcpu); | ||||
break; | break; | ||||
} | } | ||||
error = vm_copy_setup(ctx, vcpu, &vis->paging, gla, | error = vm_copy_setup(ctx, vcpu, &vis->paging, gla, | ||||
bytes, prot, iov, nitems(iov)); | bytes, prot, iov, nitems(iov), &fault); | ||||
if (error == -1) { | if (error) { | ||||
retval = -1; /* Unrecoverable error */ | retval = -1; /* Unrecoverable error */ | ||||
break; | break; | ||||
} else if (error == 1) { | } else if (fault) { | ||||
retval = 0; /* Resume guest to handle fault */ | retval = 0; /* Resume guest to handle fault */ | ||||
break; | break; | ||||
} | } | ||||
if (vie_alignment_check(vis->paging.cpl, bytes, | if (vie_alignment_check(vis->paging.cpl, bytes, | ||||
vis->cr0, vis->rflags, gla)) { | vis->cr0, vis->rflags, gla)) { | ||||
vm_inject_ac(ctx, vcpu, 0); | vm_inject_ac(ctx, vcpu, 0); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |