Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/bhyverun.c
Show First 20 Lines • Show All 760 Lines • ▼ Show 20 Lines | if (!vie->decoded) { | ||||
* Attempt to decode in userspace as a fallback. This allows | * Attempt to decode in userspace as a fallback. This allows | ||||
* updating instruction decode in bhyve without rebooting the | * updating instruction decode in bhyve without rebooting the | ||||
* kernel (rapid prototyping), albeit with much slower | * kernel (rapid prototyping), albeit with much slower | ||||
* emulation. | * emulation. | ||||
*/ | */ | ||||
vie_restart(vie); | vie_restart(vie); | ||||
mode = vmexit->u.inst_emul.paging.cpu_mode; | mode = vmexit->u.inst_emul.paging.cpu_mode; | ||||
cs_d = vmexit->u.inst_emul.cs_d; | cs_d = vmexit->u.inst_emul.cs_d; | ||||
(void)vmm_decode_instruction(mode, cs_d, vie); | if (vmm_decode_instruction(mode, cs_d, vie) != 0 || | ||||
vm_set_register(ctx, *pvcpu, VM_REG_GUEST_RIP, | |||||
vmexit->rip + vie->num_processed) != 0) | |||||
markj: Indentation should also be by 4 spaces on this line. It might be a bit clearer if the two… | |||||
goto fail; | |||||
} | } | ||||
err = emulate_mem(ctx, *pvcpu, vmexit->u.inst_emul.gpa, | err = emulate_mem(ctx, *pvcpu, vmexit->u.inst_emul.gpa, | ||||
vie, &vmexit->u.inst_emul.paging); | vie, &vmexit->u.inst_emul.paging); | ||||
if (err) { | if (err) { | ||||
if (err == ESRCH) { | if (err == ESRCH) { | ||||
EPRINTLN("Unhandled memory access to 0x%lx\n", | EPRINTLN("Unhandled memory access to 0x%lx\n", | ||||
vmexit->u.inst_emul.gpa); | vmexit->u.inst_emul.gpa); | ||||
} | } | ||||
goto fail; | |||||
} | |||||
return (VMEXIT_CONTINUE); | |||||
fail: | |||||
fprintf(stderr, "Failed to emulate instruction sequence [ "); | fprintf(stderr, "Failed to emulate instruction sequence [ "); | ||||
for (i = 0; i < vie->num_valid; i++) | for (i = 0; i < vie->num_valid; i++) | ||||
fprintf(stderr, "%02x", vie->inst[i]); | fprintf(stderr, "%02x", vie->inst[i]); | ||||
FPRINTLN(stderr, " ] at 0x%lx", vmexit->rip); | FPRINTLN(stderr, " ] at 0x%lx", vmexit->rip); | ||||
return (VMEXIT_ABORT); | return (VMEXIT_ABORT); | ||||
} | |||||
return (VMEXIT_CONTINUE); | |||||
} | } | ||||
static pthread_mutex_t resetcpu_mtx = PTHREAD_MUTEX_INITIALIZER; | static pthread_mutex_t resetcpu_mtx = PTHREAD_MUTEX_INITIALIZER; | ||||
static pthread_cond_t resetcpu_cond = PTHREAD_COND_INITIALIZER; | static pthread_cond_t resetcpu_cond = PTHREAD_COND_INITIALIZER; | ||||
static int | static int | ||||
vmexit_suspend(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) | vmexit_suspend(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 656 Lines • Show Last 20 Lines |
Indentation should also be by 4 spaces on this line. It might be a bit clearer if the two conditions were split into separate if-statements.