Fix handling of SIB instructions. We were jumping to the SIB node _before_

fetching the displacement, so the node would always think there was no
displacement.

This didn't alter the final GPA we would be touching - because it is
fetched from the kernel directly and not from the computation -, but it
altered the instruction length, and on some guests (like Fedora 64bit),
the VCPU would resume execution at the wrong RIP and crash.

Now these guests work.
This commit is contained in:
maxv 2019-02-17 20:25:46 +00:00
parent 90b9898718
commit 4cdf419d72

View File

@ -1,4 +1,4 @@
/* $NetBSD: libnvmm_x86.c,v 1.23 2019/02/15 16:42:27 maxv Exp $ */
/* $NetBSD: libnvmm_x86.c,v 1.24 2019/02/17 20:25:46 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@ -2233,15 +2233,15 @@ node_regmodrm(struct x86_decode_fsm *fsm, struct x86_instr *instr)
strg->u.reg = reg;
}
/* The displacement applies to RM. */
strm->disp.type = get_disp_type(instr);
if (has_sib(instr)) {
/* Overwrites RM */
fsm_advance(fsm, 1, node_sib);
return 0;
}
/* The displacement applies to RM. */
strm->disp.type = get_disp_type(instr);
if (is_rip_relative(fsm, instr)) {
/* Overwrites RM */
strm->type = STORE_REG;