Source-Changes-HG archive

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

[src/trunk]: src/lib/libnvmm Ah, fix bug: when the opcode has an immediate, w...



details:   https://anonhg.NetBSD.org/src/rev/4192b0a66f5e
branches:  trunk
changeset: 447839:4192b0a66f5e
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Jan 26 14:44:54 2019 +0000

description:
Ah, fix bug: when the opcode has an immediate, we fill the src with a
register storage, but then we overwrite it without zeroing out the highest
bits of the resulting immediate (which may contain garbage from the union).

diffstat:

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

diffs (29 lines):

diff -r 771709f26a49 -r 4192b0a66f5e lib/libnvmm/libnvmm_x86.c
--- a/lib/libnvmm/libnvmm_x86.c Sat Jan 26 14:38:29 2019 +0000
+++ b/lib/libnvmm/libnvmm_x86.c Sat Jan 26 14:44:54 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: libnvmm_x86.c,v 1.15 2019/01/13 10:43:22 maxv Exp $    */
+/*     $NetBSD: libnvmm_x86.c,v 1.16 2019/01/26 14:44:54 maxv Exp $    */
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -2071,12 +2071,14 @@
                instr->emul = group11[instr->regmodrm.reg].emul;
        }
 
-       reg = get_register_reg(instr, opcode);
-       if (reg == NULL) {
-               return -1;
+       if (!opcode->immediate) {
+               reg = get_register_reg(instr, opcode);
+               if (reg == NULL) {
+                       return -1;
+               }
+               strg->type = STORE_REG;
+               strg->u.reg = reg;
        }
-       strg->type = STORE_REG;
-       strg->u.reg = reg;
 
        if (has_sib(instr)) {
                /* Overwrites RM */



Home | Main Index | Thread Index | Old Index