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
This commit is contained in:
Peter Grehan 2020-11-19 07:23:39 +00:00
parent 89744405e6
commit 887d46ef5b

View File

@ -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,7 +781,12 @@ 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);
}
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]);
@ -785,9 +794,6 @@ vmexit_inst_emul(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
return (VMEXIT_ABORT);
}
return (VMEXIT_CONTINUE);
}
static pthread_mutex_t resetcpu_mtx = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t resetcpu_cond = PTHREAD_COND_INITIALIZER;