Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libnvmm Fix handling of SIB instructions. We were jumpin...



details:   https://anonhg.NetBSD.org/src/rev/f1ba5f409880
branches:  trunk
changeset: 448991:f1ba5f409880
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Feb 17 20:25:46 2019 +0000

description:
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.

diffstat:

 lib/libnvmm/libnvmm_x86.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (28 lines):

diff -r f20f6b0b3e48 -r f1ba5f409880 lib/libnvmm/libnvmm_x86.c
--- a/lib/libnvmm/libnvmm_x86.c Sun Feb 17 14:04:31 2019 +0000
+++ b/lib/libnvmm/libnvmm_x86.c Sun Feb 17 20:25:46 2019 +0000
@@ -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 @@
                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;



Home | Main Index | Thread Index | Old Index