Changeset View
Changeset View
Standalone View
Standalone View
stable/10/usr.sbin/bhyve/bhyverun.c
Show First 20 Lines • Show All 301 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
return (VMEXIT_CONTINUE); | return (VMEXIT_CONTINUE); | ||||
} | } | ||||
static int | static int | ||||
vmexit_inout(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu) | vmexit_inout(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu) | ||||
{ | { | ||||
int error; | int error; | ||||
int bytes, port, in, out, string; | int bytes, port, in, out; | ||||
int vcpu; | int vcpu; | ||||
vcpu = *pvcpu; | vcpu = *pvcpu; | ||||
port = vme->u.inout.port; | port = vme->u.inout.port; | ||||
bytes = vme->u.inout.bytes; | bytes = vme->u.inout.bytes; | ||||
string = vme->u.inout.string; | |||||
in = vme->u.inout.in; | in = vme->u.inout.in; | ||||
out = !in; | out = !in; | ||||
/* Extra-special case of host notifications */ | /* Extra-special case of host notifications */ | ||||
if (out && port == GUEST_NIO_PORT) { | if (out && port == GUEST_NIO_PORT) { | ||||
error = vmexit_handle_notify(ctx, vme, pvcpu, vme->u.inout.eax); | error = vmexit_handle_notify(ctx, vme, pvcpu, vme->u.inout.eax); | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | static vmexit_handler_t handler[VM_EXITCODE_MAX] = { | ||||
[VM_EXITCODE_SPINUP_AP] = vmexit_spinup_ap, | [VM_EXITCODE_SPINUP_AP] = vmexit_spinup_ap, | ||||
[VM_EXITCODE_SUSPENDED] = vmexit_suspend, | [VM_EXITCODE_SUSPENDED] = vmexit_suspend, | ||||
[VM_EXITCODE_TASK_SWITCH] = vmexit_task_switch, | [VM_EXITCODE_TASK_SWITCH] = vmexit_task_switch, | ||||
}; | }; | ||||
static void | static void | ||||
vm_loop(struct vmctx *ctx, int vcpu, uint64_t startrip) | vm_loop(struct vmctx *ctx, int vcpu, uint64_t startrip) | ||||
{ | { | ||||
int error, rc, prevcpu; | int error, rc; | ||||
enum vm_exitcode exitcode; | enum vm_exitcode exitcode; | ||||
cpuset_t active_cpus; | cpuset_t active_cpus; | ||||
if (vcpumap[vcpu] != NULL) { | if (vcpumap[vcpu] != NULL) { | ||||
error = pthread_setaffinity_np(pthread_self(), | error = pthread_setaffinity_np(pthread_self(), | ||||
sizeof(cpuset_t), vcpumap[vcpu]); | sizeof(cpuset_t), vcpumap[vcpu]); | ||||
assert(error == 0); | assert(error == 0); | ||||
} | } | ||||
error = vm_active_cpus(ctx, &active_cpus); | error = vm_active_cpus(ctx, &active_cpus); | ||||
assert(CPU_ISSET(vcpu, &active_cpus)); | assert(CPU_ISSET(vcpu, &active_cpus)); | ||||
error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, startrip); | error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RIP, startrip); | ||||
assert(error == 0); | assert(error == 0); | ||||
while (1) { | while (1) { | ||||
error = vm_run(ctx, vcpu, &vmexit[vcpu]); | error = vm_run(ctx, vcpu, &vmexit[vcpu]); | ||||
if (error != 0) | if (error != 0) | ||||
break; | break; | ||||
prevcpu = vcpu; | |||||
exitcode = vmexit[vcpu].exitcode; | exitcode = vmexit[vcpu].exitcode; | ||||
if (exitcode >= VM_EXITCODE_MAX || handler[exitcode] == NULL) { | if (exitcode >= VM_EXITCODE_MAX || handler[exitcode] == NULL) { | ||||
fprintf(stderr, "vm_loop: unexpected exitcode 0x%x\n", | fprintf(stderr, "vm_loop: unexpected exitcode 0x%x\n", | ||||
exitcode); | exitcode); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 277 Lines • Show Last 20 Lines |