aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorPeter Grehan <grehan@FreeBSD.org>2020-11-19 07:23:39 +0000
committerPeter Grehan <grehan@FreeBSD.org>2020-11-19 07:23:39 +0000
commit887d46ef5beb4f4900d25a8062f01e82b84c03b1 (patch)
tree917d4e92205b9697bda96c179080276b3d636c3d /usr.sbin
parent89744405e64b2116fbdd7d0e866a34731c96e4d5 (diff)
downloadsrc-887d46ef5beb4f4900d25a8062f01e82b84c03b1.tar.gz
src-887d46ef5beb4f4900d25a8062f01e82b84c03b1.zip
Advance RIP after userspace instruction decode
Add update to RIP after a userspace instruction decode (as is done for the in-kernel counterpart of this case). Submitted by: adam_fenn.io Reviewed by: cem, markj Approved by: grehan (bhyve) MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D27243
Notes
Notes: svn path=/head/; revision=367834
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bhyve/bhyverun.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c
index a2b8acdb752d..51df78c5f5ea 100644
--- a/usr.sbin/bhyve/bhyverun.c
+++ b/usr.sbin/bhyve/bhyverun.c
@@ -766,7 +766,11 @@ vmexit_inst_emul(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
vie_restart(vie);
mode = vmexit->u.inst_emul.paging.cpu_mode;
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)
+ goto fail;
+ if (vm_set_register(ctx, *pvcpu, VM_REG_GUEST_RIP,
+ vmexit->rip + vie->num_processed) != 0)
+ goto fail;
}
err = emulate_mem(ctx, *pvcpu, vmexit->u.inst_emul.gpa,
@@ -777,15 +781,17 @@ vmexit_inst_emul(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
EPRINTLN("Unhandled memory access to 0x%lx\n",
vmexit->u.inst_emul.gpa);
}
-
- fprintf(stderr, "Failed to emulate instruction sequence [ ");
- for (i = 0; i < vie->num_valid; i++)
- fprintf(stderr, "%02x", vie->inst[i]);
- FPRINTLN(stderr, " ] at 0x%lx", vmexit->rip);
- return (VMEXIT_ABORT);
+ goto fail;
}
return (VMEXIT_CONTINUE);
+
+fail:
+ fprintf(stderr, "Failed to emulate instruction sequence [ ");
+ for (i = 0; i < vie->num_valid; i++)
+ fprintf(stderr, "%02x", vie->inst[i]);
+ FPRINTLN(stderr, " ] at 0x%lx", vmexit->rip);
+ return (VMEXIT_ABORT);
}
static pthread_mutex_t resetcpu_mtx = PTHREAD_MUTEX_INITIALIZER;