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).
This commit is contained in:
maxv 2019-01-26 14:44:54 +00:00
parent 9ee0549652
commit c07836be52
1 changed files with 8 additions and 6 deletions

View File

@ -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 @@ node_regmodrm(struct x86_decode_fsm *fsm, struct x86_instr *instr)
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 */